Add create-userdir command to initialize a user directory
This commit is contained in:
@@ -31,6 +31,8 @@ ARGS_EDGE = ARGS_COMMON_OPTIMIZE + ["stoploss_range"]
|
||||
|
||||
ARGS_LIST_EXCHANGES = ["print_one_column"]
|
||||
|
||||
ARGS_CREATE_USERDIR = ["user_data_dir"]
|
||||
|
||||
ARGS_DOWNLOADER = ARGS_COMMON + ["pairs", "pairs_file", "days", "exchange", "timeframes", "erase"]
|
||||
|
||||
ARGS_PLOT_DATAFRAME = (ARGS_COMMON + ARGS_STRATEGY +
|
||||
@@ -106,8 +108,7 @@ class Arguments(object):
|
||||
:return: None
|
||||
"""
|
||||
from freqtrade.optimize import start_backtesting, start_hyperopt, start_edge
|
||||
from freqtrade.utils import start_list_exchanges
|
||||
|
||||
from freqtrade.utils import start_create_userdir, start_list_exchanges
|
||||
subparsers = self.parser.add_subparsers(dest='subparser')
|
||||
|
||||
# Add backtesting subcommand
|
||||
@@ -125,6 +126,11 @@ class Arguments(object):
|
||||
hyperopt_cmd.set_defaults(func=start_hyperopt)
|
||||
self._build_args(optionlist=ARGS_HYPEROPT, parser=hyperopt_cmd)
|
||||
|
||||
create_userdir_cmd = subparsers.add_parser('create-userdir',
|
||||
help="Create user-data directory.")
|
||||
create_userdir_cmd.set_defaults(func=start_create_userdir)
|
||||
self._build_args(optionlist=ARGS_CREATE_USERDIR, parser=create_userdir_cmd)
|
||||
|
||||
# Add list-exchanges subcommand
|
||||
list_exchanges_cmd = subparsers.add_parser(
|
||||
'list-exchanges',
|
||||
|
@@ -58,6 +58,11 @@ AVAILABLE_CLI_OPTIONS = {
|
||||
help='Path to backtest data.',
|
||||
metavar='PATH',
|
||||
),
|
||||
"user_data_dir": Arg(
|
||||
'--userdir', '--user-data-dir',
|
||||
help='Path to Userdata Directory.',
|
||||
metavar='PATH',
|
||||
),
|
||||
# Main options
|
||||
"strategy": Arg(
|
||||
'-s', '--strategy',
|
||||
|
@@ -6,11 +6,12 @@ import logging
|
||||
import sys
|
||||
import warnings
|
||||
from argparse import Namespace
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
|
||||
from freqtrade import OperationalException, constants
|
||||
from freqtrade.configuration.check_exchange import check_exchange
|
||||
from freqtrade.configuration.folder_operations import create_datadir
|
||||
from freqtrade.configuration.folder_operations import create_datadir, create_userdata_dir
|
||||
from freqtrade.configuration.json_schema import validate_config_schema
|
||||
from freqtrade.loggers import setup_logging
|
||||
from freqtrade.misc import deep_merge_dicts
|
||||
@@ -173,6 +174,12 @@ class Configuration(object):
|
||||
Extract information for sys.argv and load datadir configuration:
|
||||
the --datadir option
|
||||
"""
|
||||
if 'user_data_dir' in self.args and self.args.user_data_dir:
|
||||
config.update({'user_data_dir': self.args.user_data_dir})
|
||||
create_userdata_dir(config['user_data_dir'])
|
||||
elif 'user_data_dir' not in config:
|
||||
config.update({'user_data_dir': str(Path.cwd() / "user_data")})
|
||||
|
||||
if 'datadir' in self.args and self.args.datadir:
|
||||
config.update({'datadir': create_datadir(config, self.args.datadir)})
|
||||
else:
|
||||
|
Reference in New Issue
Block a user