private void RedrawChart() { this.chart.Series.Clear(); if (Content != null) { var trainingRows = Content.ProblemData.TrainingIndices; var testRows = Content.ProblemData.TestIndices; this.chart.Series.Add(SIGNALS_SERIES_NAME); this.chart.Series[SIGNALS_SERIES_NAME].YAxisType = AxisType.Secondary; this.chart.Series[SIGNALS_SERIES_NAME].LegendText = SIGNALS_SERIES_NAME; this.chart.Series[SIGNALS_SERIES_NAME].ChartType = SeriesChartType.FastLine; this.chart.Series[SIGNALS_SERIES_NAME].Points.DataBindXY( trainingRows.Concat(testRows).ToArray(), Content.TrainingSignals.Concat(Content.TestSignals).ToArray()); this.chart.Series[SIGNALS_SERIES_NAME].Tag = Content; var trainingPriceChanges = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceChangeVariable, trainingRows); var testPriceChanges = Content.ProblemData.Dataset.GetDoubleValues(Content.ProblemData.PriceChangeVariable, testRows); IEnumerable <double> accumulatedTrainingPrice = GetAccumulatedProfits(trainingPriceChanges); IEnumerable <double> accumulatedTestPrice = GetAccumulatedProfits(testPriceChanges); this.chart.Series.Add(PRICEVARIABLE_SERIES_NAME); this.chart.Series[PRICEVARIABLE_SERIES_NAME].YAxisType = AxisType.Primary; this.chart.Series[PRICEVARIABLE_SERIES_NAME].LegendText = PRICEVARIABLE_SERIES_NAME; this.chart.Series[PRICEVARIABLE_SERIES_NAME].ChartType = SeriesChartType.FastLine; this.chart.Series[PRICEVARIABLE_SERIES_NAME].Points.DataBindXY( trainingRows.Concat(testRows).ToArray(), accumulatedTrainingPrice.Concat(accumulatedTestPrice).ToArray()); this.chart.Series[PRICEVARIABLE_SERIES_NAME].Tag = Content; IEnumerable <double> trainingProfit = OnlineProfitCalculator.GetProfits(trainingPriceChanges, Content.TrainingSignals, Content.ProblemData.TransactionCosts); IEnumerable <double> testProfit = OnlineProfitCalculator.GetProfits(testPriceChanges, Content.TestSignals, Content.ProblemData.TransactionCosts); IEnumerable <double> accTrainingProfit = GetAccumulatedProfits(trainingProfit); IEnumerable <double> accTestProfit = GetAccumulatedProfits(testProfit); this.chart.Series.Add(ASSET_SERIES_NAME); this.chart.Series[ASSET_SERIES_NAME].YAxisType = AxisType.Primary; this.chart.Series[ASSET_SERIES_NAME].LegendText = ASSET_SERIES_NAME; this.chart.Series[ASSET_SERIES_NAME].ChartType = SeriesChartType.FastLine; this.chart.Series[ASSET_SERIES_NAME].Points.DataBindXY( trainingRows.Concat(testRows).ToArray(), accTrainingProfit.Concat(accTestProfit).ToArray()); this.chart.Series[ASSET_SERIES_NAME].Tag = Content; this.UpdateStripLines(); } }
public static double Calculate(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, ISymbolicExpressionTree solution, IProblemData problemData, IEnumerable <int> rows) { IEnumerable <double> signals = GetSignals(interpreter, solution, problemData.Dataset, rows); IEnumerable <double> returns = problemData.Dataset.GetDoubleValues(problemData.PriceChangeVariable, rows); OnlineCalculatorError errorState; double profit = OnlineProfitCalculator.Calculate(returns, signals, problemData.TransactionCosts, out errorState); if (errorState != OnlineCalculatorError.None) { return(0.0); } else { return(profit); } }