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

      ConstructGen<double> conBottomLeft = new ConstructGen<double>(list.Count);
      conBottomLeft.ColumnHeadings = new string[conBottomLeft.ArrayLength];
      int i = 0;
      foreach (string s in list.Keys)
      {
        conBottomLeft.ColumnHeadings[i] = s;
        DatedDataCollectionGen<double> coll = list[s].Data;

        DatedDataCollectionGen<double> monthly = coll.ToPeriod(m_blArgs.Period, m_blArgs.Collation);
        for (int j = 0; j < monthly.Length; ++j)
          conBottomLeft.SetValue(monthly.Dates[j], i, monthly.Data[j]);

        ++i;
      }
      conBottomLeft.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_BL_title.Text = titleBuilder.ToString();

      simpleWtsColumnChart2.Create<DateTime, string>(new SortedDictionary<DateTime, double[]>(conBottomLeft.GetInnerData()), conBottomLeft.ColumnHeadings, ExtensionMethods.FormatStringForPeriodicity(m_blArgs.Period));
      //simpleWtsColumnChart2.SetYAxisScaleRange(0d, double.MinValue);
    }
Ejemplo n.º 2
0
    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());
    }
    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);
    }
Ejemplo n.º 4
0
    private SortedDictionary<DateTime, double[]> getCumulativePnls()
    {
      int[] selIndexes = getSelectedIndixes();

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

      DateTime prevDate = DateTime.MinValue;

      DateTime startDate = m_comp.GetDate(m_focus);
      int startI = m_comp.PnlConstruct.Dates.IndexOf(startDate);

      int endI = m_comp.PnlConstruct.Dates.IndexOf(m_comp.AsOfDate);

      for (int i = startI; i <= endI; ++i)
      {
        DateTime date = m_comp.PnlConstruct.Dates[i];

        for (int j = 0; j < selIndexes.Length; ++j)
        {
          if (i == startI)
          {
            cum.SetValue(date, j, m_comp.PnlConstruct.GetValue(date, selIndexes[j]));
          }
          else
          {
            cum.SetValue(date, j, m_comp.PnlConstruct.GetValue(date, selIndexes[j]) + cum.GetValue(prevDate, j));
          }
        }

        prevDate = date;
      }

      return new SortedDictionary<DateTime, double[]>(cum.GetInnerData());
    }