public void StartTest() { int completedPassCounter = 0; _optimizer.OnOptimizationPassCompletionEvent += (sender, robot) => { completedPassCounter++; }; _optimizer.Start(); Assert.AreEqual(9, completedPassCounter); }
private static void Optimize(ISymbol symbol, IEnumerable <IBar> data) { var startTime = data.Min(iBar => iBar.Time); var endTime = data.Max(iBar => iBar.Time); var symbolsData = new List <ISymbolBacktestData> { new SymbolBacktestData(symbol, data) }; var optimizerSettings = new OptimizerSettings { AccountBalance = 10000, AccountLeverage = 500, BacktesterType = typeof(OhlcBacktester), BacktestSettingsType = typeof(BacktestSettings), BacktesterInterval = TimeSpan.FromHours(1), }; optimizerSettings.SymbolsData = symbolsData; optimizerSettings.BacktestSettingsParameters = new object[] { startTime, endTime, }; optimizerSettings.TradeEngineType = typeof(BacktestTradeEngine); optimizerSettings.TimerContainerType = typeof(TimerContainer); optimizerSettings.ServerType = typeof(Server); optimizerSettings.RobotSettingsType = typeof(RobotParameters); optimizerSettings.RobotType = typeof(SingleSymbolMaCrossOverBot); optimizerSettings.Parameters = new List <OptimizeParameter>() { new OptimizeParameter("Fast MA Period", 5, 15, 5), new OptimizeParameter("Slow MA Period", 20), new OptimizeParameter("Volume", 1) }; var optimizer = new GridOptimizer(optimizerSettings); optimizer.OnOptimizationPassCompletionEvent += Optimizer_OnOptimizationPassCompletionEvent; optimizer.OnOptimizationStoppedEvent += Optimizer_OnOptimizationStoppedEvent; optimizer.OnOptimizationStartedEvent += Optimizer_OnOptimizationStartedEvent; optimizer.Start(); }