public KeyStats GetKeyStats(string symbol) { string IEXTrading_API_PATH = BASE_URL + "stock/" + symbol + "/stats"; string kstatsList = ""; KeyStats stats = null; // connect to the IEXTrading API and retrieve information httpClient.BaseAddress = new Uri(IEXTrading_API_PATH); HttpResponseMessage response = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult(); // read the Json objects in the API response if (response.IsSuccessStatusCode) { kstatsList = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } // now, parse the Json strings as C# objects if (!kstatsList.Equals("")) { // https://stackoverflow.com/a/46280739 stats = JsonConvert.DeserializeObject <KeyStats>(kstatsList); } if (stats.marketCap != null && stats.evEBITDA != null) { stats.evEBITDA = stats.marketCap / stats.EBITDA; } return(stats); }
public KeyStats GetKeyStats(string symbol) { string IEXTrading_API_PATH = BASE_URL + "stock/" + symbol + "/stats"; string kstatsList = ""; KeyStats stats = null; httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); // connect to the IEXTrading API and retrieve information httpClient.BaseAddress = new Uri(IEXTrading_API_PATH); HttpResponseMessage response = httpClient.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult(); // read the Json objects in the API response if (response.IsSuccessStatusCode) { kstatsList = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } // now, parse the Json strings as C# objects if (!kstatsList.Equals("")) { // https://stackoverflow.com/a/46280739 stats = JsonConvert.DeserializeObject <KeyStats>(kstatsList); } return(stats); }
private DataUpdates(DateTime occuredutc, DataPoint[] dataPoints, Delistings delistings, Dividends dividends, Earnings earnings, Financials financials, KeyStats keystats, QuoteBars quotebars, Splits splits, TradeBars tradebars, TradingStatusUpdates tradingStatusUpdates, Ticks ticks) { //TODO: for cloning this object (so it becomes immutable) throw new NotImplementedException(); }
/* * The Symbols action calls the GetSymbols method that returns a list of Companies. * This list of Companies is passed to the Symbols View. */ public IActionResult KeyStats(string symbol) { //Set ViewBag variable first ViewBag.dbSuccessComp = 0; KeyStats stats = GetKeyStats(symbol); //Save companies in TempData, so they do not have to be retrieved again TempData["Stats"] = JsonConvert.SerializeObject(stats); return(View(stats)); }
public Report() { dividends = new List <Dividend>(); changeIntervals = new List <decimal>(); keyStats = new KeyStats(); }