public void TestCSVLoader() { var loader = new CSVFinal(); loader.DateFormat = "yyyy.MM.dd hh:mm:ss"; var tickerAAPL = new TickerSymbol("AAPL", "NY"); var desc = new MarketDataDescription(tickerAAPL, MarketDataType.Close, true, true); MarketMLDataSet marketData = new MarketMLDataSet(loader, 5, 1); marketData.AddDescription(desc); marketData.SequenceGrandularity = Util.Time.TimeUnit.Hours; var begin = new DateTime(2006, 1, 1); var end = new DateTime(2007, 7, 31); loader.GetFile((AssemblyDirectory + "\\smallCSV.csv")); marketData.Load(begin, end); marketData.Generate(); // first test the points IEnumerator<TemporalPoint> itr = marketData.Points.GetEnumerator(); itr.MoveNext(); TemporalPoint point = itr.Current; Assert.AreEqual(0, point.Sequence); Assert.AreEqual(1, point.Data.Length); Assert.AreEqual(1.12884, point[0]); Assert.AreEqual(5, marketData.Points.Count); }
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, 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(-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(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; }