ChartnautDocs

Options levels

options.eod.levels gives a script the options levels for a chart: call wall, put wall, gamma flip, gamma exposure, expected move and the gamma profile by strike. There is one row per chart, view and trading day, worked out from that day's US options close and the next morning's open interest, and already in the chart's own price units. It is part of Options Levels, on Pro. Read it through a dataset handle. Data Provided by Databento.

meta({ shortName: "Walls", kind: "overlay" });
dialog({ title: "Options walls" });

const lv = dataset("options.eod.levels", {
  where: { instrument: { fromInstrument: true }, view: "combined" },
});

output.line({ id: "callWall", color: "#26a69a", name: "Call wall" });
output.line({ id: "putWall", color: "#ef5350", name: "Put wall" });
output.line({ id: "flip", color: "#ffb300", name: "Gamma flip" });

export function onBar(ctx) {
  const r = lv.last;
  if (!r) return;
  if (r.callWall !== undefined) ctx.plot("callWall", r.callWall);
  if (r.putWall !== undefined) ctx.plot("putWall", r.putWall);
  if (r.flip !== undefined) ctx.plot("flip", r.flip);
}

Each line steps to the new day's level when that day's row takes effect, at about 09:50 New York time. How each level is worked out is on How options levels are calculated.

Which charts have levels

Options levels are rolling out chart by chart: S&P 500 charts first (built from SPX, SPXW and SPY, views combined, index and etf), then NAS100, Gold and Bitcoin. The dataset listing (GET /public/v1/datasets, the MCP tool list_datasets, the agent's find_datasets) gives the current coverage: each chart with levels, from when, and its newest tradeDate. In a script, lv.coverage.dataFrom is when the chart's levels begin. On a chart without options levels yet, a read with { fromInstrument: true } is refused with this chart has no options data, naming the charts that have them.

Declaring the handle

A levels handle must filter on both instrument and view. Rows of different views and charts share a time, so give each one value when you read last. To read several views, see Several views in one handle.

Filter

Values

instrument

{ fromInstrument: true } for the chart the script runs on, or a chart by name or symbol: "SP500" or "HYPERLIQUID:xyz:SP500"

view

"combined" (index and ETF options together), "index" (SPX and SPXW) or "etf" (SPY), or several of them as an array

Naming the instrument reads that chart's levels from any chart, still in that chart's price units: SP500 levels on a NAS100 chart are SP500 prices. The default lookback of 7 days covers a long weekend, when the newest row can be four days old.

Several views in one handle

A setting cannot go in where, so a script that lets the trader pick a view declares every view it can take and picks by row.view. Read with within, never last: with several views, last is whichever row came first.

const lv = dataset("options.eod.levels", {
  where: { instrument: { fromInstrument: true }, view: ["combined", "index", "etf"] },
});

export function onBar(ctx) {
  const rows = lv.within({ before: "7d" }).filter((r) => r.view === ctx.params.view);
  const r = rows[rows.length - 1];
  if (r && r.callWall !== undefined) ctx.plot("callWall", r.callWall);
}

This uses one of your plan's handles per script (Free 2, Pro 4), where one handle per view would use three.

Fields

Prices are in the chart's units. Gamma exposure is in dollars per 1% move in the underlying.

Field

Meaning

key

instrument|view|tradeDate

instrument

The chart symbol, e.g. HYPERLIQUID:xyz:SP500

view

combined, index or etf

roots

The option roots read, e.g. ["SPX", "SPXW", "SPY"]

tradeDate

The options close the row is built from, YYYY-MM-DD

knownFrom

When the row takes effect, unix seconds

modelVersion

The maths version, eod-v3

schemaVersion

The row shape, 1

spot

The chart's price at the 16:00 New York close on tradeDate

ratio

Chart price divided by the index price at the close, used to convert every level

callWall

The strike at or above spot with the largest call gamma exposure

putWall

The strike at or below spot with the largest put gamma exposure

absGammaStrike

The strike with the largest gamma exposure, calls and puts added regardless of sign

flip

The price nearest spot where dealers' net gamma turns from negative to positive. Optional

netGex

Dealers' net gamma exposure at spot

grossGex

Call and put gamma exposure added regardless of sign

expectedMove

The at-the-money straddle of the front expiry, in chart points

putCallOiRatio

Put open interest divided by call open interest

iv30

30-day implied volatility in percent, worked out the way the VIX is

frontExpiry

The nearest expiry after tradeDate, YYYY-MM-DD. Optional

frontCallWall, frontPutWall, frontFlip, frontExpectedMove

The same levels from the front expiry alone. Optional

flips

Every price where net gamma changes sign, ascending

strikes

The profile's strikes in chart prices, ascending: one per index strike (per SPY strike in the etf view)

callGamma, putGamma, netGamma

Gamma exposure at each strike, box and conversion positions left out (as the walls leave them out). putGamma is zero or negative, and netGamma is their sum

callOi, putOi

Open interest at each strike, in contracts, box and conversion positions left out

boxCallGamma, boxPutGamma, boxCallOi, boxPutOi

The box and conversion positions at each strike, zero elsewhere. callGamma[i] + boxCallGamma[i] counts every position

callWallInclBoxes, putWallInclBoxes, absGammaStrikeInclBoxes

The walls with box and conversion positions counted, the way most published levels read. Optional

The profile lists are the same length and line up by index: callGamma[i] is the call gamma at strikes[i]. On SP500 the strikes are one index strike apart (5 index points, which is 5 × ratio on the chart) and reach 20% either side of spot. Because they follow the index strikes, they shift slightly from day to day as ratio moves: to compare a strike across days, match the nearest strike, never an exact price.

Every number apart from schemaVersion is optional: a level that cannot be worked out on a day is undefined, such as the flip when net gamma never changes sign. Check before you draw or compare one.

When a row becomes visible

A row for trading day D takes effect on the next trading day, when it was computed plus 10 minutes. That is usually about 09:50 New York time. Days filled in from history take effect at 10:00. Until then, lv.last is the previous day's row.

Backtests and replay switch at the same moment a live chart did, so a level a backtest acts on is a level a trader could have seen. If a night's data is late, the previous row stays in force: check tradeDate when freshness matters.

Before the first day Chartnaut holds, reads are empty. lv.coverage.dataFrom says when the data begins:

if (!lv.last && lv.coverage.dataFrom !== undefined && ctx.time < lv.coverage.dataFrom) {
  // Options levels available from lv.coverage.dataFrom
}

Reading the profile

The profile lists are frozen. sort, reverse, splice and push throw a TypeError, so copy before reordering: list.toSorted(...) or [...list].sort(...). Reading, map, filter and slice work as usual.

The three strikes with the most gamma, largest first:

const r = lv.last;
if (r) {
  const top = r.strikes
    .map((strike, i) => ({ strike, gex: Math.abs(r.netGamma[i]) }))
    .toSorted((a, b) => b.gex - a.gex)
    .slice(0, 3);
}

Patterns

Distance to each wall, in points:

const r = lv.last;
if (r && r.callWall !== undefined && r.putWall !== undefined) {
  ctx.plot("toCallWall", r.callWall - ctx.close);
  ctx.plot("toPutWall", ctx.close - r.putWall);
}

Above or below the flip. Above it dealers are net long gamma, which tends to damp moves; below it they are net short gamma, which tends to extend them:

const r = lv.last;
const regime = r && r.flip !== undefined ? (ctx.close > r.flip ? "long gamma" : "short gamma") : "unknown";

The expected-move band around the previous close, with moveUp and moveDown declared as output.line:

const r = lv.last;
if (r && r.spot !== undefined && r.expectedMove !== undefined) {
  ctx.plot("moveUp", r.spot + r.expectedMove);
  ctx.plot("moveDown", r.spot - r.expectedMove);
}

In studies

A study reads at a time. In scope(ctx), lv.asOf(ctx.event.knownAt)?.last is the row in force when the event fired:

const lv = dataset("options.eod.levels", { where: { instrument: { fromInstrument: true }, view: "combined" } });

export function scope(ctx) {
  const r = lv.asOf(ctx.event.knownAt)?.last;
  if (!r || r.flip === undefined) return null;
  return { regime: ctx.event.payload.price > r.flip ? "above flip" : "below flip" };
}

Research with options levels builds a definition and a study on the walls. Pine indicators cannot read datasets: use TypeScript. The per-contract chain behind these levels is options.eod.contracts, on Pro.