From 3517c86fa28786630bcb49c3c58bcddd41f0cf74 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 16 Jun 2020 16:02:38 +0200 Subject: [PATCH] Fail if both ticker_interval and timeframe are present in a configuration Otherwise the wrong might be used, as it's unclear which one the intend of the user is --- .../configuration/deprecated_settings.py | 5 +++++ tests/test_configuration.py | 20 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/freqtrade/configuration/deprecated_settings.py b/freqtrade/configuration/deprecated_settings.py index cefc6ac14..03ed41ab8 100644 --- a/freqtrade/configuration/deprecated_settings.py +++ b/freqtrade/configuration/deprecated_settings.py @@ -72,4 +72,9 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None: "DEPRECATED: " "Please use 'timeframe' instead of 'ticker_interval." ) + if 'timeframe' in config: + raise OperationalException( + "Both 'timeframe' and 'ticker_interval' detected." + "Please remove 'ticker_interval' from your configuration to continue operating." + ) config['timeframe'] = config['ticker_interval'] diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 689e62ab9..cccc87670 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -1144,11 +1144,21 @@ def test_process_deprecated_setting(mocker, default_conf, caplog): def test_process_deprecated_ticker_interval(mocker, default_conf, caplog): message = "DEPRECATED: Please use 'timeframe' instead of 'ticker_interval." - process_temporary_deprecated_settings(default_conf) + config = deepcopy(default_conf) + process_temporary_deprecated_settings(config) assert not log_has(message, caplog) - del default_conf['timeframe'] - default_conf['ticker_interval'] = '15m' - process_temporary_deprecated_settings(default_conf) + del config['timeframe'] + config['ticker_interval'] = '15m' + process_temporary_deprecated_settings(config) assert log_has(message, caplog) - assert default_conf['ticker_interval'] == '15m' + assert config['ticker_interval'] == '15m' + + config = deepcopy(default_conf) + # Have both timeframe and ticker interval in config + # Can also happen when using ticker_interval in configuration, and --timeframe as cli argument + config['timeframe'] = '5m' + config['ticker_interval'] = '4h' + with pytest.raises(OperationalException, + match=r"Both 'timeframe' and 'ticker_interval' detected."): + process_temporary_deprecated_settings(config)