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 ShouldBeAbleToBuildListOfQuotesFromJsonFile() { string sampleJSONQuoteFilePath = "..\\..\\..\\Samples\\EFC-ByMinute-201912090230-201912200906.json"; List <DataModels.Quote> EFCbyMinute = ReadWriteJSONToDisk.getQuotesFromJSON(sampleJSONQuoteFilePath); Assert.IsTrue(EFCbyMinute.Count > 3); }
public void testCreateDirectoryMethod() { Assert.IsTrue(Directory.Exists(testingHttpClient.path)); ReadWriteJSONToDisk.testCreateDirectory($"{testingHttpClient.path}//Price_History"); Assert.IsTrue(Directory.Exists($"{testingHttpClient.path}//Price_History")); //ReadWriteJSONToDisk.testCreateDirectory($"{testingHttpClient.path}//Price_History//TEST//ByMinute");//creating a TEST directory that does not exist causes issue with the Trading Console program //Assert.IsTrue(Directory.Exists($"{testingHttpClient.path}//Price_History//TEST//ByMinute")); }
public void testCreateDirectoryMethod() { Assert.IsTrue(Directory.Exists(testingHttpClient.path)); ReadWriteJSONToDisk.testCreateDirectory($"{testingHttpClient.path}//Price_History"); Assert.IsTrue(Directory.Exists($"{testingHttpClient.path}//Price_History")); ReadWriteJSONToDisk.testCreateDirectory($"{testingHttpClient.path}//Price_History//TEST//ByMinute"); Assert.IsTrue(Directory.Exists($"{testingHttpClient.path}//Price_History//TEST//ByMinute")); }
public void ShouldBeAbleToChooseSourceOfTruthFile() { string samplePath = "..\\..\\..\\Samples"; List <DataModels.QuoteFile> quoteFilesFromFunction = ReadWriteJSONToDisk.getQuotesFileListFromDirectory(samplePath); DataModels.QuoteFile sourceOfTruth = StockHistory.ChooseSourceOfTruthFile(quoteFilesFromFunction); Assert.IsNotNull(sourceOfTruth); }
public void MapCombiningPriceLists() { string sampleJSONQuoteFilePath1 = "..\\..\\..\\Samples\\EFC-ByMinute-201912090230-201912200906.json"; string sampleJSONQuoteFilePath2 = "..\\..\\..\\Samples\\EFC-ByMinute-201912110230-201912240607.json"; List <DataModels.Quote> EFCbyMinute1 = ReadWriteJSONToDisk.getQuotesFromJSON(sampleJSONQuoteFilePath1); List <DataModels.Quote> EFCbyMinute2 = ReadWriteJSONToDisk.getQuotesFromJSON(sampleJSONQuoteFilePath2); List <DataModels.Quote> EFCbyMinuteFinal = EFCbyMinute1.Union(EFCbyMinute2, new DataModels.CompareQuoteByDatetime()) .OrderBy(o => o.datetime) .ToList(); Assert.IsTrue(EFCbyMinuteFinal.Count > EFCbyMinute1.Count && EFCbyMinuteFinal.Count > EFCbyMinute2.Count); Assert.IsTrue(EFCbyMinuteFinal.Contains(EFCbyMinute1.First()) && EFCbyMinuteFinal.Contains(EFCbyMinute1.Last())); //foreach (DataModels.Quote thisQuote in EFCbyMinute2) // Assert.IsTrue(EFCbyMinuteFinal.Contains(thisQuote)); List <DataModels.Quote> StockHistoryCombinedList = StockHistory.CombineQuoteLists(EFCbyMinute1, EFCbyMinute2); Assert.IsTrue(StockHistoryCombinedList.Count == EFCbyMinuteFinal.Count); }
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); } } }