// единичный тест public BotPanel TestBot(OptimazerFazeReport reportFaze, OptimizerReport reportToBot) { if (_primeThreadWorker != null) { return(null); } string botName = NumberGen.GetNumberDeal(StartProgram.IsOsOptimizer).ToString(); List <string> names = new List <string> { botName }; _asyncBotFactory.CreateNewBots(names, _master.StrategyName, _master.IsScript, StartProgram.IsTester); OptimizerServer server = CreateNewServer(reportFaze); List <IIStrategyParameter> parametrs = reportToBot.GetParameters(); BotPanel bot = CreateNewBot(botName, parametrs, parametrs, server, StartProgram.IsTester); DateTime timeStartWaiting = DateTime.Now; while (bot.IsConnected == false) { Thread.Sleep(50); if (timeStartWaiting.AddSeconds(20) < DateTime.Now) { SendLogMessage( OsLocalization.Optimizer.Message10, LogMessageType.Error); return(null); } } server.TestingStart(); timeStartWaiting = DateTime.Now; while (bot.TabsSimple[0].CandlesAll == null || bot.TabsSimple[0].TimeServerCurrent.AddHours(1) < reportFaze.Faze.TimeEnd) { Thread.Sleep(20); if (timeStartWaiting.AddSeconds(20) < DateTime.Now) { break; } } Thread.Sleep(2000); return(bot); }
private void StartAsuncBotFactoryOutOfSample(OptimazerFazeReport reportFiltred, string botType, bool isScript, string faze) { List <string> botNames = new List <string>(); for (int i = 0; i < reportFiltred.Reports.Count; i++) { string botName = reportFiltred.Reports[i].BotName.Replace(" InSample", "") + " OutOfSample"; botNames.Add(botName); } _asyncBotFactory.CreateNewBots(botNames, botType, isScript, StartProgram.IsOsOptimizer); }
private void ButtonLoadFromFile_Click(object sender, RoutedEventArgs e) { Title = "Optimizer Report"; try { OpenFileDialog myDialog = new OpenFileDialog(); myDialog.Filter = "*.txt|"; myDialog.ShowDialog(); if (string.IsNullOrEmpty(myDialog.FileName)) { System.Windows.Forms.MessageBox.Show(OsLocalization.Journal.Message2); return; } if (_reports == null) { _reports = new List <OptimazerFazeReport>(); } else { _reports.Clear(); } using (StreamReader reader = new StreamReader(myDialog.FileName)) { while (reader.EndOfStream == false) { string str = reader.ReadLine(); if (string.IsNullOrEmpty(str)) { continue; } OptimazerFazeReport newReport = new OptimazerFazeReport(); newReport.LoadFromString(str); _reports.Add(newReport); } } RepaintResults(); } catch (Exception error) { MessageBox.Show(error.ToString()); } }
// алгоритм оптимизации /// <summary> /// place of work flow responsible for optimization /// место работы потока отвечающего за оптимизацию /// </summary> private async void PrimeThreadWorkerPlace() { ReportsToFazes = new List <OptimazerFazeReport>(); int countBots = BotCountOneFaze(); SendLogMessage(OsLocalization.Optimizer.Message4 + countBots, LogMessageType.System); _countAllServersMax = countBots; for (int i = 0; i < _master.Fazes.Count; i++) { if (_neadToStop) { _primeThreadWorker = null; TestReadyEvent?.Invoke(ReportsToFazes); return; } if (_master.Fazes[i].TypeFaze == OptimizerFazeType.InSample) { OptimazerFazeReport report = new OptimazerFazeReport(); report.Faze = _master.Fazes[i]; ReportsToFazes.Add(report); StartOptimazeFazeInSample(_master.Fazes[i], report, _parameters, _parametersOn); } else { SendLogMessage("ReportsCount" + ReportsToFazes[ReportsToFazes.Count - 1].Reports.Count.ToString(), LogMessageType.System); OptimazerFazeReport reportFiltred = new OptimazerFazeReport(); EndOfFazeFiltration(ReportsToFazes[ReportsToFazes.Count - 1], reportFiltred); OptimazerFazeReport report = new OptimazerFazeReport(); report.Faze = _master.Fazes[i]; ReportsToFazes.Add(report); StartOptimazeFazeOutOfSample(report, reportFiltred); } } SendLogMessage(OsLocalization.Optimizer.Message7, LogMessageType.System); TestReadyEvent?.Invoke(ReportsToFazes); _primeThreadWorker = null; return; }
private void StartOptimazeFazeOutOfSample(OptimazerFazeReport report, OptimazerFazeReport reportInSample) { SendLogMessage(OsLocalization.Optimizer.Message6, LogMessageType.System); for (int i = 0; i < reportInSample.Reports.Count; i++) { while (_servers.Count >= _master.ThreadsCount) { Thread.Sleep(50); } if (_neadToStop) { while (true) { Thread.Sleep(50); if (_servers.Count == 0) { break; } } if (TestReadyEvent != null) { TestReadyEvent(ReportsToFazes); } _primeThreadWorker = null; return; } while (_botsInTest.Count >= _master.ThreadsCount) { Thread.Sleep(50); } // SendLogMessage("Bot Out of Sample", LogMessageType.System); StartNewBot(reportInSample.Reports[i].GetParameters(), new List <IIStrategyParameter>(), report, reportInSample.Reports[i].BotName.Replace(" InSample", "") + " OutOfSample"); } while (true) { Thread.Sleep(50); if (_servers.Count == 0)// && _botsInTest.Count == 0) { break; } } }
/// <summary> /// launch another robot as part of optimization /// запустить ещё одного робота, в рамках оптимизации /// </summary> /// <param name="parametrs">list of all parameters/список всех параметров</param> /// <param name="paramOptimized">brute force options/параметры по которым осуществляется перебор</param> /// <param name="report">current optimization phase/текущая фаза оптимизации</param> /// <param name="botsInFaze">list of bots already running in the current phase/список ботов уже запущенный в текущей фазе</param> /// <param name="botName">the name of the created robot/имя создаваемого робота</param> private void StartNewBot(List <IIStrategyParameter> parametrs, List <IIStrategyParameter> paramOptimized, OptimazerFazeReport report, string botName) { /*if (!MainWindow.GetDispatcher.CheckAccess()) * { * MainWindow.GetDispatcher.Invoke( * new Action * <List<IIStrategyParameter>, List<IIStrategyParameter>, * OptimazerFazeReport, string>(StartNewBot), * parametrs, paramOptimized, report, botName); * await Task.Delay(1000); * return; * }*/ OptimizerServer server = CreateNewServer(report); try { decimal num = Convert.ToDecimal(botName[0]); } catch { botName = server.NumberServer + botName; } BotPanel bot = CreateNewBot(botName, parametrs, paramOptimized, server, StartProgram.IsOsOptimizer); // wait for the robot to connect to its data server // ждём пока робот подключиться к своему серверу данных DateTime timeStartWaiting = DateTime.Now; while (bot.IsConnected == false) { Thread.Sleep(20); if (timeStartWaiting.AddSeconds(2000) < DateTime.Now) { SendLogMessage( OsLocalization.Optimizer.Message10, LogMessageType.Error); return; } } _botsInTest.Add(bot); server.TestingStart(); }
/// <summary> /// filtering results at the end of the current phase /// фильтрация результатов в конце текущей фазы /// </summary> private void EndOfFazeFiltration(OptimazerFazeReport bots, OptimazerFazeReport botsToOutOfSample) { int startCount = bots.Reports.Count; for (int i = 0; i < bots.Reports.Count; i++) { if (_master.FilterMiddleProfitIsOn && bots.Reports[i].AverageProfitPercent < _master.FilterMiddleProfitValue) { } else if (_master.FilterProfitIsOn && bots.Reports[i].TotalProfit < _master.FilterProfitValue) { } else if (_master.FilterMaxDrowDownIsOn && bots.Reports[i].MaxDrowDawn < _master.FilterMaxDrowDownValue) { } else if (_master.FilterProfitFactorIsOn && bots.Reports[i].ProfitFactor < _master.FilterProfitFactorValue) { } else if (_master.FilterDealsCountIsOn && bots.Reports[i].PositionsCount < _master.FilterDealsCountValue) { } else { botsToOutOfSample.Reports.Add(bots.Reports[i]); } } if (botsToOutOfSample.Reports.Count == 0) { /* SendLogMessage(OsLocalization.Optimizer.Message8, LogMessageType.System); * MessageBox.Show(OsLocalization.Optimizer.Message8); * NeadToMoveUiToEvent(NeadToMoveUiTo.TabsAndTimeFrames);*/ } else if (startCount != botsToOutOfSample.Reports.Count) { SendLogMessage(OsLocalization.Optimizer.Message9 + (startCount - botsToOutOfSample.Reports.Count), LogMessageType.System); } }
private OptimizerServer CreateNewServer(OptimazerFazeReport report) { // 1. Create a new server for optimization. And one thread respectively // 1. создаём новый сервер для оптимизации. И один поток соответственно OptimizerServer server = ServerMaster.CreateNextOptimizerServer(_master.Storage, _serverNum, _master.StartDepozit); _serverNum++; _servers.Add(server); server.TestingEndEvent += server_TestingEndEvent; server.TypeTesterData = _master.Storage.TypeTesterData; server.TestintProgressChangeEvent += server_TestintProgressChangeEvent; for (int i = 0; _master.TabsSimpleNamesAndTimeFrames != null && i < _master.TabsSimpleNamesAndTimeFrames.Count; i++) { Security secToStart = _master.Storage.Securities.Find(s => s.Name == _master.TabsSimpleNamesAndTimeFrames[i].NameSecurity); server.GetDataToSecurity(secToStart, _master.TabsSimpleNamesAndTimeFrames[i].TimeFrame, report.Faze.TimeStart, report.Faze.TimeEnd); } for (int i = 0; _master.TabsIndexNamesAndTimeFrames != null && i < _master.TabsIndexNamesAndTimeFrames.Count; i++) { List <string> secNames = _master.TabsIndexNamesAndTimeFrames[i].NamesSecurity; for (int i2 = 0; secNames != null && i2 < secNames.Count; i2++) { string curSec = secNames[i2]; Security secToStart = _master.Storage.Securities.Find(s => s.Name == curSec); server.GetDataToSecurity(secToStart, _master.TabsIndexNamesAndTimeFrames[i].TimeFrame, report.Faze.TimeStart, report.Faze.TimeEnd); } } return(server); }
/// <summary> /// filtering results at the end of the current phase /// фильтрация результатов в конце текущей фазы /// </summary> private void EndOfFazeFiltration(OptimazerFazeReport bots, OptimazerFazeReport botsToOutOfSample) { int startCount = bots.Reports.Count; for (int i = 0; i < bots.Reports.Count; i++) { if (_master.IsAcceptedByFilter(bots.Reports[i])) { botsToOutOfSample.Reports.Add(bots.Reports[i]); } } if (botsToOutOfSample.Reports.Count == 0) { /* SendLogMessage(OsLocalization.Optimizer.Message8, LogMessageType.System); * MessageBox.Show(OsLocalization.Optimizer.Message8); * NeadToMoveUiToEvent(NeadToMoveUiTo.TabsAndTimeFrames);*/ } else if (startCount != botsToOutOfSample.Reports.Count) { SendLogMessage(OsLocalization.Optimizer.Message9 + (startCount - botsToOutOfSample.Reports.Count), LogMessageType.System); } }
/// <summary> /// launch another robot as part of optimization /// запустить ещё одного робота, в рамках оптимизации /// </summary> /// <param name="parametrs">list of all parameters/список всех параметров</param> /// <param name="paramOptimized">brute force options/параметры по которым осуществляется перебор</param> /// <param name="report">current optimization phase/текущая фаза оптимизации</param> /// <param name="botsInFaze">list of bots already running in the current phase/список ботов уже запущенный в текущей фазе</param> /// <param name="botName">the name of the created robot/имя создаваемого робота</param> private void StartNewBot(List <IIStrategyParameter> parametrs, List <IIStrategyParameter> paramOptimized, OptimazerFazeReport report, string botName) { OptimizerServer server = CreateNewServer(report); try { decimal num = Convert.ToDecimal(botName.Substring(0, 1)); } catch { botName = server.NumberServer + botName; } BotPanel bot = CreateNewBot(botName, parametrs, paramOptimized, server, StartProgram.IsOsOptimizer); // wait for the robot to connect to its data server // ждём пока робот подключиться к своему серверу данных DateTime timeStartWaiting = DateTime.Now; while (bot.IsConnected == false) { Thread.Sleep(20); if (timeStartWaiting.AddSeconds(2000) < DateTime.Now) { SendLogMessage( OsLocalization.Optimizer.Message10, LogMessageType.Error); return; } } _botsInTest.Add(bot); server.TestingStart(); }
private async void StartOptimazeFazeInSample(OptimizerFaze faze, OptimazerFazeReport report, List <IIStrategyParameter> allParameters, List <bool> parametersToOptimization) { ReloadAllParam(allParameters); // 2 проходим первую фазу, когда нужно обойти все варианты List <IIStrategyParameter> optimizedParamStart = new List <IIStrategyParameter>(); for (int i = 0; i < allParameters.Count; i++) { if (parametersToOptimization[i]) { optimizedParamStart.Add(allParameters[i]); } } List <IIStrategyParameter> optimizeParamCurrent = CopyParameters(optimizedParamStart); ReloadAllParam(optimizeParamCurrent); bool isStart = true; while (true) { bool isAndOfFaze = false; // all parameters passed/все параметры пройдены for (int i2 = 0; i2 < optimizeParamCurrent.Count + 1; i2++) { if (i2 == optimizeParamCurrent.Count) { isAndOfFaze = true; break; } if (isStart) { isStart = false; break; } if (optimizeParamCurrent[i2].Type == StrategyParameterType.Int) { StrategyParameterInt parameter = (StrategyParameterInt)optimizeParamCurrent[i2]; if (parameter.ValueInt < parameter.ValueIntStop) { // at the current index you can increment the value // по текущему индексу можно приращивать значение parameter.ValueInt = parameter.ValueInt + parameter.ValueIntStep; if (i2 > 0) { for (int i3 = 0; i3 < i2; i3++) { // reset all previous parameters to zero // сбрасываем все предыдущие параметры в ноль ReloadParam(optimizeParamCurrent[i3]); } } break; } } else if (optimizeParamCurrent[i2].Type == StrategyParameterType.Decimal ) { StrategyParameterDecimal parameter = (StrategyParameterDecimal)optimizeParamCurrent[i2]; if (parameter.ValueDecimal < parameter.ValueDecimalStop) { // at the current index you can increment the value // по текущему индексу можно приращивать значение parameter.ValueDecimal = parameter.ValueDecimal + parameter.ValueDecimalStep; if (i2 > 0) { for (int i3 = 0; i3 < i2; i3++) { // reset all previous parameters to zero // сбрасываем все предыдущие параметры в ноль ReloadParam(optimizeParamCurrent[i3]); } } break; } } } if (isAndOfFaze) { break; } while (_servers.Count >= _master.ThreadsCount) { Thread.Sleep(50); } if (_neadToStop) { while (true) { Thread.Sleep(50); if (_servers.Count == 0) { break; } } TestReadyEvent?.Invoke(ReportsToFazes); _primeThreadWorker = null; return; } while (_botsInTest.Count >= _master.ThreadsCount) { Thread.Sleep(50); } //SendLogMessage("BotInSample" ,LogMessageType.System); StartNewBot(_parameters, optimizeParamCurrent, report, " InSample"); } while (true) { Thread.Sleep(50); if (_servers.Count == 0) // || _botsInTest.Count == 0) { break; } } SendLogMessage(OsLocalization.Optimizer.Message5, LogMessageType.System); }
// алгоритм оптимизации /// <summary> /// place of work flow responsible for optimization /// место работы потока отвечающего за оптимизацию /// </summary> private async void PrimeThreadWorkerPlace() { ReportsToFazes = new List <OptimazerFazeReport>(); int countBots = BotCountOneFaze(_parameters, _parametersOn); SendLogMessage(OsLocalization.Optimizer.Message4 + countBots, LogMessageType.System); DateTime timeStart = DateTime.Now; _countAllServersMax = countBots; for (int i = 0; i < _master.Fazes.Count; i++) { if (_neadToStop) { _primeThreadWorker = null; TestReadyEvent?.Invoke(ReportsToFazes); return; } if (_master.Fazes[i].TypeFaze == OptimizerFazeType.InSample) { OptimazerFazeReport report = new OptimazerFazeReport(); report.Faze = _master.Fazes[i]; ReportsToFazes.Add(report); StartAsuncBotFactoryInSample(countBots, _master.StrategyName, _master.IsScript, "InSample"); StartOptimazeFazeInSample(_master.Fazes[i], report, _parameters, _parametersOn); } else { SendLogMessage("ReportsCount" + ReportsToFazes[ReportsToFazes.Count - 1].Reports.Count.ToString(), LogMessageType.System); OptimazerFazeReport reportFiltred = new OptimazerFazeReport(); EndOfFazeFiltration(ReportsToFazes[ReportsToFazes.Count - 1], reportFiltred); OptimazerFazeReport report = new OptimazerFazeReport(); report.Faze = _master.Fazes[i]; ReportsToFazes.Add(report); StartAsuncBotFactoryOutOfSample(reportFiltred, _master.StrategyName, _master.IsScript, "OutOfSample"); StartOptimazeFazeOutOfSample(report, reportFiltred); } GC.Collect(); GC.WaitForPendingFinalizers(); } TimeSpan time = DateTime.Now - timeStart; SendLogMessage(OsLocalization.Optimizer.Message7, LogMessageType.System); SendLogMessage("Total test time = " + time.ToString(), LogMessageType.System); TestReadyEvent?.Invoke(ReportsToFazes); _primeThreadWorker = null; return; }
// прогрузка одного робота по параметрам public BotPanel TestBot(OptimazerFazeReport faze, OptimizerReport report) { return(_optimizerExecutor.TestBot(faze, report)); }
/// <summary> /// draw a table of results /// прорисовать таблицу результатов /// </summary> private void PaintTableResults() { if (_gridResults == null) { return; } if (_gridResults.InvokeRequired) { _gridResults.Invoke(new Action(PaintTableResults)); return; } _gridResults.SelectionChanged -= _gridResults_SelectionChanged; _gridResults.CellMouseClick -= _gridResults_CellMouseClick; UpdateHeaders(); _gridResults.Rows.Clear(); if (_reports == null) { return; } if (_gridFazesEnd.CurrentCell == null) { return; } int num = 0; num = _gridFazesEnd.CurrentCell.RowIndex; if (num >= _reports.Count) { return; } OptimazerFazeReport fazeReport = _reports[num]; if (fazeReport == null) { return; } for (int i = 0; i < fazeReport.Reports.Count; i++) { OptimizerReport report = fazeReport.Reports[i]; if (report == null || report.TabsReports.Count == 0 || !_master.IsAcceptedByFilter(report)) { continue; } DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell()); if (report.TabsReports.Count == 1) { row.Cells[0].Value = report.BotName; } else { row.Cells[0].Value = "Сводные"; } DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell(); cell2.Value = report.GetParamsToDataTable(); row.Cells.Add(cell2); DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell(); cell3.Value = report.PositionsCount; row.Cells.Add(cell3); DataGridViewTextBoxCell cell4 = new DataGridViewTextBoxCell(); cell4.Value = report.TotalProfit.ToStringWithNoEndZero() + " (" + report.TotalProfitPersent.ToStringWithNoEndZero() + "%)"; row.Cells.Add(cell4); DataGridViewTextBoxCell cell5 = new DataGridViewTextBoxCell(); cell5.Value = report.MaxDrowDawn.ToStringWithNoEndZero(); row.Cells.Add(cell5); DataGridViewTextBoxCell cell6 = new DataGridViewTextBoxCell(); cell6.Value = report.AverageProfit.ToStringWithNoEndZero(); row.Cells.Add(cell6); DataGridViewTextBoxCell cell7 = new DataGridViewTextBoxCell(); cell7.Value = report.AverageProfitPercent.ToStringWithNoEndZero(); row.Cells.Add(cell7); DataGridViewTextBoxCell cell8 = new DataGridViewTextBoxCell(); cell8.Value = report.ProfitFactor.ToStringWithNoEndZero(); row.Cells.Add(cell8); DataGridViewTextBoxCell cell9 = new DataGridViewTextBoxCell(); cell9.Value = report.PayOffRatio.ToStringWithNoEndZero(); row.Cells.Add(cell9); DataGridViewTextBoxCell cell10 = new DataGridViewTextBoxCell(); cell10.Value = report.Recovery.ToStringWithNoEndZero(); row.Cells.Add(cell10); DataGridViewButtonCell cell11 = new DataGridViewButtonCell(); cell11.Value = OsLocalization.Optimizer.Message40; row.Cells.Add(cell11); _gridResults.Rows.Add(row); if (report.TabsReports.Count > 1) { for (int i2 = 0; i2 < report.TabsReports.Count; i2++) { _gridResults.Rows.Add(GetRowResult(report.TabsReports[i2])); } } } _gridResults.SelectionChanged += _gridResults_SelectionChanged; _gridResults.CellMouseClick += _gridResults_CellMouseClick; }
private void UpdatePie() { if (_gridDep.InvokeRequired) { _gridDep.Invoke(new Action(UpdatePie)); return; } int countProfitBots = 0; int countLossBots = 0; if (_reports == null) { return; } if (_reports.Count <= 1) { return; } if (_reports.Count == 2 && _reports[1].Reports.Count == 0) { return; } int num = 0; OptimizerReport inSampleReport = null; for (int i = 0; i < _reports.Count; i++) { OptimazerFazeReport curReport = _reports[i]; if (curReport == null || curReport.Reports == null || curReport.Reports.Count == 0) { continue; } if (curReport.Faze.TypeFaze == OptimizerFazeType.InSample) { inSampleReport = curReport.Reports[0]; } if (curReport.Faze.TypeFaze == OptimizerFazeType.OutOfSample) { string botName = inSampleReport.BotName.Replace(" InSample", ""); // reportToPaint = curReport.Reports.Find(rep => rep.BotName.StartsWith(botName)); for (int i2 = 0; i2 < curReport.Reports.Count; i2++) { if (curReport.Reports[i2].BotName.StartsWith(botName)) { if (curReport.Reports[i2].TotalProfit > 0) { countProfitBots += 1; } else { countLossBots += 1; } break; } } } } if (countProfitBots + countLossBots == 0) { return; } decimal profitPercent = Math.Round((Convert.ToDecimal(countProfitBots) / (countProfitBots + countLossBots) * 100), 0); decimal lossPercent = Math.Round((Convert.ToDecimal(countLossBots) / (countProfitBots + countLossBots) * 100), 0); _chartPie.Series[0].Points.Clear(); DataPoint point1 = new DataPoint(1, countProfitBots); point1.AxisLabel = "Profit " + profitPercent + " %"; point1.Color = Color.FromArgb(57, 157, 54); _chartPie.Series[0].Points.Add(point1); if (countLossBots != 0) { DataPoint point2 = new DataPoint(2, countLossBots); point2.AxisLabel = "Loss " + lossPercent + " %"; point2.Color = Color.FromArgb(255, 83, 0); _chartPie.Series[0].Points.Add(point2); } }
private void UpdateColumns() { if (_gridDep.InvokeRequired) { _gridDep.Invoke(new Action(UpdateColumns)); return; } int countBestTwenty = 0; int count20_40 = 0; int count40_60 = 0; int count60_80 = 0; int countWorst20 = 0; if (_reports == null) { return; } if (_reports.Count <= 1) { return; } if (_reports.Count == 2 && _reports[1].Reports.Count == 0) { return; } int num = 0; OptimizerReport inSampleReport = null; for (int i = 0; i < _reports.Count; i++) { OptimazerFazeReport curReport = _reports[i]; if (curReport == null || curReport.Reports == null || curReport.Reports.Count == 0) { continue; } if (curReport.Faze.TypeFaze == OptimizerFazeType.InSample) { inSampleReport = curReport.Reports[0]; } if (curReport.Faze.TypeFaze == OptimizerFazeType.OutOfSample) { string botName = inSampleReport.BotName.Replace(" InSample", ""); // reportToPaint = curReport.Reports.Find(rep => rep.BotName.StartsWith(botName)); for (int i2 = 0; i2 < curReport.Reports.Count; i2++) { if (curReport.Reports[i2].BotName.StartsWith(botName)) { decimal botNum = Convert.ToDecimal(i2 + 1) / curReport.Reports.Count * 100m; if (botNum <= 20) { countBestTwenty += 1; } else if (botNum > 20 && botNum <= 40) { count20_40 += 1; } else if (botNum > 40 && botNum <= 60) { count40_60 += 1; } else if (botNum > 60 && botNum <= 80) { count60_80 += 1; } else if (botNum > 80) { countWorst20 += 1; } break; } } } } /* int countBestTwenty = 0; * int count20_40 = 0; * int count40_60 = 0; * int count60_80 = 0; * int countWorst20 = 0;*/ _chart.Series[0].Points.Clear(); DataPoint point1 = new DataPoint(1, countBestTwenty); point1.AxisLabel = "Best 20%"; point1.Color = Color.FromArgb(57, 157, 54); DataPoint point2 = new DataPoint(2, count20_40); point2.AxisLabel = "20 - 40 %"; point2.Color = Color.FromArgb(57, 157, 54); DataPoint point3 = new DataPoint(3, count40_60); point3.AxisLabel = "40 - 60 %"; point3.Color = Color.FromArgb(149, 159, 176); DataPoint point4 = new DataPoint(4, count60_80); point4.AxisLabel = "60 - 80 %"; point4.Color = Color.FromArgb(255, 83, 0); DataPoint point5 = new DataPoint(5, countWorst20); point5.AxisLabel = "Worst 20 %"; point5.Color = Color.FromArgb(255, 83, 0); _chart.Series[0].Points.Add(point1); _chart.Series[0].Points.Add(point2); _chart.Series[0].Points.Add(point3); _chart.Series[0].Points.Add(point4); _chart.Series[0].Points.Add(point5); }
private void UpdGridDep() { if (_gridDep.InvokeRequired) { _gridDep.Invoke(new Action(UpdGridDep)); return; } _gridDep.Rows.Clear(); if (_reports == null) { return; } if (_reports.Count <= 1) { return; } if (_reports.Count == 2 && _reports[1].Reports.Count == 0) { return; } int num = 0; OptimizerReport inSampleReport = null; for (int i = 0; i < _reports.Count; i++) { OptimazerFazeReport curReport = _reports[i]; if (curReport == null || curReport.Reports == null || curReport.Reports.Count == 0) { continue; } if (curReport.Faze.TypeFaze == OptimizerFazeType.InSample) { inSampleReport = curReport.Reports[0]; } OptimizerReport reportToPaint; if (curReport.Faze.TypeFaze == OptimizerFazeType.InSample) { reportToPaint = curReport.Reports[0]; } else // if(curReport.Faze.TypeFaze == OptimizerFazeType.OutOfSample) { string botName = inSampleReport.BotName.Replace(" InSample", ""); reportToPaint = curReport.Reports.Find(rep => rep.BotName.StartsWith(botName)); } if (reportToPaint == null) { continue; } DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells[0].Value = curReport.Faze.TypeFaze.ToString(); DataGridViewTextBoxCell cell2 = new DataGridViewTextBoxCell(); cell2.Value = curReport.Faze.TimeStart.ToShortDateString(); row.Cells.Add(cell2); DataGridViewTextBoxCell cell3 = new DataGridViewTextBoxCell(); cell3.Value = curReport.Faze.TimeEnd.ToShortDateString(); row.Cells.Add(cell3); DataGridViewTextBoxCell cell4 = new DataGridViewTextBoxCell(); if (curReport.Faze.TypeFaze == OptimizerFazeType.InSample) { cell4.Value = inSampleReport.BotName.Replace(" InSample", ""); } row.Cells.Add(cell4); DataGridViewTextBoxCell cell5 = new DataGridViewTextBoxCell(); cell5.Value = reportToPaint.GetParamsToDataTable(); row.Cells.Add(cell5); DataGridViewTextBoxCell cell6 = new DataGridViewTextBoxCell(); if (curReport.Faze.TypeFaze == OptimizerFazeType.OutOfSample) { string botName = inSampleReport.BotName.Replace(" InSample", ""); // reportToPaint = curReport.Reports.Find(rep => rep.BotName.StartsWith(botName)); for (int i2 = 0; i2 < curReport.Reports.Count; i2++) { string curName = curReport.Reports[i2].BotName.Replace(" InSample", "").Replace(" OutOfSample", ""); if (curName == botName) { cell6.Value = (i2 + 1).ToString(); break; } } } row.Cells.Add(cell6); DataGridViewTextBoxCell cell7 = new DataGridViewTextBoxCell(); cell7.Value = reportToPaint.TotalProfit; row.Cells.Add(cell7); _gridDep.Rows.Add(row); } }