Пример #1
0
        public static NeuralStockSettings GetDefault()
        {
            var obj = new NeuralStockSettings
            {
                InitialCash              = 20000,
                StartDate                = DateTime.Today.AddYears(-1),
                PercentageTraining       = 0.6,
                NumberANNs               = 100,
                NumberHiddenLayers       = 1,
                NumberNeuronsHiddenLayer = 15
            };

            return(obj);
        }
Пример #2
0
        public TrainingSession(StockPortfolio portfolio, Stock stock, BestNetworkDTO dto, NeuralStockSettings settings)
        {
            this._statisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();
            this.Portfolio          = portfolio;
            this.Stock = stock;

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

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

            var strategy = new StrategyI(StrategySettings.FromJson(dto.StrategySettings))
            {
                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);

            this._cachedPredictions.Clear();
            this.SplitTrainTestData();

            var trainingTestingData = this.PrepareAnnData(strategy, false);

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

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