Market LabDocs
ScriptingData Types

Open Interest

Normalized open interest records for Market Lab scripts.

Open Interest

type OpenInterest = {
  t: number
  value: number
  o: number
  h: number
  l: number
  c: number
  n: number
  mark_price?: number
  notional?: number
}
  • t is Unix milliseconds.
  • value is the current normalized OI value and equals c for candle records.
  • o, h, l, and c contain period OHLC when the provider supplies it.
  • n is the sample count.
  • BULK snapshots can include mark_price and notional.
export function onData(ctx, input, history) {
  const current = history.source('oi@binancef@mmt', 0)
  const previous = history.source('oi@binancef@mmt', 1)
  if (!current || !previous) return

  return {
    metrics: {
      oi: current.value,
      change: current.value - previous.value,
    },
  }
}

On this page