Fix refresh_latest_ohlcv bug

This commit is contained in:
Matthias 2021-08-17 06:44:20 +02:00
parent f471915828
commit 9758bed250
2 changed files with 7 additions and 2 deletions

View File

@ -1253,7 +1253,7 @@ class Exchange:
logger.debug("Refreshing candle (OHLCV) data for %d pairs", len(pair_list)) logger.debug("Refreshing candle (OHLCV) data for %d pairs", len(pair_list))
input_coroutines = [] input_coroutines = []
cached_pairs = []
# Gather coroutines to run # Gather coroutines to run
for pair, timeframe in set(pair_list): for pair, timeframe in set(pair_list):
if (((pair, timeframe) not in self._klines) if (((pair, timeframe) not in self._klines)
@ -1265,6 +1265,7 @@ class Exchange:
"Using cached candle (OHLCV) data for pair %s, timeframe %s ...", "Using cached candle (OHLCV) data for pair %s, timeframe %s ...",
pair, timeframe pair, timeframe
) )
cached_pairs.append((pair, timeframe))
results = asyncio.get_event_loop().run_until_complete( results = asyncio.get_event_loop().run_until_complete(
asyncio.gather(*input_coroutines, return_exceptions=True)) asyncio.gather(*input_coroutines, return_exceptions=True))
@ -1287,6 +1288,10 @@ class Exchange:
results_df[(pair, timeframe)] = ohlcv_df results_df[(pair, timeframe)] = ohlcv_df
if cache: if cache:
self._klines[(pair, timeframe)] = ohlcv_df self._klines[(pair, timeframe)] = ohlcv_df
# Return cached klines
for pair, timeframe in cached_pairs:
results_df[(pair, timeframe)] = self.klines((pair, timeframe), copy=False)
return results_df return results_df
def _now_is_time_to_refresh(self, pair: str, timeframe: str) -> bool: def _now_is_time_to_refresh(self, pair: str, timeframe: str) -> bool:

View File

@ -115,7 +115,7 @@ class VolumePairList(IPairList):
pairlist = self._pair_cache.get('pairlist') pairlist = self._pair_cache.get('pairlist')
if pairlist: if pairlist:
# Item found - no refresh necessary # Item found - no refresh necessary
return pairlist return pairlist.copy()
else: else:
# Use fresh pairlist # Use fresh pairlist
# Check if pair quote currency equals to the stake currency. # Check if pair quote currency equals to the stake currency.