Skip to content

Commit 8dc278f

Browse files
committed
refactor: simplify ws exchange handling
1 parent 5f907d4 commit 8dc278f

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

freqtrade/exchange/exchange.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ def __init__(
267267
exchange_conf.get("ccxt_async_config", {}), ccxt_async_config
268268
)
269269
self._api_async = self._init_ccxt(exchange_conf, False, ccxt_async_config)
270-
self._has_watch_ohlcv = self.exchange_has("watchOHLCV") and self._ft_has["ws_enabled"]
270+
_has_watch_ohlcv = self.exchange_has("watchOHLCV") and self._ft_has["ws_enabled"]
271271
if (
272272
self._config["runmode"] in TRADE_MODES
273273
and exchange_conf.get("enable_ws", True)
274-
and self._has_watch_ohlcv
274+
and _has_watch_ohlcv
275275
):
276276
self._ws_async = self._init_ccxt(exchange_conf, False, ccxt_async_config)
277277
self._exchange_ws = ExchangeWS(self._config, self._ws_async)
@@ -2449,11 +2449,7 @@ def _can_use_websocket(
24492449
Check if we can use websocket for this pair.
24502450
Acts as typeguard for exchangeWs
24512451
"""
2452-
if (
2453-
self._has_watch_ohlcv
2454-
and exchange_ws
2455-
and candle_type in (CandleType.SPOT, CandleType.FUTURES)
2456-
):
2452+
if exchange_ws and candle_type in (CandleType.SPOT, CandleType.FUTURES):
24572453
return True
24582454
return False
24592455

tests/exchange_online/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def exchange_ws(request, exchange_conf, exchange_mode, class_mocker):
599599
else:
600600
pytest.skip("Exchange does not support futures.")
601601

602-
if not exchange._has_watch_ohlcv:
602+
if not exchange._exchange_ws:
603603
pytest.skip("Exchange does not support watch_ohlcv.")
604604
yield exchange, name, pair
605605
exchange.close()

0 commit comments

Comments
 (0)