Exemplo n.º 1
0
        public async Task <List <CandleDto> > GetCandlesAsync(Instrument instrument, TimePeriod timePeriod, DateTime startTime, DateTime endTime)
        {
            if (!ExchangeConfig.SupportedInstruments.ContainsKey(instrument))
            {
                _logger.Log(LogLevel.Error, $"{ExchangeConfig.ExchangeName} does not support the {instrument} instrument");

                return(null);
            }

            var request = new CandleRequest
            {
                Symbol       = _exchangeApi.ToSymbol(instrument),
                StartAt      = 0,
                Count        = 750,
                TimeInterval = _exchangeApi.ToTimePeriod(timePeriod),
                StartTime    = startTime.ToUtcTimeString(),
                EndTime      = endTime.ToUtcTimeString(),
            };

            var channelPath = ExchangeConfig.SupportedRestChannels[ExchangeChannel.Candle];

            var response = await _exchangeApi.GetAllAsync <CandleDto, CandleResponse>(channelPath, request);

            foreach (var candleModel in response)
            {
                candleModel.Period = timePeriod;
            }

            return(response.ToList());
        }