Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import time
- import datetime
- import urllib2
- def fetch():
- start_tid = 130500
- stop_tid = -1
- start_date = '2009-01-01'
- stop_date = '2011-06-09'
- start_ts = int(time.mktime(time.strptime(start_date, '%Y-%m-%d')))
- stop_ts = int(time.mktime(time.strptime(stop_date, '%Y-%m-%d')))
- r = { 'tid':start_tid, 'date':0 }
- arr = []
- while r['date'] < stop_ts:
- url = 'https://mtgox.com/code/data/getTrades.php?since=' + str(r['tid'])
- socket = urllib2.urlopen(url)
- js = json.load(socket)
- socket.close()
- for r in js:
- arr.append(r)
- arr.sort(key=lambda x:-float(x['price']))
- r = js[-1]
- for r in arr[0:100]:
- print r['tid'], datetime.datetime.fromtimestamp(r['date']), r['amount'], r['item'], '@', r['price'], r['price_currency']
- def main():
- fetch()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement