Moving should_not_update logic to async function per pair. if there is
no new candle, async function will just return the last cached candle locally and doesn’t hit the API
This commit is contained in:
@@ -137,22 +137,9 @@ class FreqtradeBot(object):
|
||||
"""
|
||||
# TODO: maybe add since_ms to use async in the download-script?
|
||||
# TODO: Add tests for this and the async stuff above
|
||||
|
||||
ticker_interval = self.strategy.ticker_interval
|
||||
interval_in_seconds = constants.TICKER_INTERVAL_MINUTES[ticker_interval] * 60
|
||||
|
||||
should_not_update = ((self._klines_last_fetched_time +
|
||||
interval_in_seconds + 1) > round(time.time()))
|
||||
|
||||
if should_not_update:
|
||||
return False
|
||||
|
||||
logger.debug("Refreshing klines for %d pairs", len(pair_list))
|
||||
datatups = asyncio.get_event_loop().run_until_complete(
|
||||
self.exchange.async_get_candles_history(pair_list, ticker_interval))
|
||||
|
||||
# fetching the timestamp of last candle
|
||||
self._klines_last_fetched_time = datatups[0][1][-1][0] / 1000
|
||||
self.exchange.async_get_candles_history(pair_list, self.strategy.ticker_interval))
|
||||
|
||||
# updating klines
|
||||
self._klines = {pair: data for (pair, data) in datatups}
|
||||
|
Reference in New Issue
Block a user