Store and read exchange data in test/testdata/<exchange> sub directory.
To help manage a multi-exchange bot
This commit is contained in:
@@ -4,7 +4,6 @@ This module contains the argument manager class
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import arrow
|
||||
from typing import List, Tuple, Optional
|
||||
@@ -70,12 +69,16 @@ class Arguments(object):
|
||||
type=str,
|
||||
metavar='PATH',
|
||||
)
|
||||
# default to none, if none passed we build a default
|
||||
# which includes exchange as a subdir in config
|
||||
# has to be this way around as config.json is not read yet to capture
|
||||
# exchange value
|
||||
self.parser.add_argument(
|
||||
'-d', '--datadir',
|
||||
help='path to backtest data (default: %(default)s',
|
||||
help='path to backtest data (help_hints',
|
||||
dest='datadir',
|
||||
default=os.path.join('freqtrade', 'tests', 'testdata'),
|
||||
type=str,
|
||||
default=None,
|
||||
metavar='PATH',
|
||||
)
|
||||
self.parser.add_argument(
|
||||
|
@@ -4,6 +4,7 @@ This module contains the configuration class
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from argparse import Namespace
|
||||
from typing import Optional, Dict, Any
|
||||
from jsonschema import Draft4Validator, validate
|
||||
@@ -143,9 +144,24 @@ class Configuration(object):
|
||||
logger.info('Parameter --timerange detected: %s ...', self.args.timerange)
|
||||
|
||||
# If --datadir is used we add it to the configuration
|
||||
# If not passed as an arg, we build testdata path including 'exchange' as a sub dir
|
||||
if 'datadir' in self.args and self.args.datadir:
|
||||
config.update({'datadir': self.args.datadir})
|
||||
logger.info('Using data folder: %s ...', self.args.datadir)
|
||||
else:
|
||||
exchange = config.get('exchange', {}).get('name').lower()
|
||||
if exchange:
|
||||
default = os.path.join('freqtrade', 'tests', 'testdata', exchange)
|
||||
config.update({'datadir': default})
|
||||
# What if user has no exchange as arg or in file - set catchall
|
||||
else:
|
||||
logger.info("No exchange set")
|
||||
default = os.path.join('freqtrade', 'tests', 'testdata', 'catchall')
|
||||
|
||||
if not os.path.exists(config['datadir']):
|
||||
os.makedirs(config['datadir'])
|
||||
logger.info("Made directory: %s", config['datadir'])
|
||||
|
||||
logger.info('Using data folder: %s ...', config['datadir'])
|
||||
|
||||
# If -r/--refresh-pairs-cached is used we add it to the configuration
|
||||
if 'refresh_pairs' in self.args and self.args.refresh_pairs:
|
||||
|
Reference in New Issue
Block a user