From cc29126d6112ce5a59c23708aa5947177695f81b Mon Sep 17 00:00:00 2001 From: gcarq Date: Mon, 6 Nov 2017 00:16:24 +0100 Subject: [PATCH] make download_backtest_data.py platform independent --- .../tests/testdata/download_backtest_data.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/freqtrade/tests/testdata/download_backtest_data.py b/freqtrade/tests/testdata/download_backtest_data.py index d6212cfea..16f4c0802 100644 --- a/freqtrade/tests/testdata/download_backtest_data.py +++ b/freqtrade/tests/testdata/download_backtest_data.py @@ -1,18 +1,20 @@ #!/usr/bin/env python3 """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"] -OUTPUT_DIR = 'freqtrade/tests/testdata/' +PAIRS = ['BTC-OK', 'BTC-NEO', 'BTC-DASH', 'BTC-ETC', 'BTC-ETH', 'BTC-SNT'] +OUTPUT_DIR = path.dirname(path.realpath(__file__)) -for cur in CURRENCIES: - url1 = 'https://bittrex.com/Api/v2.0/pub/market/GetTicks?marketName=BTC-' - url = url1+cur+'&tickInterval=fiveMin' - x = urlopen(url) - json_data = x.read() - json_str = str(json_data, 'utf-8') - output = OUTPUT_DIR + 'btc-'+cur+'.json' - with open(output, 'w') as file: - file.write(json_str) +# Init Bittrex exchange +exchange._API = Bittrex({'key': '', 'secret': ''}) + +for pair in PAIRS: + data = exchange.get_ticker_history(pair) + filename = path.join(OUTPUT_DIR, '{}.json'.format(pair.lower())) + with open(filename, 'w') as fp: + json.dump(data, fp)