fetch_orderbook
is a one-shot snapshot.
fetch_orderbook
OrderbookRequest
| Field | Type | Description |
|---|---|---|
market_id | string | Native market ID |
outcome | string? | "Yes" or "No" (binary markets) |
token_id | string? | Polymarket CLOB token; takes precedence over outcome |
Orderbook { market_id, asset_id, bids, asks, last_update_id?, timestamp?, hash? }
with bids sorted high-to-low and asks low-to-high. See
Orderbook for the full shape.
Helpers on Orderbook
The Rust type exposes a few zero-copy helpers (Python/TS receive them as
plain dicts and have to compute equivalents):
| Method | Returns |
|---|---|
best_bid() | Option<f64> |
best_ask() | Option<f64> |
mid_price() | Option<f64> — exact midpoint via FixedPrice |
spread() | Option<f64> |
has_data() | bool |
sort() | sorts bids descending, asks ascending |