stable/freqtrade/tests/testdata/download_backtest_data.py

36 lines
977 B
Python
Raw Normal View History

2017-10-14 12:40:26 +00:00
#!/usr/bin/env python3
2017-10-13 13:50:50 +00:00
2017-10-15 15:24:49 +00:00
"""This script generate json data from bittrex"""
import json
2018-03-17 21:44:47 +00:00
import sys
2017-10-15 15:24:49 +00:00
from freqtrade import (exchange, arguments, misc)
from freqtrade.exchange import ccxt
2017-10-13 13:50:50 +00:00
2018-04-19 06:06:56 +00:00
BASE_PATH = 'freqtrade/tests/testdata'
2018-04-19 06:01:34 +00:00
arguments = arguments.Arguments(sys.argv[1:], 'download utility')
arguments.scripts_options()
args = arguments.parse_args()
TICKER_INTERVALS = ['1m', '5m']
PAIRS = []
if args.pair:
with open(args.pair) as file:
PAIRS = json.load(file)
PAIRS = list(set(PAIRS))
print('About to download pairs:', PAIRS)
2017-10-13 13:50:50 +00:00
# Init Bittrex exchange
exchange._API = ccxt.bittrex({'key': '', 'secret': ''})
for pair in PAIRS:
for tick_interval in TICKER_INTERVALS:
print('downloading pair %s, interval %s' % (pair, tick_interval))
data = exchange.get_ticker_history(pair, tick_interval)
pair_print = pair.replace('/', '_')
filename = '{}-{}.json'.format(pair_print, tick_interval)
misc.file_dump_json(filename, data)