コード例 #1
0
ファイル: Runner.cs プロジェクト: heimanhon/researchwork
    public static void Go()
    {
      var spreadDefs = new[]
      {
        new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["C "],0,MonthCode.U),new MonthYearOffset(Singleton<ComIDs>.Instance["C "],0,MonthCode.Z),false),
        new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["W "],0,MonthCode.U),new MonthYearOffset(Singleton<ComIDs>.Instance["W "],0,MonthCode.Z),false),
        //new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["S "],0,MonthCode.Q),new MonthYearOffset(Singleton<ComIDs>.Instance["S "],1,MonthCode.F),false),
        new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["SB"],0,MonthCode.V),new MonthYearOffset(Singleton<ComIDs>.Instance["SB"],1,MonthCode.K),false),
        new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["NG"],0,MonthCode.X),new MonthYearOffset(Singleton<ComIDs>.Instance["NG"],0,MonthCode.H),false),
        new SpreadDefinition(new MonthYearOffset(Singleton<ComIDs>.Instance["XB"],0,MonthCode.J),new MonthYearOffset(Singleton<ComIDs>.Instance["XB"],0,MonthCode.U),false),
      };

      foreach (var spreadDef in spreadDefs)
      {
        //StratParamSurface.StratParamData resultSet = new StratParamSurface.StratParamData("minWindowSize_, zScoreThreshold"
        var listOfpoints = new List<StratParamSurface.StratParamDataPoint>();
        
        for(int days=30; days<120; days+=10)
        {
          for(double threshold=0.5;threshold<2.0;threshold+=0.1)
          {
            var args = new WeightGeneratorArgs()
            {
              Lookback=5,
              MinWindowLength=days,
              WeightGenerationType=WeightGeneratorType.LongestZScoreOverThreshold,
              ZScoreThreshold=threshold
            };

            var gen = new SpreadWeightGenerator(args, spreadDef);

            var pnl = gen.GetSimplePnl();

            if (pnl.Length == 0) continue; // weren't met

            var eval = new ReturnsEval.DataSeriesEvaluator(pnl.Dates, pnl.Data, "blah", ReturnsEval.DataSeriesType.Returns);

            listOfpoints.Add(new StratParamSurface.StratParamDataPoint()
            {
              X = Convert.ToDouble(days),
              Y = threshold,
              Eval = eval
            });
          }
        }

        var data = new StratParamSurface.StratParamData(
          XLabel_: "minWindowSize_",
          YLabel_: "zScoreThreshold",
          data_: listOfpoints,
          pointFunc_: (p) => p.Eval.Daily.AnnualSharpeRatio
          );

        var control = new StratParamSurface();
        control.Create(data);
        control.DisplayInShowForm(spreadDef.ToString());
      }
    }
コード例 #2
0
    public void Create(int defaultLookback_ = 5)
    {
      m_args = new WeightGeneratorArgs();

      // default values
      m_args.Lookback = 5;
      m_args.WeightGenerationType = WeightGeneratorType.MinMaxAverageNormalizedValues;
      m_args.MinWindowLength = 30;
      m_args.ZScoreThreshold = 1d;

      cmbWeightGenType.AddItems(typeof(WeightGeneratorType), true);

      tbLookback.Bind(m_args, "Lookback", new Validators.IntValidator());
      cmbWeightGenType.Bind(m_args, "WeightGenerationType", new Validators.EnumDescValidator(WeightGeneratorType.MinMaxAverageNormalizedValues));
      tbMinWindowLength.Bind(m_args, "MinWindowLength", new Validators.IntValidator());
      tbZScoreThreshold.Bind(m_args, "ZScoreThreshold", new Validators.DoubleValidator("##0.0#"));
    }