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


C# ConstructGen类代码示例

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


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

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

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

示例3: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      List<SortHelpClass> list = new List<SortHelpClass>();

      foreach (DateTime date in signalResults_.Dates)
      {
        //wts_.MultValue(date, i, val, val < 0);

        list.Clear();

        for (int i = 0; i < signalResults_.ArrayLength; ++i)
        {
          double val = signalResults_.GetValue(date, i);

          if (double.IsNaN(val) == false)
            list.Add(new SortHelpClass(val, i, m_abs,false,false));
        }

        QuickSort.Sort<SortHelpClass>(list);



        for (int i = 0; i < wts_.ArrayLength && i < list.Count; ++i)
        {
          wts_.MultValue(date, list[i].ArrayIndex, list[i].Value, list[i].Value < 0);
        }

      }

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

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

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

示例6: DoWeights

    public override void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      for (int i = 0; i < products_.Count; ++i)
      {
        double avg = 0;
        for (int j = 0; j < signalResults_.Dates.Count; ++j)
        {
          if(j<WindowLength)
          {
            wts_.SetValue(signalResults_.Dates[j],i,0);
            continue;
          }

          // if the product is not valid on this date then the weight is zero.
          if (double.IsNaN(filters_.GetValue(signalResults_.Dates[j],i)))
          {
            wts_.SetValue(signalResults_.Dates[j], i, 0.0);
          }
          else
          {
            for (int y = 0; y < WindowLength; ++y)
              avg += signalResults_.GetValue(signalResults_.Dates[j - y], i);
            avg /= WindowLength;

            double val = signalResults_.GetValue(signalResults_.Dates[j], i) / avg;

            wts_.MultValue(signalResults_.Dates[j], i, val, false);
          }
        }
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:31,代码来源:WtImpactDemeaning.cs

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

示例8: ComputeDailySSBeforeEachEvent

        /// <summary>
        /// This is to compute the daily SS before each event
        /// </summary>
        public static Tuple<double, double> ComputeDailySSBeforeEachEvent(ConstructGen<double> seasonalitySeries, int eventDateIndex, int ssWindow)
        {
            // inputs: data series
            // now - event return / std
            var beforeEventSSSeries = new List<double>();
            
            foreach (var eventDate in seasonalitySeries.Dates.OrderBy(d => d))
            {
                var b4Event = seasonalitySeries[eventDate].Where((x, i) => !double.IsNaN(x) && i < eventDateIndex && Math.Abs(eventDateIndex - i) <= ssWindow);
                if (b4Event != null)
                {
                    b4Event.ForEach(e => beforeEventSSSeries.Add(e));                    
                }
            }

            double avgSS = Double.NaN;
            double RSS = double.NaN;
            if (beforeEventSSSeries.Any())
            {
                var validSeries = beforeEventSSSeries.Where(s => !double.IsNaN(s)).ToArray();
                var stddev = Statistics.Stdev(validSeries);
                avgSS = validSeries.Select(s => s/stddev).Average();
                var recent20PercentSS = validSeries.Select(s => s/stddev)
                    .Skip((int) (validSeries.Length*0.8)).Average();

                RSS = recent20PercentSS - avgSS;
            }
            return new Tuple<double, double>(avgSS, RSS);
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:32,代码来源:SeasonalityStats.cs

示例9: Setup

 public void Setup(ConstructGen<double> input_, TZ tz_)
 {
   if (input_ == null)
     _cache[tz_] = new DateTime[0];
   else
     _cache[tz_] = m_builderFunction(input_);
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:7,代码来源:EventDefDynamic.cs

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

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

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

示例13: DoWeights

    public void DoWeights(ConstructGen<double> signalResults_, ConstructGen<double> fullSignalResults_, ConstructGen<double> wts_, List<ProductBase> products_, ConstructGen<double> filters_)
    {
      if (ValueWt.Enabled)
        ValueWt.DoWeights(signalResults_, fullSignalResults_, wts_, products_,filters_);

      if (VolWt.Enabled)
        VolWt.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Rank.Enabled)
        Rank.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Normalise.Enabled)
        Normalise.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Demeaning.Enabled)
        Demeaning.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (CrossSectionalDemeaning.Enabled)
        CrossSectionalDemeaning.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (NormsDist.Enabled)
        NormsDist.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Sign.Enabled)
        Sign.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Side.Enabled)
        Side.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);

      if (Benjo.Enabled)
        Benjo.DoWeights(signalResults_, fullSignalResults_, wts_, products_, filters_);
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:32,代码来源:WtScheme.cs

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

示例15: getData

    protected override ConstructGen<double> getData(DateTime startDate_, DateTime endDate_, bool forceRefresh_)
    {
      var con = new ConstructGen<double>(Singleton<FXIDs>.Instance.ColumnHeadings);

      var spots = Singleton<FXSpots>.Instance.GetData(startDate_, endDate_, forceRefresh_);
      var fwds = Singleton<FXForwards1Wk>.Instance.GetData(startDate_, endDate_, forceRefresh_);

      var conventions = Singleton<FXIDs>.Instance.ConventionsDs;

      var divisor = 5d;

      foreach (var date in spots.Dates)
      {
        var spotsD = spots.GetValues(date);
        var fwdsD = fwds.GetValues(date);
        var cryD = new double[fwdsD.Length];

        for (int i = 0; i < cryD.Length; ++i)
          if (spotsD[i] != 0d && fwdsD[i] != 0d)
          {
            cryD[i] = (Math.Pow(spotsD[i] / fwdsD[i], conventions[i]) - 1d) * (252d/divisor);
          }

        con.SetValues(date, cryD);
      }

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


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