예제 #1
0
        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", "").Replace("OpT", "");
                    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", "").Replace("OpT", "");
                }
                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 = Math.Round(reportToPaint.TotalProfit, 4).ToStringWithNoEndZero();
                row.Cells.Add(cell7);

                DataGridViewTextBoxCell cell8 = new DataGridViewTextBoxCell();
                cell8.Value = Math.Round(reportToPaint.AverageProfitPercent, 4).ToStringWithNoEndZero();
                row.Cells.Add(cell8);

                DataGridViewTextBoxCell cell9 = new DataGridViewTextBoxCell();
                cell9.Value = reportToPaint.PositionsCount.ToString();
                row.Cells.Add(cell9);

                _gridDep.Rows.Add(row);
            }
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        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;
            }

            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);
        }
예제 #4
0
        private void UpdatePie()
        {
            if (_gridDep.InvokeRequired)
            {
                _gridDep.Invoke(new Action(UpdatePie));
                return;
            }

            int countProfitBots = 0;
            int countLossBots   = 0;

            if (_reports == null)
            {
                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);
            }
        }
예제 #5
0
        // прогрузка одного робота по параметрам

        public BotPanel TestBot(OptimazerFazeReport faze, OptimizerReport report)
        {
            return(_optimizerExecutor.TestBot(faze, report));
        }