> ## Documentation Index
> Fetch the complete documentation index at: https://docs.0xarchive.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Funding and open interest

> Funding annualised from the hourly rate, and open interest in USD, from 5-minute samples.

<Frame caption="BTC on 1-hour bars in the 0xArchive Terminal, 2026-10-15.">
  <img src="https://mintcdn.com/0xarchive-e895b8e7/_p6Z1TtSEb5DBnPX/images/terminal/examples/funding-oi.webp?fit=max&auto=format&n=_p6Z1TtSEb5DBnPX&q=85&s=7c49f499fc46e7153f33c32b862afafd" alt="Funding and open interest on a BTC chart" width="1038" height="664" data-path="images/terminal/examples/funding-oi.webp" />
</Frame>

<Card title="Open on a chart" icon="chart-candlestick" href="https://terminal.0xarchive.io/?symbol=BTC&interval=1h&scripts=example%3Afunding-oi" horizontal>
  Load it on BTC 1h in the terminal, then change its settings or open it in the script editor.
</Card>

Funding as a yearly rate, as bars, and open interest in USD, as a line in a pane of its own: the two share no scale.

## How it works

`derivatives()` is a sample stream: read in a handler, it gives the last 5-minute sample before the bar closed. `funding` is the rate for one hour, as a fraction, so the yearly percent is that times 24 × 365 × 100. For per-bar open interest with high and low, see [`openInterest()`](/terminal/reference/streams#openinterest).

## The script

```ts funding-oi.ts theme={"theme":"github-dark"}
// Funding, annualised from the hourly rate, and open interest in USD, as of each bar: the last 5-minute sample before it closed.
indicator('Funding and open interest');

const chart = bars();
const perp = derivatives();

const funding = plot.histogram('Funding % a year', { precision: 2 });
// A pane of its own: funding (a few percent) and open interest (billions) share no scale.
const oi = plot.line('Open interest $', { pane: 'oi' });

chart.onBar(() => {
  if (!perp.available) return;
  funding.set(perp.funding * 24 * 365 * 100, perp.funding >= 0 ? color.up : color.down);
  oi.set(perp.openInterestUsd);
});
```

## Next step

See the next example, [Breadth above VWAP](/terminal/examples/breadth-above-vwap).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.