mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-16 04:41:15 +00:00
refactor: simplify ws exchange handling
This commit is contained in:
@@ -267,11 +267,11 @@ class Exchange:
|
|||||||
exchange_conf.get("ccxt_async_config", {}), ccxt_async_config
|
exchange_conf.get("ccxt_async_config", {}), ccxt_async_config
|
||||||
)
|
)
|
||||||
self._api_async = self._init_ccxt(exchange_conf, False, 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 (
|
if (
|
||||||
self._config["runmode"] in TRADE_MODES
|
self._config["runmode"] in TRADE_MODES
|
||||||
and exchange_conf.get("enable_ws", True)
|
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._ws_async = self._init_ccxt(exchange_conf, False, ccxt_async_config)
|
||||||
self._exchange_ws = ExchangeWS(self._config, self._ws_async)
|
self._exchange_ws = ExchangeWS(self._config, self._ws_async)
|
||||||
@@ -2449,11 +2449,7 @@ class Exchange:
|
|||||||
Check if we can use websocket for this pair.
|
Check if we can use websocket for this pair.
|
||||||
Acts as typeguard for exchangeWs
|
Acts as typeguard for exchangeWs
|
||||||
"""
|
"""
|
||||||
if (
|
if exchange_ws and candle_type in (CandleType.SPOT, CandleType.FUTURES):
|
||||||
self._has_watch_ohlcv
|
|
||||||
and exchange_ws
|
|
||||||
and candle_type in (CandleType.SPOT, CandleType.FUTURES)
|
|
||||||
):
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ def exchange_ws(request, exchange_conf, exchange_mode, class_mocker):
|
|||||||
else:
|
else:
|
||||||
pytest.skip("Exchange does not support futures.")
|
pytest.skip("Exchange does not support futures.")
|
||||||
|
|
||||||
if not exchange._has_watch_ohlcv:
|
if not exchange._exchange_ws:
|
||||||
pytest.skip("Exchange does not support watch_ohlcv.")
|
pytest.skip("Exchange does not support watch_ohlcv.")
|
||||||
yield exchange, name, pair
|
yield exchange, name, pair
|
||||||
exchange.close()
|
exchange.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user