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


C# ConstructGen.SetColumnValues方法代码示例

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


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

示例1: Refresh

    public void Refresh()
    {
      // going to get historical values from our database
      ConstructGen<double> hist = new ConstructGen<double>(m_tickers.Count<string>());

      for (int i = 0; i < m_tickers.Length; ++i)
      {
        var histvalues = BbgTalk.HistoryRequester.GetHistory(SI.Data.DataConstants.DATA_START, m_tickers[i],
          "PX_LAST", false, null);

        //histvalues = histvalues.unwind_1d();

        hist.SetColumnValues(i, histvalues);
      }

      hist.SortKeys();

      // initialise 'today's' values to previous day
      hist.SetValues(DateTime.Today, (double[])hist.GetValues(hist.LastDate).Clone());

      double[] avgs = new double[m_windowLength];

      // initialise the avgs array NOTE: today's value is in item with index 0
      for (int i = 0; i < m_windowLength; ++i)
        avgs[i] = hist.GetValues(hist.Dates[hist.Dates.Count - 1 - i]).Average();

      m_avgs = avgs;
      m_liveValues = hist.GetValues(DateTime.Today);
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:LiveAverageRankBbg.cs

示例2: 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

示例3: TestOnCT

    public static ConstructGen<double> TestOnCT()
    {
      var str = KnownStructure.US_WN;

      var comps = new[]
      {
        new ChartComponent(),
        new ChartComponent(),
        new ChartComponent(),
      };

      var bondsRollMonthly = Generator.Go(cashBondRollOption_: Generator.CashBondRolling.Monthly);
      var spreadsRollMonthly = new Dictionary<BondCurves, List<CTDLine<BondSpreads>>>();
      spreadsRollMonthly[BondCurves.USD3mLibor] = Generator.GetSpreads(bondsRollMonthly, BondCurves.USD3mLibor, Generator.CashBondRolling.Monthly);

      var cdRollMonthly = new ChartDataSource(comps, spreadsRollMonthly, bondsRollMonthly);

      var impl = StructureFactory.GetStructure(str);

      impl.Configure(comps);

      var data = cdRollMonthly.GetData().SmoothedData.GetEndValues(650);

      var con = new ConstructGen<double>(1);
      con.SetColumnValues(0, data);

      return con;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:28,代码来源:DataRetriever.cs

示例4: getOHLCSeriesFromBbg

        public static ConstructGen<double> getOHLCSeriesFromBbg(DateTime firstDate_, string ticker_, bool insertNan_ = true)
        {
            var ret = new ConstructGen<double>(new string[] { "PX_OPEN", "PX_HIGH", "PX_LOW", "PX_CLOSE_1D" });
            DateTime[] bbgDates = null;
            for (int i = 0; i < ret.ColumnHeadings.Length; ++i)
            {
                DateTime start;
                if (i == 3)
                    start = firstDate_.AddDays(1);
                else
                    start = firstDate_;

                var b = BbgTalk.HistoryRequester.GetHistory(start, ticker_, ret.ColumnHeadings[i], false);

                if (b == null || b.Length == 0)
                {
                    throw new Exception(string.Format("No data retrieved for given ticker '{0}'", ticker_.ToUpper()));
                }
                else
                    b = HelperMethods.ensureAllWeekdays(b, insertNan_);

                if (i == 3)
                {
                    var closeData = bbgDates.Length > b.Dates.Length ? b.Data : b.Data.Skip(1).ToArray();
                    ret.SetColumnValues(i, bbgDates.SkipLast().ToArray(), closeData);
                }
                else
                {
                    ret.SetColumnValues(i, b.Dates, b.Data);
                    bbgDates = b.Dates;
                }
            }
            
            foreach (var d in ret.Dates.OrderByDescending(d => d))
            {
                if (ret.GetValue(d, 3) == 0)
                {
                    ret.RemoveValues(d);
                }
                else break;                
            }

            return ret;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:44,代码来源:BbgData.cs

示例5: CalculateWeights

    public static ConstructGen<PairTrade> CalculateWeights(ComID[] commodities_)
    {
      // calculate the weighting
      var con = new ConstructGen<PairTrade>(commodities_.Select(x => x.Name).ToArray());

      for (int i = 0; i < con.ArrayLength; ++i)
        con.SetColumnValues(i, CalculateWeights(commodities_[i]));

      if (con.NeedsToSortKeys())
        con.SortKeys();

      return con;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:13,代码来源:Calculator.cs

示例6: Collate

    public static void Collate(BondMarket market_=BondMarket.US)
    {
      var allTenors = SI.ExtensionMethods.CreateArray(1, 30, x => x + 1);

      var con = new ConstructGen<double>(allTenors.Select(x => string.Format("cmt_{0}", x)).ToArray());

      for (int i = 0; i < allTenors.Length; ++i)
      {
        var cr = Get(market_, allTenors[i]);
        if (cr == null) continue;

        con.SetColumnValues(i, cr.Values.GetColumnValuesAsDDC((int) CMTCarry.ColPosition.Carry));
      }

      con.WriteToCSV(string.Format(@"e:\temp\CMTCarry_{0}.csv", market_));
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:16,代码来源:CMTCarryCache.cs

示例7: expandToFullUniverse

    private static ConstructGen<double> expandToFullUniverse(ConstructGen<double> input_)
    {
      if (input_.ArrayLength == Singleton<FXIDs>.Instance.Count)
        return input_;

      System.Diagnostics.Debug.Assert(input_.ColumnHeadings != null, "Column Headings not set on ConstructGen<double> wts, therefore can't ascertain securities");

      ConstructGen<double> ret = new ConstructGen<double>(Singleton<FXIDs>.Instance.Count);
      ret.ColumnHeadings = Singleton<FXIDs>.Instance.ColumnHeadings;

      for (int i = 0; i < input_.ArrayLength; ++i)
      {
        Currency c = Singleton<FXIDs>.Instance[input_.ColumnHeadings[i]];

        ret.SetColumnValues(c.ArrayIndex, input_.Dates.ToArray<DateTime>(), input_.GetColumnValues(i));
      }
      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:18,代码来源:WtsAnalysisCompareControl.cs

示例8: doPnl

    protected override SI.ReturnsEval.DataSeriesEvaluator doPnl(TraderArgs args_, ConstructGen<double> wts_)
    {
      ConstructGen<double> allCcys = new ConstructGen<double>(Singleton<FXIDs>.Instance.ColumnHeadings);

      for (int i = 0; i < args_.Products.Count; ++i)
      {
        ProductFX prod = (ProductFX)args_.Products[i];
        allCcys.SetColumnValues(prod.CoreProduct.ArrayIndex, wts_.Dates.ToArray(), wts_.GetColumnValues(i));
      }

      var result = ReturnsFromFXWeights.DoIt_DailyWeights(allCcys);
      var eval = new ReturnsEval.DataSeriesEvaluator("FX pnl", ReturnsEval.DataSeriesType.Returns);

      if (args_.WtIndicators.Any())
        eval.Name = string.Format("FX : {0}", args_.WtIndicators[0].ToString());
      
      eval.AddInnerSeries(result.CombinedPnl.Dates.ToArray(), result.CombinedPnl.ToArray(), result.CombinedPnl.ColumnHeadings);

      return eval;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:20,代码来源:TraderFX.cs

示例9: GetTestData

    public static ConstructGen<double> GetTestData()
    {
      var ret = new ConstructGen<double>(new string[] {"PX_OPEN", "PX_HIGH", "PX_LOW", "PX_CLOSE_1D"});

      for (int i = 0; i < ret.ColumnHeadings.Length; ++i)
      {
        var s = BbgTalk.HistoryRequester.GetHistory(new DateTime(2015, 1, 1), "EUR CMPL CURNCY", ret.ColumnHeadings[i], false);

        if (i == 3)
        {
          s = unwind_1d(s);
        }

        ret.SetColumnValues(i, s.Dates, s.Data);
      }

      ret.Dates.Remove(DateTime.Today);

      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:20,代码来源:DataRetriever.cs

示例10: GoMulti

    public static void GoMulti()
    {
      var data = DataRetriever.GetData(indexStart_: "ES", suffix_: "Index", contractIndex_: 1);

      var listOfEvals = new List<ReturnsEval.DataSeriesEvaluator>();

      foreach (var firstWindow in new[] {5, 10, 15, 20, 25, 50, })
      {
        var indic = new SI.Research.Technicals.MACross(firstWindow, firstWindow * 2);

        var signals = indic.GenerateWeightSeries(data, null);

        for (int i = 0; i < signals.Length; ++i)
          signals.Data[i] = signals.Data[i] < 0d ? -1d : 1d;

        signals = CollapseToChanges(signals);

        if (false)
        {
          var con = new ConstructGen<double>(new[] { "Signal", "CleanPrice" });
          con.SetColumnValues(0, signals);

          foreach (var date in con.Dates)
            con.SetValue(date, 1, data.ValueOnExactDate(date));

          con.DisplayInGrid("changes with price levels");
        }

        //signals.DisplayInGrid("changes");


        var pnl = GeneratePnl(data, signals);

        var eval = new ReturnsEval.DataSeriesEvaluator(pnl.Dates, pnl.Data, string.Format("ES_{0}", firstWindow), ReturnsEval.DataSeriesType.Returns);
        listOfEvals.Add(eval);

      }
      listOfEvals.Display("blah");
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:39,代码来源:TryStuffOut.cs

示例11: btnCombinePnl_Click

    private void btnCombinePnl_Click(object sender, EventArgs e)
    {
      var all = spreadWeightGeneratorCollectionGrid1.ListOfGenerators;

      if (all.Count() == 0) return;

      ConstructGen<double> con = new ConstructGen<double>(all.Count());
      con.ColumnHeadings = new string[con.ArrayLength];

      for (int i = 0; i < con.ArrayLength; ++i)
      {
        var item = all.ElementAt(i);
        con.ColumnHeadings[i] = item.ToString();
        con.SetColumnValues(i, item.GetSimplePnl());
      }

      if (con.NeedsToSortKeys())
        con.SortKeys();

      var eval = new ReturnsEval.DataSeriesEvaluator("Combined", ReturnsEval.DataSeriesType.Returns);
      eval.AddInnerSeries(con.Dates.ToArray(), con.ToArray(), con.ColumnHeadings);

      eval.Display("Combined");
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:24,代码来源:SpreadsMainControl.cs

示例12: ConstructTickerTrueSpreads

        private static void ConstructTickerTrueSpreads(List<RollResults> results, ref ConstructGen<string> ticker, ref ConstructGen<double> spreads,
                                                  Func<RollResults, RollResultContractItem> GetResults, string headingTickerPostfix, string headingValuePostfix)
        {
            var resultItem = results.Where(r => GetResults(r) != null).ToArray();
            if (resultItem.Any())
            {
                var content =
                    resultItem.Select(r => new { r.Identifier, GetResults(r).TrueSpread }).ToLookup(l => l.Identifier);
                var lookupHeader = resultItem.Select(r => r.Identifier).ToArray();
                ticker = new ConstructGen<string>(content.Count)
                {
                    ColumnHeadings = resultItem.Select(r => r.Identifier + " " + headingTickerPostfix).ToArray()
                };
                spreads = new ConstructGen<double>(content.Count)
                {
                    ColumnHeadings = resultItem.Select(r => r.Identifier + " " + headingValuePostfix).ToArray()
                };

                for (int i = 0; i < ticker.ArrayLength; i++)
                {
                    var series = content[lookupHeader[i]].First().TrueSpread;
                    if (series != null)
                    {
                        ticker.SetColumnValues(i, series.Dates, series.Data.Select(x => x.Name).ToArray());
                        spreads.SetColumnValues(i, series.Dates, series.Data.Select(x => x.Value).ToArray());
                    }
                }
            }            
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:RollSeriesGenerator.cs

示例13: GetInvoiceSpreadsAsConstruct

    public static ConstructGen<double> GetInvoiceSpreadsAsConstruct()
    {
      var configs = invoiceSpreadConfigs().ToArray();

      var con = new ConstructGen<double>(
        configs.Select(x => string.Format("{0}_{1}_{2}", x.Future, x.Series + 1, x.Curve.ToString())).ToArray());

      for (int i = 0; i < configs.Length; ++i)
      {
        var spreads = getInvoiceSpreadsCollectionFromMongo(configs[i]);
        con.SetColumnValues(i,
          new DatedDataCollectionGen<double>(spreads.Lines.Select(x => x.Date).ToArray(),
            spreads.Lines.Select(x => x.InvoiceSpread ?? 0d).ToArray()));
      }

      if (con.NeedsToSortKeys())
        con.SortKeys();

      // feed forward missing values
      {
        var values = con.GetValues(con.Dates[0]);

        for (int i = 1; i < con.Dates.Count; ++i)
        {
          var date = con.Dates[i];

          var todayValues = con.GetValues(date);

          for (int j = 0; j < todayValues.Length; ++j)
          {
            if (todayValues[j] == 0d)
              todayValues[j] = values[j];
          }

          values = todayValues;
        }
      }

      return con;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:40,代码来源:InvoiceSpreadGenerator.cs

示例14: GetFlow

    public static ConstructGen<double> GetFlow(ConstructGen<double> wts_)
    {
      var ret = new ConstructGen<double>(wts_.ColumnHeadings);

      for (int i = 0; i < wts_.ArrayLength; ++i)
      {
        ret.SetColumnValues(i, wts_.GetColumnValuesAsDDC(i).ToDifferences().ToAbs());
      }
      return ret;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:10,代码来源:BacktestHelper.cs

示例15: AllConstantMaturityPrices

    public ConstructGen<double> AllConstantMaturityPrices()
    {
      if (m_allFuturePrices != null)
        return m_allFuturePrices;

      // get the quarterlyin contracts
      var allIMMs = Underlying.IMM_Contracts();

      // build up the list of prices for all contracts

      ConstructGen<double> subCon;
      {
        var con = new ConstructGen<double>(allIMMs.Select(x => x.SymmetryCode).ToArray());
        {
          for (int i = 0; i < con.ArrayLength; ++i)
            con.SetColumnValues(i, allIMMs[i].GetPrices(marketSnapCode_:MarketSnapCode,quoteSource_:QuoteSourceCode,priceType_:1));

          con.SortKeys();
        }

        var dates = SI.Strategy.RatesSpreads.DateHelper.GetBusinessDates(CurveNames.USD3M);

        subCon = new ConstructGen<double>(con.ColumnHeadings);

        foreach (var date in dates)
          if (con.Dates.Contains(date))
            subCon.SetValues(date, con.GetValues(date));
      }

      // create the construct that will hode the constant maturity prices
      // is NumContracts+1 as first column will be interest rate fixing

      m_allFuturePrices =
        new ConstructGen<double>(
          ExtensionMethods.CreateArrayRep(Underlying.FutureStart, NumContracts+1)
            .Select((x, i) => string.Format("{0}cm{1}", x.ToUpper(), i))
            .ToArray());

      foreach (var date in subCon.Dates)
      {
        // set the fixing
        m_allFuturePrices.SetValue(date, 0, Underlying.FixingInstrmnet.GetPrices().ValueOnDate(date)*100d);

        for (int pointIndex = 0; pointIndex < NumContracts; ++pointIndex)
        {
          var daysForward = Convert.ToDouble(pointIndex + 1)*DaysSpan;
          var forwardDate = date.AddDays(daysForward);

          int beforeIndex=-1, afterIndex=-1;
          for (int i = 0; i < allIMMs.Count-1; ++i)
          {
            if(allIMMs[i].Maturity.Value==forwardDate)
            {
              beforeIndex = i;
              afterIndex = i;
              break;
            }
            else if (allIMMs[i].Maturity.Value < forwardDate && allIMMs[i+1].Maturity.Value > forwardDate)
            {
              beforeIndex = i;
              afterIndex = i + 1;
            }
          }

          // were the indexes of the contract that straddle the forward date found?
          if (beforeIndex >= 0)
          {
            if (beforeIndex == afterIndex)
            {
              m_allFuturePrices.SetValue(date, pointIndex+1, 100d-subCon.GetValue(date, beforeIndex));
            }
            else
            {
              var beforeValue = subCon.GetValue(date, beforeIndex);
              var afterValue = subCon.GetValue(date, afterIndex);

              if (beforeValue == 0d || afterValue == 0d)
                continue;

              var width = allIMMs[afterIndex].Maturity.Value - allIMMs[beforeIndex].Maturity.Value;

              var w1 = forwardDate - allIMMs[beforeIndex].Maturity.Value;

              var propAfter = w1.TotalDays/width.TotalDays;

              var interpValue = (afterValue*propAfter) + (beforeValue*(1d - propAfter));

              m_allFuturePrices.SetValue(date, pointIndex+1, 100d-interpValue);
            }
          }
        }
      }

      return m_allFuturePrices;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:95,代码来源:ConstantMaturityFutures.cs


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