fix: Runtime error on ohlcv deepcopy

closes #11335
This commit is contained in:
Matthias
2025-02-05 18:07:03 +01:00
parent 85753be7cb
commit dbb9f225d0
+7
View File
@@ -9,6 +9,8 @@ import ccxt
from freqtrade.constants import Config, PairWithTimeframe from freqtrade.constants import Config, PairWithTimeframe
from freqtrade.enums.candletype import CandleType from freqtrade.enums.candletype import CandleType
from freqtrade.exceptions import TemporaryError
from freqtrade.exchange.common import retrier
from freqtrade.exchange.exchange import timeframe_to_seconds from freqtrade.exchange.exchange import timeframe_to_seconds
from freqtrade.exchange.exchange_types import OHLCVResponse from freqtrade.exchange.exchange_types import OHLCVResponse
from freqtrade.util import dt_ts, format_ms_time, format_ms_time_det from freqtrade.util import dt_ts, format_ms_time, format_ms_time_det
@@ -83,13 +85,18 @@ class ExchangeWS:
""" """
self._ccxt_object.ohlcvs.get(paircomb[0], {}).pop(paircomb[1], None) self._ccxt_object.ohlcvs.get(paircomb[0], {}).pop(paircomb[1], None)
@retrier(retries=3)
def ohlcvs(self, pair: str, timeframe: str) -> list[list]: def ohlcvs(self, pair: str, timeframe: str) -> list[list]:
""" """
Returns a copy of the klines for a pair/timeframe combination Returns a copy of the klines for a pair/timeframe combination
Note: this will only contain the data received from the websocket Note: this will only contain the data received from the websocket
so the data will build up over time. so the data will build up over time.
""" """
try:
return deepcopy(self._ccxt_object.ohlcvs.get(pair, {}).get(timeframe, [])) return deepcopy(self._ccxt_object.ohlcvs.get(pair, {}).get(timeframe, []))
except RuntimeError as e:
# Capture runtime errors and retry
raise TemporaryError(f"Error deepcopying: {e}") from e
def cleanup_expired(self) -> None: def cleanup_expired(self) -> None:
""" """