Created
February 7, 2018 10:43
-
-
Save vladthelittleone/a4d77f8e037edea6398ebc1dff195cb5 to your computer and use it in GitHub Desktop.
Revisions
-
vladthelittleone created this gist
Feb 7, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ def create_dictionary(pairs): order_book = polo.returnOrderBook(depth=1) dictionary = collections.defaultdict(dict) for pair in pairs: p = pair.upper() src, dst = split(p) ask_order = order_book[p]['asks'][0] src_ask = { 'pair': src + '_' + dst, 'price': float(ask_order[0]), 'amount': float(ask_order[1]) } bid_order = order_book[p]['bids'][0] src_bid = { 'pair': dst + '_' + src, 'price': 1 / float(bid_order[0]), 'amount': float(bid_order[1]) * float(bid_order[0]) } dictionary[src][dst] = src_ask dictionary[dst][src] = src_bid return dictionary