Exemplo n.º 1
0
    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());
      }
    }
Exemplo n.º 2
0
    protected override void Dispose(bool disposing)
    {
      base.Dispose(disposing);

      if (disposing)
      {
        m_gen = null;
      }
    }
 public MenuItem_GenericAction(SpreadWeightGenerator sw_, Action<SpreadWeightGenerator> action_, string title_)
   : base (sw_,title_)
 {
   m_action = action_;
 }
Exemplo n.º 4
0
    public MenuItem_ShowTrades(SpreadWeightGenerator gen_)
      : base(gen_,string.Format("{0} => Show Trades",gen_))
    {

    }
Exemplo n.º 5
0
 public MenuItemBase(SpreadWeightGenerator gen_, string title_)
 {
   m_gen = gen_;
   Text = title_;
 }
 public SpreadWeightGeneratorCombiner(SpreadWeightGenerator[] spreads_)
 {
   Spreads = spreads_;
 }
    public MenuItem_ShowPnlDetailed(SpreadWeightGenerator gen_)
      : base(gen_, string.Format("{0} => Show Pnl Result (detailed)", gen_))
    {

    }
    public MenuItem_ShowSeasonality(SpreadWeightGenerator gen_)
      : base(gen_,string.Format("{0} => Show Seasonality",gen_))
    {

    }
 public void Add(SpreadWeightGenerator generator_)
 {
   if (generator_ != null)
     m_list.Add(generator_);
 }
    public MenuItems_ShowPnlResult(SpreadWeightGenerator gen_)
      : base(gen_, string.Format("{0} => Show Pnl Result", gen_))
    {

    }