public void TestExecuteStrategy() { string code = "rb1710"; int start = 20170601; int end = 20170603; IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end); MockStrategy strategy = new MockStrategy(); executor.Strategy = strategy; executor.OnFinished += Executor_OnFinished; executor.Execute(); //AssertUtils.AssertEqual_List("executorhistory", GetType(), strategy.PrintData); }
public void TestParamter() { IStrategy strategy = new MockStrategy_Parameter(); strategy.Parameters.SetParameterValue("PERIOD", KLinePeriod.KLinePeriod_15Minute); string code = "rb1710"; int start = 20170601; int end = 20170603; IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end); executor.Strategy = strategy; executor.Run(); //List<string> results = (List<string>)strategy.GetData("RESULT"); //AssertUtils.AssertEqual_List("StrategyParameter_15Minute", GetType(), results); }
public void TestExecuteStrategy_MA() { string code = "rb1710"; int start = 20170601; int end = 20170603; IStrategyExecutor_Single executor = StrategyTestUtils.CreateExecutor_CodePeriod(code, start, end); MockStrategy_Ma strategy = new MockStrategy_Ma(); executor.Strategy = strategy; executor.Run(); List <float> floats = strategy.MAList; IDataPackage_Code dataPackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end); IKLineData_Extend klineData = dataPackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute); List <float> floats2 = KLineDataUtils.MaList(klineData, klineData.BarPos, klineData.Length - 1, 5); for (int i = 0; i < floats.Count; i++) { Console.WriteLine(floats[i] + "," + floats2[i]); } AssertUtils.AssertEqual_List(floats2, floats); }