channels.spotVolume
Builds a channel for live spot buy and sell volume. Accepts a product on one exchange or a coin across exchanges.
Pass it to velo.channels.feed() with a data listener to receive updates.
Imports
import { Velo } from 'velo-sdk';Example
const velo = new Velo({ apiKey: process.env.VELO_API_KEY! });
const product = {
exchange: 'coinbase',
coin: 'BTC',
product: 'BTC-USD',
} as const;
const single = velo.channels.spotVolume(product, { metric: 'dollars' }).on({
data: (row) => console.log(row.time, row.buy_dollar_volume),
error: ({ reason }) => console.error('Channel error:', reason),
});
const aggregated = velo.channels.spotVolume({ coin: product.coin }, { metric: 'dollars' }).on({
data: (entries) => console.table(entries),
error: ({ reason }) => console.error('Aggregated channel error:', reason),
});
const watcher = await velo.watch(velo.channels.feed([single, aggregated]), {
on: { error: (error) => console.error('Connection error:', error) },
});
// Later:
watcher.close();Definition
Simplified signature. The SDK infers the returned channel's data type from the target and options.
function spotVolume(
target: Target<SpotExchange>,
options?: { readonly metric?: 'coins' | 'dollars' },
): Channel;Parameters
target
- Type:
Target<SpotExchange> - Required
A spot product with exchange, coin, and product, as returned by the
catalog. Pass { coin } on its own for
an aggregated channel across spot exchanges.
options
| Property | Type | Default | Description |
|---|---|---|---|
metric | 'coins' | 'dollars' | 'dollars' | Units for the returned values. |
Channel metrics use the plural coins and dollars; historical selectors use coin and dollar.
Return Type
- Type:
Channel
Returns a channel typed with the selected target and options.
| Metric | Fields |
|---|---|
coins | buy_coin_volume, sell_coin_volume |
dollars | buy_dollar_volume, sell_dollar_volume |
{
"exchange": "coinbase",
"coin": "BTC",
"product": "BTC-USD",
"time": 1785160560000,
"buy_dollar_volume": 420000,
"sell_dollar_volume": 310000
}[
{
"exchange": "coinbase",
"coin": "BTC",
"buy_dollar_volume": 420000,
"sell_dollar_volume": 310000
}
]