static void FetchData() { var db = Database.GetProductionDatabase(MongoHostInfo.FromAppSettings()); var coll = db.MongoDatabase.GetCollection("DbBar"); coll.EnsureIndex(new IndexKeysBuilder().Ascending("Symbol", "Timestamp")); var allBars = db.QueryAll <DbBar>(_ => true); DateTime firstDate = DateTime.Parse("11/10/2001", null, DateTimeStyles.AdjustToUniversal); DateTime lastDate = allBars.Any() ? allBars.OrderByDescending(x => x.Timestamp).First().Timestamp : firstDate; var predicted = "DIA"; var firstFetchDate = lastDate.AddDays(1); Console.WriteLine("Fetching from {0:MM/dd/yyyy} to today", firstFetchDate.Date); VersaceDataFetching.DownloadData(predicted, firstFetchDate, DateTime.Now.Date); Console.Write("Storing in mongo ..."); var allNewBars = new List <DbBar>(); foreach (var symbol in DataPreprocessing.GetTickers(predicted)) { foreach (var dbBar in DataImport.LoadVersace(symbol).Select(x => new DbBar(db, symbol, x.Timestamp, x.Open, x.Low, x.High, x.Close, x.Volume))) { allNewBars.Add(dbBar); } } db.StoreAll(allNewBars); Console.WriteLine("done"); }