From d82b25e2a0c6d9000a53f303819412a62b842532 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 21 Aug 2015 00:49:52 +0000 Subject: [PATCH] specify symbol from command line --- collect-data/collect_books.py | 9 +++++---- collect-data/collect_trades.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/collect-data/collect_books.py b/collect-data/collect_books.py index 03baa55..a4196cc 100644 --- a/collect-data/collect_books.py +++ b/collect-data/collect_books.py @@ -2,15 +2,16 @@ import time import json from pymongo import MongoClient +import sys api = 'https://api.bitfinex.com/v1' -symbol = 'ltcusd' +symbol = sys.argv[1] limit = 25 -book_url = '{0}/book/{1}?limit_bids={2}&limit_asks={2}'.format(api, - symbol, limit) +book_url = '{0}/book/{1}usd?limit_bids={2}&limit_asks={2}'.format(api, symbol, + limit) client = MongoClient() db = client['bitmicro'] -ltc_books = db['ltc_books'] +ltc_books = db[symbol+'_books'] def format_book_entry(entry): diff --git a/collect-data/collect_trades.py b/collect-data/collect_trades.py index 795104f..268aae5 100644 --- a/collect-data/collect_trades.py +++ b/collect-data/collect_trades.py @@ -2,14 +2,15 @@ import time import json from pymongo import MongoClient +import sys api = 'https://api.bitfinex.com/v1' -symbol = 'ltcusd' +symbol = sys.argv[1] limit = 1000 client = MongoClient() db = client['bitmicro'] -ltc_trades = db['ltc_trades'] +ltc_trades = db[symbol+'_trades'] def format_trade(trade): @@ -29,8 +30,8 @@ def get_json(url): last = 0 while True: - url = '{0}/trades/{1}?timestamp={2}&limit_trades={3}'.format(api, symbol, - last, limit) + url = '{0}/trades/{1}usd?timestamp={2}&limit_trades={3}'.format(api, symbol, + last, limit) trades, code = get_json(url) if code != 200: