# Orderbook (/scripting-v2/data-types/orderbook)



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`.

```python
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](/scripting-v2/sources/orderbook).
