Created
December 2, 2013 16:39
-
-
Save eordano/7752352 to your computer and use it in GitHub Desktop.
Gekko candle data for backtesting - source from bitstamp, bitcoinwisdom. Parameter "frame" is in minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import json | |
import requests | |
import random | |
parser = argparse.ArgumentParser() | |
parser.add_argument("frame", type=int) | |
args = parser.parse_args() | |
frame = 60 * args.frame | |
target_filename = 'candles.csv' | |
data = requests.get('http://s2.bitcoinwisdom.com:8080/period?step=%d&sid=621009ec&symbol=bitstampbtcusd&nonce=%s' % (frame, random.randint(0, 2**32))) | |
s = json.loads(data.content) | |
with open(target_filename, 'w') as target: | |
target.write('ts,sarasa,sarasa,asd,asdf,asdf,asdf,as\n') | |
for i in s: | |
target.write(','.join(map(str, [i[0]] + i[3:]))+'\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment