public override double GetSchemeProfit(StockHistorySet testData, AbstractPredictor Predictor, int today, int daysToPredict) { var stocksInOrder = testData.AllStockHistories.OrderByDescending(x => Predictor.PredictValue(x, today, daysToPredict) / x.Closes[today]).ToArray(); var tenBest = stocksInOrder.Take(10).ToArray(); double profit = 0D; foreach (StockHistory stockHistory in tenBest) { double startV = stockHistory.Closes[today]; double actualEndV = stockHistory.Closes[today + daysToPredict]; profit += (actualEndV - startV); } return profit / 10; }
public override double GetSchemeProfit(StockHistorySet testData, AbstractPredictor Predictor, int today, int daysToPredict) { double profit = 0D; // If prediction is higher, buy 1 unit. Otherwise, short 1 unit foreach (StockHistory stockHistory in testData.AllStockHistories) { double startV = stockHistory.Closes[today]; double predictedEndV = Predictor.PredictValue(stockHistory, today, daysToPredict); double actualEndV = stockHistory.Closes[today + daysToPredict]; if (Predictor is RandomPredictor) { ; ; } if (predictedEndV > startV) profit += (actualEndV - startV); else profit += (startV - actualEndV); } return profit / testData.AllStockHistories.Count; }