Add user_data_dir to configuration
This commit is contained in:
@@ -9,7 +9,7 @@ import arrow
|
||||
from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
|
||||
from freqtrade import constants
|
||||
|
||||
ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir"]
|
||||
ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir", "user_data_dir"]
|
||||
|
||||
ARGS_STRATEGY = ["strategy", "strategy_path"]
|
||||
|
||||
|
@@ -176,9 +176,13 @@ class Configuration(object):
|
||||
"""
|
||||
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:
|
||||
# Default to cwd/user_data (legacy option ...)
|
||||
config.update({'user_data_dir': str(Path.cwd() / "user_data")})
|
||||
# reset to user_data_dir so this contains the absolute path.
|
||||
config['user_data_dir'] = create_userdata_dir(config['user_data_dir'])
|
||||
|
||||
logger.info('Using user-data directory: %s ...', config['user_data_dir'])
|
||||
|
||||
if 'datadir' in self.args and self.args.datadir:
|
||||
config.update({'datadir': create_datadir(config, self.args.datadir)})
|
||||
|
@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> str:
|
||||
|
||||
folder = Path(datadir) if datadir else Path('user_data/data')
|
||||
folder = Path(datadir) if datadir else Path(f"{config['user_data_dir']}/data")
|
||||
if not datadir:
|
||||
# set datadir
|
||||
exchange_name = config.get('exchange', {}).get('name').lower()
|
||||
@@ -20,7 +20,7 @@ def create_datadir(config: Dict[str, Any], datadir: Optional[str] = None) -> str
|
||||
return str(folder)
|
||||
|
||||
|
||||
def create_userdata_dir(directory: str):
|
||||
def create_userdata_dir(directory: str) -> str:
|
||||
sub_dirs = ["backtest_results", "data", "hyperopts", "plots", "strategies", ]
|
||||
folder = Path(directory)
|
||||
if not folder.is_dir():
|
||||
@@ -32,3 +32,5 @@ def create_userdata_dir(directory: str):
|
||||
subfolder = folder / f
|
||||
if not subfolder.is_dir():
|
||||
subfolder.mkdir(parents=False)
|
||||
# TODO: convert this to return Path
|
||||
return str(folder.resolve())
|
||||
|
Reference in New Issue
Block a user