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


C# ConstructGen.GetValues方法代码示例

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


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

示例1: DeMarkSetupForChart

      public static void DeMarkSetupForChart(UltraChart chart, ConstructGen<double> candleData_, bool isDateChart, int openIndex_=0, int highIndex_=1, int lowIndex_=2, int closeIndex_=3,
                                                                            int setupLength_=9, int countdownLength_=13)
      {
          var closes = candleData_.GetColumnValuesAsDDC(closeIndex_);
          var range = closes.Data.Max() - closes.Data.Min();
          var cellHeight = range / 10d;



          var setupStarts = Analysis.GetSetups(candleData_, openIndex_, highIndex_, lowIndex_, closeIndex_, setupLength_);
          Analysis.AddCountdowns(candleData_, setupStarts, openIndex_, highIndex_, lowIndex_, closeIndex_, setupLength_, countdownLength_);

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

              var arr = candleData_.GetValues(date);
              //dt.LoadDataRow(new object[]
              //{
              //    date,
              //    arr[openIndex_],
              //    arr[highIndex_],
              //    arr[lowIndex_],
              //    arr[closeIndex_],
              //    0d
              //}, true);

              foreach (var mark in setupStarts)
              {
                  addAnnotations(chart, date, mark, i, cellHeight, arr, openIndex_, highIndex_, lowIndex_, closeIndex_);
              }
          }
      }
开发者ID:heimanhon,项目名称:researchwork,代码行数:33,代码来源:DeMarkChart3.cs

示例2: Create

    public override void Create(ConstructGen<double> wts_, ConstructGen<double> c2v_, ConstructGen<double> perf_)
    {
      base.Create(wts_, c2v_, perf_);

      if(RegionBreakdown!=null && RegionBreakdown.Count>0)
        foreach (WtsAnalyzerFXGroup wa in RegionBreakdown)
          wa.Create(wts_, c2v_,perf_);

      NumRebals = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), ExtensionMethods.GenerateArrayAllOfValue<double>(1d, wts_.Dates.Count)), DataEncapsDispValueType.Sum, "NumRebals");
      Sharpe = (Statistics.Average(base.Return.Data.Data) * 252d) / (Statistics.Stdev(base.Return.Data.Data) * Math.Sqrt(252d));

      ConstructGen<double> ccyTCosts = getTCostForDates(wts_.Dates);
      double[] tCcosts = new double[wts_.Dates.Count];

      if (false)
      {
        int[] ndfIndincies =
          Singleton<FXIDs>.Instance.Where<Currency>(x => x.IsGroup(FXGroup.NDF))
            .Select<Currency, int>(x => x.ArrayIndex)
            .ToArray<int>();

        DatedDataCollectionGen<double> adjReturn = (DatedDataCollectionGen<double>) Return.Data.Clone();

        for (int i = 0; i < wts_.Dates.Count; ++i)
        {
          int indexOfReturn = adjReturn.IndexOf(wts_.Dates[i]);
          double dayAdj = 0d;

          double[] wtsToday = wts_.GetValues(wts_.Dates[i]);
          if (i == 0)
          {
            foreach (int ndfIndex in ndfIndincies)
              dayAdj += -Math.Abs(wtsToday[ndfIndex]*ccyTCosts.GetValue(wts_.Dates[i], ndfIndex));
          }
          else
          {
            double[] wtsYest = wts_.GetValues(wts_.Dates[i - 1]);

            foreach (int ndfIndex in ndfIndincies)
              dayAdj += -Math.Abs((wtsToday[ndfIndex] - wtsYest[ndfIndex])*ccyTCosts.GetValue(wts_.Dates[i], ndfIndex));
          }

          tCcosts[i] += dayAdj;

          if (indexOfReturn != -1)
            adjReturn.Data[indexOfReturn] += dayAdj;
        }
      }

      NDF_TCost = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray(), tCcosts), DataEncapsDispValueType.Sum, "NDF_TCosts");
      NetReturn = new DataEncapsValue(Return.Data,DataEncapsDispValueType.Sum, "AdjReturn");
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:52,代码来源:WtsAnalyzer.cs

示例3: Create

    public virtual void Create(ConstructGen<double> wts_, ConstructGen<double> c2v_, ConstructGen<double> perf_)
    {
      double[] dollWts = new double[wts_.Dates.Count];
      double[] turnover = new double[wts_.Dates.Count];
      double[] flow = new double[wts_.Dates.Count];
      double[] leverage = new double[wts_.Dates.Count];

      for(int i=0;i<wts_.Dates.Count;++i)
      {
        double[] todayWts = wts_.GetValues(wts_.Dates[i]);
        dollWts[i]=Statistics.Sum(todayWts);
        leverage[i] = Statistics.SumAbs(todayWts);

        if(i==0)
        {
          turnover[i] = flow[i]=dollWts[i];
        }
        else
        {
          double[] prevWts = wts_.GetValues(wts_.Dates[i-1]);

          double t = 0d;
          double f = 0d;

          for (int j = 0; j < prevWts.Length; ++j)
          {
            if (todayWts[j] == prevWts[j] && todayWts[j] == 0d) continue;
            t += prevWts[j]==0d ? todayWts[j] : Math.Abs((todayWts[j] - prevWts[j]) / prevWts[j]);
            f += Math.Abs(todayWts[j] - prevWts[j]);
          }

          flow[i] = f;
          turnover[i] = t;
        }
      }

      SumWt = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), dollWts),"SumWt");
      Turnover = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), turnover),"Turnover");
      Flow = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), flow),"Flow");
      Leverage = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), leverage),"Leverage");
      //C2V = new DataEncapsValue(new DatedDataCollectionGen<double>(wts_.Dates.ToArray<DateTime>(), ExtensionMethods.GenerateArrayAllOfValue<double>(1d, wts_.Dates.Count)),"C2V");

      double[] perf = new double[perf_.Dates.Count];
      for (int i = 0; i < perf_.Dates.Count; ++i)
        perf[i] = Statistics.Sum(perf_.GetValues(perf_.Dates[i]));
      Return = new DataEncapsValue(new DatedDataCollectionGen<double>(perf_.Dates.ToArray<DateTime>(), perf),DataEncapsDispValueType.Sum,"Return");

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:48,代码来源:WtsAnalyzerBase.cs

示例4: getConstructOfInvoiceSpreads

    private ConstructGen<double> getConstructOfInvoiceSpreads()
    {
      var con = new ConstructGen<double>(Configs.Length);

      for (int i = 0; i < con.ArrayLength; ++i)
      {
        for (int j = 0; j < Collections[i].Lines.Count; ++j)
        {
          var date = Collections[i].Lines[j].Date;
          var val = Collections[i].Lines[j].InvoiceSpread;

          con.SetValue(date, i, val ?? double.PositiveInfinity);
        }
      }

      con.SortKeys();

      // feed forward missing values

      double[] before = null;

      foreach (var date in con.Dates)
      {
        var today = con.GetValues(date);
        if (before != null)
        {
          for(int i=0;i<today.Length;++i)
            if (double.IsInfinity(today[i]))
              today[i] = before[i];
        }
        before = today;
      }

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

示例5: Create

    public void Create(ConstructGen<double> con_)
    {
      setupDataTable();

      double cumulative = 0d;

      foreach (var date in con_.Dates)
      {
        var values = con_.GetValues(date);

        var wt = values[(int)Headings.Weight];

        var dailyPnl = values[(int)Headings.Pnl];

        cumulative += dailyPnl;

        dt.LoadDataRow(new object[] 
        {
          date,
          cumulative,
          values[(int)Headings.Spot],
          wt > 0d ? wt : 0d,
          wt < 0d ? wt : 0d
          }, true);
      }

      m_con = con_;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:28,代码来源:WtPnlAnalysis.cs

示例6: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      double[] sigToday = new double[products_.Count];

      foreach (DateTime date in signalResults_.Dates)
      {
        double[] filterToday = filters_.GetValues(date);
        int productValidCount = 0;
        double sum = 0;

        for (int i = 0; i < sigToday.Length; ++i)
        {
          sigToday[i] = signalResults_.GetValue(date, i);
          if (double.IsNaN(filterToday[i]) == false && double.IsNaN(sigToday[i]) == false)
          {
            ++productValidCount;
            sum += sigToday[i];
          }
        }

        var avg = sum / Convert.ToDouble(productValidCount);

        for (int i = 0; i < sigToday.Length; ++i)
        {
          if (double.IsNaN(filterToday[i]) == false && double.IsNaN(sigToday[i]) == false)
            wts_.MultValue(date, i, sigToday[i] - avg);
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:WtImpactCrossSectionalDemeaning.cs

示例7: DoScaleWeights

    public static ConstructGen<double> DoScaleWeights(ConstructGen<double> wts_, TraderArgs args_, Func<DateTime,double> getVolTargetForDate_)
    {
      if (wts_.ColumnHeadings == null)
        wts_.ColumnHeadings = args_.Products.Select(x => x.Name).ToArray();

      var logReturns = args_.AllProductPrices(fillInGapsWithPrevious_: true).ToLogReturns(
        args_.Products.Select(x => x.Convention).ToArray());

      var scaledWts = new ConstructGen<double>(wts_.ColumnHeadings);

      foreach (var date in wts_.Dates)
      {
        var wtArr = wts_.GetValues(date);

        for (int i = 0; i < wtArr.Length; ++i)
          if (double.IsInfinity(wtArr[i]))
            wtArr[i] = 0d;

        int indexOfDate = logReturns.FindIndexOfEffectiveDateOnDate(date);

        indexOfDate = (indexOfDate < 252) ? 252 : indexOfDate - 1; // note offset

        var subValues = logReturns.GetSubValues(logReturns.Dates[indexOfDate - 251], logReturns.Dates[indexOfDate]);

        var covArr = SI.Data.FXHistCovar.MatCovar(subValues.ToArray());

        var cov = new CovarianceItem(covArr);

        scaledWts.SetValues(date, cov.ScaleSeries(wtArr, getVolTargetForDate_(date)));
      }

      return scaledWts;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:33,代码来源:TraderGen.cs

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

示例9: doPnl

    protected override ReturnsEval.DataSeriesEvaluator doPnl(TraderArgs args_, ConstructGen<double> wts_)
    {
      var priceReturns =
        args_.AllProductPrices(fillInGapsWithPrevious_: true)
          .ToReturns(args_.Products.Select(x => x.Convention).ToArray());


      var stratReturns = new ConstructGen<double>(priceReturns.ColumnHeadings);

      double[] appliedWeights = null;

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

        var priceReturnsArr = priceReturns.GetValues(date);

        if (appliedWeights != null)
        {
          for (int j = 0; j < priceReturnsArr.Length; ++j)
            stratReturns.SetValue(date, j, appliedWeights[j]*priceReturnsArr[j]);
        }

        if (wts_.Dates.Contains(date))
        {
          appliedWeights = wts_.GetValues(date);
        }
      }

      var eval = new ReturnsEval.DataSeriesEvaluator("Gen pnl from weights", ReturnsEval.DataSeriesType.Returns);
      eval.AddInnerSeries(stratReturns.Dates.ToArray(), stratReturns.ToArray(), stratReturns.ColumnHeadings);

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

示例10: Create

    public void Create(ConstructGen<double> candleData_, int openIndex_ = 0, int highIndex_ = 1, int lowIndex_ = 2, int closeIndex_ = 3, int setupLength_=9, int countdownLength_=13)
    {
      var dt = new DataTable();
      dt.Rows.Clear();
      dt.Columns.Clear();

      dt.Columns.Add("Date", typeof(DateTime));
      dt.Columns.Add("Open", typeof(double));
      dt.Columns.Add("High", typeof(double));
      dt.Columns.Add("Low", typeof(double));
      dt.Columns.Add("Close", typeof(double));
      dt.Columns.Add("Volume", typeof(double));

      ultraChart1.DataSource = dt;

      var closes = candleData_.GetColumnValuesAsDDC(closeIndex_);
      var range = closes.Data.Max() - closes.Data.Min();
      var cellHeight = range/10d;


      var setupStarts = DeMarkAnalysis.GetSetups(candleData_,openIndex_,highIndex_,lowIndex_,closeIndex_,setupLength_);
      DeMarkAnalysis.AddCountdowns(candleData_, setupStarts,openIndex_,highIndex_,lowIndex_,closeIndex_,setupLength_,countdownLength_);


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

        var arr = candleData_.GetValues(date);
        dt.LoadDataRow(new object[]
        {
          date,
          arr[openIndex_],
          arr[highIndex_],
          arr[lowIndex_],
          arr[closeIndex_],
          0d
        }, true);

        foreach(var mark in setupStarts)
        {
          addAnnotations(date, mark, i, cellHeight, arr,openIndex_,highIndex_,lowIndex_,closeIndex_);
        }
      }

      EstablishDefaultTooltip(hash =>
      {
        int rowNumber = (int) hash["DATA_ROW"];

        return string.Format("{0} Open: {1}, High: {2}, Low: {3}, Close: {4}",
          ((DateTime) dt.Rows[rowNumber]["Date"]).ToString("dd-MMM-yyyy"),
          ((double) dt.Rows[rowNumber]["Open"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["High"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["Low"]).ToString(CultureInfo.InvariantCulture),
          ((double)dt.Rows[rowNumber]["Close"]).ToString(CultureInfo.InvariantCulture)
          ).Replace(",", System.Environment.NewLine);

      });
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:59,代码来源:DeMarkChart3.cs

示例11: loadListFromWeights

    private void loadListFromWeights(ConstructGen<double> wts_, IList<PositionLine<Currency>> list_)
    {
      var lastDate = wts_.Dates.Last();

      var wtsLast = wts_.GetValues(lastDate);

      for (int i = 0; i < wts_.ArrayLength; ++i)
        findIn(list_, Singleton<FXIDs>.Instance[i]).Position = wtsLast[i];
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:9,代码来源:FXBreakoutRebalanceControl.cs

示例12: Create

    public void Create(ConstructGen<double> con_)
    {
      setupDataTable();

      double cumulative = 0d;

      Side lastSide = Side.None;

      foreach (var date in con_.Dates)
      {
        var values = con_.GetValues(date);

        var wt = values[(int)Headings.Weight];
        var dailyPnl = values[(int)Headings.Pnl];
        var ccyrate = values[(int)Headings.Spot];

        cumulative += dailyPnl;

        dt.LoadDataRow(new object[] { date, cumulative, ccyrate, wt }, true);

        if (wt > 0d)
        {
          if (lastSide != Side.Long)
          {
            dtLongPoints.LoadDataRow(new object[] { date, ccyrate }, true);
            lastSide = Side.Long;
          }
        }
        else if (wt < 0d)
        {
          if (lastSide != Side.Short)
          {
            dtShortPoints.LoadDataRow(new object[] { date, ccyrate }, true);
            lastSide = Side.Short;
          }
        }
        else
        {
          if (lastSide != Side.Flat)
          {
            dtFlatPoints.LoadDataRow(new object[] { date, ccyrate }, true);
            lastSide = Side.Flat;
          }
        }
      }

      {
        var ccyAxix = ultraChart.CompositeChart.ChartAreas[0].Axes.FromKey("y_axis_ccyRate");

        ccyAxix.RangeType = AxisRangeType.Custom;
        var ccyValues = con_.GetColumnValues((int)Headings.Spot);
        ccyAxix.RangeMin = ccyValues.Min();
        ccyAxix.RangeMax = ccyValues.Max();
      }

      m_con = con_;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:57,代码来源:WtPnlAnalysis3.cs

示例13: Create

    public void Create(ConstructGen<double> con_)
    {
      setupDataTable();

      double cumulative = 0d;

      double? prevWt=null;

      foreach (var date in con_.Dates)
      {
        var values = con_.GetValues(date);

        var wt = values[(int)Headings.Weight];
        var dailyPnl = values[(int)Headings.Pnl];
        var ccyrate = values[(int)Headings.Spot];

        cumulative += dailyPnl;

        var objArr = new object[dt.Columns.Count];

        objArr[0] = date;
        objArr[1] = cumulative;

        var indexForWt = getIndexForWt(wt);
        objArr[indexForWt] = ccyrate;

        if (prevWt.HasValue)
        {
          var indexForPrevWt = getIndexForWt(prevWt.Value);

          if (indexForWt != indexForPrevWt)
            objArr[indexForPrevWt] = ccyrate;
        }


        objArr[5] = wt > 0d ? wt : 0d;
        objArr[6] = wt < 0d ? wt : 0d;

        dt.LoadDataRow(objArr, true);

        prevWt = wt;
      }

      {
        var ccyAxix = ultraChart.CompositeChart.ChartAreas[0].Axes.FromKey("y_axis_ccyRate");

        ccyAxix.RangeType = AxisRangeType.Custom;
        var ccyValues = con_.GetColumnValues((int)Headings.Spot);
        ccyAxix.RangeMin = ccyValues.Min();
        ccyAxix.RangeMax = ccyValues.Max();
      }

      m_con = con_;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:54,代码来源:WtPnlAnalysis2.cs

示例14: WtsSeriesAnalyzer

    public WtsSeriesAnalyzer(string name_, ConstructGen<double> wts_, ConstructGen<double> dailyReturns_, GetCov covDelegate_, bool addFXGroups_=true)
    {
      m_wts = wts_;
      m_perf = dailyReturns_;
      m_covDelegate=covDelegate_;
      Name=name_;

      m_c2v = new ConstructGen<double>(wts_.ArrayLength);
      m_c2v.ColumnHeadings = wts_.ColumnHeadings;
      foreach (DateTime date in wts_.Dates)
      {
        double[] dayWts = wts_.GetValues(date);
        if (Statistics.SumAbs(dayWts) == 0d  || covDelegate_==null)
          m_c2v.SetValues(date, new double[m_c2v.ArrayLength]);
        else
          m_c2v.SetValues(date, covDelegate_(date).GetContToVar(wts_.GetValues(date), false));
      }
      m_anal = new WtsAnalyzer(Name);

      if(addFXGroups_) m_anal.AddFXGroups();
      analyzePersistence();
      EvaluateAll();
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:23,代码来源:WtsSeriesAnalyzer.cs

示例15: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      double[] sigToday = new double[products_.Count];
      double sum;

      foreach (DateTime date in signalResults_.Dates)
      {
        double[] filterToday = filters_.GetValues(date);
        sum = 0;

        for (int i = 0; i < sigToday.Length; ++i)
          if(double.IsNaN(filterToday[i])==false)
            sum += signalResults_.GetValue(date, i);

        for (int i = 0; i < sigToday.Length; ++i)
          if(double.IsNaN(filterToday[i])==false)
            wts_.MultValue(date, i, signalResults_.GetValue(date, i) / sum, false);
      }

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


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