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


C# ConstructGen.SortKeys方法代码示例

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


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

    public static ConstructGen<double> GetSmoothCurvesColumnsAreCurvePoints(DateTime valueDate_, uint curveCount_, BondMarket market_, BondField field_, SI.Data.BondCurves curve_, string close_ = "MLP", string source_ = "MLP")
    {
      DateTime date = valueDate_;

      var points = new List<decimal>();

      for (decimal d = 1M; d < 30M; d = d + 0.25M)
        points.Add(d);

      var con = new ConstructGen<double>(points.Select(x => x.ToString()).ToArray());

      for (int i = 0; i < curveCount_; ++i)
      {
        var curve = GetSmoothCurve(date, market_, field_, curve_, close_, source_);
        if (curve == null) continue;

        foreach (var node in curve.GetNodes())
        {
          int index = points.IndexOf(node);

          if (index == -1) continue;

          var point = curve.GetValue(node);

          if(point.HasValue)
            con.SetValue(date, index, point.Value);
        }

        date = MyCalendar.PrevWeekDay(date);
      }

      con.SortKeys();

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

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

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

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

    public void Create(IList<DataSeriesEvaluator> evals_)
    {
      m_evals = evals_;
      m_pnls = new ConstructGen<double>(evals_.Count);

      for (int evalIndex = 0; evalIndex < evals_.Count; ++evalIndex)
        for (int i = 0; i < m_evals[evalIndex].Daily.Data.Length; ++i)
          m_pnls.SetValue(m_evals[evalIndex].Daily.Dates[i], evalIndex, m_evals[evalIndex].Daily.Data[i]);

      m_pnls.SortKeys();

      m_customStartDate = DateTime.Today.Month == 1
        ? new DateTime(DateTime.Today.Year - 1, 1, 1)
        : new DateTime(DateTime.Today.Year, 1, 1);

      //AsOfDate = MyCalendar.PrevWeekDay(DateTime.Today);
      AsOfDate = m_pnls.LastDate;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:18,代码来源:EvalComparer.cs

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

示例8: buildData

    private void buildData()
    {
      var pxDates = new List<DateTime>();
      var pxValues = new List<double>();

      for (int y = 2003;y <= DateTime.Now.Year; ++y)
      {
        // find the contracts
        var conLon = Long.Underlying.Futures.Where(x => x.Expiry.Year-Long.YearOffset == y && x.Expiry.Month == (int)Long.Month).FirstOrDefault();
        var conShort = Short.Underlying.Futures.Where(x => x.Expiry.Year-Short.YearOffset == y && x.Expiry.Month == (int)Short.Month).FirstOrDefault();

        if (conLon != null && conShort != null)
        {
          m_contractsLongShort.Add(y, new KeyValuePair<ComFutureMeta, ComFutureMeta>(conLon, conShort));

          // last trade of this pair is the earliest lastTrade date of the two
          var lastTrade = (conLon.LastTrade < conShort.LastTrade) ? conLon.LastLastDate : conShort.LastLastDate;
          var dataStart = lastTrade.AddYears(-1);

          if (MyCalendar.IsWeekend(dataStart)) dataStart = MyCalendar.NextWeekDay(dataStart);

          ConstructGen<double> con = new ConstructGen<double>(new string[] { conLon.Ticker, conShort.Ticker, "Diff", "Normalized" });

          con.SetColumnValues((int)dataColumns.Long, conLon.Prices.GetSubValues(dataStart, lastTrade));
          con.SetColumnValues((int)dataColumns.Short, conShort.Prices.GetSubValues(dataStart, lastTrade));

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

          if (con.Dates.Count == 0)
            continue;

          // calculate differences
          foreach (DateTime date in con.Keys)
          {
            double[] d = con.GetValues(date);

            // if we have a value for both contracts on this day
            if (d[(int)dataColumns.Long] != 0d && d[(int)dataColumns.Short] != 0d)
            {
              // save down the difference
              d[(int)dataColumns.Diff] = d[(int)dataColumns.Long] - d[(int)dataColumns.Short];

              if (date.Year == y)
              {
                pxDates.Add(date);
                pxValues.Add(d[2]);
              }
            }
          }

          // normalize differences
          {
            DatedDataCollectionGen<double> diffs = con.GetColumnValuesAsDDC((int)dataColumns.Diff);

            if (diffs==null || diffs.Length == 0)
              continue;

            var min = diffs.Data.Min();
            var max = diffs.Data.Max();

            var normArr = new double[diffs.Length];

            for (int i = 0; i < normArr.Length; ++i)
              normArr[i] = (diffs.Data[i] - min) / (max - min);

            con.SetColumnValues((int)dataColumns.NormalizedDiff, new DatedDataCollectionGen<double>(diffs.Dates, normArr));
          }


          m_yearToPxs.Add(y, con);
        }
      }
      m_hasBuiltData = true;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:74,代码来源:SpreadDefinition.cs

示例9: AllProductPrices

    public ConstructGen<double> AllProductPrices(bool fillInGapsWithPrevious_ = true)
    {
      // start by generating price series

      ConstructGen<double> prices = new ConstructGen<double>(Products.Select(x => x.Name).ToArray());

      for (int i = 0; i < Products.Count; ++i)
        prices.SetColumnValues(i, Products[i].Prices);

      if (prices.NeedsToSortKeys())
        prices.SortKeys();

      // fill in any missing values (holidays)
      if(fillInGapsWithPrevious_)
      {
        double[] yesterday = null;

        foreach (var date in prices.Dates)
        {
          var today = prices.GetValues(date);

          if (yesterday != null)
          {
            for(int i=0;i<today.Length;++i)
              if (today[i] == 0d)
                today[i] = yesterday[i];
          }

          yesterday = today;
        }
      }

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

示例10: Go

    public void Go()
    {
      var allweights=new ConstructGen<WeightsLine>(Spreads.Length);

      // mark each of the individual spread weight entry/exit points in the construct - could well be different dates per spread...
      for(int i=0;i<Spreads.Length;++i)
      {
        var wts = Spreads[i].GenerateWeights();

        foreach (var wt in wts)
        {
          if (wt.EntryDate <= DateTime.Today) allweights.SetValue(wt.EntryDate, i, wt);
          if (wt.ExitDate <= DateTime.Today) allweights.SetValue(wt.ExitDate, i, wt);
        }
      }

      allweights.SortKeys();


      // on each date, note the positions that are carried over from an earlier trade on the same day, so that we have a
      // full picture of what is in play on that day
      WeightsLine[] prev = null;
      foreach (var date in allweights.Dates)
      {
        var todays = allweights.GetValues(date);
        if (prev != null)
        {
          for (int i = 0; i < todays.Length; ++i)
          {
            if (prev[i] != null && todays[i]==null && date <= prev[i].ExitDate)
              todays[i] = prev[i];
          }
        }

        prev = todays;
      }

      if (allweights.NeedsToSortKeys()) allweights.SortKeys();

      // go through each of the dates to generate a covariance and scale the positions 
      foreach (DateTime date in allweights.Keys)
      {
        var arr = allweights.GetValues(date);

        // build up list of indicies that are live on the current date
        var liveIndicies = new List<int>();

        for (int i = 0; i < arr.Length; ++i)
          if (arr[i] != null && arr[i].ExitDate > date)
            liveIndicies.Add(i);

        if (!liveIndicies.Any()) continue;

        var liveItems = liveIndicies.Select(x => arr[x]).ToArray();

        // for all live items form an array of recent returns over of length 'NumDaysForCovariance'
        var returns = new double[NumDaysForCovariance, liveIndicies.Count()];
        var rawSpreadWeights = new double[liveIndicies.Count()];

        for (int i = 0; i < liveIndicies.Count; ++i)
        {
          var indexReturns = liveItems[i].GetAllSpreadReturns();

          // have prices been updated?
          if (indexReturns.LastDate < date)
            continue;

          int indexOfDate = indexReturns.IndexOfElsePrevious(date);
          --indexOfDate;


          var slice = indexReturns.Data.Slice(indexOfDate - NumDaysForCovariance + 1, NumDaysForCovariance);
          rawSpreadWeights[i] = liveItems[i].SpreadWeight/Statistics.Stdev(slice);
          returns.SetColumn(i, slice);
        }

        // buil the covariance
        var covar = new CovarianceItem(Utils.CalculateCovariance(returns));

        // vol bucketing
        var targetvol = liveItems.Length*0.02;

        // scale the weights
        var newwts = covar.ScaleSeries(rawSpreadWeights, targetvol);

        for (int i = 0; i < newwts.Length; ++i)
          liveItems[i].AddCombineWeight(date, newwts[i]);
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:89,代码来源:SpreadWeightGeneratorCombiner.cs

示例11: Test


//.........这里部分代码省略.........
        //    false)),
        new SpreadWeightGenerator(
          new WeightGeneratorArgs()
          {
            Lookback = lookback,
            WeightGenerationType = genType,
            MinWindowLength = 60,
            ZScoreThreshold = 1.3d
          },
          new SpreadDefinition(
            new MonthYearOffset(ComIDs.Corn, 0, MonthCode.U),
            new MonthYearOffset(ComIDs.Corn, 0, MonthCode.Z),
            false)),
        //new SpreadWeightGenerator(
        //  new WeightGeneratorArgs()
        //  {
        //    Lookback = lookback,
        //    WeightGenerationType = genType,
        //    MinWindowLength = 90,
        //    ZScoreThreshold = 0.8d
        //  },
        //  new SpreadDefinition(
        //    new MonthYearOffset(ComIDs.Corn, 0, MonthCode.U),
        //    new MonthYearOffset(ComIDs.Corn, 0, MonthCode.Z),
        //    false)),
        new SpreadWeightGenerator(
          new WeightGeneratorArgs()
          {
            Lookback = lookback,
            WeightGenerationType = genType,
            MinWindowLength = 40,
            ZScoreThreshold = 1.5d
          },
          new SpreadDefinition(
            new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.U),
            new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.Z),
            false)),
        //new SpreadWeightGenerator(
        //  new WeightGeneratorArgs()
        //  {
        //    Lookback = lookback,
        //    WeightGenerationType = genType,
        //    MinWindowLength = 50,
        //    ZScoreThreshold = 1.3d
        //  },
        //  new SpreadDefinition(
        //    new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.U),
        //    new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.Z),
        //    false)),
        //new SpreadWeightGenerator(
        //  new WeightGeneratorArgs()
        //  {
        //    Lookback = lookback,
        //    WeightGenerationType = genType,
        //    MinWindowLength = 70,
        //    ZScoreThreshold = 1.1d
        //  },
        //  new SpreadDefinition(
        //    new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.U),
        //    new MonthYearOffset(ComIDs.Wheat, 0, MonthCode.Z),
        //    false)),
        new SpreadWeightGenerator(
          new WeightGeneratorArgs()
          {
            Lookback = lookback,
            WeightGenerationType = genType,
            MinWindowLength = 50,
            ZScoreThreshold = 1.6d
          },
          new SpreadDefinition(
            new MonthYearOffset(ComIDs.RBOB, 0, MonthCode.J),
            new MonthYearOffset(ComIDs.RBOB, 0, MonthCode.U),
            false)),
      };

      var comb = new SpreadWeightGeneratorCombiner(arr) {NumDaysForCovariance = 42, TargetVol = 0.06};
      comb.Go();

      {
        var combinedPnl = new ConstructGen<double>(arr.Length);

        combinedPnl.ColumnHeadings =
          arr.Select(x => string.Format("{0} / {1} / {2}", x.Spread, x.Args.MinWindowLength, x.Args.ZScoreThreshold))
            .ToArray();

        for (int i = 0; i < arr.Length; ++i)
          combinedPnl.SetColumnValues(i, arr[i].GetCombinedPnl());

        if (combinedPnl.NeedsToSortKeys())
          combinedPnl.SortKeys();


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

        combinedPnl.SumRows().ToCumulative().DisplayLineChart("combined pnl of scaled weights");
      }

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

示例12: ShowPortfolioPnlProgression

    public void ShowPortfolioPnlProgression()
    {
      var pnl = new ConstructGen<double>(Positions.Select(x=>x.Security).ToArray());

      var flp = new System.Windows.Forms.FlowLayoutPanel();

      var listOfInfraBoxes = new List<Infragistics.Win.Misc.UltraGroupBox>();

      for (int i = 0; i < pnl.ArrayLength; ++i)
      {
        var posPnl = Positions[i].GeneratePnlSinceFix();

        for (int d = 0; d < posPnl.Length; ++d)
        {
          pnl.SetValue(posPnl.Dates[d], i, posPnl.Data[d].Close);
        }

        {
          Infragistics.Win.Misc.UltraGroupBox box = new Infragistics.Win.Misc.UltraGroupBox();
          box.Text = string.Format("{0} {1}", Positions[i].Security, Positions[i].Pnl.ToString("###0.0#;(###0.0#);-"));
          box.Tag = Positions[i].Pnl;
          box.Size = new System.Drawing.Size(250, 250);

          var chart = new SI.Controls.BarDataPointChart();
          chart.SetYAxisFormat("##0.0#");
          chart.Dock = System.Windows.Forms.DockStyle.Fill;
          chart.Create(posPnl);
          box.Controls.Add(chart);
          listOfInfraBoxes.Add(box);
        }
      }

      Infragistics.Win.Misc.UltraGroupBox[] boxArr = listOfInfraBoxes.OrderByDescending(x => (double)x.Tag).ToArray();

      {
        double max = 0d;
        foreach (Infragistics.Win.Misc.UltraGroupBox box in boxArr)
        {
          max = Math.Max(max, ((SI.Controls.BarDataPointChart)box.Controls[0]).YAxisAbsoluteMax);
        }

        foreach (Infragistics.Win.Misc.UltraGroupBox box in boxArr)
        {
          ((SI.Controls.BarDataPointChart)box.Controls[0]).SetMaxMinYAxisRange(max);
        }
      }

      foreach (Infragistics.Win.Misc.UltraGroupBox box in boxArr)
      {
        flp.Controls.Add(box);
      }


      pnl.SortKeys();

      for (int i = 0; i < pnl.ArrayLength; ++i)
      {
        DatedDataCollectionGen<double> col = pnl.GetColumnValuesAsDDC(i);
        double last = col.Data[0];

        for (int j = 1; j < col.Length; ++j)
        {
          double val = col.Data[j];

          if (val == 0d)
          {
            if (last != 0d)
            {
              pnl.SetValue(col.Dates[j], i, last);
            }
          }
          else
            last = val;
        }
      }

      DatedDataCollectionGen<double> total = pnl.SumRows();

      KeyValuePair<string, System.Windows.Forms.Control>[] cons = new KeyValuePair<string, System.Windows.Forms.Control>[3];

      var stack = new Controls.SimpleStackedColumnChart();

      stack.Create<string, string>(
        pnl.Dates.Select(x => x.ToString("HH:mm")).ToArray(),
        Positions.Select(x => x.Security).ToArray(),
        pnl.ToArray());
      cons[0] = new KeyValuePair<string, System.Windows.Forms.Control>("position attributed", stack);


      //stack.DisplayInShowForm(string.Format("{0} pnl progression, position attributed", this.Name));

      var lcdd = new SI.Controls.LineChartDataDisplay();
      lcdd.AddSeries(total.Dates, total.Data, Name, 40, "#0.0#");
      lcdd.SetXAxisFormat("HH:mm");
      //lcdd.DisplayInShowForm(string.Format("{0} total pnl progression", m_p.DisplayName));
      cons[1] = new KeyValuePair<string, Control>("total", lcdd);

      cons[2] = new KeyValuePair<string, Control>("comp", flp);

      cons.DisplayInShowForm(string.Format("{0} pnl progression", Name));
//.........这里部分代码省略.........
开发者ID:heimanhon,项目名称:researchwork,代码行数:101,代码来源:LivePortfolio.cs

示例13: getRollingVols

    private SortedDictionary<DateTime, double[]> getRollingVols()
    {
      int[] selIndexes = getSelectedIndixes();

      ConstructGen<double> cum = new ConstructGen<double>(selIndexes.Length);

      DateTime startDate = m_comp.GetDate(m_focus);
      for (int i = 0; i < cum.ArrayLength; ++i)
      {
        ReturnsEval.DataSeriesEvaluator e = m_comp.GetEval(selIndexes[i]);
        if(e.Daily.Dates[0]>startDate)
          e.Evaluate(); 
        e.Daily.GenerateRollingWindowSeries(m_extraArgs.RollingWindowLength);

        for (int j = 0; j < e.Daily.RollingSharpeSeries[m_extraArgs.RollingSeriesType].Dates.Length; ++j)
        {
          DateTime date = e.Daily.RollingSharpeSeries[m_extraArgs.RollingSeriesType].Dates[j];
          if (date < startDate)
            continue;
          double val = e.Daily.RollingSharpeSeries[m_extraArgs.RollingSeriesType].Data[j];

          if(m_extraArgs.RollingSeriesType==SI.ReturnsEval.RollingSeriesType.Vol)
            val /= 100.0;

          cum.SetValue(date, i, val);
        }
      }
      cum.SortKeys();
      return new SortedDictionary<DateTime, double[]>(cum.GetInnerData());
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:EvalComparerControl.cs

示例14: Go


//.........这里部分代码省略.........

      // (I'll show you how to do this more easily in a bit...

      // let's look at what we can do with construct and how we use it

      DateTime conDate = new DateTime(2014, 1, 1);

      firstConstruct.SetValue(conDate, 0, 100.2);

      // this has set the value for the first column (AUD) on the given Date

      // we get it out by:

      var v1 = firstConstruct.GetValue(conDate, 0);

      // set the second value:

      firstConstruct.SetValue(conDate, 1, 45.6);

      // this has set the value for the given date for 'CAD'

      // we could set all values at once using SetValues rather than SetValue

      firstConstruct.SetValues(conDate, new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9});

      // and we could get them out using:

      double[] allValuesOnDate = firstConstruct.GetValues(conDate);

      // there are lots of methods on Construct<T> to make our life easier when dealing with data

      // we can fill it up randomly using the SetValues, and then just call SortKeys() to ensure teh dates are in order

      firstConstruct.SortKeys();

      // this means that we will be iterate over the dates in order when we go through it

      // e.g.

      foreach (DateTime date in firstConstruct.Dates)
      {
        var datesVAlues = firstConstruct.GetValues(date);

        // here we could process them...
      }

      // there are methods on ConstructGen<T> to make it easy to see what's in it.  e.g.

      firstConstruct.DisplayInGrid("Grid of construct values");
      firstConstruct.DisplayInDataCollectionDisplay("Display each column as a line in a chart");

      // there is also a useful method to get the column of values as a DatedDataCollection<T>

      DatedDataCollectionGen<double> firstColumn = firstConstruct.GetColumnValuesAsDDC(0);

      // this is an expensive operation FYI, so you wouldn't use this iterating over the dates within the ConstructGen<T> , but it is useful

      
      // ok, now, as we have a set universe of ccys, in the way I extract data from the database (prices / weights / carry / etc) I tend to pull
      // out in a standard way, making a ConstructGen<double> with a column for every currency in the universe

      // so, for example, if I wanted the spots from the database from 2013 onwards, I would call this

      SI.Data.FXSpots spotsProvider = new FXSpots();

      ConstructGen<double> spots = spotsProvider.GetData(new DateTime(2013, 1, 1), DateTime.Today);
开发者ID:heimanhon,项目名称:researchwork,代码行数:67,代码来源:L1.cs

示例15: reloadTopRight

    private void reloadTopRight(IDictionary<string, DataEncapsValue> list)
    {
      if (list.Count == 0 || m_trArgs.Locked)
        return;

      ConstructGen<double> conTopRight = new ConstructGen<double>(list.Count);
      conTopRight.ColumnHeadings = new string[conTopRight.ArrayLength];
      int i = 0;
      foreach (string s in list.Keys)
      {
        conTopRight.ColumnHeadings[i] = s;
        DatedDataCollectionGen<double> coll = list[s].Data;
        double[] series = (cbTopRightCumulative.Checked) ? coll.Data.Cumulative() : coll.Data;
        for (int j = 0; j < series.Length; ++j)
          conTopRight.SetValue(coll.Dates[j], i, series[j]);

        ++i;
      }
      conTopRight.SortKeys();

      StringBuilder titleBuilder=new StringBuilder();
      foreach (string s in list.Values.Select<DataEncapsValue, string>(x => x.Name).Distinct<string>())
        titleBuilder.Append(s).Append(" / ");
      titleBuilder.Length -= 3;
      lbl_TR_title.Text = titleBuilder.ToString();

      dataCollectionDisplay1.Create(new SortedDictionary<DateTime, double[]>(conTopRight.GetInnerData()), conTopRight.ColumnHeadings);
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:28,代码来源:WtsAnalysisCompareControl.cs


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