tracer.data.trades#
Per-bar aggregated trade tape from /api/v1/perp/trades (or /spot/trades via opts.market='spot').
SYNTAX#
tracer.data.trades: SourceHandle // Per-bar aggregated tick tapeARGUMENTS#
opts.symbol(string) — Trading pair (default: chart symbol).opts.exchange(string) — Exchange (default: chart exchange).opts.market('perp' | 'spot') — Default 'perp'.
RETURNS#
GenericSeriesSourceData — { kind: 'trades', shape: 'series', values: { time, count, buy_volume, sell_volume, vwap } }REMARKS#
Generic series — rows arrive at the source's native cadence and are NOT 1:1 with chart candles. To align, match values.time[i] (unix SECONDS) against candles[j].time; do not assume row i corresponds to bar i (values.buy_volume[i] is generally NOT bar i's value). (Per-candle kinds like oi/funding are the exception — those are forward-filled to your candles.)
EXAMPLE#
// @indicator { name: "Buy/Sell Imbalance", pane: "sub" }
const tr = tracer.data.trades;
function onBar(i, ctx) {
// generic series: match by timestamp, not bar index (see REMARKS)
const t = candles[i].time;
const j = tr.values.time.lastIndexOf(t); // exact ts; else scan for nearest ts <= t
const imbal = j >= 0 ? tr.values.buy_volume[j] - tr.values.sell_volume[j] : null;
plot("imbal", imbal);
}