Skip to content

Instantly share code, notes, and snippets.

@solalatus
Created March 9, 2019 15:23
Show Gist options
  • Save solalatus/9baa2238d656bc0b232245256a2781c3 to your computer and use it in GitHub Desktop.
Save solalatus/9baa2238d656bc0b232245256a2781c3 to your computer and use it in GitHub Desktop.
from orderbook import OrderBook
contract_ids = [111,2222,3333,4444]#df...contractId.unique()
orderbooks={}
for contract_id in contract_ids:
orderbooks[contract_id]=OrderBook()
print(orderbooks)
data = {'type' : 'limit',
'side' : 'ask',
'quantity' : 5,
'price' : 101,
'trade_id' : 1113333, #Have no clue why, but this is mandatory. Absurd.
#I typically duplicate order_id. Dunno why.
'order_id' : 1113334444,
'timestamp': 1544662383280000000}
orderbooks[contract_ids[0]].process_order(data,True,False)
#I was lame enough to use the first contractId availabel from the list, but you get my point...
print(orderbooks[contract_ids[0]])
print("Same as:",orderbooks[111])
print(orderbooks[contract_ids[0]].get_best_ask())
orderbooks[contract_ids[0]].cancel_order("ask",1113334444)
print(orderbooks[contract_ids[0]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment