public async Task <IexKeyStats> GetKeyStats(string symbol) { var url = string.Format(KeyStatsUrlFormat, symbol); var json = await GetString(url); return(IexKeyStats.FromJson(json)); }
public void Should_Format_KeyStats() { using (StreamReader reader = new StreamReader(Path.Combine("IEXResponseText", "KeyStats.json"))) { string keyStatsJson = reader.ReadToEnd(); IEXFormatter formatter = new IEXFormatter(); IexKeyStats keyStats = formatter.FormatKeyStats(keyStatsJson); keyStats.CompanyName.Should().Be("Apple Inc."); keyStats.SharesOutstanding.Should().Be(5213840000); keyStats.Float.Should().Be(5203997571); } }
public void Should_Format_KeyStats3() { using (StreamReader reader = new StreamReader(Path.Combine("IEXResponseText", "KeyStats3.json"))) { string keyStatsJson = reader.ReadToEnd(); IEXFormatter formatter = new IEXFormatter(); IexKeyStats keyStats = formatter.FormatKeyStats(keyStatsJson); keyStats.CompanyName.Should().Be("Ormat Technologies Inc"); keyStats.Avg10Volume.Should().Be(491633); keyStats.ExDividendDate.Should().Be(DateTime.MinValue); } }
public void TestParseContent() { var testFile = TestAssembly.TestDataDir + @"\IexKeyStatsResponse.json"; var testInput = System.IO.File.ReadAllText(testFile); var testSubject = new IexKeyStats(null); var testResult = testSubject.ParseContent(testInput); Assert.IsNotNull(testResult); Assert.IsTrue(testResult.Any()); var singleResult = testResult.First(); var someValue = singleResult.peRatioHigh; Assert.AreEqual(114.1D, someValue.Value); Console.WriteLine(someValue.ToString()); }
public void TestTryParseIexKeyStatsJson() { var testContent = System.IO.File.ReadAllText(TestAssembly.TestDataDir + @"\IexKeyStatsResponse.json"); var corp = new PublicCompany(); var testResult = Copula.TryParseIexKeyStatsJson(testContent, IexKeyStats.GetUri("AAPL"), ref corp); Assert.IsTrue(testResult); Assert.IsTrue(corp.NetUris.Any()); foreach (var uri in corp.NetUris) { Console.WriteLine(uri.ToString()); } }
public void Should_Format_KeyStats2() { using (StreamReader reader = new StreamReader(Path.Combine("IEXResponseText", "KeyStats2.json"))) { string keyStatsJson = reader.ReadToEnd(); IEXFormatter formatter = new IEXFormatter(); IexKeyStats keyStats = formatter.FormatKeyStats(keyStatsJson); keyStats.CompanyName.Should().Be("Apple Inc."); keyStats.Employees.Should().Be(null); keyStats.ExDividendDate.Should().Be(null); keyStats.NextDividendDate.Should().Be(null); keyStats.NextEarningsDate.Should().Be(null); } }
public static string FormatStats(IexKeyStats item) { var sb = new StringBuilder(); sb.AppendLine($"Company Name: {item.CompanyName}"); sb.AppendLine($"Market Cap: {item.Marketcap}"); sb.AppendLine($"Beta: {item.Beta}"); sb.AppendLine($"52 Week High: {item.Week52High}"); sb.AppendLine($"52 Week low: {item.Week52Low}"); sb.AppendLine($"52 Week Change: {item.Week52Change}"); sb.AppendLine($"Short Interest: {item.ShortInterest}"); sb.AppendLine($"Short Date: {item.ShortDate}"); sb.AppendLine($"Short Ratio: {item.ShortRatio}"); sb.AppendLine($"Dividend Rate: {item.DividendRate}"); sb.AppendLine($"Dividend Yield: {item.DividendYield}"); sb.AppendLine($"Ex Dividend Date: {item.ExDividendDate}"); sb.AppendLine($"Latest EPS: {item.LatestEps}"); sb.AppendLine($"Latest EPS Date: {item.LatestEpsDate}"); sb.AppendLine($"Shares Outstanding: {item.SharesOutstanding}"); sb.AppendLine($"Float: {item.Float}"); sb.AppendLine($"Return on Equity: {item.ReturnOnEquity}"); sb.AppendLine($"Return on Capital: {item.ReturnOnCapital}"); sb.AppendLine($"Return on Assets: {item.ReturnOnAssets}"); sb.AppendLine($"Consensus EPS: {item.ConsensusEps}"); sb.AppendLine($"Number of Estimates: {item.NumberOfEstimates}"); sb.AppendLine($"EBITDA: {item.Ebitda}"); sb.AppendLine($"Revenue: {item.Revenue}"); sb.AppendLine($"Gross Profit: {item.GrossProfit}"); sb.AppendLine($"Cash: {item.Cash}"); sb.AppendLine($"Debt: {item.Debt}"); sb.AppendLine($"TTMEPS: {item.TtmEps}"); sb.AppendLine($"Revenue Per Share: {item.RevenuePerShare}"); sb.AppendLine($"Revenue Per Employee: {item.RevenuePerEmployee}"); sb.AppendLine($"P/E High: {item.PeRatioHigh}"); sb.AppendLine($"P/E Low: {item.PeRatioLow}"); return(sb.ToString()); }
public static string ToJson(IexKeyStats item) => JsonConvert.SerializeObject(item, JsonSettings);
public IexKeyStats FormatKeyStats(string keyStatsJson) { IexKeyStats keyStats = JsonConvert.DeserializeObject <IexKeyStats>(keyStatsJson); return(keyStats); }