Store and read exchange data in test/testdata/<exchange> sub directory.

To help manage a multi-exchange bot
This commit is contained in:
creslin 2018-06-03 20:54:05 +03:00 committed by creslinux
parent fff7ec1dab
commit 343ca8fe19
3 changed files with 33 additions and 6 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
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:

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