Esempio n. 1
0
 public Prediction(ProfitLossCalculator profitLossCalculator, StrategyI strategy, NeuralNet net, double buyLevel, double sellLevel)
 {
     this.ProfitLossCalculator = profitLossCalculator;
     this.Strategy             = strategy;
     this.Net       = net;
     this.BuyLevel  = buyLevel;
     this.SellLevel = sellLevel;
 }
Esempio n. 2
0
 public Prediction(ProfitLossCalculator profitLossCalculator, StrategyI strategy, NeuralNet net, double buyLevel, double sellLevel)
 {
     ProfitLossCalculator = profitLossCalculator;
     Strategy             = strategy;
     Net       = net;
     BuyLevel  = buyLevel;
     SellLevel = sellLevel;
 }
Esempio n. 3
0
        public TrainingSession(StockPortfolio portfolio, Stock stock, BestNetworkDTO dto, NeuralStockSettings settings)
        {
            _statisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();
            Portfolio          = portfolio;
            Stock = stock;

            TrainSamplePercentage         = settings.PercentageTraining;
            NumberAnns                    = settings.NumberANNs;
            NumberHiddenLayers            = settings.NumberHiddenLayers;
            NumberNeuronsPerHiddenLayer   = settings.NumberNeuronsHiddenLayer;
            NumberDaysBetweenTransactions = settings.NumberDaysBetweenTransactions;

            BuyLevel  = dto.BuyLevel;
            SellLevel = dto.SellLevel;

            var strategy = new StrategyI(StrategySettings.FromJson(dto.StrategySettings), settings)
            {
                TrainingMeansInput    = dto.TrainingMeansInput?.ToArray(),
                TrainingStdDevsInput  = dto.TrainingStdDevsInput?.ToArray(),
                TrainingMeansOutput   = dto.TrainingMeansOutput?.ToArray(),
                TrainingStdDevsOutput = dto.TrainingStdDevsOutput?.ToArray()
            };

            var tmpFileName = Path.GetTempFileName();

            File.WriteAllBytes(tmpFileName, dto.BestNeuralNet);
            var net = new NeuralNet(tmpFileName);

            _cachedPredictions.Clear();
            SplitTrainTestData();

            var trainingTestingData = PrepareAnnData(strategy, false);

            var prediction           = Predict(trainingTestingData, net, false);
            var profitLossCalculator = new ProfitLossCalculator(Portfolio.Reset(), this, prediction.Item1);

            _cachedPredictions.Add(new Prediction(profitLossCalculator, strategy, net, prediction.Item2,
                                                  prediction.Item3));
        }