# Open Interest (/scripting/data-types/oi)



```ts
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.
* standalone exchange snapshots can include `mark_price` and `notional`.

```js
export function onData(ctx, input, history) {
  const current = history.source('btc@oi@binancef@mmt', 0)
  const previous = history.source('btc@oi@binancef@mmt', 1)
  if (!current || !previous) return

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