Skip to content

Commit

Permalink
Load config.json from user_data first
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Feb 14, 2020
1 parent 3312fd3 commit 9dafc2f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions freqtrade/commands/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pathlib import Path
from typing import Any, Dict, List, Optional

from freqtrade import constants
from freqtrade.commands.cli_options import AVAILABLE_CLI_OPTIONS
from freqtrade.constants import DEFAULT_CONFIG

ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir", "user_data_dir"]

Expand Down Expand Up @@ -107,10 +107,19 @@ def _parse_args(self) -> argparse.Namespace:
# 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 ('config' in parsed_arg and parsed_arg.config is None and
((Path.cwd() / constants.DEFAULT_CONFIG).is_file() or
not ('command' in parsed_arg and parsed_arg.command in NO_CONF_REQURIED))):
parsed_arg.config = [constants.DEFAULT_CONFIG]
if ('config' in parsed_arg and parsed_arg.config is None):
conf_required = ('command' in parsed_arg and parsed_arg.command in NO_CONF_REQURIED)

if 'user_data_dir' in parsed_arg and parsed_arg.user_data_dir is not None:
# Try loading from "user_data/config.json"
cfgfile = Path(parsed_arg.user_data_dir) / DEFAULT_CONFIG
if cfgfile.is_file() or not conf_required:
parsed_arg.config = [str(cfgfile)]
else:
# Else use "config.json".
cfgfile = Path.cwd() / DEFAULT_CONFIG
if cfgfile.is_file() or not conf_required:
parsed_arg.config = [DEFAULT_CONFIG]

return parsed_arg

Expand Down

0 comments on commit 9dafc2f

Please sign in to comment.