diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 1d3bd86d6..076357577 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -875,10 +875,11 @@ class Exchange: """Validate demo trading configuration Prevents accidental configuration with wrong expectations. """ - if exchange_conf.get("demo_trading", False) and not self.get_option( - "supports_demo_trading" - ): - raise ConfigurationError(f"Demo trading is not supported for {self.name}.") + if exchange_conf.get("demo_trading", False): + if not self.get_option("supports_demo_trading"): + raise ConfigurationError(f"Demo trading is not supported for {self.name}.") + else: + logger.info(f"Demo trading enabled for {self.name}") def validate_required_startup_candles(self, startup_candles: int, timeframe: str) -> int: """ diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index cfc6f7de7..a9200f926 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -349,7 +349,6 @@ def test_validate_freqai_compat(default_conf, mocker, caplog): def test_validate_demo_trading(default_conf_usdt, mocker, caplog): - caplog.set_level(logging.INFO) # Test - nothing enabled so nothing happens ex = get_patched_exchange(mocker, default_conf_usdt, exchange="kraken") ex.validate_demo_trading(default_conf_usdt["exchange"]) @@ -358,8 +357,11 @@ def test_validate_demo_trading(default_conf_usdt, mocker, caplog): with pytest.raises(ConfigurationError, match=r"Demo trading is not supported for .*"): ex.validate_demo_trading(default_conf_usdt["exchange"]) + msg = r"Demo trading enabled for .*" + assert not log_has_re(msg, caplog) ex_bybit = get_patched_exchange(mocker, default_conf_usdt, exchange="bybit") ex_bybit.validate_demo_trading(default_conf_usdt["exchange"]) + assert log_has_re(msg, caplog) @pytest.mark.parametrize(