orderbook.levels
Describes an orderbook depth request. Takes the whole scope in one object: a target, a time window, and a resolution. Pass the result to velo.query() or velo.stream().
Imports
import { Velo } from 'velo-sdk';Examples
import { Velo, orderbook } from 'velo-sdk';
const velo = new Velo({ apiKey: process.env.VELO_API_KEY! });
const data = await velo.query(
orderbook.levels({
exchange: 'binance-futures',
product: 'BTCUSDT',
last: '1h',
resolution: '1m',
}),
);
const latest = data.snapshotAt(-1);const data = await velo.query(
orderbook.levels({
coin: 'BTC',
last: '1h',
resolution: '1m',
}),
);const request = orderbook.levels({
exchange: 'binance-futures',
product: 'BTCUSDT',
last: '1h',
resolution: '1m',
});
for await (const row of velo.stream(request)) {
console.log(row.time, row.mid);
}Definition
function levels(scope: OrderbookScope): OrderbookLevelsBuilder;Parameters
scope.exchange and scope.product
- Type:
FuturesExchangeandstring - Use both together to target one exchange product
scope.coin
- Type:
string - Use alone for the Velo-aggregated book
Provide either coin or both exchange and product.
scope.between / scope.last
- Type:
readonly [number | Date, number | Date](between) orLastDuration(last)
Provide exactly one of the two.
betweenis a[begin, end)pair ofDateobjects or millisecond timestampslastis a trailing duration, anchored when the request is executed
scope.resolution
- Type:
OrderbookResolution
Only minute-based resolutions are supported.
Return Type
- Type:
OrderbookLevelsBuilder
Returns a request. Executing it resolves to OrderbookData, which exposes rows(), snapshots(), and snapshotAt().
Requests wider than the per-request bucket cap are split into several HTTP requests automatically.