public void TestParseContent() { var testFile = TestAssembly.TestDataDir + @"\IexApiDataResponse.json"; var testInput = System.IO.File.ReadAllText(testFile); var testSubject = new IexApi(); var testResult = testSubject.ParseContent(testInput); Assert.IsNotNull(testResult); Assert.IsTrue(testResult.Any()); }
public List <string> RunCommand(ChannelMessageEventDataModel messageEvent, GroupCollection arguments = null, bool useCache = true) { if (arguments == null || arguments.Count == 1) { throw new ArgumentException("Not enough arguments"); } string symbolName = arguments[1].Value; IexApiModels.IexQuoteApiModel ticker; try { ticker = IexApi.GetIexQuote(symbolName); } catch (Http.HttpException e) { if (e.Message.Contains("NotFound")) { return(new List <string> { "Symbol does not exist" }); } throw; } if (ticker.Symbol == null) { return(new List <string> { "JSON is all f****d up." }); } DateTimeOffset now = new DateTimeOffset(TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").BaseUtcOffset); DateTimeOffset openTime = new DateTimeOffset(now.Year, now.Month, now.Day, 9, 30, 0, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").BaseUtcOffset); // Even though it says standard time it is actually DST aware DateTimeOffset closeTime = new DateTimeOffset(now.Year, now.Month, now.Day, 16, 0, 0, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").BaseUtcOffset); if ((now >= openTime && now <= closeTime) && !(now.DayOfWeek == DayOfWeek.Saturday || now.DayOfWeek == DayOfWeek.Sunday)) { return(new List <string> { FormatTicker(ticker) }); } return(new List <string> { FormatAfterHoursTicker(ticker) }); }