private void MakeCalculation() { riskPercentiles = TickerCorrelationCalculator.CalculateRisks(actives, corrMatrix, sigmas, testSettings.intervalMinutes, testSettings.simIntervalsCount, testSettings.numSimulations, testSettings.percentiles, UpdateProgressSafe); ReportCompletedSafe(riskPercentiles == null ? DialogResult.No : DialogResult.OK); }
private void BtnCalculateClick(object sender, EventArgs e) { // посчитать и вывести корреляцию var tickers = portfolio.Select(p => p.Ticker).ToList(); List <string> errors; double[][] corMatrix; var oldBtnCaption = btnCalculate.Text; btnCalculate.Text = "Производится расчет"; btnCalculate.Enabled = false; try { TickerCorrelationCalculator.CalculateCorrelation(tickers, testSettings.intervalMinutes, testSettings.corrIntervalsCount, testSettings.minCorrIntervalsCount, testSettings.uploadQuotesFromDB, out errors, out corMatrix, out tickerSigmas); } catch (Exception ex) { Logger.Error("TickerCorrelationCalculator.CalculateCorrelation()", ex); throw; } btnCalculate.Text = oldBtnCaption; btnCalculate.Enabled = true; if (errors != null && errors.Count > 0) { MessageBox.Show(string.Join(Environment.NewLine, errors), Localizer.GetString("MessageErrorCalculatingCorrelations"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // показать матрицу корреляций rtbCorr.Clear(); var sb = new StringBuilder(); sb.Append(" "); for (var i = 0; i < tickers.Count; i++) { sb.AppendFormat(" {0} ", tickers[i]); } for (var i = 0; i < tickers.Count; i++) { sb.AppendLine(); sb.AppendFormat("{0} ", tickers[i]); for (var j = 0; j < tickers.Count; j++) { var rStr = corMatrix[i][j] < 0 ? string.Format(CultureProvider.Common, " {0:f2} ", corMatrix[i][j]) : string.Format(CultureProvider.Common, " {0:f2} ", corMatrix[i][j]); sb.Append(rStr); } } rtbCorr.Text = sb.ToString(); // перейти на страницу расчета риска tabControl.SelectedTab = tabPageCorrelation; btnCalcRisk.Focus(); }