An order book is a list of buy and sell orders for a specific security or financial instrument, organized by price level [12] [13]. It is a key data structure in the matching engine for fast order matching. An efficient data structure for an order book must satisfy these requirements:
Constant lookup time. Operation includes: getting volume at a price level or between price levels.
Fast add/cancel/execute operations, preferably O(1) time complexity. Operations include: placing a new order, canceling an order, and matching an order.
Fast update. Operation: replacing an order.
Query best bid/ask.
Iterate through price levels.
GET /marketdata/orderBook/L2?symbol={:symbol}&depth={:depth}
This endpoint queries L2 order book information for a symbol with designated depth.
Parameters
symbol: the stock symbol. String
depth: order book depth per side. Int
Response
Body:
bids: array with price and size. Array
asks: array with price and size. Array
Code:
200: successful
40x: parameter error/not found/access denied/unauthorized
500: server error