Keep last_pair_refresh as tuple asw ell

This commit is contained in:
Matthias 2019-01-05 06:44:08 +01:00
parent 6525a838d1
commit d7df5d5715

View File

@ -80,7 +80,7 @@ class Exchange(object):
self._cached_ticker: Dict[str, Any] = {} self._cached_ticker: Dict[str, Any] = {}
# Holds last candle refreshed time of each pair # Holds last candle refreshed time of each pair
self._pairs_last_refresh_time: Dict[str, int] = {} self._pairs_last_refresh_time: Dict[Tuple[str, str], int] = {}
# Holds candles # Holds candles
self._klines: Dict[Tuple[str, str], DataFrame] = {} self._klines: Dict[Tuple[str, str], DataFrame] = {}
@ -545,7 +545,7 @@ class Exchange(object):
# Calculating ticker interval in second # Calculating ticker interval in second
interval_in_sec = constants.TICKER_INTERVAL_MINUTES[ticker_interval] * 60 interval_in_sec = constants.TICKER_INTERVAL_MINUTES[ticker_interval] * 60
if not (self._pairs_last_refresh_time.get(pair, 0) + interval_in_sec >= if not (self._pairs_last_refresh_time.get((pair, ticker_interval), 0) + interval_in_sec >=
arrow.utcnow().timestamp and (pair, ticker_interval) in self._klines): arrow.utcnow().timestamp and (pair, ticker_interval) in self._klines):
input_coroutines.append(self._async_get_candle_history(pair, ticker_interval)) input_coroutines.append(self._async_get_candle_history(pair, ticker_interval))
else: else:
@ -564,7 +564,7 @@ class Exchange(object):
ticks = res[2] ticks = res[2]
# keeping last candle time as last refreshed time of the pair # keeping last candle time as last refreshed time of the pair
if ticks: if ticks:
self._pairs_last_refresh_time[pair] = ticks[-1][0] // 1000 self._pairs_last_refresh_time[(pair, tick_interval)] = ticks[-1][0] // 1000
# keeping parsed dataframe in cache # keeping parsed dataframe in cache
self._klines[(pair, tick_interval)] = parse_ticker_dataframe( self._klines[(pair, tick_interval)] = parse_ticker_dataframe(
ticks, tick_interval, fill_missing=True) ticks, tick_interval, fill_missing=True)