private static IApiQuerier _apiQuerier; //Injected public SymbolsController() { //theoretical thread contention hazard, but the production version would use dependency injection //factory design pattern, so OK in prototype if (_apiQuerier == null) { _apiQuerier = new ApiQuerier("Z9770ZIXU68OT1UW"); } }
public ActionResult <IEnumerable <string> > Get() { IList <string> prices = new List <string>(); if (_apiQuerier == null) { _apiQuerier = new ApiQuerier("Z9770ZIXU68OT1UW"); } // Intraday time series for MSFT: var result = GetIntradayTimeSeries("MSFT"); var realResult = result.GetAwaiter().GetResult(); // result.TimeSeries is a dictionary with the date time as the key foreach (var point in realResult.TimeSeries) { Console.WriteLine($"{point.Key}: {point.Value.Open}"); prices.Add($"{point.Key}: {point.Value.Open}"); } return(prices.ToArray()); }
public AlphaVantageStockDataQuerier(IApiQuerier apiQuerier) { _apiQuerier = apiQuerier; }