refactor: simplify ws exchange handling

This commit is contained in:
Matthias
2025-05-10 13:30:26 +02:00
parent 5f907d4219
commit 8dc278f1a0
2 changed files with 4 additions and 8 deletions

View File

@@ -267,11 +267,11 @@ class Exchange:
exchange_conf.get("ccxt_async_config", {}), ccxt_async_config
)
self._api_async = self._init_ccxt(exchange_conf, False, ccxt_async_config)
self._has_watch_ohlcv = self.exchange_has("watchOHLCV") and self._ft_has["ws_enabled"]
_has_watch_ohlcv = self.exchange_has("watchOHLCV") and self._ft_has["ws_enabled"]
if (
self._config["runmode"] in TRADE_MODES
and exchange_conf.get("enable_ws", True)
and self._has_watch_ohlcv
and _has_watch_ohlcv
):
self._ws_async = self._init_ccxt(exchange_conf, False, ccxt_async_config)
self._exchange_ws = ExchangeWS(self._config, self._ws_async)
@@ -2449,11 +2449,7 @@ class Exchange:
Check if we can use websocket for this pair.
Acts as typeguard for exchangeWs
"""
if (
self._has_watch_ohlcv
and exchange_ws
and candle_type in (CandleType.SPOT, CandleType.FUTURES)
):
if exchange_ws and candle_type in (CandleType.SPOT, CandleType.FUTURES):
return True
return False