Merge pull request #479 from gcarq/fix/issue-478
Fix Backtesting / Hyperopt ticker_interval download
This commit is contained in:
commit
0a42a0e814
@ -218,7 +218,6 @@ def backtesting_options(parser: argparse.ArgumentParser) -> None:
|
|||||||
'-i', '--ticker-interval',
|
'-i', '--ticker-interval',
|
||||||
help='specify ticker interval in minutes (1, 5, 30, 60, 1440)',
|
help='specify ticker interval in minutes (1, 5, 30, 60, 1440)',
|
||||||
dest='ticker_interval',
|
dest='ticker_interval',
|
||||||
default=5,
|
|
||||||
type=int,
|
type=int,
|
||||||
metavar='INT',
|
metavar='INT',
|
||||||
)
|
)
|
||||||
@ -269,9 +268,8 @@ def hyperopt_options(parser: argparse.ArgumentParser) -> None:
|
|||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-i', '--ticker-interval',
|
'-i', '--ticker-interval',
|
||||||
help='specify ticker interval in minutes (default: 5)',
|
help='specify ticker interval in minutes (1, 5, 30, 60, 1440)',
|
||||||
dest='ticker_interval',
|
dest='ticker_interval',
|
||||||
default=5,
|
|
||||||
type=int,
|
type=int,
|
||||||
metavar='INT',
|
metavar='INT',
|
||||||
)
|
)
|
||||||
|
@ -171,22 +171,34 @@ def start(args):
|
|||||||
|
|
||||||
logger.info('Using config: %s ...', args.config)
|
logger.info('Using config: %s ...', args.config)
|
||||||
config = misc.load_config(args.config)
|
config = misc.load_config(args.config)
|
||||||
ticker_interval = config.get('ticker_interval', args.ticker_interval)
|
|
||||||
logger.info('Using ticker_interval: %s ...', ticker_interval)
|
# If -i/--ticker-interval is use we override the configuration parameter
|
||||||
|
# (that will override the strategy configuration)
|
||||||
|
if args.ticker_interval:
|
||||||
|
config.update({'ticker_interval': args.ticker_interval})
|
||||||
|
|
||||||
|
# init the strategy to use
|
||||||
|
config.update({'strategy': args.strategy})
|
||||||
|
strategy = Strategy()
|
||||||
|
strategy.init(config)
|
||||||
|
|
||||||
|
logger.info('Using ticker_interval: %d ...', strategy.ticker_interval)
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
pairs = config['exchange']['pair_whitelist']
|
pairs = config['exchange']['pair_whitelist']
|
||||||
if args.live:
|
if args.live:
|
||||||
logger.info('Downloading data for all pairs in whitelist ...')
|
logger.info('Downloading data for all pairs in whitelist ...')
|
||||||
for pair in pairs:
|
for pair in pairs:
|
||||||
data[pair] = exchange.get_ticker_history(pair, ticker_interval)
|
data[pair] = exchange.get_ticker_history(pair, strategy.ticker_interval)
|
||||||
else:
|
else:
|
||||||
logger.info('Using local backtesting data (using whitelist in given config) ...')
|
logger.info('Using local backtesting data (using whitelist in given config) ...')
|
||||||
logger.info('Using stake_currency: %s ...', config['stake_currency'])
|
logger.info('Using stake_currency: %s ...', config['stake_currency'])
|
||||||
logger.info('Using stake_amount: %s ...', config['stake_amount'])
|
logger.info('Using stake_amount: %s ...', config['stake_amount'])
|
||||||
|
|
||||||
timerange = misc.parse_timerange(args.timerange)
|
timerange = misc.parse_timerange(args.timerange)
|
||||||
data = optimize.load_data(args.datadir, pairs=pairs, ticker_interval=args.ticker_interval,
|
data = optimize.load_data(args.datadir,
|
||||||
|
pairs=pairs,
|
||||||
|
ticker_interval=strategy.ticker_interval,
|
||||||
refresh_pairs=args.refresh_pairs,
|
refresh_pairs=args.refresh_pairs,
|
||||||
timerange=timerange)
|
timerange=timerange)
|
||||||
max_open_trades = 0
|
max_open_trades = 0
|
||||||
@ -194,11 +206,6 @@ def start(args):
|
|||||||
logger.info('Using max_open_trades: %s ...', config['max_open_trades'])
|
logger.info('Using max_open_trades: %s ...', config['max_open_trades'])
|
||||||
max_open_trades = config['max_open_trades']
|
max_open_trades = config['max_open_trades']
|
||||||
|
|
||||||
# init the strategy to use
|
|
||||||
config.update({'strategy': args.strategy})
|
|
||||||
strategy = Strategy()
|
|
||||||
strategy.init(config)
|
|
||||||
|
|
||||||
# Monkey patch config
|
# Monkey patch config
|
||||||
from freqtrade import main
|
from freqtrade import main
|
||||||
main._CONF = config
|
main._CONF = config
|
||||||
@ -224,5 +231,5 @@ def start(args):
|
|||||||
})
|
})
|
||||||
logger.info(
|
logger.info(
|
||||||
'\n==================================== BACKTESTING REPORT ====================================\n%s', # noqa
|
'\n==================================== BACKTESTING REPORT ====================================\n%s', # noqa
|
||||||
generate_text_table(data, results, config['stake_currency'], args.ticker_interval)
|
generate_text_table(data, results, config['stake_currency'], strategy.ticker_interval)
|
||||||
)
|
)
|
||||||
|
@ -461,6 +461,11 @@ def start(args):
|
|||||||
config = load_config(args.config)
|
config = load_config(args.config)
|
||||||
pairs = config['exchange']['pair_whitelist']
|
pairs = config['exchange']['pair_whitelist']
|
||||||
|
|
||||||
|
# If -i/--ticker-interval is use we override the configuration parameter
|
||||||
|
# (that will override the strategy configuration)
|
||||||
|
if args.ticker_interval:
|
||||||
|
config.update({'ticker_interval': args.ticker_interval})
|
||||||
|
|
||||||
# init the strategy to use
|
# init the strategy to use
|
||||||
config.update({'strategy': args.strategy})
|
config.update({'strategy': args.strategy})
|
||||||
strategy = Strategy()
|
strategy = Strategy()
|
||||||
@ -468,7 +473,7 @@ def start(args):
|
|||||||
|
|
||||||
timerange = misc.parse_timerange(args.timerange)
|
timerange = misc.parse_timerange(args.timerange)
|
||||||
data = optimize.load_data(args.datadir, pairs=pairs,
|
data = optimize.load_data(args.datadir, pairs=pairs,
|
||||||
ticker_interval=args.ticker_interval,
|
ticker_interval=strategy.ticker_interval,
|
||||||
timerange=timerange)
|
timerange=timerange)
|
||||||
optimize.populate_indicators = populate_indicators
|
optimize.populate_indicators = populate_indicators
|
||||||
PROCESSED = optimize.tickerdata_to_dataframe(data)
|
PROCESSED = optimize.tickerdata_to_dataframe(data)
|
||||||
|
@ -32,7 +32,7 @@ def test_parse_args_backtesting(mocker):
|
|||||||
assert call_args.loglevel == 20
|
assert call_args.loglevel == 20
|
||||||
assert call_args.subparser == 'backtesting'
|
assert call_args.subparser == 'backtesting'
|
||||||
assert call_args.func is not None
|
assert call_args.func is not None
|
||||||
assert call_args.ticker_interval == 5
|
assert call_args.ticker_interval is None
|
||||||
|
|
||||||
|
|
||||||
def test_main_start_hyperopt(mocker):
|
def test_main_start_hyperopt(mocker):
|
||||||
|
Loading…
Reference in New Issue
Block a user