> ## 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.

# Streams

> Bars, trades, liquidations, the order book, open interest, funding, breadth and liquidation levels.

The data a script reads. Declared at the top level only. Inside a handler of stream S, S's fields describe the bar or event being run. Every other stream reads "as of" that moment: its last confirmed value at or before the current bar's time. That is the no-lookahead rule, for every kind of data.

## bars()

The chart's bars by default, or another market or interval.

```ts theme={"theme":"github-dark"}
function bars(options?: BarsOptions): Bars;
```

## MarketInfo

<ResponseField name="symbol" type="string" />

<ResponseField name="venue" type="Venue" />

<ResponseField name="tickSize" type="number">
  The smallest price step at the current price. Hyperliquid's step changes with price.
</ResponseField>

<ResponseField name="sizeDecimals" type="number" />

## IntervalInfo

<ResponseField name="code" type="IntervalCode" />

<ResponseField name="ms" type="number">
  Length in milliseconds for time bars (for months, the average month); `na` for bars that close on trades.
</ResponseField>

<ResponseField name="isTime" type="boolean" />

## BarView

One bar. Values the source does not provide are `na`.

<ResponseField name="time" type="Time" />

<ResponseField name="closeTime" type="Time">
  When the bar ends (exclusive). For time bars, `time + interval.ms`; for months, the next month's open.
</ResponseField>

<ResponseField name="open" type="number" />

<ResponseField name="high" type="number" />

<ResponseField name="low" type="number" />

<ResponseField name="close" type="number" />

<ResponseField name="volume" type="number">
  Base volume.
</ResponseField>

<ResponseField name="quoteVolume" type="number">
  Quote (USD) volume.
</ResponseField>

<ResponseField name="tradeCount" type="number" />

<ResponseField name="buyVolume" type="number">
  Taker buy and sell base volume, when the host has them.
</ResponseField>

<ResponseField name="sellVolume" type="number" />

<ResponseField name="source()" type="(name: SourceName): number">
  A bar value by name, such as `source('hl2')`.
</ResponseField>

## BarsOptions

<ResponseField name="market?" type="string">
  A market other than the chart's, such as `ETH`.
</ResponseField>

<ResponseField name="venue?" type="Venue" />

<ResponseField name="interval?" type="IntervalCode">
  An interval other than the chart's, such as `4h`.
</ResponseField>

## Bars

<ResponseField name="market" type="MarketInfo" />

<ResponseField name="interval" type="IntervalInfo" />

<ResponseField name="index" type="number">
  Bar number on this stream, from 0 at the first loaded bar.
</ResponseField>

<ResponseField name="confirmed" type="boolean">
  True when this run is for a closed bar; false for an update of the forming bar.
</ResponseField>

<ResponseField name="isNew" type="boolean">
  True on the first run of a bar.
</ResponseField>

<ResponseField name="isLast" type="boolean">
  True on the newest bar the chart has.
</ResponseField>

<ResponseField name="lastIndex" type="number">
  The index of this stream's newest bar, known on every bar of history (Pine's
  `last_bar_index`). It grows as new bars arrive; bars already run keep the value they saw.
</ResponseField>

<ResponseField name="lastTime" type="Time">
  The open time of this stream's newest bar, known on every bar (Pine's `last_bar_time`).
</ResponseField>

<ResponseField name="isRealtime" type="boolean">
  True once the run has reached live data.
</ResponseField>

<ResponseField name="ago()" type="(n: number): BarView">
  The bar `n` bars ago on this stream; `ago(0)` is the current one. Fields are `na` before the first bar.
</ResponseField>

<ResponseField name="forming" type="BarView">
  The developing bar of this stream, read from another stream's handler. It changes until the
  bar closes (it repaints), which is why it has to be asked for by name.
</ResponseField>

<ResponseField name="onBar()" type="(handler: () => void): void">
  Runs for every bar of history, once, and again on every update of the forming bar.
</ResponseField>

<ResponseField name="onClose()" type="(handler: () => void): void">
  Runs once when a bar closes, after its last `onBar`.
</ResponseField>

## trades()

```ts theme={"theme":"github-dark"}
function trades(options?: TradesOptions): Trades;
```

## Trade

One trade (a taker fill), with the identities 0xArchive records.

<ResponseField name="time" type="Time" />

<ResponseField name="price" type="number" />

<ResponseField name="size" type="number" />

<ResponseField name="notional" type="number">
  price × size, in USD.
</ResponseField>

<ResponseField name="side" type="'buy' | 'sell'">
  The taker's side.
</ResponseField>

<ResponseField name="tradeId" type="string | null" />

<ResponseField name="takerOrderId" type="string | null">
  The taker's order id: fills with the same id are one order.
</ResponseField>

<ResponseField name="taker" type="string | null">
  Wallet addresses, lower-case hex, when the source carries them.
</ResponseField>

<ResponseField name="maker" type="string | null" />

<ResponseField name="liquidation" type="boolean">
  True when the taker was being liquidated.
</ResponseField>

<ResponseField name="sameOrder" type="boolean">
  True when the same taker order filled the trade before this one on the stream (time order,
  execution order within a millisecond), filters such as `minSize` aside. False where the
  source does not say. Join fills into orders with it when `takerOrderId` is null.
</ResponseField>

<ResponseField name="oiDelta" type="number">
  The trade's change in the venue's open interest, in the market's base unit, from both sides'
  positions before it: positive where it opened positions, negative where it closed them, 0 where
  one side opened and the other closed. Hyperliquid and HIP-3 count both sides of open interest,
  Lighter longs only, as each venue's own open interest does. `na` where the venue does not know.
</ResponseField>

## TradesOptions

<ResponseField name="market?" type="string" />

<ResponseField name="venue?" type="Venue" />

<ResponseField name="minSize?" type="number">
  Skip trades smaller than this, in base units or in USD.
</ResponseField>

<ResponseField name="minNotional?" type="number" />

## Trades

<ResponseField name="onTrade()" type="(handler: (trade: Trade) => void): void">
  Runs once per trade, in execution order, before the `onBar` of the bar it falls in.
</ResponseField>

<ResponseField name="available" type="boolean">
  Whether trades cover the current bar completely. Trade history is limited, so older bars have none.
</ResponseField>

## liquidations()

```ts theme={"theme":"github-dark"}
function liquidations(options?: { market?: string; venue?: Venue; minNotional?: number }): Liquidations;
```

## Liquidation

<ResponseField name="time" type="Time" />

<ResponseField name="price" type="number" />

<ResponseField name="size" type="number" />

<ResponseField name="notional" type="number" />

<ResponseField name="side" type="'long' | 'short'">
  The side of the position that was liquidated.
</ResponseField>

<ResponseField name="user" type="string | null" />

## Liquidations

<ResponseField name="onLiquidation()" type="(handler: (liquidation: Liquidation) => void): void" />

<ResponseField name="available" type="boolean" />

## derivatives()

```ts theme={"theme":"github-dark"}
function derivatives(options?: { market?: string; venue?: Venue }): Derivatives;
```

## Derivatives

Perp state as of the current bar: the last sample at or before it. `na` when unknown.

<ResponseField name="time" type="Time">
  When the sample read was taken; `na` when there is none.
</ResponseField>

<ResponseField name="openInterest" type="number" />

<ResponseField name="openInterestUsd" type="number" />

<ResponseField name="funding" type="number">
  The funding rate for one hour, as a fraction (0.0001 is 0.01%).
</ResponseField>

<ResponseField name="markPrice" type="number" />

<ResponseField name="oraclePrice" type="number" />

<ResponseField name="premium" type="number" />

<ResponseField name="available" type="boolean" />

## breadth()

```ts theme={"theme":"github-dark"}
function breadth(options?: { venue?: 'hl' | 'hip3' }): Breadth;
```

## Breadth

The share of a venue's markets trading above their session VWAP, as of the current bar.

<ResponseField name="value" type="number">
  Percent, 0 to 100.
</ResponseField>

<ResponseField name="eligible" type="number" />

<ResponseField name="coverage" type="number">
  How complete the sample is: the percent of the venue's markets that had data for it, 0 to 100.
</ResponseField>

<ResponseField name="time" type="Time">
  When the sample read was calculated; `na` when there is none.
</ResponseField>

<ResponseField name="available" type="boolean" />

## depth()

```ts theme={"theme":"github-dark"}
function depth(options: { bandsPct: readonly number[]; market?: string; venue?: Venue }): Depth;
```

## Depth

Resting size in the book near the price, as of the current update.

<ResponseField name="bid()" type="(bandPct: number): number">
  Total resting bid and ask size within `bandPct` percent of the mid. `bandPct` must be one of the declared bands.
</ResponseField>

<ResponseField name="ask()" type="(bandPct: number): number" />

<ResponseField name="bestBid" type="number" />

<ResponseField name="bestAsk" type="number" />

<ResponseField name="mid" type="number" />

<ResponseField name="spread" type="number" />

<ResponseField name="time" type="Time">
  When the sample read was taken; `na` when there is none.
</ResponseField>

<ResponseField name="available" type="boolean">
  Book views have no history until the terminal serves one; before that only live bars have them.
</ResponseField>

## orderBook()

```ts theme={"theme":"github-dark"}
function orderBook(options?: { market?: string; venue?: Venue }): OrderBook;
```

## BookBand

A band around the mid, in basis points: 10 is 0.1%, 1000 is 10%.

```ts theme={"theme":"github-dark"}
type BookBand = 10 | 25 | 50 | 100 | 250 | 500 | 1000;
```

## BookStat

`avg`, the default: the time-weighted mean over the bar. `close`: the book at the bar's end.

```ts theme={"theme":"github-dark"}
type BookStat = 'avg' | 'close';
```

## OrderBook

The full-depth order book over each of the chart's bars (Hyperliquid and HIP-3, from 2026-03-10):
from 0xArchive's book archive, and for the newest hour from the page's live book. A bar the book
was not known for reads `na`, never 0. Live, the page holds up to 400 levels a side, so a band
that reaches past them reads `na` until the archive has the hour.

<ResponseField name="mid()" type="(options?: { stat?: BookStat }): number">
  Mid price.
</ResponseField>

<ResponseField name="spreadBps()" type="(options?: { stat?: BookStat }): number">
  Best ask less best bid over the mid, in basis points.
</ResponseField>

<ResponseField name="bestBidSize()" type="(options?: { stat?: BookStat }): number">
  Size resting at the best bid and the best ask (the best queues), in contracts.
</ResponseField>

<ResponseField name="bestAskSize()" type="(options?: { stat?: BookStat }): number" />

<ResponseField name="bid()" type="(band: BookBand, options?: { usd?: boolean; stat?: BookStat }): number">
  Resting size within `band` of the mid on one side: in contracts, or in USD with `usd: true`.
</ResponseField>

<ResponseField name="ask()" type="(band: BookBand, options?: { usd?: boolean; stat?: BookStat }): number" />

<ResponseField name="imbalance()" type="(band: BookBand, options?: { stat?: BookStat }): number">
  Bids less asks over their sum, in USD within `band`: -1 (all asks) to 1 (all bids).
</ResponseField>

<ResponseField name="slippageBuy()" type="(usd: 10000 | 100000 | 1000000): number">
  What a market order of `usd` pays against the mid at the bar's end, in basis points; `na` when the book cannot fill it.
</ResponseField>

<ResponseField name="slippageSell()" type="(usd: 10000 | 100000 | 1000000): number" />

<ResponseField name="bidLevels" type="number">
  Price levels on each side at the bar's end; `na` live.
</ResponseField>

<ResponseField name="askLevels" type="number" />

<ResponseField name="coverage" type="number">
  The share of the bar the book was known, 0 to 1.
</ResponseField>

<ResponseField name="live" type="boolean">
  True when any of the bar came from the live book rather than the archive.
</ResponseField>

<ResponseField name="time" type="Time">
  The bar's open time; `na` when there is no reading.
</ResponseField>

<ResponseField name="available" type="boolean" />

## openInterest()

```ts theme={"theme":"github-dark"}
function openInterest(options?: { market?: string; venue?: Venue }): OpenInterest;
```

## OpenInterest

Open interest over each of the chart's bars, from 0xArchive's one-minute open interest
(Hyperliquid from 2025-03-01, HIP-3 and Lighter from their own starts). A bar opens at the close
of the minute before it, so `close - open` is its whole change; its high and low are over its
minutes. In the market's base unit, or USD with `{ usd: true }` (each minute's open interest times
its mark).

The newest bars are built from the trades instead: each trade's change in open interest
(`Trade.oiDelta`), summed and anchored to the one-minute open interest, so the forming bar moves
with every trade and each bar closes where its last trade left it. On time bars of a minute or
more that is every bar since the hour before the chart opened; on seconds bars and bars that close
on trades (tick, volume, range and the rest) it is every bar, as far back as the trades reach
(`trades()`: today and the two UTC days before). USD there is each level times the price of the
trade that set it.

<ResponseField name="open()" type="(options?: { usd?: boolean }): number" />

<ResponseField name="high()" type="(options?: { usd?: boolean }): number" />

<ResponseField name="low()" type="(options?: { usd?: boolean }): number" />

<ResponseField name="close()" type="(options?: { usd?: boolean }): number" />

<ResponseField name="change()" type="(options?: { usd?: boolean }): number">
  The bar's change, close less open. In USD it is the change in coins at the bar's closing mark,
  so it counts positions opened and closed, not the price moving the ones already open.
</ResponseField>

<ResponseField name="time" type="Time">
  The bar's open time; `na` when there is no reading.
</ResponseField>

<ResponseField name="available" type="boolean" />

## funding()

```ts theme={"theme":"github-dark"}
function funding(options?: { market?: string; venue?: Venue }): Funding;
```

## Funding

The funding rate over each of the chart's bars, from 0xArchive's one-minute funding readings
(Hyperliquid from 2025-03-01, HIP-3 and Lighter from their own starts). A bar's rate is the
venue's rate at its last minute: on Hyperliquid the predicted rate for the hour then running,
which is what settles at the hour's end, so a 1h bar holds the rate its hour paid. Positive:
longs pay shorts. The forming bar moves as each minute closes, about 1 to 4 minutes behind. Only
time charts of whole minutes, 1m or longer, have it: on seconds, tick, volume and range bars
every value is `na`.

<ResponseField name="rate()" type="(options?: { hours?: number }): number">
  The rate as a fraction per hour, as the venues pay it, or per `hours` hours (8 for an eight-hour rate, 8760 for a year's).
</ResponseField>

<ResponseField name="premium" type="number">
  The premium at the bar's last minute, the mark's distance from the oracle the rate is built from; `na` on Lighter.
</ResponseField>

<ResponseField name="time" type="Time">
  The bar's open time; `na` when there is no reading.
</ResponseField>

<ResponseField name="available" type="boolean" />

## liquidationLevels()

Where open positions would be liquidated, from 0xArchive's liquidation levels.

```ts theme={"theme":"github-dark"}
function liquidationLevels(options?: { market?: string; venue?: Venue }): Levels;
```

## Level

A price level with resting size on each side, such as a liquidation or stop cluster.

<ResponseField name="price" type="number" />

<ResponseField name="longUsd" type="number">
  USD notional that would trade if price reached the level: long and short positions, or buy and sell orders.
</ResponseField>

<ResponseField name="shortUsd" type="number" />

## Levels

<ResponseField name="levels()" type="(): readonly Level[]">
  The levels as of the current bar, sorted by price. Empty when unknown.
</ResponseField>

<ResponseField name="time" type="Time">
  When the snapshot read was taken; `na` when there is none.
</ResponseField>

<ResponseField name="available" type="boolean" />

## triggers()

Resting stop and trigger orders by price, where the data exists.

```ts theme={"theme":"github-dark"}
function triggers(options?: { market?: string; venue?: Venue }): Levels;
```

## sessions

Exchange session calendars for HIP-3 stock and commodity perps (src/browser/market-calendars.mjs).

<ResponseField name="calendarOf()" type="(market: string): string | null">
  The calendar id for a market, such as `nyse`, or `null` for markets that trade around the clock.
</ResponseField>

<ResponseField name="at()" type="(calendar: string, time: Time): { readonly open: boolean; readonly regular: boolean; readonly start: Time; readonly end: Time }">
  Whether `calendar` is in session at `time` (regular or extended hours), with that session's
  bounds; when closed, `start` is the last close and `end` the next open. `regular` says whether
  the session is the regular one. Holidays and early closes included.
</ResponseField>

## Next step

Continue with [State](/terminal/reference/state).


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