client.depth
Fetches historical futures orderbook depth and asynchronously yields one snapshot at a time. Query either one exchange product or a Velo-aggregated coin.
Imports
const velo = require('velo-node')Examples
const velo = require('velo-node')
async function main() {
const client = new velo.Client('api_key')
const end = Date.now()
const snapshots = client.depth({
exchange: 'binance-futures',
product: 'BTCUSDT',
begin: end - 60 * 60 * 1000,
end,
resolution: '5m'
})
for await (const snapshot of snapshots) {
console.log(snapshot.time, snapshot.mid)
}
}
main()const velo = require('velo-node')
async function main() {
const client = new velo.Client('api_key')
const end = Date.now()
const snapshots = client.depth({
coin: 'BTC',
begin: end - 60 * 60 * 1000,
end,
resolution: '5m'
})
for await (const snapshot of snapshots) {
console.log(snapshot)
}
}
main()Definition
depth(params): AsyncIterable<Object>Parameters
params
- Type:
Object
| Property | Type | Description |
|---|---|---|
exchange | string | Exchange for a specific product. Use with product. |
product | string | Exchange-native product. Use with exchange. |
coin | string | Velo-aggregated coin. Use instead of exchange and product. |
begin | number | Beginning of the time range as a Unix timestamp in milliseconds. |
end | number | End of the time range as a Unix timestamp in milliseconds. |
resolution | `number | string` |
Provide exactly one target: either coin, or both exchange and product. Use coin only for aggregated orderbook data.
After string resolution conversion, the minute value must be 1, 5, 10, 15, 30, 60, or a multiple of 60.
Return Type
- Type:
AsyncIterable<Object>
Returns an async iterable immediately. Each yielded snapshot contains:
| Property | Type | Description |
|---|---|---|
time | number | Snapshot timestamp in milliseconds. |
mid | number | Mid-market price. |
| Price keys | number | Each remaining key is a price whose value is the size at that price. |
Requests spanning more than 512 buckets are divided into consecutive requests automatically.
For a complete workflow, see Fetch Orderbook Data.
Errors
Throws an Error before iteration for an invalid time range, unsupported resolution, or invalid target combination. Request errors surface while the async iterable is being consumed.