Init exchange before datadir ...

This commit is contained in:
Matthias 2019-08-29 06:42:56 +02:00
parent ba0d7aa09c
commit 68adfc6607

View File

@ -160,6 +160,11 @@ class Configuration(object):
Extract information for sys.argv and load directory configurations Extract information for sys.argv and load directory configurations
--user-data, --datadir --user-data, --datadir
""" """
# Check exchange parameter here - otherwise `datadir` might be wrong.
if "exchange" in self.args and self.args.exchange:
config['exchange']['name'] = self.args.exchange
logger.info(f"Using exchange {config['exchange']['name']}")
if 'user_data_dir' in self.args and self.args.user_data_dir: if 'user_data_dir' in self.args and self.args.user_data_dir:
config.update({'user_data_dir': self.args.user_data_dir}) config.update({'user_data_dir': self.args.user_data_dir})
elif 'user_data_dir' not in config: elif 'user_data_dir' not in config:
@ -297,10 +302,6 @@ class Configuration(object):
self._args_to_config(config, argname='days', self._args_to_config(config, argname='days',
logstring='Detected --days: {}') logstring='Detected --days: {}')
if "exchange" in self.args and self.args.exchange:
config['exchange']['name'] = self.args.exchange
logger.info(f"Using exchange {config['exchange']['name']}")
def _process_runmode(self, config: Dict[str, Any]) -> None: def _process_runmode(self, config: Dict[str, Any]) -> None:
if not self.runmode: if not self.runmode:
@ -361,7 +362,7 @@ class Configuration(object):
config['pairs'] = config.get('exchange', {}).get('pair_whitelist') config['pairs'] = config.get('exchange', {}).get('pair_whitelist')
else: else:
# Fall back to /dl_path/pairs.json # Fall back to /dl_path/pairs.json
pairs_file = Path(config['datadir']) / config['exchange']['name'].lower() / "pairs.json" pairs_file = Path(config['datadir']) / "pairs.json"
if pairs_file.exists(): if pairs_file.exists():
with pairs_file.open('r') as f: with pairs_file.open('r') as f:
config['pairs'] = json_load(f) config['pairs'] = json_load(f)