当前位置: 首页>>代码示例>>C#>>正文


C# ConstructGen.AvgRows方法代码示例

本文整理汇总了C#中ConstructGen.AvgRows方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructGen.AvgRows方法的具体用法?C# ConstructGen.AvgRows怎么用?C# ConstructGen.AvgRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstructGen的用法示例。


在下文中一共展示了ConstructGen.AvgRows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ATMVolsRankGroup

    protected ATMVolsRankGroup(FXGroup group_)
    {
      var currencies = Singleton<FXIDs>.Instance.Where(x => x.IsGroup(group_)).ToArray();

      var oneWeek = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());
      var oneMonth = new ConstructGen<double>(currencies.Select(x => x.Code).ToArray());

      for (int i = 0; i < currencies.Length; ++i)
      {
        {
          var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1W, "PX_LAST", false);
          oneWeek.SetColumnValues(i, vols);
        }
        {
          var vols = BbgTalk.HistoryRequester.GetHistory(DataConstants.DATA_START, currencies[i].AtTheMoneyVolTicker_1M, "PX_LAST", false);
          oneMonth.SetColumnValues(i, vols);
        }
      }

      {
        oneWeek.SortKeys();
        var avg1W = oneWeek.AvgRows();
        ATM_1W_Avg = avg1W;
        ATM_1W_o6M = avg1W.ToPercentileRanked(126);
        ATM_1W_o1Y = avg1W.ToPercentileRanked(252);
      }

      {
        oneMonth.SortKeys();
        var avg1M = oneMonth.AvgRows();
        ATM_1M_Avg = avg1M;
        ATM_1M_o6M = avg1M.ToPercentileRanked(126);
        ATM_1M_o1Y = avg1M.ToPercentileRanked(252);
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:35,代码来源:ATMVolsRank.cs

示例2: GetIndicator


//.........这里部分代码省略.........
        //  break;
        //case IndicType.VolSlope_pr252:
        //  {
        //    DatedDataCollectionGen<double> dd = BbgTalk.Core.Instance.GetHistory(Environment.UserName, DataConstants.DATA_START, ".VSL INDEX", "PX_LAST", true);
        //    ret = new DatedDataCollectionGen<double>(dd.Dates, dd.Data).ToPercentileRanked(252);
        //  }
        //  break;
        case IndicType.AvgCarry_actual:
          {
            var spots = Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true);
            var fwds = Singleton<FXForwards1Wk>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true);

            Currency[] ccys = Singleton<FXIDs>.Instance.ToArray();
            ConstructGen<double> con = new ConstructGen<double>(ccys.Select(x=>x.Code).ToArray());

            for (int d = 0; d < spots.Dates.Count; ++d)
            {
              DateTime date = spots.Dates[d];
              double ccyCarry = 0d;
              for (int c = 0; c < ccys.Length; ++c)
              {
                if (ccys[c].IsValid(date) == false)
                  continue;

                if (ccys[c].Convention == 1)
                  ccyCarry = ((spots.GetValue(date, c) / fwds.GetValue(date, c)) - 1d) * (252d / 5d);
                else
                  ccyCarry = ((fwds.GetValue(date, c) / spots.GetValue(date, c)) - 1d) * (252d / 5d);

                con.SetValue(date, c, ccyCarry);
              }
            }

            ret = con.AvgRows();

            for (int i = 1; i < ret.Length; ++i)
            {
              if (double.IsInfinity(ret.Data[i]))
                ret.Data[i] = ret.Data[i - 1];

              ret.Data[i] = Math.Max(ret.Data[i], -0.01);
            }
          }
          break;
        //case IndicType.sigNumRebals21:
        //  {
        //    DateTime[] allDates = Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true).Dates;
        //    double[] rebalInd = new double[allDates.Length];
        //    for (int i = 0; i < allDates.Length; ++i)
        //      if (sigWeights_.Dates.Contains(allDates[i]))
        //        rebalInd[i] = 1d;

        //    ret = new DatedDataCollectionGen<double>(allDates, rebalInd).ToRollingSum(21);
        //  }
        //  break;
        //case IndicType.sigTurnover21:
        //  {
        //    List<DateTime> allDates = new List<DateTime>(Singleton<FXSpots>.Instance.GetData(DataConstants.DATA_START, DateTime.Today, true).Dates);
        //    double[] tOver = new double[allDates.Count];

        //    double[] prevweights = sigWeights_.GetValues(sigWeights_.Dates[0]);

        //    for (int i = 0; i < sigWeights_.Dates.Count; ++i)
        //    {
        //      DateTime date = sigWeights_.Dates[i];
        //      int index = allDates.IndexOf(date);
开发者ID:heimanhon,项目名称:researchwork,代码行数:67,代码来源:Factory.cs


注:本文中的ConstructGen.AvgRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。