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"""
|
2017-11-05 23:16:24 +00:00
|
|
|
import json
|
2018-03-17 21:44:47 +00:00
|
|
|
import sys
|
2017-10-15 15:24:49 +00:00
|
|
|
|
2017-11-05 23:16:24 +00:00
|
|
|
from freqtrade import exchange
|
2018-01-13 16:39:36 +00:00
|
|
|
from freqtrade import misc
|
2018-04-06 07:57:08 +00:00
|
|
|
from freqtrade.exchange import ccxt
|
2017-10-13 13:50:50 +00:00
|
|
|
|
2018-01-13 16:39:36 +00:00
|
|
|
parser = misc.common_args_parser('download utility')
|
|
|
|
parser.add_argument(
|
2018-02-03 16:15:40 +00:00
|
|
|
'-p', '--pair',
|
|
|
|
help='JSON file containing pairs to download',
|
|
|
|
dest='pair',
|
|
|
|
default=None
|
2018-01-13 16:39:36 +00:00
|
|
|
)
|
|
|
|
args = parser.parse_args(sys.argv[1:])
|
|
|
|
|
2018-03-24 09:21:59 +00:00
|
|
|
TICKER_INTERVALS = ['1m', '5m'] # ticker interval in minutes (currently implemented: 1 and 5)
|
2018-01-13 16:39:36 +00:00
|
|
|
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
|
|
|
|
2017-11-05 23:16:24 +00:00
|
|
|
# Init Bittrex exchange
|
2018-04-06 07:57:08 +00:00
|
|
|
exchange._API = ccxt.bittrex({'key': '', 'secret': ''})
|
2017-11-05 23:16:24 +00:00
|
|
|
|
|
|
|
for pair in PAIRS:
|
2018-01-13 16:39:36 +00:00
|
|
|
for tick_interval in TICKER_INTERVALS:
|
|
|
|
print('downloading pair %s, interval %s' % (pair, tick_interval))
|
|
|
|
data = exchange.get_ticker_history(pair, tick_interval)
|
2018-02-03 16:15:40 +00:00
|
|
|
pair_print = pair.replace('/', '_')
|
|
|
|
filename = '{}-{}.json'.format(pair_print, tick_interval)
|
2018-01-13 16:39:36 +00:00
|
|
|
misc.file_dump_json(filename, data)
|