From 1b66f01ec0af11fa3914f89ca750834c55ae6757 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 3 Sep 2019 06:48:51 +0200 Subject: [PATCH] Always use config.json if it's available --- freqtrade/configuration/arguments.py | 7 +++++-- freqtrade/tests/test_configuration.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index addbfcf67..10350d886 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -3,6 +3,7 @@ This module contains the argument manager class """ import argparse from typing import List, Optional +from pathlib import Path from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS from freqtrade import constants @@ -73,11 +74,13 @@ class Arguments(object): """ parsed_arg = self.parser.parse_args(self.args) + # When no config is provided, but a config exists, use that configuration! + # Workaround issue in argparse with action='append' and default value # (see https://bugs.python.org/issue16399) # Allow no-config for certain commands (like downloading / plotting) - if (parsed_arg.config is None - and not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED)): + if (parsed_arg.config is None and ((Path.cwd() / constants.DEFAULT_CONFIG).is_file() or + not ('subparser' in parsed_arg and parsed_arg.subparser in NO_CONF_REQURIED))): parsed_arg.config = [constants.DEFAULT_CONFIG] return parsed_arg diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 177d365d6..7b489eba7 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -871,6 +871,8 @@ def test_pairlist_resolving_fallback(mocker): ] args = Arguments(arglist).get_parsed_arg() + # Fix flaky tests if config.json exists + args.config = None configuration = Configuration(args) config = configuration.get_config()