Ejemplo n.º 1
0
        public static void Generate(FileInfo dataDir)
        {
            IMarketLoader loader = new YahooFinanceLoader();
            var           market = new MarketMLDataSet(loader,
                                                       Config.INPUT_WINDOW, Config.PREDICT_WINDOW);
            var desc = new MarketDataDescription(
                Config.TICKER, MarketDataType.AdjustedClose, true, true);

            market.AddDescription(desc);

            var end   = DateTime.Now;            // end today
            var begin = new DateTime(end.Ticks); // begin 30 days ago

            // Gather training data for the last 2 years, stopping 60 days short of today.
            // The 60 days will be used to evaluate prediction.
            begin = begin.AddDays(-60);
            end   = end.AddDays(-60);
            begin = begin.AddYears(-2);

            market.Load(begin, end);
            market.Generate();
            EncogUtility.SaveEGB(FileUtil.CombinePath(dataDir, Config.TRAINING_FILE), market);

            // create a network
            BasicNetwork network = EncogUtility.SimpleFeedForward(
                market.InputSize,
                Config.HIDDEN1_COUNT,
                Config.HIDDEN2_COUNT,
                market.IdealSize,
                true);

            // save the network and the training
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(dataDir, Config.NETWORK_FILE), network);
        }
Ejemplo n.º 2
0
        public static MarketMLDataSet GrabData(string newfileLoad)
        {
            IMarketLoader loader = new CSVFinal();

            loader.GetFile(newfileLoad);

            var result = new MarketMLDataSet(loader,
                                             CONFIG.INPUT_WINDOW, CONFIG.PREDICT_WINDOW);
            //  var desc = new MarketDataDescription(Config.TICKER,
            //   MarketDataType.Close, true, true);

            var desc = new MarketDataDescription(CONFIG.TICKER,
                                                 MarketDataType.Close, true, true);

            result.AddDescription(desc);

            var end   = DateTime.Now;            // end today
            var begin = new DateTime(end.Ticks); // begin 30 days ago

            begin = begin.AddDays(-950);

            result.Load(begin, end);
            result.Generate();

            return(result);
        }
Ejemplo n.º 3
0
        public static MarketMLDataSet GrabData(string newfileLoad)
        {
            IMarketLoader loader = new CSVFileLoader();//CSVLoader();

            loader.GetFile(newfileLoad);

            var result = new MarketMLDataSet(loader,
                                             Config.INPUT_WINDOW, Config.PREDICT_WINDOW);
            //  var desc = new MarketDataDescription(Config.TICKER,
            //   MarketDataType.Close, true, true);

            var desc = new MarketDataDescription(Config.TICKER,
                                                 MarketDataType.Close, TemporalDataDescription.Type.PercentChange, true, true);

            result.AddDescription(desc);

            var begin = DateTime.ParseExact("29.05.2005", "dd.MM.yyyy", CultureInfo.CurrentCulture); // begin 30 days ago
            var end   = DateTime.ParseExact("22.07.2005", "dd.MM.yyyy", CultureInfo.CurrentCulture); // begin 30 days ago

            begin = begin.AddDays(Config.DAYS_OFFSET).AddDays(Config.TEST_OFFSET);
            end   = end.AddDays(Config.DAYS_OFFSET).AddDays(Config.TEST_OFFSET).AddDays(Config.TEST_STRATCH);

            result.Load(begin, end);
            result.Generate();

            return(result);
        }
Ejemplo n.º 4
0
 public T Get <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
 {
     if (marketDataDescription.Name == _name)
     {
         return(this as T);
     }
     return(null);
 }
Ejemplo n.º 5
0
 public T Get <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
 {
     if (marketDataDescription.Name == new DiscountingSourceDescription(_currency).Name)
     {
         return(this as T);
     }
     throw new MissingMarketDataException($"{GetName()} cannot be used as {marketDataDescription.Name}");
 }
 public T Get <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
 {
     if (marketDataDescription.Name == _curveToStrip.Name)
     {
         return(_curve as T);
     }
     if (_secondCurveToStrip != null && marketDataDescription.Name == _secondCurveToStrip.Name)
     {
         return(_secondCurve as T);
     }
     if (_floatingRateSources.TryGetValue(marketDataDescription.Name, out var floatingRateSource))
     {
         return(floatingRateSource as T);
     }
     return(null);
 }
 public bool CanBeA <T>(MarketDataDescription <T> marketDataDescription, IMarketDataContainer marketDataContainer)
     where T : class, IMarketDataSource
 {
     if (marketDataDescription.Name == _curveToStrip.Name)
     {
         return(true);
     }
     if (_secondCurveToStrip != null && marketDataDescription.Name == _secondCurveToStrip.Name)
     {
         return(true);
     }
     if (_floatingRateSources.ContainsKey(marketDataDescription.Name))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 8
0
        public static void Generate(string fileName)
        {
            FileInfo      dataDir = new FileInfo(@Environment.CurrentDirectory);
            IMarketLoader loader  = new CSVFinal();
            var           market  = new MarketMLDataSet(loader, CONFIG.INPUT_WINDOW, CONFIG.PREDICT_WINDOW);
            //  var desc = new MarketDataDescription(Config.TICKER, MarketDataType.Close, true, true);

            var desc = new MarketDataDescription(CONFIG.TICKER, MarketDataType.Close, true, true);

            market.AddDescription(desc);
            string currentDirectory = @"c:\";

            loader.GetFile(fileName);

            var end   = DateTime.Now;            // end today
            var begin = new DateTime(end.Ticks); // begin 30 days ago

            // Gather training data for the last 2 years, stopping 60 days short of today.
            // The 60 days will be used to evaluate prediction.
            begin = begin.AddDays(-600);
            end   = begin.AddDays(200);

            Console.WriteLine("You are loading date from:" + begin.ToShortDateString() + " To :" + end.ToShortDateString());

            market.Load(begin, end);
            market.Generate();
            EncogUtility.SaveEGB(FileUtil.CombinePath(dataDir, CONFIG.SVMTRAINING_FILE), market);

            // create a network
            //BasicNetwork network = EncogUtility.SimpleFeedForward(
            //    market.InputSize,
            //    CONFIG.HIDDEN1_COUNT,
            //    CONFIG.HIDDEN2_COUNT,
            //    market.IdealSize,
            //    true);


            SupportVectorMachine network = new SupportVectorMachine(CONFIG.INPUT_WINDOW, true);

            TrainNetworks(network, market);
            // save the network and the training
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(dataDir, CONFIG.SVMTRAINING_FILE), network);
        }
Ejemplo n.º 9
0
        public static void Generate(string fileName)
        {
            FileInfo dataDir = new FileInfo(@Environment.CurrentDirectory);
            //Lets use the CSVFinal..(and not the CSV Form loader).
            IMarketLoader loader = new CSVFinal();

            loader.GetFile(fileName);
            var market = new MarketMLDataSet(loader, Config.INPUT_WINDOW, Config.PREDICT_WINDOW);
            //  var desc = new MarketDataDescription(Config.TICKER, MarketDataType.Close, true, true);

            var desc = new MarketDataDescription(Config.TICKER, MarketDataType.Close, TemporalDataDescription.Type.PercentChange, true, true);

            market.AddDescription(desc);
            loader.GetFile(fileName);

            var begin = DateTime.ParseExact("01.01.2000", "dd.MM.yyyy", CultureInfo.CurrentCulture); // begin 30 days ago
            var end   = DateTime.ParseExact("22.06.2005", "dd.MM.yyyy", CultureInfo.CurrentCulture); // begin 30 days ago

            begin = begin.AddDays(Config.DAYS_OFFSET);
            end   = end.AddDays(Config.DAYS_OFFSET);

            // Gather training data for the last 2 years, stopping 60 days short of today.
            // The 60 days will be used to evaluate prediction.
            //begin = begin.AddDays(-200);
            //end = begin.AddDays(1);

            Console.WriteLine("You are loading date from:" + begin.ToShortDateString() + " To :" + end.ToShortDateString());

            market.Load(begin, end);
            market.Generate();
            EncogUtility.SaveEGB(FileUtil.CombinePath(dataDir, Config.TRAINING_FILE), market);

            // create a network
            BasicNetwork network = EncogUtility.SimpleFeedForward(
                market.InputSize,
                Config.HIDDEN1_COUNT,
                Config.HIDDEN2_COUNT,
                market.IdealSize,
                true);

            // save the network and the training
            EncogDirectoryPersistence.SaveObject(FileUtil.CombinePath(dataDir, Config.NETWORK_FILE), network);
        }
        public static MarketMLDataSet GrabData()
        {
            IMarketLoader loader = new YahooFinanceLoader();
            var           result = new MarketMLDataSet(loader,
                                                       Config.INPUT_WINDOW, Config.PREDICT_WINDOW);
            var desc = new MarketDataDescription(Config.TICKER,
                                                 MarketDataType.AdjustedClose, true, true);

            result.AddDescription(desc);

            var end   = DateTime.Now;            // end today
            var begin = new DateTime(end.Ticks); // begin 30 days ago

            begin = begin.AddDays(-60);

            result.Load(begin, end);
            result.Generate();

            return(result);
        }
Ejemplo n.º 11
0
        public T Get <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
        {
            T foundCurve = null;

            foreach (var marketDataSource in _curves)
            {
                if (marketDataSource.CanBeA(marketDataDescription, this))
                {
                    if (foundCurve == null)
                    {
                        foundCurve = marketDataSource.Get(marketDataDescription);
                    }
                    else
                    {
                        throw new MissingMarketDataException($"At least two curves provide the same description: {foundCurve.GetName()} and {marketDataSource.GetName()}.");
                    }
                }
            }
            if (foundCurve == null)
            {
                throw new MissingMarketDataException($"There is no market data: {marketDataDescription.Name}");
            }
            return(foundCurve);
        }
Ejemplo n.º 12
0
 public bool CanBeA <T>(MarketDataDescription <T> marketDataDescription, IMarketDataContainer marketDataContainer) where T : class, IMarketDataSource
 {
     return(marketDataDescription.Name == _name);
 }
Ejemplo n.º 13
0
 public bool CanBeA <T>(MarketDataDescription <T> marketDataDescription, IMarketDataContainer marketDataContainer)
     where T : class, IMarketDataSource
 {
     return(marketDataDescription.Name == new DiscountingSourceDescription(_currency).Name);
 }
Ejemplo n.º 14
0
 public bool Contains <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
 {
     return(_curves.Any(c => c.CanBeA(marketDataDescription, this)));
 }
Ejemplo n.º 15
0
 public T Get <T>(MarketDataDescription <T> marketDataDescription) where T : class, IMarketDataSource
 {
     return(marketDataDescription.Name == _floatingRateSourceDescription.Name ? this as T : null);
 }