Skip to content

Commit

Permalink
Always use config.json if it's available
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Sep 4, 2019
1 parent f9c7a2c commit 1b66f01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions freqtrade/configuration/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import argparse
from typing import List, Optional
from pathlib import Path

from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade import constants
Expand Down Expand Up @@ -73,11 +74,13 @@ def _parse_args(self) -> argparse.Namespace:
"""
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
Expand Down
2 changes: 2 additions & 0 deletions freqtrade/tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1b66f01

Please sign in to comment.