fix handling --exchange

This commit is contained in:
hroff-1902 2019-06-11 10:09:30 +03:00
parent 1add432673
commit dc0326db27
2 changed files with 12 additions and 13 deletions

View File

@ -443,7 +443,7 @@ class Arguments(object):
help='Log to the file specified', help='Log to the file specified',
dest='logfile', dest='logfile',
type=str, type=str,
metavar='FILE' metavar='FILE',
) )
self.parser.add_argument( self.parser.add_argument(
'-c', '--config', '-c', '--config',
@ -458,15 +458,12 @@ class Arguments(object):
'-d', '--datadir', '-d', '--datadir',
help='Path to backtest data.', help='Path to backtest data.',
dest='datadir', dest='datadir',
default=None,
type=str,
metavar='PATH', metavar='PATH',
) )
self.parser.add_argument( self.parser.add_argument(
'--pairs-file', '--pairs-file',
help='File containing a list of pairs to download.', help='File containing a list of pairs to download.',
dest='pairs_file', dest='pairs_file',
default=None,
metavar='FILE', metavar='FILE',
) )
self.parser.add_argument( self.parser.add_argument(
@ -475,14 +472,11 @@ class Arguments(object):
dest='days', dest='days',
type=int, type=int,
metavar='INT', metavar='INT',
default=None
) )
self.parser.add_argument( self.parser.add_argument(
'--exchange', '--exchange',
help='Exchange name (default: %(default)s). Only valid if no config is provided.', help='Exchange name (default: %(default)s). Only valid if no config is provided.',
dest='exchange', dest='exchange',
type=str,
default='bittrex'
) )
self.parser.add_argument( self.parser.add_argument(
'-t', '--timeframes', '-t', '--timeframes',

View File

@ -27,6 +27,9 @@ arguments.download_data_options()
# in the command line options explicitely # in the command line options explicitely
args = arguments.parse_args(no_default_config=True) args = arguments.parse_args(no_default_config=True)
# Use bittrex as default exchange
exchange_name = args.exchange or 'bittrex'
timeframes = args.timeframes timeframes = args.timeframes
pairs: List = [] pairs: List = []
@ -46,20 +49,15 @@ if args.config:
config['exchange']['key'] = '' config['exchange']['key'] = ''
config['exchange']['secret'] = '' config['exchange']['secret'] = ''
if args.exchange:
config['exchange']['name'] = args.exchange
pairs = config['exchange']['pair_whitelist'] pairs = config['exchange']['pair_whitelist']
timeframes = [config['ticker_interval']] timeframes = [config['ticker_interval']]
else: else:
if not args.exchange:
sys.exit("No exchange specified.")
config = { config = {
'stake_currency': '', 'stake_currency': '',
'dry_run': True, 'dry_run': True,
'exchange': { 'exchange': {
'name': args.exchange, 'name': exchange_name,
'key': '', 'key': '',
'secret': '', 'secret': '',
'pair_whitelist': [], 'pair_whitelist': [],
@ -71,6 +69,13 @@ else:
} }
configuration._load_logging_config(config) configuration._load_logging_config(config)
if args.config and args.exchange:
logger.warning("The --exchange option is ignored, using exchange settings from the configuration file.")
# Check if the exchange set by the user is supported
configuration.check_exchange(config)
configuration._load_datadir_config(config) configuration._load_datadir_config(config)
dl_path = Path(config['datadir']) dl_path = Path(config['datadir'])