mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
feat: Add Orderflow -> exchange support validation
This commit is contained in:
parent
8591b9f0c8
commit
72f6ee8e8b
|
@ -328,6 +328,7 @@ class Exchange:
|
|||
self.validate_trading_mode_and_margin_mode(self.trading_mode, self.margin_mode)
|
||||
self.validate_pricing(config["exit_pricing"])
|
||||
self.validate_pricing(config["entry_pricing"])
|
||||
self.validate_orderflow(config["exchange"])
|
||||
|
||||
def _init_ccxt(
|
||||
self, exchange_config: Dict[str, Any], sync: bool, ccxt_kwargs: Dict[str, Any]
|
||||
|
@ -795,6 +796,14 @@ class Exchange:
|
|||
f"Time in force policies are not supported for {self.name} yet."
|
||||
)
|
||||
|
||||
def validate_orderflow(self, exchange: Dict) -> None:
|
||||
if exchange.get("use_public_trades", False) and (
|
||||
not self.exchange_has("fetchTrades") or not self._ft_has["trades_has_history"]
|
||||
):
|
||||
raise ConfigurationError(
|
||||
f"Trade data not available for {self.name}. Can't use orderflow feature."
|
||||
)
|
||||
|
||||
def validate_required_startup_candles(self, startup_candles: int, timeframe: str) -> int:
|
||||
"""
|
||||
Checks if required startup_candles is more than ohlcv_candle_limit().
|
||||
|
|
|
@ -326,6 +326,22 @@ def test_validate_order_time_in_force(default_conf, mocker, caplog):
|
|||
ex.validate_order_time_in_force(tif2)
|
||||
|
||||
|
||||
def test_validate_orderflow(default_conf, mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
# Test bybit - as it doesn't support historic trades data.
|
||||
ex = get_patched_exchange(mocker, default_conf, exchange="bybit")
|
||||
mocker.patch(f"{EXMS}.exchange_has", return_value=True)
|
||||
ex.validate_orderflow({"use_public_trades": False})
|
||||
|
||||
with pytest.raises(ConfigurationError, match=r"Trade data not available for.*"):
|
||||
ex.validate_orderflow({"use_public_trades": True})
|
||||
|
||||
# Binance supports orderflow.
|
||||
ex = get_patched_exchange(mocker, default_conf, exchange="binance")
|
||||
ex.validate_orderflow({"use_public_trades": False})
|
||||
ex.validate_orderflow({"use_public_trades": True})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"price,precision_mode,precision,expected",
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue
Block a user