private void CalculateStatistics(XmlElement tagBody,
                                         List <EquityOnTime> listProfit,
                                         List <float> profitMonthly)
        {
            if (profitMonthly.Count < 2)
            {
                return;
            }
            var benchmarkDataVAMI = new[] { vamiBenchmarkA, vamiBenchmarkB };
            var benchmarkDataROR  = new[] { profitBenchmarkA, profitBenchmarkB };

            // табличка Historical Data
            var stat = new MonthlyReportStatistics(listProfit, profitMonthly);
            var row  = FindElement(tagBody, "tr", RowStatHistoryData);

            if (row == null)
            {
                Logger.ErrorFormat("ReportInvestorMonthly - не найден элемент <tr name=\"{0}\">",
                                   RowStatHistoryData);
                return;
            }
            var cellFund = (XmlElement)row.ChildNodes[2];

            cellFund.InnerXml = string.Format("{1:f2}%{0}{2:f0}{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f2}%{0}{7:f2}%",
                                              HtmlLineSeparator, stat.cumulativeReturn, stat.cumulativeVAMI,
                                              stat.meanReturn, stat.compoundRoRmonth,
                                              stat.largestMonthGain, stat.largestMonthLoss,
                                              stat.percentPositiveMonths);

            var rowRisk = FindElement(tagBody, "tr", RowRisk);

            // табличка Risk по фонду
            if (rowRisk == null)
            {
                Logger.ErrorFormat("ReportInvestorMonthly - не найден элемент <tr name=\"{0}\">",
                                   RowRisk);
                return;
            }
            cellFund          = (XmlElement)rowRisk.ChildNodes[1];
            cellFund.InnerXml = string.Format("{1:f2}%{0}{2:f2}%{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f1}",
                                              HtmlLineSeparator, stat.meanDeviation, stat.sharpRatio,
                                              stat.downsideDeviation8pc, stat.sortinoRatio8pc,
                                              stat.maxRelDrawdown, stat.drawDownMonths);

            for (var i = 0; i < 2; i++)
            {
                var cellBench = (XmlElement)row.ChildNodes[3 + i];
                //var monthlyProfitPlain = benchmarkData[i].Select(d => d.b).ToList();
                stat = new MonthlyReportStatistics(benchmarkDataVAMI[i], benchmarkDataROR[i].Select(p => p.equity).ToList());
                cellBench.InnerXml = string.Format("{1:f2}%{0}{2:f0}{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f2}%{0}{7:f2}%",
                                                   HtmlLineSeparator, stat.cumulativeReturn, stat.cumulativeVAMI,
                                                   stat.meanReturn, stat.compoundRoRmonth,
                                                   stat.largestMonthGain, stat.largestMonthLoss,
                                                   stat.percentPositiveMonths);
                var cellBenchRisk = (XmlElement)rowRisk.ChildNodes[2 + i];
                cellBenchRisk.InnerXml = string.Format("{1:f2}%{0}{2:f2}%{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f1}",
                                                       HtmlLineSeparator, stat.meanDeviation, stat.sharpRatio,
                                                       stat.downsideDeviation8pc, stat.sortinoRatio8pc,
                                                       stat.maxRelDrawdown, stat.drawDownMonths);
            }
        }
        private void CalculateStatistics(XmlElement tagBody,
            List<EquityOnTime> listProfit,
            List<float> profitMonthly)
        {
            if (profitMonthly.Count < 2) return;
            var benchmarkDataVAMI = new[] { vamiBenchmarkA, vamiBenchmarkB };
            var benchmarkDataROR = new[] { profitBenchmarkA, profitBenchmarkB };

            // табличка Historical Data
            var stat = new MonthlyReportStatistics(listProfit, profitMonthly);
            var row = FindElement(tagBody, "tr", RowStatHistoryData);
            if (row == null)
            {
                Logger.ErrorFormat("ReportInvestorMonthly - не найден элемент <tr name=\"{0}\">",
                                   RowStatHistoryData);
                return;
            }
            var cellFund = (XmlElement)row.ChildNodes[2];
            cellFund.InnerXml = string.Format("{1:f2}%{0}{2:f0}{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f2}%{0}{7:f2}%",
                                              HtmlLineSeparator, stat.cumulativeReturn, stat.cumulativeVAMI,
                                              stat.meanReturn, stat.compoundRoRmonth,
                                              stat.largestMonthGain, stat.largestMonthLoss,
                                              stat.percentPositiveMonths);

            var rowRisk = FindElement(tagBody, "tr", RowRisk);
            // табличка Risk по фонду
            if (rowRisk == null)
            {
                Logger.ErrorFormat("ReportInvestorMonthly - не найден элемент <tr name=\"{0}\">",
                                   RowRisk);
                return;
            }
            cellFund = (XmlElement)rowRisk.ChildNodes[1];
            cellFund.InnerXml = string.Format("{1:f2}%{0}{2:f2}%{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f1}",
                                              HtmlLineSeparator, stat.meanDeviation, stat.sharpRatio,
                                              stat.downsideDeviation8pc, stat.sortinoRatio8pc,
                                              stat.maxRelDrawdown, stat.drawDownMonths);

            for (var i = 0; i < 2; i++)
            {
                var cellBench = (XmlElement)row.ChildNodes[3 + i];
                //var monthlyProfitPlain = benchmarkData[i].Select(d => d.b).ToList();
                stat = new MonthlyReportStatistics(benchmarkDataVAMI[i], benchmarkDataROR[i].Select(p => p.equity).ToList());
                cellBench.InnerXml = string.Format("{1:f2}%{0}{2:f0}{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f2}%{0}{7:f2}%",
                                              HtmlLineSeparator, stat.cumulativeReturn, stat.cumulativeVAMI,
                                              stat.meanReturn, stat.compoundRoRmonth,
                                              stat.largestMonthGain, stat.largestMonthLoss,
                                              stat.percentPositiveMonths);
                var cellBenchRisk = (XmlElement)rowRisk.ChildNodes[2 + i];
                cellBenchRisk.InnerXml = string.Format("{1:f2}%{0}{2:f2}%{0}{3:f2}%{0}{4:f2}%{0}{5:f2}%{0}{6:f1}",
                                              HtmlLineSeparator, stat.meanDeviation, stat.sharpRatio,
                                              stat.downsideDeviation8pc, stat.sortinoRatio8pc,
                                              stat.maxRelDrawdown, stat.drawDownMonths);
            }
        }