Created
February 7, 2018 10:43
-
-
Save vladthelittleone/a4d77f8e037edea6398ebc1dff195cb5 to your computer and use it in GitHub Desktop.
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 characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment