public async Task<IActionResult> GetAsync(string assetPairId, CandleType candleType, DateTime startDate, DateTime endDate) { if (string.IsNullOrWhiteSpace(assetPairId)) return NotFound(); var candles = await _candlesService.GetAsync(assetPairId, Enum.Parse<Domain.Entities.CandleType>(candleType.ToString()), startDate, endDate); var model = _mapper.Map<List<CandleModel>>(candles); return Ok(model); }
private static async Task LoadInterval(CandleType candle, string source, CandlesPersistentAzureStorage storage, string symbol, int digits, bool isRevert) { Console.WriteLine(); Console.WriteLine($"----- {candle.ToString()} --------"); var interval = ""; switch (candle) { case CandleType.Minute: interval = "1m"; break; case CandleType.Hour: interval = "1h"; break; case CandleType.Day: interval = "1d"; break; case CandleType.Month: interval = "1M"; break; } var data = await GetCandles(source, 1000, interval, 0, isRevert, digits); var count = 0; //while (data.Any() && count < 45000) while (data.Any() && count < 3000) { Console.Write($"Read {data.Count} items from Binance ... "); await storage.BulkSave(symbol, true, digits, candle, data); await storage.BulkSave(symbol, false, digits, candle, data); Console.WriteLine($"Save {data.Count} items"); var lastTime = data.Min(e => e.DateTime).UnixTime(); count += data.Count; data = await GetCandles(source, 1000, interval, lastTime - 1, isRevert, digits); } }