Skip to content
Velo

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()

Definition

depth(params): AsyncIterable<Object>

Parameters

params

  • Type: Object
PropertyTypeDescription
exchangestringExchange for a specific product. Use with product.
productstringExchange-native product. Use with exchange.
coinstringVelo-aggregated coin. Use instead of exchange and product.
beginnumberBeginning of the time range as a Unix timestamp in milliseconds.
endnumberEnd of the time range as a Unix timestamp in milliseconds.
resolution`numberstring`

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:

PropertyTypeDescription
timenumberSnapshot timestamp in milliseconds.
midnumberMid-market price.
Price keysnumberEach 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.