From bfe05868eb6e1bf43b144725c10d522904b3c27f Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 28 Apr 2026 20:51:47 +0200 Subject: [PATCH] feat: implement unwatchOHLCV closes #13082 Co-authored-by: Copilot --- freqtrade/exchange/exchange_ws.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/freqtrade/exchange/exchange_ws.py b/freqtrade/exchange/exchange_ws.py index 38cc0a2aa..7cffa3f57 100644 --- a/freqtrade/exchange/exchange_ws.py +++ b/freqtrade/exchange/exchange_ws.py @@ -177,9 +177,24 @@ class ExchangeWS: ) ) + def exchange_has(self, endpoint: str) -> bool: + """ + Checks if exchange implements a specific API endpoint. + Wrapper around ccxt 'has' attribute + :param endpoint: Name of endpoint (e.g. 'fetchOHLCV', 'fetchTickers') + :return: bool + """ + return endpoint in self._ccxt_object.has and self._ccxt_object.has[endpoint] + async def _unwatch_ohlcv(self, pair: str, timeframe: str, candle_type: CandleType) -> None: try: - await self._ccxt_object.un_watch_ohlcv_for_symbols([[pair, timeframe]]) + if self.exchange_has("unWatchOHLCVForSymbols"): + await self._ccxt_object.un_watch_ohlcv_for_symbols([[pair, timeframe]]) + elif self.exchange_has("unWatchOHLCV"): + await self._ccxt_object.un_watch_ohlcv(pair, timeframe) + else: + logger.debug("un_watch_ohlcv not supported for %s, %s", pair, timeframe) + except ccxt.NotSupported as e: logger.debug("un_watch_ohlcv_for_symbols not supported: %s", e) pass