.depth
Fetches historical orderbook depth and yields one snapshot at a time. Requests wider than the endpoint's per-request limit are split automatically.
Example
end = client.timestamp()
params = {
'exchange': 'binance-futures',
'product': 'BTCUSDT',
'begin': end - 60 * 60 * 1000,
'end': end,
'resolution': '5m',
}
for snapshot in client.depth(params):
print(snapshot['timestamp'], snapshot['midprice'])params = {
'coin': 'BTC',
'begin': end - 60 * 60 * 1000,
'end': end,
'resolution': '5m',
}
for snapshot in client.depth(params):
print(snapshot)Parameters
params
- Type:
dict
See Depth parameters for the accepted fields.
Yields
dict
Each snapshot contains:
| Key | Type | Description |
|---|---|---|
timestamp | float | Snapshot timestamp in milliseconds. |
midprice | float | Mid-market price. |
| Price keys | float | Each remaining numeric key is a price whose value is the size at that price. |
A batch with no matching depth data yields an empty dictionary.