Most agents optimise expected return. MARKGAP optimises the cash it can collect at a fixed timestamp.
This competition takes one number at one moment: 11:00 on Friday. A book that is up at 11:00 and still open is not up — it is holding an unpriced liability.
So MARKGAP changes the objective function. It carries two books at once — one marked at the midpoint, one marked at what it could liquidate for — and treats the distance between them, the markgap, as the headline metric rather than a footnote. A clock decays its own risk budget toward zero and forces the book flat before the horizon. The gap ends at zero, and one honest number remains.
Not preferences — constraints checked in code before any order exists.
Every structure has a finite, computed worst case before submission. No naked shorts, no undefined-risk legs — a rule and a hard constraint of the account.
Nothing opens until the agent has priced what it would cost to close it this instant, and that modelled exit passes the gate. If it can’t price its exit, it doesn’t enter.
The book must be flat before the deadline. A position still open at the horizon is a bug, not a trade — settled by a hard flatten, not by hope.
A deterministic engine does everything that touches money. The model is confined to a single dial it can only turn down.
VIX and term structure, realised vs implied vol, a trend filter, scheduled events — all computed deterministically.
Returns a risk-budget multiplier in [0, 1] that can only shrink exposure, then writes the journal rationale. Never on the critical path.
Strike, width, size, gates, order, exit — pure functions, unit-tested. The math, not the model, decides.
The model never picks a strike, never sizes a position, never places an order. If inference times out, a constant multiplier is used and trading continues.
The failure points on Alpaca’s options stack are where the engineering actually lives.
Structures go as one order_class="mleg" with the net-price sign
convention handled — positive debit, negative credit — plus GCD-1 ratio and
penny-increment validation before submission.
Exits try a combined multi-leg close and fall back to a leg-by-leg sequence on
error 42210000 — short leg first, never leaving an uncovered short.
Alpaca returns no Greeks for 0DTE or when a quote is one-sided, so MARKGAP computes Black–Scholes itself and uses Alpaca’s as a cross-check — standing down when they diverge.
Order state comes from the trade_updates stream, with REST polling for
assignment and expiry. An accepted request is not a fill.
FLATTEN fires, the book empties, and one number remains.
Greeks, marks, sizing and gates are pure functions with tests.
Alpaca’s denominator is days-to-expiry. At 0DTE, it’s empty.
The full engine — dual-book marks, the twelve gates, the clock, and the live dashboard — is open source. The 2-minute demo walks the real paper account.