mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Improve ohlcv pair cache with since_ms
avoids some rare bugs in more complex configurations.
This commit is contained in:
parent
3680e199ce
commit
4cfd5d004e
|
@ -2171,16 +2171,16 @@ class Exchange:
|
|||
|
||||
timeframes = {p[1] for p in pairs}
|
||||
for timeframe in timeframes:
|
||||
if timeframe not in self._expiring_candle_cache:
|
||||
if (timeframe, since_ms) not in self._expiring_candle_cache:
|
||||
timeframe_in_sec = timeframe_to_seconds(timeframe)
|
||||
# Initialise cache
|
||||
self._expiring_candle_cache[timeframe] = PeriodicCache(ttl=timeframe_in_sec,
|
||||
maxsize=1000)
|
||||
self._expiring_candle_cache[(timeframe, since_ms)] = PeriodicCache(
|
||||
ttl=timeframe_in_sec, maxsize=1000)
|
||||
|
||||
# Get candles from cache
|
||||
candles = {
|
||||
c: self._expiring_candle_cache[c[1]].get(c, None) for c in pairs
|
||||
if c in self._expiring_candle_cache[c[1]]
|
||||
c: self._expiring_candle_cache[(c[1], since_ms)].get(c, None) for c in pairs
|
||||
if c in self._expiring_candle_cache[(c[1], since_ms)]
|
||||
}
|
||||
pairs_to_download = [p for p in pairs if p not in candles]
|
||||
if pairs_to_download:
|
||||
|
@ -2188,7 +2188,7 @@ class Exchange:
|
|||
pairs_to_download, since_ms=since_ms, cache=False
|
||||
)
|
||||
for c, val in candles.items():
|
||||
self._expiring_candle_cache[c[1]][c] = val
|
||||
self._expiring_candle_cache[(c[1], since_ms)][c] = val
|
||||
return candles
|
||||
|
||||
def _now_is_time_to_refresh(self, pair: str, timeframe: str, candle_type: CandleType) -> bool:
|
||||
|
|
Loading…
Reference in New Issue
Block a user