This commit is contained in:
creslin 2018-06-04 08:24:26 +00:00 committed by GitHub
commit bbd20fa809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 8 deletions

View File

@ -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(

View File

@ -4,6 +4,7 @@ This module contains the configuration class
import json
import logging
from os import path, makedirs
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 = 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 = path.join('freqtrade', 'tests', 'testdata', 'catchall')
if not path.exists(config['datadir']):
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:

View File

@ -266,14 +266,14 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
arglist = [
'--config', 'config.json',
'--strategy', 'DefaultStrategy',
'--datadir', '/foo/bar',
'--datadir', 'freqtrade/tests/testdata/',
'backtesting',
'--ticker-interval', '1m',
'--live',
'--realistic-simulation',
'--refresh-pairs-cached',
'--timerange', ':100',
'--export', '/bar/foo'
'--export', 'user_data/data'
]
args = Arguments(arglist, '').get_parsed_arg()

View File

@ -8,18 +8,26 @@ import arrow
from freqtrade import (exchange, arguments, misc)
DEFAULT_DL_PATH = 'freqtrade/tests/testdata'
arguments = arguments.Arguments(sys.argv[1:], 'download utility')
arguments.testdata_dl_options()
args = arguments.parse_args()
# Added exchange as a subdirectory to download into
# as Freqtrad now supports multiple exchanges.
DEFAULT_DL_PATH = 'freqtrade/tests/testdata/' + args.exchange
DEFAULT_PAIR_FILE = DEFAULT_DL_PATH + "/" + "pairs.json"
TICKER_INTERVALS = ['1m', '5m']
PAIRS = []
# Added a check for a default pairs file in per exchange specific dir
if args.pairs_file:
with open(args.pairs_file) as file:
PAIRS = json.load(file)
elif os.path.isfile(DEFAULT_PAIR_FILE) is True:
with open(DEFAULT_PAIR_FILE) as file:
PAIRS = json.load(file)
PAIRS = list(set(PAIRS))
dl_path = DEFAULT_DL_PATH