Skip to main content

types.SourceHandle#

Handle returned from source(kind, opts?).

SYNTAX#

interface SourceHandle<K> { readonly kind: K; readonly values: <columnar arrays for K>; readonly data: <full payload for K>; }

ARGUMENTS#

  • kind (SourceKind) — The discriminator — same string passed to source(kind, ...). Use if (handle.kind === 'ohlcv') ... to branch on type.
  • values (object) — Columnar arrays. For ohlcv, exposes time[], open[], high[], low[], close[], volume[]. For orderbook, undefined (snapshot fields live on data instead).
  • data (object) — Full payload as the host fetched it. For orderbook, includes bestBid, bestAsk, midPrice, spread, spreadBps, imbalance.

RETURNS#

Type definition.

EXAMPLE#

const dailyOhlcv = source('ohlcv', { interval: '1D', limit: 200 });
function onBar(i, ctx) {
  const dClose = dailyOhlcv.values.close[i];
  if (dClose !== undefined) plot('daily-close', dClose);
}

SEE ALSO#

data.source