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 tosource(kind, ...). Useif (handle.kind === 'ohlcv') ...to branch on type.values(object) — Columnar arrays. Forohlcv, exposestime[],open[],high[],low[],close[],volume[]. Fororderbook, undefined (snapshot fields live ondatainstead).data(object) — Full payload as the host fetched it. Fororderbook, includesbestBid,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);
}