diff --git a/freqtrade/commands/build_config_commands.py b/freqtrade/commands/build_config_commands.py index 97f3838e2..499597f32 100644 --- a/freqtrade/commands/build_config_commands.py +++ b/freqtrade/commands/build_config_commands.py @@ -127,7 +127,7 @@ def ask_user_config() -> Dict[str, Any]: "name": "trading_mode", "message": "Do you want to trade Perpetual Swaps (perpetual futures)?", "default": False, - "filter": lambda val: '"futures"' if val else '"spot"', + "filter": lambda val: 'futures' if val else 'spot', "when": lambda x: x["exchange_name"] in ['binance', 'gateio'], }, { @@ -202,16 +202,15 @@ def ask_user_config() -> Dict[str, Any]: }, ] answers = prompt(questions) - answers["margin_mode"] = ( - '\n "margin_mode": "isolated",' - if answers["trading_mode"] == '"futures"' - else '' - ) if not answers: # Interrupted questionary sessions return an empty dict. raise OperationalException("User interrupted interactive questions.") - + answers["margin_mode"] = ( + '\n "margin_mode": "isolated",' + if answers.get("trading_mode") == 'futures' + else '' + ) # Force JWT token to be a random string answers['api_server_jwt_key'] = secrets.token_hex() diff --git a/freqtrade/templates/base_config.json.j2 b/freqtrade/templates/base_config.json.j2 index 922213ee7..6e72442c8 100644 --- a/freqtrade/templates/base_config.json.j2 +++ b/freqtrade/templates/base_config.json.j2 @@ -13,7 +13,7 @@ "fiat_display_currency": "{{ fiat_display_currency }}",{{ ('\n "timeframe": "' + timeframe + '",') if timeframe else '' }} "dry_run": {{ dry_run | lower }}, "cancel_open_orders_on_exit": false, - "trading_mode": {{ trading_mode }},{{ margin_mode }} + "trading_mode": "{{ trading_mode }}",{{ margin_mode }} "unfilledtimeout": { "buy": 10, "sell": 10,