feat: show message when enabling demo trading mode

This commit is contained in:
Matthias
2026-04-07 07:00:59 +02:00
parent e7f9059ff4
commit 1ac68d6161
2 changed files with 8 additions and 5 deletions
+5 -4
View File
@@ -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:
"""
+3 -1
View File
@@ -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(