Skip to main content

tracer.data.basis#

Perp basis (perp - spot) from /api/v1/perp/basis/current (default) or /perp/basis/history (when opts.mode='history').

SYNTAX#

tracer.data.basis: SourceHandle  // Perp basis (current or history mode)

ARGUMENTS#

  • opts.symbol (string) — Trading pair.
  • opts.exchange (string) — Exchange.
  • opts.mode ('current' | 'history') — Default 'current' (live snapshot). 'history' returns the archived series.

RETURNS#

GenericSeriesSourceData with basis columns.

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.basis_pct[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: "Basis %", pane: "sub" }
const b = tracer.data.basis;
// Or: source("basis", { mode: "history" })
function onBar(i, ctx) {
  // generic series: match by timestamp, not bar index (see REMARKS)
  const t = candles[i].time;
  const j = b.values.time.lastIndexOf(t); // exact ts; else scan for nearest ts <= t
  plot("basis_pct", j >= 0 ? b.values.basis_pct[j] : null);
}