Skip to main content

tracer.data.long_short#

Long-short positioning ratio from /api/v1/perp/long-short.

SYNTAX#

tracer.data.long_short: SourceHandle  // Long-short positioning ratios

ARGUMENTS#

  • opts.symbol (string) — Trading pair (default: chart symbol).
  • opts.exchange (string) — Exchange (default: chart exchange).
  • opts.interval (string) — Bucket interval.

RETURNS#

GenericSeriesSourceData with positioning + top-trader 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.long_short_ratio[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: "L/S Ratio", pane: "sub" }
const ls = tracer.data.long_short;
function onBar(i, ctx) {
  // generic series: match by timestamp, not bar index (see REMARKS)
  const t = candles[i].time;
  const j = ls.values.time.lastIndexOf(t); // exact ts; else scan for nearest ts <= t
  plot("ratio", j >= 0 ? ls.values.long_short_ratio[j] : null);
}