Orderbook
Normalized orderbook dictionaries available to Python V2.
An orderbook record contains:
| Key | Type | Meaning |
|---|---|---|
exchange | string | Normalized exchange. |
symbol | string | Normalized symbol. |
timestamp_ms | integer | Snapshot time in Unix milliseconds. |
bids | list | Bid levels, best price first. |
asks | list | Ask levels, best price first. |
Each level contains price and quantity.
book = history.source("btc@orderbook@bulkf", 0)
if book is not None:
best_bid = book["bids"][0]["price"]
spread = ctx.study.spread(book)The number of levels is limited by the source's configured depth. See Orderbook Source.