示例#1
0
        public TrainingSession(StockPortfolio portfolio, Stock stock)
        {
            this._statisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();

            this.Portfolio = portfolio;
            this.Stock     = stock;
        }
        public ProfitLossCalculator(StockPortfolio portfolio, TrainingSession trainingSession, SortedList <DateTime, SignalEnum> signals)
        {
            this._statisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();

            this.Portfolio       = portfolio;
            this.TrainingSession = trainingSession;
            this.Signals         = signals;

            this.Calculate();
        }
示例#3
0
        public ProfitLossCalculator(StockPortfolio portfolio, TrainingSession trainingSession,
                                    Dictionary <DateTime, SignalEnum> signals)
        {
            _statisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();

            Portfolio       = portfolio;
            TrainingSession = trainingSession;
            Signals         = signals;

            Calculate();
        }
示例#4
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));
        }