mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
fix: Fix WS restart bug after network outage
This could lead to messed up candles in case of an outage that took more than 1 candle.
This commit is contained in:
parent
0ad8fcf834
commit
faf7b830c9
|
@ -78,6 +78,12 @@ class ExchangeWS:
|
|||
finally:
|
||||
self.__cleanup_called = True
|
||||
|
||||
def _pop_history(self, paircomb: PairWithTimeframe) -> None:
|
||||
"""
|
||||
Remove history for a pair/timeframe combination from ccxt cache
|
||||
"""
|
||||
self.ccxt_object.ohlcvs.get(paircomb[0], {}).pop(paircomb[1], None)
|
||||
|
||||
def cleanup_expired(self) -> None:
|
||||
"""
|
||||
Remove pairs from watchlist if they've not been requested within
|
||||
|
@ -91,6 +97,8 @@ class ExchangeWS:
|
|||
if last_refresh > 0 and (dt_ts() - last_refresh) > ((timeframe_s + 20) * 1000):
|
||||
logger.info(f"Removing {p} from watchlist")
|
||||
self._klines_watching.discard(p)
|
||||
# Pop history to avoid getting stale data
|
||||
self._pop_history(p)
|
||||
changed = True
|
||||
if changed:
|
||||
logger.info(f"Removal done: new watch list ({len(self._klines_watching)})")
|
||||
|
@ -128,6 +136,7 @@ class ExchangeWS:
|
|||
|
||||
logger.info(f"{pair}, {timeframe}, {candle_type} - Task finished - {result}")
|
||||
self._klines_scheduled.discard((pair, timeframe, candle_type))
|
||||
self._pop_history((pair, timeframe, candle_type))
|
||||
|
||||
async def _continuously_async_watch_ohlcv(
|
||||
self, pair: str, timeframe: str, candle_type: CandleType
|
||||
|
|
Loading…
Reference in New Issue
Block a user