public void ShouldBeAbleToGetAListOfByMinuteFiles() { string samplePath = "..\\..\\..\\Samples"; string[] files = Directory.GetFiles(samplePath); List <DataModels.QuoteFile> quoteFiles = new List <DataModels.QuoteFile>(); foreach (string file in files) { if (file.EndsWith(".json")) { DataModels.QuoteFile thisFile = new DataModels.QuoteFile(); thisFile.path = file; thisFile.info = new FileInfo(file); List <string> splitname = thisFile.info.Name.Replace(".json", "").Split('-').ToList(); Regex rgx = new Regex(@"\d"); Assert.IsTrue(rgx.IsMatch(splitname[3])); thisFile.startDate = splitname.Where(q => rgx.IsMatch(q.ToString())).First(); thisFile.endDate = splitname.Where(q => rgx.IsMatch(q)).Last(); quoteFiles.Add(thisFile); } } Assert.IsTrue(quoteFiles.Count > 1); Assert.IsNotNull(quoteFiles.First().info.Name); List <DataModels.QuoteFile> quoteFilesFromFunction = ReadWriteJSONToDisk.getQuotesFileListFromDirectory(samplePath); Assert.IsTrue(quoteFiles.Count == quoteFilesFromFunction.Count); }
public void ShouldBeAbleToChooseSourceOfTruthFile() { string samplePath = "..\\..\\..\\Samples"; List <DataModels.QuoteFile> quoteFilesFromFunction = ReadWriteJSONToDisk.getQuotesFileListFromDirectory(samplePath); DataModels.QuoteFile sourceOfTruth = StockHistory.ChooseSourceOfTruthFile(quoteFilesFromFunction); Assert.IsNotNull(sourceOfTruth); }
private static void UpdateTrackedSymbolsMyMinuteData(HttpClient client, string apiKey, string tradeDataPath, List <string> TrackedStockSymbols) { foreach (string symbol in TrackedStockSymbols) { Log.write($"Updating Market Hours for Symbols {symbol}"); string storageFolderPath = StockHistory.getSymbolsPriceHistoryPath(tradeDataPath, symbol, "ByMinute"); List <QuoteFile> priceByMinuteFiles = ReadWriteJSONToDisk.getQuotesFileListFromDirectory(storageFolderPath); DateTime MaxModDate = new DateTime(0); if (priceByMinuteFiles.Count() > 0) { MaxModDate = priceByMinuteFiles.Select(s => s.info.LastWriteTime).Max(); } if (DateTime.Now.AddDays(-1) > MaxModDate) { string newUpdatedFile = StockHistory.UpdateStockByMinuteHistoryFile(client, apiKey, symbol, tradeDataPath, true); Log.write($"Symbol By Minute updated {newUpdatedFile}"); Ultility.delay(250); } } }