D12-F02-A01 / Complete engineering topic

Maximum-Executable-Volume Auction

A production-minded guide to Maximum-Executable-Volume Auction.

D12 · MATCHING ENGINES AND VENUE LO…
D12-F02-A01Canonical / Tested / Open
D12 / D12-F02

Build the first auction objective without prematurely hiding price ties.

The decision this tutorial makes visible

Maximum volume is often the first auction objective, but it may leave several prices. Returning one arbitrary price at this stage makes downstream tie-breaks impossible to audit.

The precise question is: Which candidate price or prices maximize the quantity that can execute in a frozen call-auction book?

A practitioner needs to know what the diagnostic does and does not justify. A builder needs a contract that can be reproduced from the same point-in-time inputs in Python, TypeScript, a visual, and a browser lab.

Intuition before notation

Imagine sliding one clearing price through the book. Demand falls as price rises, supply grows, and executable volume is the smaller side at each candidate.

The result depends on the declared algorithm scope, input clocks, units, equality and rounding policies, and unsupported-state treatment. Change one of those and the output represents a different decision even when its field name is unchanged.

Scope and nearby methods

The canonical model evaluates every unique tick-aligned limit price plus a reference price, includes market orders at every candidate, and returns the complete maximum-volume candidate set.

VariantDefinitionBest useMain limitation
Canonical maximum-volume candidate setReturn all volume-maximizing pricesTeach the first objectiveDoes not finish a tied auction
Xetra cash auctionMaximum volume then surplus and reference rulesVenue-specific price determinationMore objectives than this topic
Nasdaq crossMaximum pairing within session-specific rule hierarchyNasdaq opening/closing crossesOrder eligibility and protections differ

What is sourced, selected, synthetic, and derived

RoleMaterial claimEvidenceBoundary
Sourced factT7 materials establish maximum execution as an auction objective and the Nasdaq rulebook supplies a current cash-cross comparison; neither requires a unique price after this first objective.S1 (T7 functional objective), S2 (Xetra market model), and S4 (Nasdaq comparison); S3 records current T7 release applicabilityVenue rulebooks do not validate the repository-authored fixture or selected simplifications.
Implementation choiceThe canonical model evaluates every unique tick-aligned limit price plus a reference price, includes market orders at every candidate, and returns the complete maximum-volume candidate set.Frozen package definitionThis is a declared teaching convention rather than universal or venue-conformant logic.
Synthetic teaching inputAll orders, references, collars, bands, and quantities are repository-authored.datasets/canonical-input.jsonThey are not observed imbalance messages or participant orders.
Author-derived calculationAt 99, 100, and 101, executable quantities are 200, 600, and 300. The unique maximum-volume price is 100 with 600 executable shares.Formula, fixture, independent arithmetic, and Python/TypeScript parityCorrect calculation does not predict a future venue cross.

The authoritative sources support only the exact facts named in the claim ledger. They do not certify the synthetic numbers in this tutorial. The repository fixture is deliberately invented for auditability, and the displayed output is author-derived under the selected implementation choice.

Formula, symbols, and numerical policy

Plain text
B(p)=sum buy q where market or limit>=p; S(p)=sum sell q where market or limit<=p; V(p)=min(B(p),S(p))
SymbolMeaningUnitPolicy
B(p)cumulative executable buy quantityshares/contractsmarket plus buy limits at or above p
S(p)cumulative executable sell quantityshares/contractsmarket plus sell limits at or below p
V(p)executable volumeshares/contractsmin(B,S)
P*maximum-volume candidate setpricesretain every argmax
  • Candidate prices are unique tick-aligned limit prices plus the declared reference.
  • Buy demand includes market orders and buy limits greater than or equal to candidate price.
  • Sell supply includes market orders and sell limits less than or equal to candidate price.
  • Equality at a limit or collar is included.

Read the formula in the same order as the algorithm. Validate identity, ordering, units, and supported state first. Apply the selected equality and window rules second. Calculate with unrounded numeric values. Round only at the declared presentation boundary, and preserve null as a diagnostic rather than coercing it to zero.

Build the algorithm

  1. Validate orders, ticks, identity, and reference
  2. Build the candidate price set
  3. Compute cumulative buy and sell quantity
  4. Calculate executable quantity and imbalance
  5. Return every maximum-volume candidate

Production-minded operational checklist

  1. Resolve venue, security, auction session, timezone, and effective rule version.
  2. Freeze eligible interest, tick table, references, collars, and market-control state.
  3. Evaluate every protected candidate from one end-of-call snapshot.
  4. Apply objectives lexicographically and retain every survivor at each stage.
  5. Persist imbalance, selection trace, no-cross reason, and publication provenance.

The checklist is intentionally strict: an explicit rejection is safer than a plausible output built from stale, malformed, or unsupported state.

Worked synthetic example

The canonical fixture is synthetic teaching data, not an observed control event, customer order, or broker execution. Its primary author-derived output, maximum_executable_quantity, is 600.0. The complete input and output are in datasets/canonical-input.json and datasets/expected-output.json.

At 99, 100, and 101, executable quantities are 200, 600, and 300. The unique maximum-volume price is 100 with 600 executable shares.

Counterfactual checkpoint

Maximum-volume tie remains a set. Construct two candidate prices with the same highest executable quantity. The output changes because choosing one price belongs to a later tie-break and cannot be hidden inside the first objective.

The structured result retains state and diagnostics in addition to the primary number. That makes the calculation independently reviewable and prevents a partial, null, rejected, or venue-bounded outcome from being mistaken for an unqualified value.

Boundary and counterexample workbook

The playground computes every scenario at 61 deterministic parameter states. The table uses the declared focus step and states whether that focus reproduces the canonical fixture. The full state ledger and compressed transition segments are in datasets/scenario-results.json.

ScenarioReview focusPurposeStatePrimary outputDiagnosticDecision segments
Canonical auction curveStep 30 · canonical fixtureOne order size moves through the canonical volume and imbalance profile.unique-maximum600.0 executableprices 100 · unique-maximum1
Maximum-volume tieStep 30 · comparison focusTwo or more prices share the first objective.unique-maximum500.0 executableprices 101 · unique-maximum1
Imbalance-resolution boundaryStep 30 · comparison focusEqual volume survives while absolute imbalance separates candidates.maximum-volume-tie500.0 executableprices 100,101 · maximum-volume-tie1
Market-order pressureStep 30 · comparison focusMarket quantity participates at every candidate price.unique-maximum630.0 executableprices 101 · unique-maximum3
No-cross controlStep 30 · comparison focusBuy and sell limits remain uncrossed at every candidate.no-cross0.0 executableprices 99,100,101 · no-cross1
Reference-only candidateStep 30 · comparison focusThe declared reference adds a price not present on an order.unique-maximum600.0 executableprices 100 · unique-maximum1
One-sided failureStep 30 · comparison focusOnly one side has executable interest and no clearing price may be invented.no-cross0.0 executableprices 100,101 · no-cross1

These rows are not backtest observations. They are controlled counterexamples that expose how one driver changes the state, output, or reason code while the rest of the contract stays fixed.

Visualize the boundary

Maximum-Executable-Volume Auction annotated teaching map

Open this SVG at full size, or use the guided playground to compare the seven topic-specific canonical, boundary, policy, and failure scenarios.

The Mermaid flow answers where the selected calculation sits in the processing sequence. The SVG keeps the formula, output, decision boundary, and invariant visible together. The lab lets the reader step through the same structured states without changing the underlying definition.

Implementation walkthrough

The Python and TypeScript references begin with the same validation contract, reject malformed and unsupported state before calculation, preserve declared ordering and rounding policies, and return structured diagnostics rather than one context-free number.

The main implementation branches are:

  • One candidate has greatest volume — Return a unique price, because No later tie-break is needed.
  • Several candidates share greatest volume — Return every tied price, because The next topic owns imbalance resolution.
  • Every candidate has zero volume — Return no-cross, because No price executes both sides.

Neither reference silently fetches data, mutates caller-owned inputs outside the declared engine behavior, guesses hidden state, or substitutes a provider default. Shared JSON fixtures make value, null, state, and reason-code drift visible across languages.

Testing and validation

Definition tests compare every canonical field, reject malformed state, and exercise the material boundary. Family validation recomputes every playground state from the reference function. Independent arithmetic is recorded beside the fixture rather than inferred only from implementation output.

The audit must preserve these invariants:

  • Executable quantity equals min(cumulative buy, cumulative sell) at each candidate.
  • Imbalance equals cumulative buy minus cumulative sell.
  • Every later objective is applied only to survivors of every earlier objective.
  • A no-cross state never publishes a fabricated clearing price.

Passing definition and parity checks proves that the implementation matches the selected contract. It does not prove production performance, universal applicability, or a later market outcome.

Failure modes and misuse

  • Auction objective order and eligible interest vary by venue, session, security, and rule version.
  • A candidate price from an incomplete public book is not a venue-conformant auction prediction.
  • Definition fidelity does not establish execution probability, liquidity quality, or trading value.

Debugging order

When a result looks surprising, inspect the state in this order:

  1. Confirm identifiers, scope, side, and decision clock.
  2. Confirm units, ordering, and point-in-time inputs.
  3. Confirm equality, rounding, null, and reset policies.
  4. Recalculate the invariant and declared scenario focus before changing code.

Evidence and historical boundary

Historical decision: deferred. A named auction reconstruction would require a sequence-complete licensed imbalance and order feed, exact session and order eligibility, reference and collar history, regulatory state, corrections, timestamps, and redistribution rights. Synthetic books expose the objective hierarchy without inventing unavailable auction interest.

The primary sources are T7 Release 14 Functional Reference, Xetra Release 14 market model, Xetra Release 14.1 production notice, Nasdaq Equity 4. They support the source roles listed in the research ledger, not a redistributable historical observation, a private participant decision, production conformance certification, execution-quality result, profitability claim, or prediction claim.

Summary and next topic

You can now calculate and preserve the full maximum-volume candidate set. The learning flow is: Hybrid Pro-Rata/Time Matching → Maximum-Executable-Volume Auction → Minimum-Imbalance Tie-Break. Carry the result forward only with its scope, clock, state, and evidence label.

Maximum-Executable-Volume Auction calculation flow

This flow identifies the selected calculation stages and the structured output.

Rendering system map…

Takeaway: The auction curve produces a candidate set before it produces a final price.

ReferencesPrimary sources and evidence notes

Expand the source trail, evidence role, and limitations behind the engineering choices.

S1 — T7 Release 14.0 Functional Reference, Version 3

  • Organization or authors: Deutsche Börse Group
  • Source type: Official trading-system functional reference
  • Publication or effective date: Release 14.0 documentation accessed 2026-07-30
  • Version: Version 3
  • URL or DOI: https://www.xetra.com/resource/blob/4591804/afb8a01ba7c00951ad48f8196d9f3732/data/T7_Release_14.0_-_Functional_Reference_Version_3.pdf
  • Accessed: 2026-07-30
  • Jurisdiction: Deutsche Börse T7 cash and derivatives markets
  • Supports: Cash-auction most-executable-volume, lowest-surplus, directional surplus, reference-price, and volatility-interruption mechanics.
  • Limitations: Market and product configuration determine applicable behavior; the package is not a T7 conformance implementation.

S2 — Market Model for the Trading Venue Xetra, T7 Release 14.0

  • Organization or authors: Deutsche Börse Cash Market
  • Source type: Official venue market model
  • Publication or effective date: 27 October 2025
  • Version: T7 Release 14.0
  • URL or DOI: https://www.xetra.com/xetra-en/technology/t7/system-documentation/release14-0/production
  • Accessed: 2026-07-30
  • Jurisdiction: Xetra cash market
  • Supports: Opening, closing, auction-call, indicative price, executable volume, imbalance, and volatility-interruption phases.
  • Limitations: The documentation page links versioned artifacts; exact current parameters are instrument configuration.

S3 — Introduction of T7 Release 14.1

S4 — Nasdaq Equity 4 Trading Rules

  • Organization or authors: The Nasdaq Stock Market LLC
  • Source type: Official exchange rulebook
  • Publication or effective date: Current rulebook accessed 2026-07-30
  • Version: Current online rule text
  • URL or DOI: https://listingcenter.nasdaq.com/rulebook/nasdaq/rules/Nasdaq%20Equity%204
  • Accessed: 2026-07-30
  • Jurisdiction: United States equities; Nasdaq
  • Supports: Current Reference Price, maximum pairing, minimum imbalance, opening and closing eligible interest, and cross processing.
  • Limitations: The rules contain session-, security-, order-type-, LULD-, and exception-specific branches not reproduced by the package.

Evidence boundary

The sources establish the exact rule, interface, protocol, or research context named above. They do not verify the repository-authored synthetic fixture, thresholds, empirical usefulness, execution probability, or profitability. Package-selected choices remain labeled as implementation choices wherever they are used.

auction-matching.ts
export type JsonObject = Record<string, any>;

function num(name: string, value: unknown, positive = false, nonnegative = false): number {
  if (typeof value !== "number" || !Number.isFinite(value)) throw new TypeError(`${name} must be a finite number`);
  if (positive && value <= 0) throw new RangeError(`${name} must be positive`);
  if (nonnegative && value < 0) throw new RangeError(`${name} must be nonnegative`);
  return value;
}
function integer(name: string, value: unknown, nonnegative = false): number {
  const result = num(name, value);
  if (!Number.isInteger(result)) throw new RangeError(`${name} must be an integer`);
  if (nonnegative && result < 0) throw new RangeError(`${name} must be nonnegative`);
  return result;
}
function text(name: string, value: unknown): string {
  if (typeof value !== "string" || !value.trim()) throw new TypeError(`${name} must be a non-empty string`);
  return value;
}
function onTick(value: number, tick: number): boolean {
  return Math.abs(value / tick - Math.round(value / tick)) <= 1e-8;
}
function parseOrders(raw: unknown, tick: number): JsonObject[] {
  if (!Array.isArray(raw) || raw.length === 0) throw new RangeError("orders must be a non-empty list");
  const ids = new Set<string>(), sequences = new Set<number>();
  return raw.map((item, index) => {
    if (!item || typeof item !== "object") throw new TypeError(`orders[${index}] must be an object`);
    const order = item as JsonObject, orderId = text(`orders[${index}].order_id`, order.order_id);
    if (ids.has(orderId)) throw new RangeError("order_id values must be unique"); ids.add(orderId);
    const side = text(`orders[${index}].side`, order.side);
    if (!["buy", "sell"].includes(side)) throw new RangeError("order side must be buy or sell");
    const orderType = text(`orders[${index}].order_type`, order.order_type);
    const sequence = integer(`orders[${index}].arrival_sequence`, order.arrival_sequence, true);
    if (sequences.has(sequence)) throw new RangeError("arrival_sequence values must be unique"); sequences.add(sequence);
    const quantity = num(`orders[${index}].quantity`, order.quantity, true);
    let price: number | null = null;
    if (["market", "MOO", "MOC"].includes(orderType)) {
      if (order.price != null) throw new RangeError("market-style auction orders must not carry a price");
    } else if (["limit", "LOO", "LOC", "DAY"].includes(orderType)) {
      price = num(`orders[${index}].price`, order.price, true);
      if (!onTick(price, tick)) throw new RangeError("order price must align with tick_size");
    } else throw new RangeError(`unsupported auction order_type: ${orderType}`);
    return {order_id: orderId, side, order_type: orderType, price, quantity, arrival_sequence: sequence};
  });
}
function evaluationAt(price: number, orders: JsonObject[]): JsonObject {
  const buy = orders.filter(order => order.side === "buy" && (order.price == null || order.price >= price)).reduce((sum, order) => sum + order.quantity, 0);
  const sell = orders.filter(order => order.side === "sell" && (order.price == null || order.price <= price)).reduce((sum, order) => sum + order.quantity, 0);
  const executable = Math.min(buy, sell), imbalance = buy - sell;
  return {price, buy_quantity: buy, sell_quantity: sell, executable_quantity: executable, imbalance_quantity: imbalance, absolute_imbalance: Math.abs(imbalance), imbalance_side: imbalance > 0 ? "buy" : imbalance < 0 ? "sell" : "none"};
}
function evaluateBook(ordersRaw: unknown, referenceRaw: unknown, tickRaw: unknown, low: number | null = null, high: number | null = null): [JsonObject[], number, number, JsonObject[]] {
  const reference = num("reference_price", referenceRaw, true), tick = num("tick_size", tickRaw, true);
  if (!onTick(reference, tick)) throw new RangeError("reference_price must align with tick_size");
  const orders = parseOrders(ordersRaw, tick), priceSet = new Set<number>([reference]);
  orders.forEach(order => { if (order.price != null) priceSet.add(order.price); });
  const candidates = [...priceSet].filter(price => (low == null || price >= low - 1e-12) && (high == null || price <= high + 1e-12)).sort((a, b) => a - b);
  if (!candidates.length) throw new RangeError("no candidate price remains inside the declared collar");
  return [orders, reference, tick, candidates.map(price => evaluationAt(price, orders))];
}

export function maximumExecutableVolumeAuction(ordersRaw: unknown, referenceRaw: unknown, tickRaw: unknown): JsonObject {
  const [orders, reference, tick, evaluations] = evaluateBook(ordersRaw, referenceRaw, tickRaw);
  const maximum = Math.max(...evaluations.map(row => row.executable_quantity)), winners = evaluations.filter(row => row.executable_quantity === maximum);
  return {model: "maximum-executable-volume-candidate-set", reference_price: reference, tick_size: tick, order_count: orders.length, maximum_executable_quantity: maximum, maximum_volume_prices: winners.map(row => row.price), unique_price: winners.length === 1 ? winners[0].price : null, candidate_evaluations: evaluations, state: maximum === 0 ? "no-cross" : winners.length === 1 ? "unique-maximum" : "maximum-volume-tie"};
}

export function minimumImbalanceTieBreak(ordersRaw: unknown, referenceRaw: unknown, tickRaw: unknown): JsonObject {
  const [orders, reference, tick, evaluations] = evaluateBook(ordersRaw, referenceRaw, tickRaw);
  const maximum = Math.max(...evaluations.map(row => row.executable_quantity));
  const volumeWinners = evaluations.filter(row => row.executable_quantity === maximum);
  const minimum = Math.min(...volumeWinners.map(row => row.absolute_imbalance));
  const winners = volumeWinners.filter(row => row.absolute_imbalance === minimum);
  return {model: "maximum-volume-then-minimum-imbalance", reference_price: reference, tick_size: tick, order_count: orders.length, maximum_executable_quantity: maximum, minimum_absolute_imbalance: minimum, volume_winner_prices: volumeWinners.map(row => row.price), minimum_imbalance_prices: winners.map(row => row.price), selected_price: winners.length === 1 ? winners[0].price : null, candidate_evaluations: evaluations, state: maximum === 0 ? "no-cross" : winners.length === 1 ? "tie-resolved" : "tie-remains"};
}

function crossPrice(session: string, ordersRaw: unknown, referenceRaw: unknown, tickRaw: unknown, lowRaw: unknown, highRaw: unknown): JsonObject {
  const reference = num("reference_price", referenceRaw, true), tick = num("tick_size", tickRaw, true), low = num("collar_low", lowRaw, true), high = num("collar_high", highRaw, true);
  if (low > reference || high < reference || low > high) throw new RangeError("collar must contain the reference price");
  if (![reference, low, high].every(value => onTick(value, tick))) throw new RangeError("reference and collar prices must align with tick_size");
  const parsed = parseOrders(ordersRaw, tick), allowed = new Set(session === "opening" ? ["MOO", "LOO", "DAY"] : ["MOC", "LOC", "DAY"]);
  if (parsed.some(order => !allowed.has(order.order_type))) throw new RangeError(`unsupported order type for ${session} cross`);
  const [, , , evaluations] = evaluateBook(parsed, reference, tick, low, high);
  const maximum = Math.max(...evaluations.map(row => row.executable_quantity));
  if (maximum === 0) return {model: `declared-${session}-cross`, session, reference_price: reference, collar_low: low, collar_high: high, selected_price: null, executed_quantity: 0, imbalance_quantity: 0, selection_trace: ["no candidate price executes both sides"], candidate_evaluations: evaluations, state: "no-cross"};
  let stage = evaluations.filter(row => row.executable_quantity === maximum);
  const trace = [`maximize executable quantity at ${maximum}`];
  const minimum = Math.min(...stage.map(row => row.absolute_imbalance));
  stage = stage.filter(row => row.absolute_imbalance === minimum); trace.push(`minimize absolute imbalance at ${minimum}`);
  let selected: JsonObject;
  if (stage.length > 1) {
    const signs = new Set(stage.map(row => row.imbalance_side));
    if (signs.size === 1 && signs.has("buy")) {
      selected = stage.reduce((a, b) => a.price > b.price ? a : b); trace.push("buy surplus selects the highest remaining price");
    } else if (signs.size === 1 && signs.has("sell")) {
      selected = stage.reduce((a, b) => a.price < b.price ? a : b); trace.push("sell surplus selects the lowest remaining price");
    } else {
      selected = [...stage].sort((a, b) => Math.abs(a.price - reference) - Math.abs(b.price - reference) || a.price - b.price)[0];
      trace.push("mixed or zero surplus selects the price nearest the reference");
    }
  } else { selected = stage[0]; trace.push("the objective hierarchy leaves one price"); }
  return {model: `declared-${session}-cross`, session, reference_price: reference, collar_low: low, collar_high: high, eligible_order_count: parsed.length, selected_price: selected.price, executed_quantity: selected.executable_quantity, buy_quantity: selected.buy_quantity, sell_quantity: selected.sell_quantity, imbalance_quantity: selected.imbalance_quantity, imbalance_side: selected.imbalance_side, selection_trace: trace, candidate_evaluations: evaluations, state: "crossed"};
}

export function openingCrossPrice(orders: unknown, previousClose: unknown, tick: unknown, low: unknown, high: unknown): JsonObject {
  return crossPrice("opening", orders, previousClose, tick, low, high);
}
export function closingCrossPrice(orders: unknown, reference: unknown, tick: unknown, low: unknown, high: unknown): JsonObject {
  return crossPrice("closing", orders, reference, tick, low, high);
}

export function volatilityAuctionReopening(inputs: JsonObject): JsonObject {
  const reference = num("reference_price", inputs.reference_price, true);
  const dynamicRef = num("dynamic_reference", inputs.dynamic_reference, true), dynamicPct = num("dynamic_band_pct", inputs.dynamic_band_pct, true);
  const staticRef = num("static_reference", inputs.static_reference, true), staticPct = num("static_band_pct", inputs.static_band_pct, true);
  const potential = num("potential_continuous_price", inputs.potential_continuous_price, true), indicative = num("indicative_auction_price", inputs.indicative_auction_price, true);
  const multiplier = num("extended_band_multiplier", inputs.extended_band_multiplier, true);
  if (multiplier < 1) throw new RangeError("extended_band_multiplier must be at least one");
  const executable = num("executable_quantity", inputs.executable_quantity, false, true);
  const dynamicLow = dynamicRef * (1 - dynamicPct), dynamicHigh = dynamicRef * (1 + dynamicPct);
  const staticLow = staticRef * (1 - staticPct), staticHigh = staticRef * (1 + staticPct);
  const dynamicBreach = potential < dynamicLow || potential > dynamicHigh, staticBreach = potential < staticLow || potential > staticHigh, triggered = dynamicBreach || staticBreach;
  const expandedDynamicLow = dynamicRef * (1 - dynamicPct * multiplier), expandedDynamicHigh = dynamicRef * (1 + dynamicPct * multiplier);
  const expandedStaticLow = staticRef * (1 - staticPct * multiplier), expandedStaticHigh = staticRef * (1 + staticPct * multiplier);
  const inside = indicative >= expandedDynamicLow && indicative <= expandedDynamicHigh && indicative >= expandedStaticLow && indicative <= expandedStaticHigh;
  let state: string, reopened: boolean, reopenPrice: number | null, reason: string;
  if (!triggered) { state = "continuous"; reopened = false; reopenPrice = null; reason = "potential price remains inside both active corridors"; }
  else if (executable === 0) { state = "auction-no-cross"; reopened = false; reopenPrice = null; reason = "volatility auction has no executable quantity"; }
  else if (inside) { state = "reopened"; reopened = true; reopenPrice = indicative; reason = "indicative auction price is executable and inside both expanded corridors"; }
  else { state = "extended-volatility-auction"; reopened = false; reopenPrice = null; reason = "indicative auction price remains outside an expanded corridor"; }
  return {model: "dual-corridor-volatility-auction-reopening", reference_price: reference, potential_continuous_price: potential, dynamic_corridor: [dynamicLow, dynamicHigh], static_corridor: [staticLow, staticHigh], dynamic_breach: dynamicBreach, static_breach: staticBreach, triggered, indicative_auction_price: indicative, executable_quantity: executable, expanded_dynamic_corridor: [expandedDynamicLow, expandedDynamicHigh], expanded_static_corridor: [expandedStaticLow, expandedStaticHigh], inside_reopening_corridor: inside, reopened, reopen_price: reopenPrice, reason, state};
}

export function calculate(topicId: string, inputs: JsonObject): JsonObject {
  if (!inputs || typeof inputs !== "object" || Array.isArray(inputs)) throw new TypeError("inputs must be an object");
  if (topicId === "D12-F02-A01") return maximumExecutableVolumeAuction(inputs.orders, inputs.reference_price, inputs.tick_size);
  if (topicId === "D12-F02-A02") return minimumImbalanceTieBreak(inputs.orders, inputs.reference_price, inputs.tick_size);
  if (topicId === "D12-F02-A03") return openingCrossPrice(inputs.orders, inputs.previous_close, inputs.tick_size, inputs.collar_low, inputs.collar_high);
  if (topicId === "D12-F02-A04") return closingCrossPrice(inputs.orders, inputs.closing_reference, inputs.tick_size, inputs.collar_low, inputs.collar_high);
  if (topicId === "D12-F02-A05") return volatilityAuctionReopening(inputs);
  throw new RangeError(`unsupported topic_id: ${topicId}`);
}
Full-height labplaygroundOpen full screen