client.depth_metrics() when you need derived liquidity metrics for market impact estimation and liquidity analysis. This method calculates depth, spread, imbalance, and slippage metrics from order book data.
Method signature
Parameters
| Parameter | Type | Required | Notes |
|---|---|---|---|
| source | str | Yes | Source ID |
| market | str | Yes | Normalized market or instrument ID |
| from_ | str/datetime/date/int | Yes | Inclusive start time (ISO 8601, datetime, date, or epoch microseconds) |
| to | str/datetime/date/int | Yes | Exclusive end time (same formats as from_) |
| depth_pct | float | No | Depth percentage for bid/ask imbalance (default: 0.01 = 1%) |
| slippage_notional | float | No | Notional amount for slippage calculation (default: 10000.0) |
| limit | int | No | Page size (default: 1000) |
POLARIS_API_KEY environment variable or pass api_key to PolarisClient().
Return value
List of derived depth and liquidity metric rows.Example response
Fields
Depth metrics records include:timestamp: observation time in UTC microseconds since the Unix epochvenue: exchange identifiersymbol: normalized instrument symbolspread: absolute bid-ask spreadspread_bps: spread in basis pointsbid_depth: total bid volume withindepth_pctof midask_depth: total ask volume withindepth_pctof midbid_ask_imbalance: (bid_depth - ask_depth) / (bid_depth + ask_depth)slippage_bps: estimated slippage in basis points forslippage_notionalsize
bid_ask_imbalance indicates more depth on bids (buy pressure), negative indicates more depth on asks (sell pressure).
Example
How it works
client.depth_metrics() derives liquidity metrics from order book snapshots using snapshot-first replay. The SDK queries the /snapshots endpoint for historical data, reads from local cached files when available, and calculates depth, spread, imbalance, and slippage metrics from the order book data.
For more details on snapshot-based queries, see Snapshots.
Related documentation
- L2 snapshots for raw order book data
- BBO if you only need top-of-book quotes
- Events if you need order book updates mixed with other event types
- Authentication