Contract odds

View as MarkdownOpen the editor

Before you trade one option, Contract Odds answers two questions: will it make money, and how much should you stake?

Pick a call (a bet on a rise) or put (a bet on a fall), long (bought) or short (sold). Then set its strike (the option's price level) and expiry (the day the option ends), or leave them at 0. A card leads with the chance of profit and a stake from the Kelly rule (a bet-size formula). It needs this symbol's options, and its odds are the market's price, not a forecast.

Under the hood: the probability of profit is lognormal from the contract's IV. On a stock it adds a risk-neutral drift at the rate, and none on a futures or crypto forward. The premium is the Premium setting, else the chart's close on the contract's own chart, else the Black-Scholes or Black-76 model price. Kelly is p - (1 - p) / odds, with odds the most it can make over the most it can lose and no volatility adjustment. It reads the options_chain.cells contract page view on the live bar (Data sources, Chain page views). It keeps only the contracts at the strike nearest the one set, of the type and the expiry set. It prices them with the options kit's Greeks, normCdf, optionsAsOfMs, optionsLiveUntilMs, optionsYearsToGo and optionsTradeDay (Options kit). It names the expiry through TextBuilder.expiry (A second builder). It takes the contract from a price and a date setting (Kinds of setting). It draws a render.hud card with no look word over data-only outputs and five text slots (HUD cards, The default look). It is also the contract-odds template, the Contract Odds card under HUDs in the editor's starter list, which compiles as written.

The wrun indicator

// Contract Odds: the odds that one option trade makes money, read from this symbol's options. You pick its strike (the
// option's price level), expiry (the day the option ends), call or put, long or short. A card leads with the chance of
// profit and the bankroll share the Kelly rule (a bet-size formula) stakes. Under it come the breakeven, the premium
// (the money paid for an option) and the best and worst case. The breakeven is the price where the trade neither wins
// nor loses at expiry. The chance comes from implied volatility (how big a move option prices expect). Use it before
// you place a trade: its odds are the market's, not a forecast.
//
// Technical notes: one option contract of the chart's own chain held to its expiry, read as odds. A card at the bottom
// of the pane answers one question first: what are the odds this trade makes money, and how much of a bankroll would
// Kelly put on it? Under the answer: the probability of profit at expiry, the breakeven, the premium and where it came
// from, the most the position can make and lose per contract, the odds ratio and the Kelly fractions (full, half and
// quarter).
// The chart does not tell an indicator which contract it shows, so the settings name it: the strike (0 = the strike
// nearest the expiry's forward), the expiry (0 = the first expiry after today), call or put, long or short, and the
// premium (0 = the chart's close on the contract's own chart, else the model price from the contract's IV). The
// probability is lognormal from the contract's IV, with a risk-neutral drift at the rate on a stock (none on a futures
// or crypto forward). Kelly is p - (1 - p) / odds, odds the most it can make over the most it can lose: an unlimited
// gain reads p, an unlimited loss no edge; full Kelly here takes no volatility adjustment (1). The chain rides the
// live bar only: history bars draw nothing, and everything is measured on the last bar at the chain's as-of (the live
// bar's close), an OPRA contract live and priced until 15 minutes past its 16:00 stamp.

section("Contract");
param.price("strike", 0.0, { min: 0, label: "Strike", description: "The strike, the option's price level. 0 picks the listed strike nearest the forward price, today's price carried to that expiry." });
param.time("expiry", 0, { label: "Expiry date", description: "The expiry, the date the option ends. 0 picks the first expiry after today." });
param.choice("type", ["call", "put"], "call", { label: "Type" });
param.choice("position", ["long", "short"], "long", { label: "Position", description: "long: you buy the option and pay the premium (the money paid for an option). short: you sell it and collect the premium." });
param.number("premium", 0, { min: 0, label: "Premium", description: "The premium (the money paid for an option), per unit, that you paid or got. At 0 it uses the close when this chart is the option's own. Elsewhere 0 uses a formula price from implied volatility." });
param.number("rate_pct", 4, { min: 0, max: 20, step: 0.25, label: "Rate, percent", description: "The interest rate for the model price and a stock's expected drift. Crypto options always price at 0." });
input("close", ohlcv.close); // the chart's own close: the premium on the contract's own chart, spot where a contract reports none
input("chain", options_chain.cells, { max_cells: 16000, venue: "auto", page_view: "contract", expiry_day: "@expiry", side: "@type", strike: "@strike", rate: "@rate_pct", description: "This symbol's options. US listed options on a US stock or its options, CME options on a future, Deribit on BTC and ETH. Only the contracts at the strike nearest yours, of your type and expiry." }); // [strike, expiry_ms, side, oi, gamma, delta, mark_iv, underlying, multiplier, vega] per contract, in the chain's order
market.zone(); // the market's clock: 0 UTC (crypto), 1 New York (US stocks), 2 Chicago (CME): the calendar, the liveness and the model
chart.interval_sec(); // the bar's length: the chain's as-of is the live bar's close time, the block naming none
// The readings, data-only: the card's tiles read them and the Console can too. Each is NaN on history bars.
output("matched_strike", none, overlay, { description: "The strike of the option the card reads. Live candle only." });
output("expiry_days", none, overlay, { description: "Days to the option's expiry on the market's own calendar, 0 on the expiry day." });
output("contract_iv", none, overlay, { description: "The option's implied volatility (IV), the yearly move size its price assumes, in percent." });
output("premium_used", none, overlay, { description: "The premium (the option's price per unit) the card uses. premium_source says where it came from." });
output("premium_source", none, overlay, { description: "Where the premium came from: 0 the Premium setting, 1 the chart's close, 2 the model price" });
output("breakeven", none, overlay, { description: "The market's price at expiry where the trade breaks even. It is the strike plus the premium on a call, minus it on a put." });
output("prob_profit", none, overlay, { description: "The odds this trade makes money at expiry, in percent, from the option's IV. Market odds, not a forecast." });
output("max_gain", none, overlay, { description: "The most one contract can make at expiry, in dollars. Empty when unlimited." });
output("max_loss", none, overlay, { description: "The most one contract can lose at expiry, in dollars. Empty when unlimited." });
output("odds_ratio", none, overlay, { description: "Max gain divided by max loss. Empty when either is unlimited." });
output("kelly_full", none, overlay, { description: "Full Kelly: the share of your bankroll the Kelly rule stakes on this edge, in percent. It is p - (1 - p) / odds, with no volatility adjustment. Empty when the loss is unlimited." });
output("kelly_half", none, overlay, { description: "Half of full Kelly, in percent." });
output("kelly_quarter", none, overlay, { description: "A quarter of full Kelly, in percent." });
output("tone", none, overlay, { description: "The headline's tone: 0 no edge (Kelly at or below 0), 1 no reading, 2 an edge. Live candle only." });
string("read", { max_bytes: 64 }); // the headline: the position, its odds and half Kelly, or why there is no reading
string("title", { max_bytes: 48 }); // the card's title: the contract, its expiry and the days to go
string("premium_text", { max_bytes: 40 }); // the premium and where it came from
string("gain_text", { max_bytes: 24 }); // dollars, or unlimited
string("loss_text", { max_bytes: 24 });

// The card: the odds lead as the headline; the title names the contract. A tile's label is fixed text, so the
// premium's source and an unlimited gain or loss ride string slots.
render.hud("odds", {
  position: "bottom_center",
  title: "{{title}}",
  columns: 2,
  tiles: [
    tile.pill("Odds", "read", { headline: true }),
    tile.value("Probability of profit", "prob_profit", { format: "%" }),
    tile.value("Breakeven", "breakeven", { format: "price" }),
    tile.rows([
      ["Premium", "premium_text"],
      ["Max gain", "gain_text"],
      ["Max loss", "loss_text"],
      ["Odds ratio", "odds_ratio", "0.00"],
      ["Full Kelly", "kelly_full", "%"],
      ["Half Kelly", "kelly_half", "%"],
      ["Quarter Kelly", "kelly_quarter", "%"],
      ["Implied volatility", "contract_iv", "%"],
    ]),
  ],
});

const TUPLE = 10; // f64s per contract: strike, expiry_ms, side, oi, gamma, delta, mark_iv, underlying, multiplier, vega
const MIN_T_MS = 900000.0; // 15 minutes: a contract closer to its expiry prices no time left, as the chart's greeks do
const greeks = new Greeks(); // the model price; allocated once
const expiryText = new TextBuilder(16); // the expiry's label, the kit's spelling, copied into the title

let pickStrike = 0.0; // settings, read in onStart()
let pickDay: f64 = NaN; // the picked expiry's date, days since 1970-01-01; NaN = the first expiry after today
let isCall = true;
let isLong = true;
let pickPremium = 0.0;
let rate = 0.04;
let zone = 0;
let intervalMs = 0.0; // the bar's length in milliseconds; 0 where the host writes none
let nowMs: f64 = NaN; // the chain's as-of, the live bar's close
let close: f64 = NaN; // this bar
let t: f64 = NaN;
let why = ""; // the no-reading line, set by measure()
let matched = false; // a contract was matched on the live bar
let strike: f64 = NaN; // the readings, measured on the live bar
let expiryMs: f64 = NaN;
let days: f64 = NaN;
let ivPoints: f64 = NaN;
let premium: f64 = NaN;
let source = 0;
let breakeven: f64 = NaN;
let prob: f64 = NaN;
let gain: f64 = NaN; // dollars; Infinity when unlimited
let loss: f64 = NaN;
let kelly: f64 = NaN; // raw Kelly as a fraction; -Infinity when the loss is unlimited

function onStart(): void {
  pickStrike = p_strike();
  pickDay = p_expiry() > 0.0 ? Math.floor(p_expiry() / 86400.0) : NaN; // the picker's UTC date
  isCall = p_type() == 0.0;
  isLong = p_position() == 0.0;
  pickPremium = p_premium();
  zone = i32(p_market_zone());
  intervalMs = p_chart_interval_sec() * 1000.0;
  rate = zone == 0 ? 0.0 : p_rate_pct() / 100.0; // crypto chains are quoted at a rate of 0
}

function fin(v: f64): f64 { // an output never carries an infinity: NaN stands for "unlimited" and "none"
  return isFinite(v) ? v : NaN;
}

// ── The contract: the expiry, then the strike on the picked side ──
function pickExpiry(cells: StaticArray<f64>, n: i32, nowMs: f64, todayKey: f64): f64 { // the expiry the settings name; NaN when the chain lists none
  let best = Infinity;
  for (let i = 0; i + TUPLE - 1 < n; i += TUPLE) {
    const e = cells[i + 1];
    if (!(cells[i] > 0.0) || !(optionsLiveUntilMs(e, zone) > nowMs) || e >= best) continue; // live: still trading at the as-of
    const day = optionsTradeDay(e, zone); // a calendar question: the expiry's trade date on the market's own clock
    if (isNaN(pickDay) ? day > todayKey : day == pickDay) best = e;
  }
  return best == Infinity ? NaN : best;
}
function pickContract(cells: StaticArray<f64>, n: i32, expiry: f64, nowMs: f64): i32 { // the cell index of the contract; -1 when the side lists none
  let at = -1;
  let gap = Infinity;
  for (let i = 0; i + TUPLE - 1 < n; i += TUPLE) {
    if (cells[i + 1] != expiry || !(cells[i] > 0.0) || (cells[i + 2] > 0.0) != isCall) continue;
    let target = pickStrike;
    if (!(target > 0.0)) { // the strike nearest the expiry's forward: spot carried at the rate on a stock, the underlying itself elsewhere
      const under = cells[i + 7] > 0.0 ? cells[i + 7] : close;
      target = zone == 1 ? under * Math.exp(rate * optionsYearsToGo(expiry, nowMs, zone)) : under;
    }
    const d = Math.abs(cells[i] - target);
    if (d < gap || (d == gap && at >= 0 && cells[i] < cells[at])) {
      gap = d;
      at = i;
    }
  }
  return at;
}

// ── The odds, measured on the live bar ──
function measure(n: i32): void {
  const cells = in_chain_view(); // the live chain in place: the first n values of the build's own buffer
  nowMs = optionsAsOfMs(t * 1000.0, intervalMs); // the chain's as-of: the live bar's close time
  const todayKey = optionsTradeDay(nowMs, zone);
  matched = false;
  let live = false;
  for (let i = 0; i + TUPLE - 1 < n; i += TUPLE) if (cells[i] > 0.0 && optionsLiveUntilMs(cells[i + 1], zone) > nowMs) live = true;
  if (!live) {
    why = "No options still trading";
    return;
  }
  expiryMs = pickExpiry(cells, n, nowMs, todayKey);
  if (isNaN(expiryMs)) {
    why = isNaN(pickDay) ? "No expiry after today" : "No expiry on the picked date";
    return;
  }
  const at = pickContract(cells, n, expiryMs, nowMs);
  if (at < 0) {
    why = isCall ? "No call listed at that expiry" : "No put listed at that expiry";
    return;
  }
  matched = true;
  strike = cells[at];
  days = optionsTradeDay(expiryMs, zone) - todayKey;
  ivPoints = cells[at + 6] > 0.0 ? cells[at + 6] : NaN; // mark IV rides the chain in percentage points
  const spot = cells[at + 7] > 0.0 ? cells[at + 7] : close;
  const multiplier = cells[at + 8] > 0.0 ? cells[at + 8] : 1.0;
  const left = optionsLiveUntilMs(expiryMs, zone) - nowMs; // to the expiry's end: 16:15 New York on OPRA
  const years = left < MIN_T_MS ? 0.0 : left / OPTIONS_YEAR_MS;
  const sigma = ivPoints / 100.0;
  const side = isCall ? 1.0 : -1.0;
  // The premium: the setting, else the chart's close on the contract's own chart (a close far from the underlying is
  // the option's own price), else the model price from the contract's IV.
  if (pickPremium > 0.0) {
    premium = pickPremium;
    source = 0;
  } else if (close > 0.0 && Math.abs(close / spot - 1.0) > 0.2) {
    premium = close;
    source = 1;
  } else {
    premium = zone == 1 ? greeks.spot(side, spot, strike, years, sigma, rate) : greeks.forward(side, spot, strike, years, sigma, rate);
    source = 2;
  }
  breakeven = isCall ? strike + premium : strike - premium;
  // The probability the underlying ends past the breakeven: lognormal at the IV, drifting at the rate on a stock's spot,
  // not at all on a forward; at expiry the answer is spot's own side of it.
  const drift = zone == 1 ? rate : 0.0;
  let above: f64 = NaN; // P(underlying at expiry > breakeven)
  if (isNaN(breakeven)) above = NaN; // no premium (a contract without IV on the underlying's chart): unavailable
  else if (breakeven <= 0.0) above = 1.0;
  else if (years == 0.0) above = spot > breakeven ? 1.0 : 0.0;
  else if (sigma > 0.0) above = normCdf((Math.log(spot / breakeven) + (drift - 0.5 * sigma * sigma) * years) / (sigma * Math.sqrt(years)));
  const longWins = isCall ? above : 1.0 - above;
  prob = isLong ? longWins : 1.0 - longWins;
  // Per contract at expiry: a long pays the premium and a short collects it; a call's upside has no ceiling, a put's
  // stops at the strike less the premium.
  const capped = (strike - premium) * multiplier; // a put held to a worthless underlying
  const paid = premium * multiplier;
  if (isLong) {
    gain = isCall ? Infinity : capped;
    loss = paid;
  } else {
    gain = paid;
    loss = isCall ? Infinity : capped;
  }
  const odds = gain / loss;
  if (isNaN(prob) || isNaN(odds)) kelly = NaN;
  else if (odds == Infinity) kelly = prob; // nothing to lose against an unlimited gain: Kelly reads p
  else if (!(odds > 0.0)) kelly = -Infinity; // nothing to win, or an unlimited loss: no edge
  else kelly = prob - (1.0 - prob) / odds;
}

// ── Text helpers ──
function sbGrouped(n: i64): void { // 84210 -> 84,210
  if (n >= 1000) {
    sbGrouped(n / 1000);
    sb_text(",");
    const r = n % 1000;
    if (r < 100) sb_text("0");
    if (r < 10) sb_text("0");
    sb_int(r);
  } else sb_int(n);
}
function sbPrice(v: f64): void { // decimals follow the price's size: 67,000 / 660.50 / 4.125
  if (v >= 1000.0) sbGrouped(i64(Math.round(v)));
  else if (v >= 100.0) sb_f64(v, 2);
  else sb_f64(v, 3);
}
function sbDollars(v: f64): void { // $65,590, or unlimited
  if (!isFinite(v)) {
    sb_text("unlimited");
    return;
  }
  if (v < 0.0) {
    sb_text("-");
    v = -v;
  }
  sb_text("$");
  sbGrouped(i64(Math.round(v)));
}
function sbContract(): void { // 660 call, 662.50 put
  if (strike == Math.floor(strike)) sbGrouped(i64(strike));
  else sbPrice(strike);
  sb_text(isCall ? " call" : " put");
}
function writeWords(): void {
  sb_clear();
  sb_text(isLong ? "Long " : "Short ");
  sbContract();
  if (isNaN(prob)) sb_text(": no implied volatility");
  else {
    sb_text(": ");
    sb_f64(prob * 100.0, 1);
    sb_text("% to profit, ");
    if (kelly > 0.0) {
      sb_text("half Kelly ");
      sb_f64(kelly * 50.0, 1);
      sb_text("%");
    } else sb_text("no edge");
  }
  str_read_sb();
  sb_clear();
  expiryText.clear().expiry(expiryMs, nowMs, zone); // the expiry's trade date: 16 Oct, or 15 Jan '27 in another year
  for (let i = 0; i < expiryText.length(); i += 1) sb_char(load<u8>(<usize>expiryText.ptr() + <usize>i));
  sb_text(" ");
  sbContract();
  sb_text(", ");
  sb_int(i64(days));
  sb_text("d");
  str_title_sb();
  sb_clear();
  if (isNaN(premium)) sb_text("no price");
  else {
    sbPrice(premium);
    sb_text(source == 0 ? ", your premium" : source == 1 ? ", the chart's close" : ", the model price");
  }
  str_premium_text_sb();
  sb_clear();
  if (isNaN(gain)) sb_text("-");
  else sbDollars(gain);
  str_gain_text_sb();
  sb_clear();
  if (isNaN(loss)) sb_text("-");
  else sbDollars(loss);
  str_loss_text_sb();
}

// onBar() runs once per bar: history rows carry an empty block and cost one read; the live bar matches the contract and
// measures its odds, then writes the readings (NaN on history rows) and the card's words.
function onBar(): void {
  close = bar.close();
  t = bar.time();
  let chainCells = -1;
  matched = false;
  if (bar.isLast()) {
    chainCells = in_chain_cells();
    if (chainCells >= TUPLE && !isNaN(t)) measure(chainCells);
    else why = "Waiting for this symbol's options";
  }
  const full = kelly * 100.0; // percent of the bankroll; the volatility adjustment is 1
  out_matched_strike(matched ? strike : NaN);
  out_expiry_days(matched ? days : NaN);
  out_contract_iv(matched ? ivPoints : NaN);
  out_premium_used(matched ? fin(premium) : NaN);
  out_premium_source(matched && !isNaN(premium) ? f64(source) : NaN);
  out_breakeven(matched ? fin(breakeven) : NaN);
  out_prob_profit(matched ? fin(prob * 100.0) : NaN);
  out_max_gain(matched ? fin(gain) : NaN);
  out_max_loss(matched ? fin(loss) : NaN);
  out_odds_ratio(matched ? fin(gain / loss) : NaN);
  out_kelly_full(matched ? fin(full) : NaN);
  out_kelly_half(matched ? fin(full * 0.5) : NaN);
  out_kelly_quarter(matched ? fin(full * 0.25) : NaN);
  out_tone(matched && !isNaN(kelly) ? (kelly > 0.0 ? 2.0 : 0.0) : bar.isLast() ? 1.0 : NaN);
  if (matched) writeWords();
  else if (bar.isLast()) {
    // Nothing to read: the headline says why, so the card is never a row of blanks.
    sb_clear();
    sb_text(why);
    str_read_sb();
    sb_clear();
    sb_text("no contract read");
    str_title_sb();
  }
}

How it works

The settings name the contract. An indicator reads the chart's market, never which listed contract a chart shows, so the contract is four settings. Expiry date picks the expiry whose trade date, on the market's own clock (optionsTradeDay(): New York on a US stock, Chicago on CME, UTC on crypto), is the picked date; left at 0 it is the first expiry after today, the trade date of the chain's as-of (optionsAsOfMs(), the live bar's close). Either way the expiry is a live one, still trading at the as-of: on a US listed option until 15 minutes past its stamp (optionsLiveUntilMs(): a PM expiry stamped 16:00 New York trades until 16:15), on CME and crypto until the stamp. Strike picks the listed strike nearest the setting at that expiry; left at 0 it is the strike nearest the expiry's forward (spot carried at the rate on a US stock, the underlying itself on futures and crypto). Type is call or put, Position long (bought, paying the premium) or short (sold, collecting it). The title names what was matched, the expiry by its label: 20 Nov 680 call, 36d (an expiry in another year reads its year, 15 Jan '27).

The premium, and where it came from. The Premium setting wins when it is above 0. Left at 0, a chart whose close sits more than 20% from the contract's underlying is taken for the contract's own chart, and its close is the premium; on the underlying's chart the premium is the model price, the contract's IV priced by Black-Scholes on spot on a US stock and by Black-76 on the underlying on futures and crypto, at the Rate setting (4% by default, 0 on crypto). The first row says which: 4.250, the chart's close, 4.105, the model price or 5.000, your premium. A deep in-the-money contract whose price sits within 20% of its underlying reads as the underlying's chart; set the premium there.

The breakeven and the probability. The breakeven is the strike plus the premium on a call and the strike minus it on a put. The probability of profit is the chance the underlying ends past it at expiry, lognormal at the contract's IV over the time left to its end (from the as-of to optionsLiveUntilMs(), in 365-day years): a stock's spot drifts at the rate, a futures or crypto forward does not drift. A long call profits above its breakeven, a long put below it; a short position profits exactly where the long one does not, so the two probabilities sum to 100%. A contract within 15 minutes of its end has no time left: the answer is which side of the breakeven the underlying is on.

Max gain and max loss, per contract. In dollars, times the multiplier (100 on a US listed option, the point value on CME, 1 on crypto): a long pays the premium and can lose no more; a long call's upside has no ceiling (unlimited), a long put's stops at the strike less the premium. A short collects the premium as its most; a short call's loss has no ceiling, a short put's stops at the strike less the premium.

Kelly. The odds ratio is the most it can make over the most it can lose, and Kelly's fraction of the bankroll is p - (1 - p) / odds with p the probability of profit. An unlimited gain against a capped loss reads p itself; an unlimited loss, or nothing to win, has no edge, and so does any fraction at or below zero. Some tools scale full Kelly by a volatility adjustment they do not publish; this card takes none, so full Kelly is the raw fraction, half Kelly half of it and quarter Kelly a quarter. The headline names half Kelly with an edge and says "no edge" without one.

The card reads the outputs. The headline pill over read, the probability in percent and the breakeven at the chart's price digits, then rows: the premium and its source, max gain and max loss ($65,500 or unlimited), the odds ratio, the three Kelly fractions in percent and the contract's IV. Each output is a number on the live bar (prob_profit, kelly_half, breakeven) for the Console and for a watch; an unlimited gain or loss reads NaN there, never an infinity.

What the settings do

  • Strike: The strike, the option's price level. 0 picks the listed strike nearest today's price carried forward to the expiry.
  • Expiry date: The expiry (the day the option ends). 0 picks the first expiry after today.
  • Type: call: an option that pays when price rises. put: one that pays when price falls.
  • Position: long: you bought the option and paid its premium (the money paid for an option). short: you sold it and collected the premium.
  • Premium: The option's price per unit that you paid or got. At 0 it uses the close when this chart is the option's own, else a formula price.
  • Rate, percent: The interest rate the formula price uses, with crypto options always at 0.
  • Odds: The trade in words: the chance of profit and half the Kelly stake. It reads no edge when Kelly stakes nothing.
  • Probability of profit: The chance the trade makes money at expiry. It comes from the option's implied volatility (how big a move option prices expect): market odds, not a forecast.
  • Breakeven: The price the market must pass at expiry for the trade to make money.
  • Premium: The option's price per unit, and whether it came from you, the chart's close or the formula.
  • Max gain: The most one contract can make at expiry, or unlimited.
  • Max loss: The most one contract can lose at expiry, or unlimited.
  • Odds ratio: The max gain divided by the max loss.
  • Full Kelly: The share of your bankroll the Kelly rule (a bet-size formula from odds and payoff) would stake on this trade.
  • Half Kelly: Half the full Kelly stake, a common safer size.
  • Quarter Kelly: A quarter of the full Kelly stake.
  • Implied volatility: The option's implied volatility, the yearly move size its price assumes.

Where it runs

It works on charts of coins with options on Deribit (a crypto options exchange), such as BTC, ETH and SOL. A copy you run from the editor (where you write and run your own indicators) reads them too. On a US stock chart, or the chart of one of its options, it reads that stock's US listed options. The data is 15 minutes behind unless you have real-time US options data. On a futures chart from CME (Chicago futures exchange), it reads that future's options, 10 minutes behind unless you have real-time CME data. The legend names where the options come from. Copies you run from the editor, publish yourself or run as a Cloud (Protected) copy all read US listed options. A Protected copy runs on OpenMarket's servers and keeps its code hidden. Copies you run from the editor or publish yourself read CME options too, once you accept the CME market data terms. A Protected copy does not run on a CME chart.

When data is missing

The card's headline says why instead of going blank. It reads "Waiting for this symbol's options" until the options arrive. It reads "No options still trading" when every listed expiry has stopped trading. It reads "No expiry on the picked date" when no option ends that day. A weekend or a past expiry does this. It reads "No expiry after today" when only today's expiry is left. It reads "No put listed at that expiry" (or call) when that side lists none. An option with no implied volatility reads "no implied volatility" after its name. Then the card's probability and Kelly lines read -. On the chart these options are on, with no Premium set, it has no formula price either. Then the card's Premium line reads "no price" and Breakeven stays empty, instead of a false 100% or 0%.

Customize it

  • Your own fill. Type the price you paid or received into Premium: the breakeven, the probability and Kelly follow it.
  • The contract on screen. On the contract's own chart, set its strike, expiry date and type; the close is its premium.
  • A short premium seller. Set Position to short on a put: a capped loss gives a finite Kelly; a short call has none.
  • Another rate. Change Rate when rates move; crypto chains stay at 0.

Run it

  1. In the editor's Explorer, press the Templates icon ("Browse starter templates") and pick Contract Odds under HUDs.
  2. Press Run on a BTC chart: the card appears at the bottom centre over the at-the-money call of the first expiry after today.
  3. Set Strike, Expiry date, Type and Position to the trade you are weighing; at the editor's Console prompt, type prob_profit and kelly_half to read them on the live bar.

Concepts used