public void TestStrategyExecute_Multi() { finishedCount = 0; string[] codes = new string[] { "rb", "ma", "m", "a", "j", "jd" }; int startDate = 20170101; int endDate = 20180101; ICodePeriodList codePeriodPackage = StrategyCenter.Default.BelongDataCenter.CodePeriodFactory.CreateCodePeriodList(codes, startDate, endDate, CodeChooseMethod.Maincontract); StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods(); referedPeriods.UseTickData = false; referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute); StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute); StrategyArguments_CodePeriodList arguments = new StrategyArguments_CodePeriodList(codePeriodPackage, referedPeriods, forwardPeriod); IStrategyExecutor_Multi executor = StrategyCenter.Default.GetStrategyExecutorFactory().CreateExecutor_Multi_History(arguments); IStrategy strategy = StrategyGetter.GetStrategy(typeof(MockStrategy_Event)); executor.Strategy = strategy; executor.OnStrategyDayFinished += Executor_OnStrategyDayFinished; executor.OnStrategyFinished += Executor_OnStrategyFinished; executor.Execute(); StrategyCenter.Default.GetStrategyExecutorPool().ThreadCount = 2; StrategyCenter.Default.GetStrategyExecutorPool().MaxExecutorCount = 3; StrategyCenter.Default.GetStrategyExecutorPool().Execute(); while (finishedCount < 6) { } }
private static StrategyArguments_CodePeriodList GetStrategyPackage(List <string> codes, int start, int end) { StrategyReferedPeriods referedPeriods = new StrategyReferedPeriods(); referedPeriods.UseTickData = false; referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute); StrategyForwardPeriod forwardPeriod = new StrategyForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute); ICodePeriodFactory codePeriodFactory = DataCenter.Default.CodePeriodFactory; ICodePeriodList codePeriodPackage = codePeriodFactory.CreateCodePeriodList(codes, start, end, CodeChooseMethod.Maincontract); StrategyArguments_CodePeriodList strategyCodePeriodPackage = new StrategyArguments_CodePeriodList(codePeriodPackage, referedPeriods, forwardPeriod); return(strategyCodePeriodPackage); }
public void TestCodePackageCreate_Catelog() { CodePeriodListChooser codePackageInfo = new CodePeriodListChooser(); codePackageInfo.CodeChooseMethod = CodeChooseMethod.Catelog; codePackageInfo.Codes.Add("RB"); codePackageInfo.Codes.Add("M"); codePackageInfo.Codes.Add("A"); codePackageInfo.Start = 20170101; codePackageInfo.End = 20180101; IDataReader dataReader = TestDataCenter.Instance.DataReader; CodePeriodFactory fac = new CodePeriodFactory(dataReader); ICodePeriodList codePackage = fac.CreateCodePeriodList(codePackageInfo); Console.WriteLine(codePackage); }
public void TestCodePackageCreate_Normal() { CodePeriodListChooser codePackageInfo = new CodePeriodListChooser(); codePackageInfo.CodeChooseMethod = CodeChooseMethod.Normal; codePackageInfo.Codes.Add("RB1705"); codePackageInfo.Codes.Add("RB1709"); codePackageInfo.Codes.Add("RB1801"); codePackageInfo.Start = 20170101; codePackageInfo.End = 20180101; IDataReader dataReader = TestDataCenter.Instance.DataReader; CodePeriodFactory fac = new CodePeriodFactory(dataReader); ICodePeriodList codePackage = fac.CreateCodePeriodList(codePackageInfo); Assert.AreEqual(3, codePackage.CodePeriods.Count); Assert.AreEqual(20170101, codePackage.CodePeriods[0].StartDate); }
public StrategyArguments_CodePeriodList(ICodePeriodList codePeriodPackage, StrategyReferedPeriods referedPeriods, StrategyForwardPeriod forwardPeriod, StrategyTraderSetting traderSetting) : this(codePeriodPackage, referedPeriods, forwardPeriod) { this.TraderSetting = traderSetting; }
public StrategyArguments_CodePeriodList(ICodePeriodList codePeriodPackage, StrategyReferedPeriods referedPeriods, StrategyForwardPeriod forwardPeriod) { this.codePeriodPackage = codePeriodPackage; this.ReferedPeriods = referedPeriods; this.ForwardPeriod = forwardPeriod; }