- class bourse.core.OrderBook
Rust orderbook interface
Python interface to a Rust implementation of an orderbook. Allow orders to be placed and modified. The orderbook also stores data on all orders created on the market, allowing the state of orders to be queried from Python.
Examples
import bourse book = bourse.core.OrderBook(0, True) # Place a new order order_id = book.place_order( True, 100, 0, price=50 ) # Get touch prices bid, ask = book.bid_ask() # Get the status of the order status = book.order_status(order_id)
OrderBook Methods¶
- OrderBook(**kwargs)
Create and return a new object. See help(type) for accurate signature.
- best_ask_vol() int
Get the current ask side touch volume
- best_ask_vol_and_orders()
Get the current ask side touch volume and order count
- best_bid_vol() int
Get the current bid side touch volume
- best_bid_vol_and_orders()
Get the current bid side touch volume and order count
- cancel_order(order_id: int)
Cancel order
- disable_trading()
Disable trading
- enable_trading()
Enable trading
- get_orders() list[tuple]
Get order data
- get_trades() list[tuple]
Get trade data
-
modify_order(order_id: int, new_price: int =
None
, ...) Modify an order
- order_status(order_id: int) int
Get the status of an order
-
save_json_snapshot(path: str, pretty: bool =
False
) Save a snapshot of the order book state to JSON