channels.fundingRate
Builds a channel for live futures funding rates and funding spend rates. 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: 'binance-futures',
coin: 'BTC',
product: 'BTCUSDT',
} as const;
const single = velo.channels.fundingRate(product).on({
data: (row) => console.log(row.time, row.funding_rate),
error: ({ reason }) => console.error('Channel error:', reason),
});
const aggregated = velo.channels.fundingRate({ coin: product.coin }).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 fundingRate(
target: Product<FuturesExchange>,
options?: { readonly measure?: 'rate' | 'coins' | 'dollars'; readonly weighted?: false },
): Channel;
function fundingRate(
target: Coin,
options?:
| { readonly measure?: 'rate'; readonly weighted?: boolean }
| { readonly measure: 'coins' | 'dollars'; readonly weighted?: false },
): Channel;Parameters
target
- Type:
Target<FuturesExchange> - Required
A futures product with exchange, coin, and product, as returned by the
catalog. Pass { coin } on its own for
an aggregated channel across futures exchanges.
options
| Property | Type | Default | Description |
|---|---|---|---|
measure | 'rate' | 'coins' | 'dollars' | 'rate' | Funding rate or the rate multiplied by open interest in the selected units. |
weighted | boolean | false | Adds coin open-interest weights. Available only for a coin target with measure: 'rate'. |
Return Type
- Type:
Channel
Returns a channel typed with the selected target and options.
| Measure | Field | Description |
|---|---|---|
rate | funding_rate | Funding rate as a fraction: 0.0001 is 0.01% |
coins | coin_funding_spend_rate | Rate multiplied by coin open interest |
dollars | dollar_funding_spend_rate | Rate multiplied by dollar open interest |
{
"exchange": "binance-futures",
"coin": "BTC",
"product": "BTCUSDT",
"time": 1785160560000,
"funding_rate": 0.0001
}[
{
"exchange": "binance-futures",
"coin": "BTC",
"funding_rate": 0.0001
}
]Weighted funding rate
With weighted: true, each exchange entry also includes
coin_open_interest_close. The payload supplies the weights so you can calculate
an average: sum each funding_rate multiplied by its open interest, then divide
by the total open interest.
const weighted = velo.channels.fundingRate({ coin: product.coin }, { weighted: true }).on({
data: (entries) => {
let totalWeight = 0;
let weightedSum = 0;
for (const entry of entries) {
const value = entry.funding_rate;
const weight = entry.coin_open_interest_close;
if (value === null || weight === null) continue;
totalWeight += weight;
weightedSum += value * weight;
}
console.log(totalWeight > 0 ? weightedSum / totalWeight : null);
},
error: ({ reason }) => console.error('Weighted channel error:', reason),
});
const weightedWatcher = await velo.watch(velo.channels.feed([weighted]), {
on: { error: (error) => console.error('Connection error:', error) },
});
// Later:
weightedWatcher.close();