Data sources

View as MarkdownOpen the editor

The market data a wrun indicator can read on the chart: the sources the chart serves, the fields and knobs each one takes, what each value means, and the celled sources that hand the module a whole block of rows per bar.

A source is one feed (candles, funding, a book snapshot, a footprint) declared as an input, or read straight off the chart's own candle through bar; the module itself has no network, and every number it sees arrives through one of these, fetched by the chart over the bars it has loaded.

The same candles twice. Pine reads the bars and their volume. wrun also reads the order book's resting orders, the buyers and sellers at every price, the call and put walls from the options chain, and the long and short liquidations under the bars that forced them.Pinethe candlesand their volumewruncall wallput wallresting orders in the bookbuyers and sellersat every priceliquidations,longs and shorts
  1. Pine reads the candles and their volume.
  2. wrun reads the same candles and what moved them: the resting orders in the order book and the buyers and sellers at every price (celled sources), the call and put walls from the options chain, and long and short liquidations (feed sources).

Loading a source

One declaration per field you read beyond the chart's own candle. The source is a namespace word, the field is a member, and the options object carries the knobs:

text
input("close", ohlcv.close);                                        // the chart's own candles
input("funding", funding.rate_close);                               // another feed, same market
input("buy", trades.volume, { side: "BUY" });                       // a required knob
input("iv", implied_volatility.implied_volatility, { tenor: "ONE_M" });
input("btc", ohlcv.close, { symbol: "BTCUSDT", exchange: "BINANCE_FUTURES" }); // another market's candles
input("daily", ohlcv.close, { interval: "1d" });                    // a coarser interval, as of its close
input("liqs", liquidations.liquidations, { side: "SELL", missing: "zero" });
input("us10y", economic.value, { publisher: "FRED", series: "DGS10" }); // a series named by its own knobs
input("aqi", series.value, { ref: "@you/your-feed" });              // a published feed, by its address
input("bar_t", time.bar_open_sec);                                  // the bar's open, epoch seconds
input("profile", volume_profile.cells, { max_cells: 8192 });        // a celled source
input("d", candles.cells, { interval: "1d", bars: 400 });           // closed daily candles as a stream
input("oi_coins", oi.close, { currency: "Coin" });                  // open interest in the venue's own units
input("oi_h", oi_candles.cells, { interval: "1h", bars: 744 });     // closed hourly open interest candles
input("vp_h", volume_profile_candles.cells, { interval: "1h", bars: 744, max_cells: 32768 }); // each closed hour's volume by price

The editor derives the sheet from these declarations as it compiles: each one becomes an inputSources entry keyed by input name ({ "source": "trades", "field": "volume", "side": "BUY" }). Every value is read in onBar() through in_<name>(), a celled block through in_<name>_cells() and in_<name>_view() (Celled sources).

The bar grid and the bar's own fields

The chart's own candle needs no declaration: bar.open(), bar.high(), bar.low(), bar.close(), bar.volume() and bar.time() read it inside onBar(), and reading a field adds its input to the sheet, on the chart's own market and interval, with no options:

MemberInput it addsSource field
bar.open()openohlcv.open
bar.high()highohlcv.high
bar.low()lowohlcv.low
bar.close()closeohlcv.close
bar.volume()volumeohlcv.volume
bar.time()bar_ttime.bar_open_sec (the bar's open, epoch seconds UTC)

Input 0 of the sheet is the bar grid: the market and interval every row is a candle of, which every other input aligns to. The rules:

  • A file with no input line runs on the chart's own candles. It gets close as input 0 whether or not it reads bar.close(), then the other fields it reads (bar.time() alone gives close, bar_t).
  • The first input line is the grid. Once a file has an input line, the first one is input 0, never a bar field. A file whose first input line names another candle field (a lone input("high", ohlcv.high);) keeps that line, so the grid stays on high instead of moving to the close; bar.high() reads through it, and the other bar fields work either way. A typed scalar feed may come first (input("fund", funding.rate_close) then bar.close() gives fund, close); a celled or time input first is refused when the sheet is checked (celled source class 'volume_profile' cannot be the primary input (index 0): the primary must be a fetched scalar series that defines the request grid; a time source cannot be the primary input (index 0); the primary defines the request grid, declare a feed or metric source first; for intrabar, wrun_intrabar_primary: input 'm1' reads intrabar cells at index 0; the primary input must be a fetched scalar series that defines the request grid the finer bars are sliced by (declare ohlcv first, intrabar as a secondary input); for candles, wrun_candles_primary: input 'd' reads candles at index 0; the primary input must be a fetched scalar series that defines the request grid the candles are delivered on (declare ohlcv first, candles as a secondary input)), so a file with a celled input keeps a scalar line in front of it (input("close", ohlcv.close);).
  • Declared inputs keep their order and indexes. The fields the file reads through bar that no declared input serves are appended after them, in the fixed order open, high, low, close, volume, bar_t.
  • A declared input serves its field. When an input is exactly that feed (a scalar input with that source and field and no option other than description), bar.close() reads through it, under its own name and index: input("price", ohlcv.close) serves bar.close(), and in_price() and bar.close() are then the same value. A symbol, exchange, interval, views, missing or any other option, a param.source pick or a derived view makes it another feed, and the field is added as an input of its own.
  • The bar's names are reserved. An input named open, high, low, close, volume or bar_t with another feed, in a file that reads that field through bar, is refused on the line of the first read: bar.close() reads the chart's own ohlcv.close through an input named 'close', and input 'close' is already declared with another feed; rename the declared input (open, high, low, close, volume and bar_t are the bar's own names). The same name is fine when the file never reads that field through bar.

Symbol and exchange are literals

Every option is a literal, read from the text without running it. An input without a pin follows the chart's market. A pinned input names symbol and exchange together, written in the chart's own ids (BTCUSDT on BINANCE_FUTURES): symbols are venue-native, so the editor refuses half a pin, which would name a market that does not exist. Leaving the pin off is how an input follows the chart. A pin may name a stock or ETF (POLYGON), a forex pair, gold or silver (FX_OTC: EUR/USD, XAU/USD, XAG/USD) beside the crypto venues (Stocks, forex and gold); a secondary input pinned to the CME Group family (CME, CBOT, NYMEX, COMEX, GLOBEX) is refused by name, because that market data cannot be read from another market's script (the first input is the package's own market, and whether a host serves a CME market is the host's call). Which inputs may pin a market or an interval is on Multi-source and Multi-timeframe; the venue ids are on Symbol format.

Feed sources

A feed source serves one number per bar. Every one needs its field, and each reads the chart's own market or its coin: only a secondary ohlcv or trades input may name another market, an odds input names its own Polymarket market, and a few series are named by a knob of their own (a fund, a publisher and a series id, a token, a published feed's address). The tables group them the way a chart does: the market itself, the options of its coin, and the series from beyond the venue.

The chart's market

SourceFieldsKnobsWhat the chart serves
ohlcvopen, high, low, close, volumenoneThe chart's own candles, history plus the live bar. Close prices are ohlcv + close; there is no "market" or "price" source. A secondary input may pin another market or a coarser interval.
tradesvolumeside: BUY or SELL (required); currency: USD, Coin or Auto (optional)One side's traded volume per bar, in the base asset (coins), history plus live. currency: "USD" reads it in dollars instead (each trade's notional), "Coin" in coins; two inputs differing only in currency are two lanes, so a package with a units setting declares both and picks one. "Auto" reads contracts on a futures market and dollars everywhere else (Size units). Any other field is refused by name.
oiopen, high, low, closecurrency: USD (the default) or CoinOpen interest, refreshed by polling: in USD by default, or under currency: "Coin" in the venue's own units (coins, or contracts on a venue that counts in contracts), read as the venue reports it. May pin a coarser interval. Its closed candles as a stream are the celled oi_candles (Celled sources).
liquidationsliquidationsside (optional): BUY or SELLLiquidation volume in USD, history plus live. With side the value is that side's; without it, the bar's total over both sides. Rows exist only where liquidations happened, so declare missing: "zero" when a quiet bar should read 0.
fundingrate_closenoneThe funding rate in percent, normalized to a one-hour interval, history plus live. The other funding fields are refused by name. May pin a coarser interval.
long_short_ratiototal_account, top_trader_account, top_trader_positionnoneThe market's long/short ratios, plain ratios of longs over shorts: every account, the venue's top traders counted by account, and the top traders counted by position size. Refreshed by polling. A value at or below 0 reads NaN, and the chart must be 5 minutes or coarser.
oddsopen, high, low, close (default), volumesymbol: the market's condition id (required); outcome: YES (default) or NOA Polymarket market's YES probability, 0 to 1, refreshed by polling. Details below.
timebar_open_sec, trade_date, sessionnoneThe bar's open time in epoch seconds, its exchange trade date, and its session phase (below).

Options, by the chart's coin

SourceFieldsKnobsWhat the chart serves
implied_volatilityimplied_volatilitytenor: ONE_W, ONE_M, TWO_M, THREE_M or SIX_M (required)Deribit's implied volatility for the chart's coin at that tenor, refreshed by polling. ONE_D, THREE_D and ONE_Y are refused by name: the data carries none of them.
skewskewtenor, as above (required); delta: 5, 15, 25 (the default) or 35Deribit's skew for the chart's coin at that tenor and delta, refreshed by polling.
volatility_indexopen, high, low, closenoneDeribit's volatility index (DVOL) for the chart's coin, in index points, refreshed by polling. BTC and ETH.
options_oiputs, callsvenue: deribit (the default) or binancePut and call open interest of the chart's coin on that venue, in the venue's own units (contracts on Deribit, the base coin on Binance), refreshed by polling. BTC and ETH; another coin is refused by name.
options_volumeputs, callsvenue, as abovePut and call volume of the chart's coin on that venue, in contracts, refreshed by polling. BTC and ETH; another coin is refused by name.

These are per-bar summaries. The chain itself, contract by contract, is the celled options_chain source (Options chain), and its strike rows bar by bar the celled option_strikes source (Option strikes).

US listed options, by the chart's underlying

options_flow, option_daily and option_stats_10m read the options of any chart's underlying: a crypto coin's, a CME future's or a US stock's. options_flow reads the flow of the chart's own chain, one book of it under scope: "ticker" (book), or another root's flow (underlying), and reads its wider scopes per market (below). option_daily and option_stats_10m each read the chain its venue picks (by default the chart's own chain: a crypto venue's, a CME future's, a US stock's listed options) and one book of it (book), as the option surface does. The chart in the browser serves them; an alert and a Protected indicator on OpenMarket's servers refuse each one by its own name (US listed options).

SourceFieldsKnobsWhat the chart serves
options_flowthe 36 flow fields belowscope, dte, moneyness, venue, book, underlying, min_premium, max_dte (all optional but min_premium under scope: "prints")One bar's option flow of the chart's underlying, or of a wider scope: premium in USD, contracts in the chain's own size, prints as counts.
option_dailythe 31 statistics fields belowvenue and book (both optional, as on option_surface)One book's daily options statistics, a daily join: IV by tenor, volumes, open interest, exposures, walls, max pain and the front expiry's implied move.
option_stats_10mthe same 31 fieldsvenue and book, as aboveThe same statistics every 10 minutes, each row on the bar holding it, for every underlying whose options quote live: on CME, the contract months whose options quote live, the other months having daily rows only. Any other underlying has no 10-minute rows, so its inputs read their fill on every bar; an option_daily input beside them tells it apart when it has daily rows. On the chart, an underlying whose last week holds daily rows and no 10-minute rows also gets a note on the indicator's legend ("No live option quotes for" the underlying), and the run goes on drawing.

options_flow fields split each bar's prints by side against the quote (_ask, _bid, _mid, _none) and by calls and puts: call_prem_ask, call_prem_bid, call_prem_mid, call_prem_none, put_prem_ask, put_prem_bid, put_prem_mid, put_prem_none, call_prem_total, put_prem_total, the same ten as contracts (call_contracts_ask ... put_contracts_total), net_call_prem and net_put_prem (premium at the ask minus premium at the bid), their _capped twins (each print's premium capped at 2,000,000), the share delta and the vega at the ask and the bid (share_delta_ask, share_delta_bid, vega_ask, vega_bid), prints, vol_above_ask and vol_below_bid (contracts printed outside the quote), n_priced (the prints with greeks), and the contracts printed outside the quote by calls and puts (call_contracts_above_ask, call_contracts_below_bid, put_contracts_above_ask, put_contracts_below_bid). scope is "ticker" (the default: the chart's underlying), "market" (every underlying), "equity", "etf" or "index" (every underlying of that kind), "venue" with venue naming one exchange, or "prints": the chart's underlying summed from its prints at or above min_premium (USD, required there) and, with max_dte, expiring within that many days (0, the default, keeps every expiry), the per-bar sums beside an option_prints input of the same floor. dte is "all" (the default), "0dte", "week" (1 to 7 days), "month" (8 to 35) or "later"; moneyness is "all" (the default), "otm" or "itm". Under scope: "venue" the chart serves call_prem_total, put_prem_total, call_contracts_total, put_contracts_total and prints only, with no dte or moneyness split; anything else is refused by name (wrun_options_flow_venue_field), and so is a venue without that scope. min_premium and max_dte outside scope: "prints" are refused by name (wrun_option_knob_invalid); each also takes a setting (knobs from a setting).

Each scope reads what its market has:

scopeUS stock chartCrypto chartCME futures chart
"ticker"the chart's underlyingthe chart's coin on the chain's venue, one book (book)the chain's future
"market"every US underlyingthe chart's coin on every crypto options venue, every bookevery CME option of the chain's exchange
"equity", "etf", "index"every underlying of that kindnot servednot served
"venue"one exchange's printsthe chart's coin on that venue ("DERIBIT", "OKEX_OPTIONS"), every booknot served

A scope the chart's market does not serve reads the input's fill on every bar (declare missing: "nan" or "zero"), as a chart without options does. book is read under scope: "ticker" only: the other scopes sum every book of the coin, and a book beside them is refused by name.

underlying reads one root's flow, as it reads one root's chain on the options chain: "auto" (the default) the chart's own chain, "derived" the first root the derived table maps the chart's root to (Derived roots: NDX on an NQ chart, SPX on ES), a root in capitals ("QQQ", "SPY"), or "@<param>" naming a select setting whose picks are those words (knobs from a setting). The root's flow is read on the plane that lists it, under that plane's rules: QQQ's US listed options flow on a CME NQ chart, at your own US options tier. A CME root is read on a CME futures chart only, such as ES's options on an NQ chart. On a stock, coin or index chart it is refused by name (Limitations). A root is read under scope: "ticker" or "prints" only: the other scopes span underlyings, so an underlying other than "auto" beside them is refused by name (wrun_option_knob_invalid). The chart's own price stays the price input, so a Flow VWAP on NQ weighs NQ's prices by QQQ's premium and draws in NQ's units.

Off US listed options the units follow the chain: premium in USD, contracts in the coin on a crypto chain and in contracts on CME, the share delta in the chart's own size (the coin, CME futures contracts). Crypto and CME prints carry the taker's side and no quote, so _ask is the taker buying, _bid the taker selling, and _mid, _none, vol_above_ask and vol_below_bid read 0 on a bar that has flow.

The statistics fields of option_daily and option_stats_10m: coin (the underlying as a symbol code, below), underlying_price, the ATM implied volatility at nine tenors (atm_iv_1d, atm_iv_5d, atm_iv_7d, atm_iv_14d, atm_iv_30d, atm_iv_60d, atm_iv_90d, atm_iv_180d, atm_iv_365d, in percentage points), rr25_30d, call_volume, put_volume, call_premium, put_premium, call_oi, put_oi, the exposures net_gex, net_dex, net_vex, net_charm, net_vanna and front_net_gex (USD), call_wall, put_wall, gamma_flip, gamma_magnet, max_pain_front (prices), implied_move_front (a price distance) and n_contracts. net_gex and gamma_flip are the data plane's readings over every live expiry, and gamma_flip is the options kit's gamma flip (The gamma flip and older rows). The volumes and the open interest are in the chain's own size: the coin on a crypto chain, contracts on US listed options and CME. The premium is in USD on US listed options and reads NaN on a crypto or CME chain until its prints are served. A value the data plane does not have reads NaN under missing: "nan".

On a crypto chart the same fields read that coin's chain. Here OKX's BTC chain, which the whole indicator then reads (the inputs of one indicator read one chain):

wrun
input("close", ohlcv.close);
input("iv30", option_daily.atm_iv_30d, { venue: "okx", missing: "nan" });
input("oi_calls", option_daily.call_oi, { venue: "okx", missing: "nan" }); // in BTC, the chain's coin

Flow and statistics read side by side, on a US stock chart:

input("close", ohlcv.close);
input("call_prem", options_flow.net_call_prem, { missing: "nan" }); // the chart's underlying
input("put_prem", options_flow.net_put_prem, { missing: "nan" });
input("market_calls", options_flow.call_prem_total, { scope: "market", dte: "0dte", missing: "nan" }); // every underlying, 0DTE
input("iv30", option_daily.atm_iv_30d, { missing: "nan" });
input("move", option_daily.implied_move_front, { missing: "nan" });
output("net_flow", histogram, lower, { description: "Net call premium minus net put premium on the chart's underlying, USD" });
output("market_0dte_calls", line, lower, { description: "Call premium across every US listed underlying, 0DTE, USD" });
output("iv30", line, lower, { unit: "%", description: "30-day ATM implied volatility" });
output("move_pct", line, lower, { unit: "%", description: "The front expiry's implied move as a share of the close" });

function onBar(): void {
  const close = bar.close();
  if (isNaN(close)) return;
  out_net_flow(in_call_prem() - in_put_prem());
  out_market_0dte_calls(in_market_calls());
  out_iv30(in_iv30());
  const move = in_move();
  out_move_pct(close > 0.0 && !isNaN(move) ? (100.0 * move) / close : NaN);
}

The contract-level reads are celled (US listed options).

The gamma flip and older rows

gamma_flip in option_daily and option_stats_10m is the options kit's gamma flip over every live expiry: the gamma curve's zero nearest the underlying (GammaCurve.flip(), The canonical numbers). A card that prints it names it the gamma flip with its scope, Gamma flip · all expiries.

Some older rows keep the data plane's earlier rule, the crossing of a running net GEX sum over the strikes. That rule often finds no crossing, so those rows often read NaN:

  • US listed options: the daily rows through 2026-10-20, the 10-minute rows before 2026-10-20, and on 2026-10-20 the 10-minute rows of the underlyings whose minute data starts after 2026-10-13 13:30 UTC (SPX, NDX, VIX, XSP and RUT among them).
  • CME: the 10-minute rows before 2026-10-21 12:10 UTC, and the daily rows of a contract on a day without usable settlement prices.
  • Crypto: the 10-minute rows before 2026-10-21 12:10 UTC of Bybit's ETH, SOL, XRP, DOGE, HYPE, MNT and XAUT chains and OKX's HYPE chain, whose minute data starts too late to recompute them.

Every other row reads the gamma flip: the rest of crypto, CME's other daily rows, and the other 10-minute rows of 2026-10-20 on US listed options (1,626 underlyings, SPY and QQQ among them).

The chart's options heatmap draws its cumulative GEX zero line by the earlier running-sum rule from its own per-strike totals, so that line is a separate number, not the gamma flip.

Beyond the chart's venue

SourceFieldsKnobsWhat the chart serves
etf_flowflow_usdfund: an ETF ticker (IBIT, FBTC, ETHA, ...) or all (required)Daily net spot-ETF flow in USD, on a chart of BTC, ETH or SOL; another coin, or a ticker the coin does not list, is refused by name.
etf_holdingsholdingsfund: an ETF ticker or all (required)The fund's holdings, in coins of its underlying; all sums every fund listed for the chart's coin. A coin without listed funds, or a ticker the coin does not list, is refused by name.
etf_premiumpremium_ratefund: one ETF ticker (required)The fund's premium to its net asset value, in percent, daily. all is refused by name: a rate does not sum across funds.
ethena_positionscollateralnoneEthena's collateral held against the chart's coin, in USD, summed over the venues that hold it. BTC and ETH; another coin is refused by name.
bitfinex_fundingfunding_size, credit_size, active_credit_size, margin_ratenoneBitfinex margin funding for the chart's coin: the total funding provided, the funding used in positions and the active credits, each in the funding currency, and the margin rate as an APR in percent.
treasury_balancebalanceasset (optional): an upper-case ticker, the chart's coin when absentBinance's own balance of that coin (its liability minus its customer liability), in coins, published monthly.
token_supplymarketcap, first_marketcap, marketcap_dominance_percent, circulating_supply, total_supply, max_supply, total_value_locked, fully_diluted_valuation, cg_marketcap_rank, total_volume, usd_pricetoken: the token's display name (required)A token's supply and market-cap series, daily. The token is named the way the series spells it (Bitcoin, Ethereum, Solana), never by its ticker; a name the chart does not list is refused by name, and so is a one-minute chart.
economicvaluepublisher and series (both required)One economic series in the publisher's own unit, daily or slower: { publisher: "FRED", series: "DGS10" } is the US 10-year Treasury yield in percent. A publisher the chart does not know is refused by name.
seriesvalueref: the feed's address, @scope/name (required); missing: carry (the default) or nanA published feed's reading (its first value key), the last reading inside a bar winning. Never the first input, and read on 1m, 5m, 15m, 30m, 1h, 4h, 1D and 1W charts: Feeds as inputs.

Every feed in the last two tables is refreshed by polling, and none takes a market or an interval pin: each follows the chart's coin or the series its knobs name.

A few behaviors to plan for:

  • Funding exists on perpetuals only. On a spot, FX or prediction market, a funding input that declares missing: "nan" or "zero" reads that fill on every bar; on the default carry policy the run stops with a message naming the funding rate.
  • ETF flows are daily. On an intraday chart the day's value lands on the first bar of its day and the later bars of that day follow the missing policy (carry repeats it across the day, nan and zero leave a one-bar spike); on a daily chart it joins row for row; on a coarser chart each bar sums its days. A day's flow is known after the US session, so on an intraday chart it is a same-day display, never a signal that was available at the day's open.
  • Daily levels land the same way, and never sum. etf_premium, economic and treasury_balance are daily or slower: a chart bar reads the newest value at or before its day. On an intraday chart the day's value lands on the first bar of its day and the later bars follow the missing policy; on a daily chart it joins row for row; on a coarser chart a bar reads its last day. A slower series (a monthly balance, a weekly print) carries between its prints under carry.
  • Polymarket odds. Pin the market by its condition id (0x followed by 64 hex characters) in symbol. The exchange is implied (declaring one is refused), and the chart has no market picker, so a binding is refused. outcome: "NO" reads 1 minus the close. An odds input may be the first input (the rows are still the chart's candles), and it needs a chart of one minute or coarser. The prediction-market starters in the template picker ship a placeholder market: Run refuses them until you paste a real condition id into the input's symbol.
  • Required and optional sources. A source the chart must have (volume profile, implied volatility, skew, the options chain, ETF flows, funding on the default policy, the candles of a pinned or intrabar input) that answers empty stops the run with a toast naming it. Trades, open interest, liquidations and the book may legitimately be empty for a stretch, so they read their missing fill (the book an empty block) instead. Every other feed of the options and beyond-the-venue tables, and long_short_ratio, follows the funding rule: an empty answer stops the run with a message naming the feed, unless every input that reads it declares missing: "nan" or "zero", in which case those inputs read that fill. A volume profile declared missing: "empty" is optional: on a market that serves none (a stock, an index), or a stretch with no profile, every bar reads an empty block (in_<name>_cells() is 0) and the run goes on, so the parts of the indicator that read it blank while the rest draws as usual. A bar whose profile has more buckets than the input's max_cells reads the same empty block on an optional profile (on a required one it stops the run: a block is never truncated). "empty" is the one word a celled input takes, and only a volume profile takes it.

A code-first file that exercises the per-source requirements together (a required side, a required tenor, an optional side with a missing policy) and puts the units side by side:

input("close", ohlcv.close);
input("buy_volume", trades.volume, { side: "BUY" });
input("iv_1m", implied_volatility.implied_volatility, { tenor: "ONE_M" });
input("sell_liqs", liquidations.liquidations, { side: "SELL", missing: "zero", description: "SELL-side liquidations, 0 on bars without any" });
output("stress", line, lower, { description: "SELL liquidations per dollar of buy volume, scaled by one-month IV" });

function onBar(): void {
  // trades volume is in coins; liquidations are already in USD.
  const buyUsd = in_buy_volume() * bar.close();
  const iv = in_iv_1m();
  if (isNaN(buyUsd) || buyUsd <= 0.0 || isNaN(iv)) return;
  out_stress((in_sell_liqs() / buyUsd) * iv);
}

The option summaries read the same way. This one puts five of them side by side on a BTC or ETH perpetual chart of 5 minutes or coarser: put/call ratios by open interest (Deribit, the default venue) and by volume (Binance), the volatility index, a one-week skew at 5 delta, and the top traders' long/short ratio:

input("close", ohlcv.close);
input("put_oi", options_oi.puts); // venue absent: Deribit, in contracts
input("call_oi", options_oi.calls);
input("put_volume", options_volume.puts, { venue: "binance" });
input("call_volume", options_volume.calls, { venue: "binance" });
input("dvol", volatility_index.close);
input("wing_skew", skew.skew, { tenor: "ONE_W", delta: 5 });
input("long_short", long_short_ratio.top_trader_position, { missing: "nan", description: "Top traders' long/short ratio by position, NaN on a bar without a print" });
output("put_call_oi", line, lower, { description: "Puts over calls by open interest, Deribit" });
output("put_call_volume", line, lower, { description: "Puts over calls by volume, Binance" });
output("dvol", line, lower, { description: "Deribit volatility index, index points" });
output("wing_skew", line, lower, { description: "One-week skew at 5 delta" });
output("long_short", line, lower, { description: "Top traders' long/short ratio by position" });

function onBar(): void {
  if (isNaN(bar.close())) return;
  // A ratio needs a positive denominator: NaN before the first print, never a division by zero.
  const callOi = in_call_oi();
  const callVolume = in_call_volume();
  out_put_call_oi(callOi > 0.0 ? in_put_oi() / callOi : NaN);
  out_put_call_volume(callVolume > 0.0 ? in_put_volume() / callVolume : NaN);
  out_dvol(in_dvol());
  out_wing_skew(in_wing_skew());
  out_long_short(in_long_short());
}

And the series from beyond the venue, on a BTC chart. Holdings and the treasury balance arrive in coins, so the chart's close prices them; the ETF premium, the yield and the token's market cap arrive in their own units and are plotted as they are:

input("close", ohlcv.close);
input("etf_coins", etf_holdings.holdings, { fund: "all" }); // coins held by every listed fund
input("marketcap", token_supply.marketcap, { token: "Bitcoin" }); // USD; the token by its display name
input("premium", etf_premium.premium_rate, { fund: "IBIT" }); // percent, daily
input("us10y", economic.value, { publisher: "FRED", series: "DGS10" }); // the publisher's unit: percent
input("treasury", treasury_balance.balance, { asset: "BTC" }); // coins; monthly
input("ethena", ethena_positions.collateral);
input("provided", bitfinex_funding.funding_size); // funding currency
input("lent", bitfinex_funding.credit_size); // the part in use
output("etf_share", line, lower, { unit: "%", description: "Spot-ETF holdings as a share of the market cap" });
output("premium", line, lower, { unit: "%", description: "IBIT premium to net asset value" });
output("us10y", line, lower, { unit: "%", description: "US 10-year Treasury yield" });
output("treasury_usd", line, lower, { description: "Binance's own BTC balance, in USD" });
output("ethena", line, lower, { description: "Ethena collateral in the chart's coin" });
output("utilization", line, lower, { unit: "%", description: "Bitfinex funding in use, as a share of funding provided" });

function onBar(): void {
  const close = bar.close();
  if (isNaN(close)) return;
  // Holdings and the treasury balance are coins: the close turns them into USD.
  const cap = in_marketcap();
  out_etf_share(cap > 0.0 ? (100.0 * in_etf_coins() * close) / cap : NaN);
  out_premium(in_premium());
  out_us10y(in_us10y());
  out_treasury_usd(in_treasury() * close);
  out_ethena(in_ethena());
  const provided = in_provided();
  out_utilization(provided > 0.0 ? (100.0 * in_lent()) / provided : NaN);
}

Alignment and the missing policy

The rows are the chart's own candles: the first input follows the chart's market and interval, and every other input is aligned onto those rows. Sources at the chart's interval join by bar open, row for row; a coarser interval pin contributes to a row only as of that row's close, so a forming 4h candle never leaks into the 1h rows under it (Multi-timeframe). A scalar source with no observation on a bar delivers, by policy, the latest value carried forward (missing: "carry", the default; NaN before the first observation), NaN ("nan"), or 0 ("zero"). Celled blocks never carry: a bar with no observation gets an empty block.

The time source

time.bar_open_sec carries the bar's open timestamp (epoch seconds, UTC), taken from the chart's own candle, so a module can do session and calendar math deterministically (Time and sessions); bar.time() reads it with no declaration. Two more fields carry the bar's market facts, so an indicator never has to know the venue's calendar:

  • time.trade_date: the bar's exchange trade date, as epoch seconds at 00:00 UTC of that date. On CME futures the trade date starts at the 17:00 Chicago open, so an evening bar belongs to the next date; on forex, gold and silver (FX_OTC) it starts at the 17:00 New York open, so Sunday's evening bars belong to Monday; on US stocks it is the New York calendar date; on crypto, HIP-3 and Polymarket markets it is the UTC date.
  • time.session: 1 regular, 2 pre-market, 3 after-hours, 0 closed. US stocks follow the New York pre-market, regular (09:30 to 16:00) and after-hours sessions; CME futures read 1 inside the contract's regular trading hours (all session long for a contract without them), 2 before and 3 after them within the same trade date, and 0 while the market is closed; forex, gold, silver and a market without sessions read 1 on every bar.

A bar of one day or longer (a 1D, 3D, 1W or 1M chart) is a whole trading day or more, so it takes the date of its own stamp and session 1 on every market: the chart stamps such bars at 00:00 UTC of their trade date. Both fields are facts of the market, the bar and its interval alone: switching the chart between regular and extended hours never changes them. Every field is filled by the chart (there is no feed behind it), every other knob is refused, and a time input is never the first input.

Celled sources

A feed source serves one number per bar. A celled source serves a whole BLOCK of rows per bar, which is what footprint-style indicators need: a footprint is the same candle sliced by price, one [low, high, buy, sell] row per price bucket, so "did buyers or sellers do the volume, and at which prices" is answerable inside one bar instead of only as a per-bar total. Celled inputs are declared as input(name, <source>.cells, { max_cells }), which moves the derived sheet to at least the second contract (abi_version: "wrun-2"); the module-side accessors are in TA library:

SourceOne tuple perWhat the chart servesKnobs
volume_profileprice bucket: [low, high, buy, sell]the chart's own volume profile for each bar, with real bucket bounds, in ascending price order; history plus livemax_cells; ticks_per_bar (1 to 500 of the market's buckets merged into one, or "@<param>" naming a param.int whose value it takes); currency ("USD" for dollar volumes, "Coin" by default, "Auto" for contracts on a futures market and dollars elsewhere); missing: "empty" (the profile optional: below)
booklevel: [price, size, side], side +1 bid, -1 askthe chart's own order book for each bar, up to 500 levels a side: bids first, then asks from the highest price down; history plus livemax_cells (1000 holds both sides); block_size (the declaration requires one, but the chart reads its own order-book feed and does not use it or max_depth)
intrabarclosed finer bar: [offset_ms, open, high, low, close, volume], offset_ms the finer open minus the bar's openthe finer candles inside each bar, of the chart's market or a pinned oneinterval (required), max_cells, symbol + exchange
candlesclosed candle of the stream's interval: [offset_ms, open, high, low, close, volume], offset_ms the candle's open minus the bar's opena stream of closed candles: the backlog on the first bar, then each candle on the bar it closes with, of the chart's market or a pinned oneinterval (required, any word), bars (1 to 5000), max_cells (the editor fills it when left out), symbol + exchange, chart_interval_below (an interval word: the stream is fetched only on a chart finer than it, and on any other chart the input reads an empty block on every bar)
oi_candlesclosed open interest candle of the stream's interval: [offset_ms, open, high, low, close], offset_ms as on candlesa stream of the leg's closed open interest candles, by the candles rules, of the chart's market or a pinned one; in the venue's own units (coins or contracts) unless currency: "USD"interval (required, any word), bars (1 to 5000), max_cells (the editor fills it when left out), currency ("Coin" by default, or "USD"), symbol + exchange, chart_interval_below; no view
volume_profile_candlesprice row of a closed candle of the stream's interval: [offset_ms, low, high, buy, sell], the rows of one candle sharing its offset_ms, candles oldest first and each candle's rows ascending by pricea stream of the leg's closed volume profiles, by the candles rules, of the chart's market or a pinned oneinterval (required, any word), bars (1 to 5000), max_cells (REQUIRED, at least bars: size it as the price rows one candle holds times bars), ticks_per_bar and currency as on volume_profile, symbol + exchange, chart_interval_below; no view
trade_volume_by_sizeUSD trade-size bucket: [bucket, buy_usd, sell_usd, buy_count, sell_count]the chart market's traded volume split by the size of each trade (each fill bucketed by its own dollar value), one tuple per bucket that traded in the bar, in ascending bucket ordermax_cells (7 holds a full bar)
options_chainlisted contract: [strike, expiry_ms, side, oi, gamma, delta, mark_iv, underlying, multiplier, vega]the newest option chain, on the newest bar onlyvenue, expiries, underlying ("auto" the chart's own chain, a root in capitals such as "SPX", "derived", or "@<param>": that root's chain, each row keeping its own underlying), max_cells, page_view or page_views and their params (Chain page views)
option_strikes(expiry, strike) row: [strike, expiry_ms, net_gex, call_gex, put_gex, net_dex, net_vex, call_oi, put_oi, call_iv, put_iv, underlying]the chart's options chain measured by strike on every bar, one snapshot per bar, on crypto, CME and US stock charts: one book of the chain venue picks (Option strikes)venue, expiries, book, underlying ("auto" the chart's own chain, a root in capitals such as "SPX", "derived", or "@<param>": that root's chain, each row keeping its own underlying), max_cells, fold: "kit" and its params (Chain page views)
tapeprint: [offset_ms, price, size, side], side +1 buy, -1 sell, size in the floor's unitthe chart market's prints at or above the floor: history from the large-print lane over the chart's window, then live prints on the forming bar (Large prints)exactly one floor, min_value (dollars), min_size (the stored size) or min_coins (coins on coin markets), each a number or a setting the floor follows; history ("0" by default, or up to "30d"), max_cells; on a second tape, needed_by (the markets that read it, and beside size_unit one param.choice that picks it)
option_printsprint: 16 values, [offset_ms, print_key, root_code, ..., venue, present]the option prints at or above min_premium, per bar, on crypto, CME and US stock charts: one book of the chain venue picks (Option prints)venue, book, min_premium (required), expiries, history, overflow, max_cells
option_contract_flowcontract that traded: 17 values, [root_code, expiry_ms, side_cp, strike, ..., present]each contract's flow in the bar, by side, on crypto, CME and US stock charts: one book of the chain venue picksvenue, book, expiries, strike_window_pct, min_volume, max_cells
option_contract_statecontract: 13 values, [root_code, expiry_ms, side_cp, strike, bid, ..., present]the newest chain summary with the prior close and prior open interest, on the newest bar only, on crypto, CME and US stock charts: one book of the chain venue picksvenue, book, expiries, strike_window_pct, max_cells, page_view or page_views and their params (Chain page views)
option_surfaceexpiry: 9 values, [expiry_ms, dte_days, forward, ..., present]the volatility surface of each expiry on every bar, on crypto, CME and US stock charts: one book of the chain venue picks (Option surface)venue, book, max_cells, pick and its params (Chain page views)
option_prints_v2print: 19 values, [offset_ms, print_key, ..., venue, block_key, rfq_key, legs, present]the option prints of option_prints with each print's block trade, its RFQ and its leg count (Block and RFQ prints)venue, book, min_premium (required), structure, expiries, history, overflow, max_cells

Every celled source reads the chart's own market (a market pin is refused) except intrabar and the three streams (candles, oi_candles and volume_profile_candles), which may name another market with symbol and exchange together. A block over max_cells refuses the run instead of being truncated, except on a volume profile declared missing: "empty", where that bar reads an empty block, and on option_prints or option_prints_v2 declared overflow: "largest", where that bar keeps its largest prints and says so. Order-book depth figures (the summed bid size, the largest ask, ...) are loops over the book block (Order flow); the intrabar and stream rules are on Multi-timeframe.

Reading a block

A celled input gets three readers and two constants, and the build owns one buffer per celled input, allocated at module start (max_cells x the tuple width, so 8192 volume profile tuples are 262,144 bytes):

  • in_<name>_cells(): i32: the f64 values in this bar's block; -1 when the bar carries none, 0 for an empty block.
  • in_<name>_view(): StaticArray<f64>: the build's own buffer, no copy. Only the first in_<name>_cells() values belong to this bar: every index past them up to the capacity reads NaN (an absent or empty bar reads NaN throughout) and an index past the capacity stops the run, so bound the loop by the count.
  • in_<name>_read(ptr: i32): i32: copies the block to memory at ptr and returns the bytes written (count x 8), -1 absent, 0 empty. It is for code that owns a buffer of its own, which then holds the block twice; prefer the view.
  • in_<name>_max_cells and in_<name>_capacity (the input's capacity x tuple width: max_cells, or max_cells + newest for a print read's union): constants. The build writes the same capacity on the sheet beside max_cells, and the chart never hands the indicator a bar's block past it.

Read the block where you write, bounded by the count:

wrun
function onBar(): void {
  const n = in_profile_cells(); if (n <= 0) return;
  const cells = in_profile_view();
  let buy = 0.0; let sell = 0.0;
  for (let i = 0; i + 3 < n; i += 4) { buy += cells[i + 2]; sell += cells[i + 3]; }
  if (buy + sell > 0.0) out_buy_share((100.0 * buy) / (buy + sell));
}

Volume by trade size

trade_volume_by_size answers "who traded this bar": the same volume split by how large each trade was. A trade is one fill, bucketed by its own dollar value, so an order that fills in pieces lands in smaller buckets: read the large buckets as a floor for what large traders did. bucket runs from 1 to 7 by the USD value of one trade:

bucketTrade size, USD
1under 1K
21K to 10K
310K to 100K
4100K to 500K
5500K to 1M
61M to 10M
710M and up

buy_usd and sell_usd are USD notional, buy_count and sell_count are trade counts. A bucket that did not trade has no tuple, and a bar with no trades is an empty block. The share of a bar's volume that arrived in trades of 100K and up:

input("close", ohlcv.close);
input("sizes", trade_volume_by_size.cells, { max_cells: 7 }); // seven buckets hold a full bar
output("large_share", line, lower, { unit: "%", description: "Share of the bar's USD volume in trades of 100K and up" });

function onBar(): void {
  const n = in_sizes_cells();
  if (n <= 0) return;
  const cells = in_sizes_view();
  let total = 0.0;
  let large = 0.0;
  // One [bucket, buy_usd, sell_usd, buy_count, sell_count] row per bucket that traded.
  for (let i = 0; i + 4 < n; i += 5) {
    const usd = cells[i + 1] + cells[i + 2];
    total += usd;
    if (cells[i] >= 4.0) large += usd; // bucket 4 starts at 100K
  }
  out_large_share(total > 0.0 ? (100.0 * large) / total : NaN);
}

What the chart does not serve

  • Another indicator's outputs: the editor has no declaration for them; an indicator reads market data and published feeds only. A watch's own series (watch/<slug>/<key>) reads on your OpenMarket runner, never on the chart (Feeds as inputs).
  • CME open interest: no source serves it. Open interest on the venues the chart serves is oi, and its closed candles as a stream oi_candles.
  • A stream's forming candle: candles (outside its "forming" view), oi_candles and volume_profile_candles deliver closed candles only. The hour still forming is the chart's own: read it from a scalar oi input or the volume_profile block of the bar (Open Interest Profile folds both).

There is no cvd source: cumulative volume delta is buy minus sell trades volume, accumulated in the module.

Options chain

options_chain is the celled source behind a gamma map: the chart market's option chain, one tuple per listed contract, so exposure by strike is a loop inside the indicator instead of a server aggregate. Declare the chart's candles first, then the chain input:

wrun
input("close", ohlcv.close);
input("chain", options_chain.cells, { max_cells: 2000 });

Each contract occupies ten f64 values: [strike, expiry_ms, side, oi, gamma, delta, mark_iv, underlying, multiplier, vega]. expiry_ms is the expiry in epoch milliseconds; side is +1 for a call and -1 for a put; oi is the open interest in the venue's amount units; gamma and delta are the venue's served greeks; mark_iv is the mark implied volatility in percentage points (15.2 is 15.2% a year, 2.4 is 2.4%: never a fraction); underlying is the chain's underlying price; multiplier is the USD value of one price unit per OI unit (1 where the OI already carries it, the CME point value on a CME chain); vega is the venue's vega, the price change per one IV point (0 where the venue serves none). Gamma exposure per contract is gamma * oi * multiplier * underlying * underlying * 0.01, summed by strike with the sign of side; vega exposure is vega * oi * multiplier, summed the same way.

The chart serves the LATEST chain, not a history of chains, so the block is present on the newest bar only: every older bar is an empty block (in_chain_cells() reads 0), and the indicator reads the chain when bar.isLast() is true. The chart refreshes it from the same 30-second snapshot its options panes use. venue: "auto" (the default) reads the chart's own market when it is an options venue (a CME futures chart reads the CME chain of its root), else the coin's Deribit chain. On a US stock chart auto reads the stock's OPRA chain, its US listed options, which the chart serves to every indicator at the viewer's own tier: real time on a real-time US options account, else delayed 15 minutes, and the legend says so. On a CME futures chart auto reads the root's CME chain, which the chart serves to every indicator that runs in the browser once the viewer is signed in and has accepted the CME market data terms, at the viewer's own tier: real time on a real-time CME account, else delayed 10 minutes. Every other word pins one venue's chain: "deribit", "cme", "binance", "okx", "bybit", "bullish" or "derive". A pinned venue is refused by name on a chart it cannot serve: a coin that venue does not list, or a venue the chart does not offer you. expiries is "all" (the default) or "nearest:N", the N nearest live expiries. max_cells counts contracts: a crypto chain over the cap refuses the run by name, never truncated, so size it for the venue (a full BTC chain is about 1,500 contracts; 2000 leaves headroom). A governed chain (OPRA on a US stock, CME on a futures chart) is never refused for its size: the chart reads as many of the expiries the input asks for as fit max_cells at 8 strikes each side of each expiry's money, then widens the window as far as the budget allows, 80 strikes at most (SPY's 36 expiries read 27 strikes a side at 4,000 and 80 at 12,000), and serves it at the viewer's own tier (real time on a real-time account, else delayed: 15 minutes on OPRA, 10 on CME). A market pin, an unknown venue word and an expiries selector outside that grammar are refused by name. A hosted run (Run on Cloud, a Protected package) reads a US stock or ETF chart's own OPRA chain on OpenMarket's servers for the run's owner, at the owner's own tier, and every frame names the tier its rows were served at (the legend's word); the other chain sources stay browser-only there, refused by name.

Option strikes

option_strikes is the celled source behind a strike map over time: every bar carries the chart's options chain measured by strike at that bar, one tuple per (expiry, strike) row, so net gamma exposure by strike, the walls and the gamma flip (the options kit's GammaCurve.loadStrikes) are a reading on every bar instead of on the newest one. Declare the chart's candles first, then the strikes input:

wrun
input("close", ohlcv.close);
input("strikes", option_strikes.cells, { max_cells: 1200, expiries: "nearest:1" });

Each row occupies twelve f64 values: [strike, expiry_ms, net_gex, call_gex, put_gex, net_dex, net_vex, call_oi, put_oi, call_iv, put_iv, underlying]. expiry_ms is the expiry in epoch milliseconds. The exposures are in USD with the contract's point value applied: call_gex and put_gex are each side's dollar gamma for a 1% move of the underlying, both positive, and net_gex is call_gex - put_gex; net_dex is the delta dollars of both sides (puts negative); net_vex is the calls' vega dollars less the puts'. call_oi and put_oi are the open interest in the chain's own size (the coin on a crypto chain, contracts on US listed options and CME), call_iv and put_iv each side's implied volatility in percentage points (32.19 is 32.19%), weighted by the open interest of the side's contracts, and underlying is the underlying price the row was measured at. A strike that lists one side reads NaN in the other side's fields, and a side that reports no IV reads NaN there: count a NaN as 0 in a sum and leave it out of an IV average (Options kit does both).

A bar's block is ONE snapshot: the newest minute of strike rows inside the bar, every expiry and strike of that minute, stamped at the bar's open, so a strike listed under two expiries is two tuples. A bar with no snapshot (outside the session, a minute the rows missed) is an empty block (in_strikes_cells() reads 0), and the rows reach back as far as the chart's strike history (about seven days). venue and expiries are the options chain's words: venue: "auto" (the default) reads the chart's own chain, which on a US stock chart is the stock's OPRA chain, its US listed options, served at the viewer's own tier (real time on a real-time US options account, else delayed 15 minutes); on a CME futures chart the future's CME chain, at the viewer's own CME tier (real time on a real-time CME account, else delayed 10 minutes); on a crypto chart the coin's chain. book reads one book of the chain, as on the option surface: "auto" (the default) is the book named like the coin, else the first book in name order, and two books are never merged. expiries is "all" (the default) or "nearest:N", which keeps the rows of the N earliest expiries each bar's snapshot lists before the block is measured against max_cells. max_cells counts rows: a bar over the cap refuses the run by name, never truncated (an SPX expiry lists about 420 strikes, so 1200 leaves headroom for nearest:1). A market pin, an unknown venue word and an expiries selector outside that grammar are refused by name, as on the chain, and only the chart's browser lane serves the source.

Option surface

option_surface is the celled source behind a skew or term-structure line over time: every bar carries the volatility surface of the chart's options chain at that bar, one tuple per expiry. It runs on crypto, CME and US stock charts. Declare the chart's candles first, then the surface input:

wrun
input("close", ohlcv.close);
input("surface", option_surface.cells, { max_cells: 40 });

Each expiry occupies nine f64 values: [expiry_ms, dte_days, forward, atm_iv, iv_p25, iv_c25, iv_p10, iv_c10, present]. expiry_ms is the expiry in epoch milliseconds, dte_days the days to it and forward its forward price; the IVs are in percentage points: the ATM IV, then the 25 delta put and call, then the 10 delta put and call. present says which values were served: bit 1 dte_days to bit 7 iv_c10, each bit its column, bit 8 the forward came from put-call parity, and bit 14 a partial bar (The present mask and partial bars). The surface keeps five-minute samples for 30 days and a daily sample after that.

venue picks the chain in the options chain's words. "auto" (the default) reads the chart's own options market (a crypto option's venue, a CME future's chain, a US stock's listed options), else the coin's Deribit chain, else the first venue that lists the coin. Every other word pins one venue's chain: "deribit", "cme", "binance", "okx", "bybit", "bullish" or "derive", refused by name on a chart that venue cannot serve.

book picks one book of that chain. A venue can list one coin in two books, each with its own contracts in its own units (Deribit's BTC, settled in BTC, and BTC_USDC, settled in USDC; OKX's BTC-USD and BTC-USD_UM), and each book is a surface of its own, never merged. "auto" (the default) reads the book named like the coin, else the first book in name order; any other word names one book as the data spells it: an upper-case letter or digit, then up to 31 more of upper-case letters, digits, ., _ and -. A word that is no book name is refused when the indicator is built (wrun_option_knob_invalid), and a book the chart's chain does not list is refused by name when it runs:

wrun
// Deribit's BTC chain on a BTC chart, its USDC-settled book
input("surface", option_surface.cells, { max_cells: 40, venue: "deribit", book: "BTC_USDC" });

venue and book are the same words on every source that reads one venue's chain: option_strikes, option_contract_state, option_surface, option_daily, option_stats_10m, option_prints, option_contract_flow and option_prints_v2 (and book on options_flow under scope: "ticker"). The inputs of one indicator read one chain across all of them, in as many books as they name: option_daily on Deribit beside option_surface on OKX is refused by name (wrun_options_chain_one_venue), and so is a market pin (wrun_option_market_pinned). On a CME or a US stock chart the surface follows the same rules as the chain there (Limitations). Only the chart's browser lane serves the source: an alert and a Protected indicator on OpenMarket's servers refuse it by name (wrun_option_surface_unsupported).

Chain page views

A chain indicator rarely reads every contract it is handed. Declare what it reads, and the chart asks the data plane for that part of the chain alone: fewer bytes, sooner. Two kinds of view exist:

  • A projection keeps the contracts the indicator's code reads, in the chain's own order and with the chain's own values. Code that read the whole chain reads a projection unchanged.
  • A fold sums the chain the way a template does and answers rows of its own layout, read through ./sdk/options (Options kit).

options_chain and option_contract_state inputs name views of the chain page in page_view (one word) or page_views (a list of at most 16 words, each once, never beside page_view: one ask carries at most 16 views). Each view's params ride the same literal as flat keys, each a number or "@<param>". The chart writes the setting's value on every run: a number as it reads, a param.choice's index, a param.bool's 0 or 1.

wrun
param.number("rate_pct", 4, { min: 0, max: 20, step: 0.25 });
input("close", ohlcv.close);
// The at-the-money strikes at each expiry's forward, and the 7.5 to 27.5 delta band of the expiry nearest 30 days
input("chain", options_chain.cells, { max_cells: 4000, venue: "auto", page_views: ["atm", "delta_band"], expiry: 30, lo: 0.075, hi: 0.275, rate: "@rate_pct" });
ViewClassAnswerParams (knob: what it takes)
wholeoptions_chainevery contractnone
clockoptions_chainthe contract the chain's clock is solved from, and each expiry's first contractsnone
atmoptions_chainper expiry, every contract at the two strikes bracketing its centrecenter (0 the underlying, among every strike with an IV; 1 the forward, the default, among the strikes within 20% of the underlying, the ones IvTerm picks from), rate (percent a year, required at the forward), within_pct (0, the default: no band of its own)
delta_bandoptions_chainon the expiry nearest expiry days, each side's contracts with a delta from lo to hi and one beyond each endexpiry (days, required), lo, hi (0.25 by default), rate (required)
windowoptions_chainthe contracts of the first view_expiries expiries within pct percent of the centreview_expiries (1 to 64, required), center (0 each expiry's underlying, 2 the chart's close, the default), pct (required), min_oi (absent: every contract)
horizon_otmoptions_chainthe volatility smile's three horizons and the out-of-the-money strikes its grid and wings reachdays1, days2, days3, pct, wing_pct (required), points (the grid's strikes)
surface_bucketsoptions_chainthe volatility surface's first expiries and the strikes its buckets readview_expiries, range_pct (required)
contractoptions_chainone contract and its strike's side groupexpiry_day (epoch seconds; 0 the first expiry after today), side (0 calls, 1 puts), strike (0 the forward), rate (required)
front_deltaoptions_chainthe front expiry's call and put nearest 25 deltanone
exposureoptions_chainfold: exposure by strike, by day bucket and by expiry (ExposureTable)lens (0 gamma, 1 delta, 2 vanna, 3 charm, 4 vega, 5 IV x OI, 6 OI), units (0 dollars, 1 the underlying), scope (0 all, 1 0DTE, 2 week, 3 month, 4 nearest, 5 buckets), nearest, rate (required)
strike_tableoptions_chainfold: the strike table OptionsChain.load() builds (OptionsChain.loadTable)none
gex_curveoptions_chainfold: net GEX over a grid of spots (GexCurve)grid_down, grid_up (required), points (125 by default)
numbersoptions_chainbook fold: net GEX, the regime and the gamma flip per scope, the forward, ATM IV and moves per expiry, the ATM IV and moves per horizon (OptionNumbers, ExpectedMoves.loadNumbers)nearest (0, the default: every live expiry) or days (above 0), never both
vol_termoptions_chainbook fold: the term structure, a row per live expiry (VolTerm)none
smileoptions_chainbook fold: the out-of-the-money IV by strike at up to three horizons (SmileRows)count (1 to 3, 3 by default), window_pct (40 by default)
surfaceoptions_chainbook fold: one lens as a strike by expiry matrix (SurfaceMatrix)lens (0 GEX, 1 OI, 2 IV, 3 DEX, 4 VEX), window_pct (20), columns (1 to 16, 8), rows (1 to 64, 21)
strike_profileoptions_chainbook fold: open interest and exposures by strike, the levels, the GEX curve over spot (StrikeProfile)nearest or days, window_pct (0, the default: every strike), strikes (0 no strike rows, 1 the default), points (0, the default: no curve, or 2 to 1000), half_pct (15)
traded, extremesoption_contract_statethe contracts that traded today; the lowest and highest strikenone
top, leadersoption_contract_statethe ranked contractstop: rank (0 volume, 1 OI, 2 premium, 3 gain), side (0 both, 1 calls, 2 puts), rows (required), min_volume; leaders: side, rank (0 contracts, 1 percent), min_prior_oi
totalsoption_contract_statefold: the summary's counts and sums (ChainTotals)none
oi_boardoption_contract_statefold: each contract's part of a strike by expiry board (OiBoard)lens (0 OI change, 1 OI change percent, 2 OI, 3 volume, 4 net volume), side, columns, window_pct (both required)
strike_changeoption_contract_statefold: the change of open interest per strike (OiBoard)side, rank, min_prior_oi

The views' expiry count is view_expiries: expiries stays the input's own word. window, horizon_otm, surface_buckets, oi_board, exposure, strike_table and gex_curve read the chart's close, so the chart asks with it. A projection's answer covers every close within 0.5% of it, and the chart asks again when the close leaves that band. A fold reads the close where a contract lists no underlying. An ask for one of these views without the close is refused. Several projections answer one list: each contract once, in the chain's order, so two contracts that match in every value still both arrive. A view ask takes a cached chain page up to 30 seconds old. A fold widens the input's block to view rows (11 values a row on options_chain, 16 on option_contract_state): size max_cells for those rows. The chart reads projections today; a fold is refused there by name (wrun_option_view_unread) until its readers land.

The book folds (numbers, vol_term, smile, surface, strike_profile) are the numbers the chart's own options panes draw, folded once a chain update over the chain page's whole book at the instant the data plane priced it, never over the input's block. So an expiries word other than "all" beside one is refused, and nearest or days scope a fold's own expiries. Each reads rows of its own width (12 values a row for numbers, 16 for vol_term, 11 for smile and surface, 13 for strike_profile; an input naming several takes the widest, never fewer than 11) and carries one stamp row ahead of its rows: the priced instant, the book's spot, its family and its units. A missing reading is NaN. The chart reads them with the read its own options panes make, and a chain whose data plane serves no views refuses them by name. A hosted run (Run on Cloud, a Protected package) refuses each one by its own name (wrun_option_views_unserved), and an alert refuses options_chain itself, as before.

option_surface takes pick: "nearest_days" keeps, per bar, the expiry nearest days with both wings served (delta 0 the 25 delta wings, the default, 1 the 10 delta ones); "tenor_bracket" keeps the two expiries that bracket tenor days. A served bar where the pick keeps no expiry arrives as one all-zero row (bit 14 set when the bar is partial), so it still reads as served; a bar with no surface arrives empty. option_strikes takes fold: "kit": each bar arrives measured with OptionStrikes' rules (nearest, window_pct required, lens 0 gamma, 1 delta or 2 vega, step_rows required, carry, levels, curve), read with OptionStrikes.loadLevels. curve: true, beside levels: true only, reads each bar at its as-of (the bar's close) over the week of its rows (each expiry still trading then on the market's zone and kind, 7 or fewer trade days out), and adds a curve row after each levels row: the numbers GammaCurve gives over that week, read with gexAtSpot(), gammaRegime(), gammaFlip(), curveSpot() and pricedAtMs() (the as-of). So a package prints net GEX, the regime and the flip off the fold, never off every minute's raw rows. A word or a param outside what it takes is refused by name (wrun_option_knob_invalid), and so is a param no declared view takes.

Large prints (tape)

tape is the celled source behind a big-trades map: the chart market's individual prints at or above a floor, one tuple per print, so where the size hit, and on which side, is a loop inside the indicator. Declare the chart's candles first, then the tape input with its floor:

wrun
const minValue = param("min_value", 100000, { min: 1, description: "Smallest print kept, in US dollars" });
input("close", ohlcv.close);
input("prints", tape.cells, { max_cells: 20000, min_value: minValue, history: "7d" });

Each print occupies four f64 values: [offset_ms, price, size, side]. offset_ms is the print's time minus the bar's open, and side is +1 for a buy and -1 for a sell (the aggressor). size is in the floor's unit, so the indicator compares and draws in the unit it floors by.

  • The floor. A tape input takes exactly one floor:

    • min_value keeps a print whose dollar value reaches it, and size is then each print's dollar value. A dollar means the same on every market, so one default fits a BTC perpetual, an ETH perpetual and a contract-sized future alike.
    • min_size keeps a print whose size reaches it, in the units the venue stores the print in: coins on a spot or linear market, contracts where the venue stores contracts, contracts on CME Group futures. size is then that stored size, so the same min_size means a different amount on each kind of market.
    • min_coins keeps every print of that many coins or more, on a market that counts coins. size is then each print's dollar value, as under min_value, so read coins as size / price. The tape must name coin markets alone: needed_by: { size_unit: [1] }.

    Each floor is a number, or the handle of a param(...): the sheet then records the setting's name, and a change in the settings dialog takes effect without a rebuild. Two floors, or none, refuse wrun_tape_floor_invalid. A value that is not a number above zero refuses wrun_tape_min_value_invalid, wrun_tape_min_size_invalid or wrun_tape_min_coins_invalid, naming the input and the setting.

  • History. history is how far before now the chart seeds prints: "0" (the default) is live only; a duration is digits then s, m, h or d, at most "30d". The chart serves the shorter of history and its own loaded window from the large-print lane, then appends live prints to the forming bar.

  • The server floor. The large-print lane keeps prints of $10,000 or more on markets quoted in USD or a dollar stablecoin, and on CME Group futures the prints at the product's contracts floor (10 ES, 5 NQ, 20 CL, 10 GC). History holds only those prints: a floor below the server's reads history at the server's floor, while live prints keep yours. A min_value floor asks the lane by dollar value. A market quoted in any other currency has no large-print history, and its prints have no dollar value, so a min_value tape reads none of them.

  • Refused charts. A one-second chart and a calendar interval (one month and coarser) refuse a tape input by name before any fetch.

A bar with more prints than max_cells refuses the run, never truncated, so size it for the floor: a lower floor means more prints per bar.

A floor for each kind of market. A tape input after the first input can name the markets it is read on with needed_by: { size_unit: [codes] } (Size units). On any other market it is never fetched and every bar reads zero prints (in_<name>_cells() is 0). Two tapes then split the markets: a dollar floor where the size is coins or shares, and a contracts floor on futures, where the contract is the number a trader reads. market.dollar_multiplier() declares the dollars one size unit is worth at one unit of price (the point value on CME: 50 on ES, 20 on NQ; 1 on a market priced in dollars or a dollar stablecoin; 0 where the host does not know it), so a contracts print can be valued as size times price times that number, the way the dollar tape values its prints:

wrun
const minValue = param.number("min_value", 100000, { min: 1, visible_by: { size_unit: [0, 1, 2] } });
const minContracts = param.number("min_contracts", 10, { min: 1, visible_by: { size_unit: [3] } });
input("close", ohlcv.close);
input("tape", tape.cells, { max_cells: 20000, min_value: minValue, history: "7d", needed_by: { size_unit: [0, 1, 2] } });
input("tape_contracts", tape.cells, { max_cells: 20000, min_size: minContracts, history: "7d", needed_by: { size_unit: [3] } });
market.dollar_multiplier();

Each tape keeps its own floor, judged on every run, even on a market that does not read it. Every other celled source refuses needed_by by name.

A floor in coins. The large-print lane answers by dollar value, so the host asks a min_coins tape in dollars: at min_coins x L x 0.9, where L is the lowest price the market traded at across the window that request reads. That floor is never above min_coins x any price in the window, so no print of min_coins or more is left out; the extra prints just under it are yours to drop by size / price. Each history page prices its own window, and the live leg prices the recent low and asks again when the last price falls below L x 0.9. A host with no price for a window refuses the tape by name (wrun_tape_coins_unpriced) and never guesses one.

A tape picked by a setting. Beside size_unit, a tape's needed_by may name one param.choice of the file with the option indexes it is read under, and the two keys hold together. One setting then picks the tape on a coin market, and the dialog shows only the floor that applies when each floor setting names the same choice in its visible_by:

wrun
param.choice("min_unit", ["Dollars", "Coins"], "Dollars", { label: "Min in", visible_by: { size_unit: [1] } });
const minValue = param.number("min_value", 500000, { min: 1, visible_by: { size_unit: [0, 1, 2], min_unit: [0] } });
const minCoins = param.number("min_coins", 10, { min: 0.0001, visible_by: { size_unit: [1], min_unit: [1] } });
input("close", ohlcv.close);
input("tape", tape.cells, { max_cells: 20000, min_value: minValue, history: "7d", needed_by: { size_unit: [0, 1, 2], min_unit: [0] } });
input("tape_coins", tape.cells, { max_cells: 20000, min_coins: minCoins, history: "7d", needed_by: { size_unit: [1], min_unit: [1] } });

On BTCUSDT, Dollars reads tape and Coins reads tape_coins. On a stock the "Min in" row is hidden, so the choice reads its default, Dollars, whatever was saved, and tape is read (Size units).

US listed options (OPRA)

Five celled sources read the options of the chart's underlying, on a crypto, CME or US stock chart (or an option contract's chart): the prints (option_prints, and option_prints_v2 with each print's block trade and RFQ), each contract's flow (option_contract_flow), the flow the data plane sums by strike, by expiry or by both (option_strike_flow) and the chain summary (option_contract_state). Each reads the chain its venue picks, one book of it, as each bar's strike snapshot (option_strikes) and each expiry's volatility surface (option_surface) do. The scalar flow and statistics sources are in the feed tables. Every one reads the chart's own underlying (a market pin is refused by name, wrun_option_market_pinned).

The numbers are in the chain's units: premium in USD, sizes in the coin on a crypto chain and in contracts on US listed options and CME, prices in USD per unit of the underlying (index points on CME, where market.option_multiplier() gives a contract's dollars). A crypto or CME print carries the taker's side and no quote.

The chart in the browser serves them, the US listed options under the US options access rule and the CME options under the CME rule (Limitations); an alert and a Protected indicator on OpenMarket's servers refuse each one by its own name (wrun_option_prints_unsupported, wrun_option_prints_v2_unsupported, ...).

The present mask and partial bars

Every tuple ends with present, a bitmask stored as a number: a value whose bit is clear was not served and reads 0, never NaN (a cell is always a finite number). Read a bit with hasBit(present, n). Bit 14 is the same on every source: the bar is partial, its block cut down by max_cells, older than the history the data plane keeps, or left unread by the chart's download budget (How much an indicator may download), so treat its totals as a floor; isPartial(present) reads it.

Tickers and option roots ride as one number, a symbol code: 0-9 are 1 to 10, A-Z 11 to 36 and . 37, and a code of up to 10 characters is the sum of each character's value times 38 to the power of the characters after it ("SPY" is 42,899). decodeSymbol(code) gives the text back ("" for anything no text encodes to) and encodeSymbol(text) the code (NaN for a lower-case letter, any other character, or more than 10 characters, never truncated). A contract is (root_code, expiry_ms, side_cp, strike), side_cp +1 a call and -1 a put. A table row or a feed line names a contract or a ticker the same way, for the chart's upcoming row click that opens that market's chart (Rows that open a market).

The tuples

SourceTupleBits of present
option_prints[offset_ms, print_key, root_code, expiry_ms, side_cp, strike, price, size, premium, aggressor, outside, underlying, iv, delta, venue, present]0 iv, 1 delta, 2 underlying, 3 the side is known, 4 the underlying is a forward
option_prints_v2[offset_ms, print_key, root_code, expiry_ms, side_cp, strike, price, size, premium, aggressor, outside, underlying, iv, delta, venue, block_key, rfq_key, legs, present]0 to 4 as on option_prints, 5 a block trade, 6 an RFQ, 7 the leg count is known
option_contract_flow[root_code, expiry_ms, side_cp, strike, vol_ask, vol_bid, vol_mid, vol_none, prem_ask, prem_bid, share_delta_net, vwap, last_price, iv_last, vol_above_ask, vol_below_bid, present]0 vwap, 1 iv_last, 2 share_delta_net
option_contract_state[root_code, expiry_ms, side_cp, strike, bid, ask, last, prev_close, theta, volume_day, oi, oi_prev, present]4 bid to 11 oi_prev, each bit its column
option_strike_flow[expiry_ms, strike, side_cp, dte_class, vol_ask, vol_bid, vol_mid, vol_none, vol_above_ask, vol_below_bid, prem_ask, prem_bid, prem_mid, prem_none, present]14 alone: every value is served (a sum over no print is 0)

option_prints

One tuple per print at or above min_premium (required, USD), on the bar it printed in. print_key identifies the print on history and live alike. On US listed options aggressor is +1 at the ask, -1 at the bid, 0 at the mid and 2 with no quote, and outside is +1 above the ask, -1 below the bid, 0 inside; on a crypto or CME chain aggressor is the taker's side (+1 bought, -1 sold) and outside is 0. Bit 3 says the side is known (a valid quote on US listed options). price is in USD per unit of the underlying (index points on CME), size in the coin on a crypto chain and in contracts elsewhere, premium in USD; underlying is the venue's index on a crypto chain and the future on CME; venue is the exchange's number. history is "live" (the default), "3d" (every print of the last three days) or "90d" (up to 90 days of the large prints, premium 25,000 USD and up, or size 150 and up on US listed options and CME: an older bar below that floor is partial). overflow: "largest" keeps a busy bar's max_cells prints with the largest premium and sets bit 14 on its first kept print instead of refusing the run. venue and book pick the chain and its book, as on the option surface. A package reads one feed of prints: two option_prints inputs with different knobs are refused by name (wrun_option_prints_one_acquisition).

The data plane also cuts and filters the prints before they reach the chart, so a bar carries only what the indicator draws:

KnobTakesKeeps
newest0 to 20,000also the window's N newest prints (0, the default: no newest cut)
newest_tail_ms0 to 60,000, beside newest, never beside overflow: "largest"also every print up to that many ms before the oldest newest print (the other legs of an order the cut would split)
types"both" (the default), "calls", "puts"the calls, the puts or both
sidesa list of "ask", "bid", "mid", "none"the prints on those sides of the quote (an empty list, the default, keeps every side)
moneyness"all" (the default), "otm", "itm"the prints out of or in the money
max_dte0 to 3,650the prints expiring within that many days (0, the default, keeps every expiry)

With overflow: "largest" the data plane keeps each bar's largest prints itself, so a busy bar arrives already cut to max_cells and still sets bit 14. The per-bar sums of every passing print, not just the kept ones, come from options_flow with scope: "prints" and the same floor:

wrun
input("prints", option_prints.cells, { max_cells: 16, min_premium: 25000, history: "90d", overflow: "largest", types: "calls" });
input("bull", options_flow.call_prem_ask, { scope: "prints", min_premium: 25000, missing: "nan" }); // every call print of 25,000 and up at the ask, summed per bar

overflow: "largest" beside newest N reads the union: each bar holds its max_cells largest prints and every print of the window's N newest that falls in it, each once, in time order. The window's newest are ranked by time, then by print key. The block then holds up to max_cells + N prints, and in_<name>_capacity counts that many, so size your buffers with it. The build writes that number on the sheet as the input's capacity, and the chart hands a bar's block to the indicator up to it: an indicator built before the field existed names none, so its bars keep their max_cells largest, as before the union. Rebuild it to read the union whole. Bit 14 marks a bar past max_cells prints, up to and including the bar that holds the N-th newest print; a newer bar holds only newest prints and is never marked. newest_tail_ms beside overflow: "largest" is refused by name (wrun_option_prints_tail_largest), because a tail would lift that bound. A table of the newest prints and marks of each bar's largest read one input:

wrun
input("prints", option_prints.cells, { max_cells: 16, newest: 2000, min_premium: 25000, history: "3d", overflow: "largest" });

option_contract_flow

One tuple per contract that traded in the bar: contracts by side, premium at the ask and the bid, the net share delta, the VWAP, the last price and IV, and the contracts printed outside the quote. On a crypto or CME chain the side is the taker's (vol_ask and prem_ask bought, vol_bid and prem_bid sold) and vol_mid, vol_none, vol_above_ask and vol_below_bid read 0; the sizes are in the coin on a crypto chain and in contracts elsewhere, vwap and last_price in USD per unit of the underlying. min_volume drops a contract below that many contracts; expiries and strike_window_pct narrow the chain, venue and book pick it. min_premium drops a contract whose premium in the bar, its four sides summed, is below that many USD; it is never beside strike_window_pct (the window is judged around the bar's underlying over every contract). span: "session" sums each trade date into one block on the bar of its first open instead of one block per bar, and history: "today" reads the newest trade date only. A ranked table of the forming bar beside the day's totals reads two inputs:

wrun
input("bar", option_contract_flow.cells, { max_cells: 6000, history: "today", min_premium: 25000 });
input("day", option_contract_flow.cells, { max_cells: 6000, history: "today", span: "session" });

option_prints_v2

The prints of option_prints, the same fifteen values in the same columns, with three more before present: block_key, the block trade the print belongs to (0 for a screen print), rfq_key, the RFQ that filled it (0 for none), each hashed as print_key is, and legs, the structure's leg count (1 for a single print, 0 when unknown). Bits 5, 6 and 7 of present say each one is known. structure keeps "all" prints (the default), "blocks" (every leg of each block trade) or "rfq" (the prints an RFQ filled); min_premium still judges each print, so read every leg of a block over a floor with "blocks" and a low floor. It takes the other knobs of option_prints, which keeps its 16 values: a package reads the identity by moving to this source. The servers refuse it by its own name (wrun_option_prints_v2_unsupported).

wrun
// Deribit's block trades on a BTC chart: every leg, from 1,000 USD of premium
input("close", ohlcv.close);
input("blocks", option_prints_v2.cells, { max_cells: 400, min_premium: 1000, structure: "blocks", venue: "deribit" });

Each print is 19 values (OPTION_PRINTS_V2_TUPLE in ./sdk/options): step the block by it and read block_key at offset 15, rfq_key at 16 and legs at 17.

option_strike_flow

The flow of the chart's underlying summed by the data plane, one tuple per group of each bar: per strike (group: "strike"), per expiry (group: "expiry") or per expiry and strike (group: "expiry_strike"), by option type. group and max_cells are required. expiry_ms is 0 on a strike row and strike 0 on an expiry row; side_cp is +1 a call and -1 a put; dte_class is 0 unless the row is split. The contracts and the premium are by the print's side against the quote, the contracts above the ask and below the bid beside them. venue and book pick the chain, as on the other celled sources; on a crypto or CME chain the side is the taker's and the mid, none, above-ask and below-bid columns read 0, the contracts in the coin on a crypto chain.

KnobTakesShapes
expiries"all" (the default), "0dte", "after_today", or "nearest:N" on the expiry and expiry_strike groupsthe expiries summed
strike_window_pctabove 0, at most 100 (strike and expiry_strike)the strikes within that many percent of the bar's underlying
strike_rows1 to 200 (strike and expiry_strike)the N strikes nearest the underlying, after the window
split_dtetrue or false (strike)each strike as a 0DTE row (dte_class 1) and an after-today row (2)
fold_typestrue or false (strike)calls and puts in one row per strike (side_cp 0): the ask columns carry the bullish side (call ask plus put bid, calls above the ask plus puts below the bid), the bid columns the bearish side
span"bar" (the default) or "session"one block per bar, or one per trade date on the bar of its first open
history"window" (the default) or "today"the chart's window, or the newest trade date only
min_volumeabove 0the rows of at least that many contracts

A knob of one group's shape beside another group is refused by name (wrun_option_knob_invalid). A partial bar sets bit 14 on its first tuple; a partial bar with no row carries one all-zero tuple with bit 14, so test the bit, never a zero strike (an expiry row has strike 0). OPTION_STRIKE_FLOW_TUPLE in ./sdk/options is the width.

The data plane holds 1-minute rows for 7 days and 5-minute rows for 30 days on every group; 30-minute rows are kept on the strike and expiry groups and held 30 days on expiry_strike. The chart reads the coarsest of them that divides its bar, and a session span the 30-minute rows.

wrun
input("by_strike", option_strike_flow.cells, { max_cells: 64, group: "strike", strike_window_pct: 10, strike_rows: 48, fold_types: true });
input("by_expiry", option_strike_flow.cells, { max_cells: 128, group: "expiry", span: "session" });

option_contract_state

The chain summary of each contract of one book with the prior session's close (prev_close) and the prior open interest (oi_prev). Like the options chain it is a snapshot of now, so it fills the newest bar only: read it on bar.isLast(). An options_chain input beside it is a separate read. The sizes (volume_day, oi, oi_prev) are in the chain's own size: the coin on a crypto chain, contracts on US listed options and CME. The prices (bid, ask, last, prev_close) are in USD per unit of the underlying on every chain: a book quoted in the coin is converted with the row's own underlying price, and its prior close (the prior UTC day's on a crypto chain) with that day's close; a price that cannot be stated so is absent, its bit clear. Knobs: venue and book (as on the option surface), expiries, strike_window_pct, max_cells.

The knobs

expiries is "all" (the default), "nearest:N" (the N nearest live expiries) or "0dte" (the expiries on the bar's own trade date), and on option_strike_flow also "after_today"; strike_window_pct keeps the strikes within that many percent of the underlying, above 0 and at most 100; structure (option_prints_v2 only) is "all", "blocks" or "rfq". A word outside those, a missing min_premium and a knob on a source that does not take it are refused by name. A busy chain is large: size max_cells for the strikes and expiries you keep.

Knobs from a setting

A few knobs take a setting in place of a value, the way the tape's floor does: write "@<setting>", the sheet records the setting's name, and the chart reads the setting on every run, so a change in the settings dialog fetches again without a rebuild. The setting's default is the value a run starts with, so it must be a legal value of the knob.

KnobSourcesThe setting
min_premiumoption_prints, option_prints_v2, option_contract_flow, options_flow (scope "prints")a number, int or price
max_dteoption_prints, option_prints_v2, options_flow (scope "prints")a number, int or price
newest_tail_msoption_prints, option_prints_v2a number, int or price
strike_rowsoption_strike_flowa number, int or price
types, moneynessoption_prints, option_prints_v2a param.choice whose picks are the knob's words
expiriesoption_strike_flowa param.choice whose picks are "all", "0dte" or "after_today" ("nearest:N" stays a literal)
sidesoption_prints, option_prints_v2a param.multi whose options are side words (the picked options are the list)
underlyingoptions_chain, option_strikes, options_flow (scope "ticker" or "prints")a param.choice whose picks are "auto", "derived" or roots in capitals, each once

A choice's pick is a word in one of two ways. A choice with style_values gives each pick its style_values word, so the dialog keeps its own labels. A choice without them gives each pick its label, so the labels must be the words.

wrun
param.number("min_premium", 25000, { min: 10000, max: 1000000000, label: "Smallest premium, USD" });
param.choice("types", ["both", "calls", "puts"], "both", { label: "Calls or puts" });
param.int("strikes", 17, { min: 5, max: 41, label: "Strike rows" });
param.choice("expiries", ["every expiry", "0DTE only", "after today"], "every expiry", { label: "Expiries", style_values: ["all", "0dte", "after_today"] });
input("prints", option_prints.cells, { max_cells: 16, min_premium: "@min_premium", history: "3d", overflow: "largest", types: "@types" });
input("by_strike", option_strike_flow.cells, { max_cells: 128, group: "strike", strike_window_pct: 25, expiries: "@expiries", strike_rows: "@strikes" });

A name that is no declared setting of that kind, a choice whose picks are not the knob's words, or a default that is no legal value is refused when the package builds (wrun_option_knob_invalid, the input and the setting named).

Reading the cells

The front expiry's net share delta from the contracts that traded, and the premium bought at the ask minus the premium sold at the bid, per bar:

input("close", ohlcv.close);
input("flow", option_contract_flow.cells, { max_cells: 400, expiries: "nearest:1", strike_window_pct: 10 });
input("prints", option_prints.cells, { max_cells: 500, min_premium: 25000, history: "3d", overflow: "largest" });
output("share_delta", line, lower, { description: "Net share delta of the front expiry's contracts that traded, shares" });
output("net_premium", histogram, lower, { description: "Premium bought at the ask minus premium sold at the bid, USD" });
output("partial", none, lower, { description: "1 on a bar whose prints were cut down to max_cells" });

function onBar(): void {
  const n = in_flow_cells();
  if (n > 0) {
    const flow = in_flow_view();
    let delta = 0.0;
    for (let i = 0; i + 16 < n; i += 17) {
      if (hasBit(flow[i + 16], 2)) delta += flow[i + 10]; // bit 2: share_delta_net is served
    }
    out_share_delta(delta);
  }
  const m = in_prints_cells();
  if (m <= 0) return;
  const prints = in_prints_view();
  let net = 0.0;
  let partial = 0.0;
  for (let i = 0; i + 15 < m; i += 16) {
    const premium = prints[i + 8];
    const aggressor = prints[i + 9];
    if (aggressor == 1.0) net += premium;
    else if (aggressor == -1.0) net -= premium;
    if (isPartial(prints[i + 15])) partial = 1.0;
  }
  out_net_premium(net);
  out_partial(partial);
}

Earnings dates

Three market facts carry the underlying's earnings report, declared like the other market.* words and read once in onStart(): market.earnings_next_ms() and market.earnings_prev_ms() (epoch milliseconds, read through earningsMs(p_market_earnings_next_ms()), which reads NaN when the chart does not know the date) and market.earnings_session() (1 before the open, -1 after the close, 0 unknown). They are upcoming: no surface fills them yet, and the chart fills them on a US stock chart once its lanes ship. Earlier reports are not served.

The option multiplier

market.option_multiplier() is the US dollars one unit of an option's price times one unit of its size is worth on the chart's options chain, so a premium is size times price times the multiplier in the units each source serves: 100 on US listed options (a contract is 100 shares), the root's point value on CME (50 on ES, 20 on NQ), 1 on a crypto chain (prices in USD per coin, sizes in coin). Declare it like the other market.* words and read it once in onStart() through p_market_option_multiplier(). The chart fills it; every other host writes 0, which means unknown: draw no premium then (read it as NaN), never a premium of 0.

The worked footprint example

The vp-buy-share-codefirst template is the footprint loop end to end: a celled volume_profile input read through its view and its cell count, and the buy share of each bar's profile as a numeric output. The whole file (code-first, so the sheet is derived):

input("close", ohlcv.close); // the first input is the bar grid: the chart's own candles
input("profile", volume_profile.cells, { max_cells: 8192 });
output("buy_share", line, lower, { label: "Buy share", format: "%", decimals: 1 });

function onBar(): void {
  const n = in_profile_cells(); if (n <= 0) return; // no profile on this bar: nothing is drawn
  const cells = in_profile_view(); // this bar's cells, four numbers each: low, high, buy, sell
  let buy = 0.0; let sell = 0.0;
  for (let i = 0; i + 3 < n; i += 4) { buy += cells[i + 2]; sell += cells[i + 3]; }
  if (buy + sell <= 0.0) return;
  const share = (100.0 * buy) / (buy + sell);
  out_buy_share(share);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

To run it, open the editor, click the Templates icon ("Browse starter templates") in the Explorer, pick VP Buy Share under Order flow, and press Run. A bar whose profile splits 60/40 to the buy side computes buy_share = 60, and a bar with no profile draws nothing. A book-driven variant loops over book.cells the same way.

How many sources you can open

On the chart a wrun indicator you add counts against your plan's per-chart indicator limit by the number of distinct sources it reads, where a source is the source name plus its pinned market: close, high and volume of the chart's own candles count once, and a pinned ohlcv input on another market counts again. Inside the indicator a derived value (an average of an input) costs nothing, since it is your arithmetic, and two inputs with the same source, market and knobs are two declarations over one feed. The practical cost of each extra source is fetch time over the loaded window (a coarse interval pin widens its fetch by two of its candles, and bars by as many as it asks). The one hard ceiling inside the module is on the other side: it may write at most 256 output slots.

How much an indicator may download

One indicator add may download at most 1 MB, every input together, on the chart's standard window: 252 bars at 1h and at 5m, the warm-up added, on a US stock's regular session, on CME and on crypto. What an input asks for sets the download, not what the indicator draws: an input that asks for every minute of each bar, every contract of a chain or thousands of prints a bar downloads all of them, even when the indicator keeps one row.

The check is arithmetic over the declared inputs, before any chart runs them. Each input costs bars served x reads per bar x rows per read x values per row x 8 bytes, charged at its caps: max_cells rows a bar, the history its source keeps (10 days of strike rows, 3 days of prints, 90 days of prints of 25,000 and up, 30 days of contract flow by five minutes), and every knob a setting drives at the end of the setting's range that downloads the most. A read the data plane bounds itself is charged at that bound instead of its caps: a strike kit fold at its levels row, its curve row and the strikes its window draws (twice over with carry, once for each book of a crypto coin), a view or a surface pick at the rows it answers, and a US stock's 09:30 hour at one row a contract, the gateway's sum of its five-minute buckets. An input the market in front of you does not serve, or a setting switches off, is charged anyway; one the chart's interval switches off (chart_interval_below) costs nothing on that window. The inputs add up, and the costliest of the six windows is the one judged.

A cut bounds an input by the picture instead of by the chart's length or the chain's size:

CutKnobBounds
newestnewest (with newest_tail_ms) on the print sourcesthe window's N newest prints
per-bar capoverflow: "largest" with a small max_cellseach bar's rows
foldfold: "kit", pick, strike_rows, a fold view (totals, strike_change, oi_board)each bar's rows, summed by the data plane
viewa projection view (atm, window, top, traded)the view's rows
today, sessionhistory: "today", span: "session"the newest session, or one block a session

The rows a bar that fit 1 MB over 265 bars, by the values each row carries:

Values a row4 (profile, tape)12 (strike rows)14 (kit rows)15 (strike flow)16 (prints)17 (contract flow)
Rows a bar1173933312927

Every build and publish reports the worst window, for example Download when a chart adds it: at most 0.84 MB of 1 MB (worst: 5m on a US stock chart; option_contract_state 0.70 MB, option_surface 0.11 MB). A build over the budget warns and still runs, so you can keep iterating; a publish over it is refused with wrun_download_over_budget, naming the window, the input that costs most with its arithmetic, and the cut that fixes it. No package skips the check: the OpenMarket templates that were over the budget when it came in publish under a named exception until their fix lands.

Availability

The editor accepts any declared source and field the kit knows; whether the chart can serve it on the market in front of you is answered when you press Run, by name, never with silent empty data. A source the chart cannot serve there shows a Could not load chip on the indicator's legend with the reason and a Retry button, and the editor's Console shows the same sentence. On a one-second chart, sources the chart does not serve at one second are declined. Where each part of an indicator runs, and what an alert can evaluate, is on Execution model.