Skip to content

Commit

Permalink
specify symbol from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Aug 21, 2015
1 parent 6870756 commit d82b25e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions collect-data/collect_books.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 5 additions & 4 deletions collect-data/collect_trades.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit d82b25e

Please sign in to comment.