public BinanceSymbolData FetchPopulateBinanceSymbolData(Enums.Symbol symbol, int limit) { Console.WriteLine("Currently Fetching Data from Binance..."); BinanceSymbolData symbolData = GetSymbolData(symbol.ToString(), "30m", limit.ToString()); indicatorService.PopulateSymbolDataListMetaData(symbolData.Periods); return(symbolData); }
public BinanceSymbolData GetSymbolData(string symbol, string interval, string limit) { BinanceSymbolData symbolData = new BinanceSymbolData(symbol); string url = string.Concat(Constants.binanceBaseUrl, Constants.candleStickEndpoint, "?", "symbol=", symbol, "&interval=", interval, "&limit=", limit); HttpResponseMessage response = client.GetAsync(url).GetAwaiter().GetResult(); //Console.WriteLine("Status Code:" + response.StatusCode); if (response.IsSuccessStatusCode) { var result = response.Content.ReadAsStringAsync().Result; JArray json = JsonConvert.DeserializeObject <JArray>(result); for (int i = 0; i < json.Count; i++) { JArray stickData = JsonConvert.DeserializeObject <JArray>(json[i].ToString()); symbolData.Periods.Add(new BinanceCandleStickData(stickData)); } symbolData.TimePolled = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds; } return(symbolData); }