make download_backtest_data.py platform independent

This commit is contained in:
gcarq 2017-11-06 00:16:24 +01:00
parent 810f2f9243
commit cc29126d61

View File

@ -1,18 +1,20 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""This script generate json data from bittrex""" """This script generate json data from bittrex"""
import json
from os import path
from urllib.request import urlopen from freqtrade import exchange
from freqtrade.exchange import Bittrex
CURRENCIES = ["ok", "neo", "dash", "etc", "eth", "snt"] PAIRS = ['BTC-OK', 'BTC-NEO', 'BTC-DASH', 'BTC-ETC', 'BTC-ETH', 'BTC-SNT']
OUTPUT_DIR = 'freqtrade/tests/testdata/' OUTPUT_DIR = path.dirname(path.realpath(__file__))
for cur in CURRENCIES: # Init Bittrex exchange
url1 = 'https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-' exchange._API = Bittrex({'key': '', 'secret': ''})
url = url1+cur+'&tickInterval=fiveMin'
x = urlopen(url) for pair in PAIRS:
json_data = x.read() data = exchange.get_ticker_history(pair)
json_str = str(json_data, 'utf-8') filename = path.join(OUTPUT_DIR, '{}.json'.format(pair.lower()))
output = OUTPUT_DIR + 'btc-'+cur+'.json' with open(filename, 'w') as fp:
with open(output, 'w') as file: json.dump(data, fp)
file.write(json_str)