From 3188d036a6832964c9a8d63ee3b0030ced9fe592 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 7 Apr 2022 08:45:45 +0000 Subject: [PATCH] improve trading_mode handling Ensure trading_mode is set by new-config handle empty strings to default to spot. closes #6663 --- freqtrade/commands/build_config_commands.py | 2 ++ freqtrade/configuration/configuration.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/freqtrade/commands/build_config_commands.py b/freqtrade/commands/build_config_commands.py index b401f52c7..be881c8ed 100644 --- a/freqtrade/commands/build_config_commands.py +++ b/freqtrade/commands/build_config_commands.py @@ -202,6 +202,8 @@ def ask_user_config() -> Dict[str, Any]: if not answers: # Interrupted questionary sessions return an empty dict. raise OperationalException("User interrupted interactive questions.") + # Ensure default is set for non-futures exchanges + answers['trading_mode'] = answers.get('trading_mode', "spot") answers['margin_mode'] = ( 'isolated' if answers.get('trading_mode') == 'futures' diff --git a/freqtrade/configuration/configuration.py b/freqtrade/configuration/configuration.py index aa8f51a1d..db0cbd5a7 100644 --- a/freqtrade/configuration/configuration.py +++ b/freqtrade/configuration/configuration.py @@ -433,8 +433,9 @@ class Configuration: logstring='Detected --new-pairs-days: {}') self._args_to_config(config, argname='trading_mode', logstring='Detected --trading-mode: {}') - config['candle_type_def'] = CandleType.get_default(config.get('trading_mode', 'spot')) - config['trading_mode'] = TradingMode(config.get('trading_mode', 'spot')) + config['candle_type_def'] = CandleType.get_default( + config.get('trading_mode', 'spot') or 'spot') + config['trading_mode'] = TradingMode(config.get('trading_mode', 'spot') or 'spot') self._args_to_config(config, argname='candle_types', logstring='Detected --candle-types: {}')