Skip to content
Velo

channels.premium

Builds a channel for live futures premium and open price. 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.premium(product).on({
  data: (row) => console.log(row.time, row.premium),
  error: ({ reason }) => console.error('Channel error:', reason),
});
 
const aggregated = velo.channels.premium({ 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 premium(
  target: Product<FuturesExchange>,
  options?: { readonly weighted?: false },
): Channel;
 
function premium(
  target: Coin,
  options?: { readonly weighted?: boolean },
): 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

PropertyTypeDefaultDescription
weightedbooleanfalseAdds coin open-interest weights. Available only for a coin target.

Return Type

  • Type: Channel

Returns a channel typed with the selected target and options.

FieldDescription
premiumMark price minus index price, in quote currency, averaged over the minute so far
open_priceThe minute's opening trade price
{
  "exchange": "binance-futures",
  "coin": "BTC",
  "product": "BTCUSDT",
  "time": 1785160560000,
  "premium": 12.5,
  "open_price": 65000
}

Weighted premium

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 premium multiplied by its open interest, then divide by the total open interest.

const weighted = velo.channels.premium({ coin: product.coin }, { weighted: true }).on({
  data: (entries) => {
    let totalWeight = 0;
    let weightedSum = 0;
    for (const entry of entries) {
      const value = entry.premium;
      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();