Multilayer stress tests for margin capacity
A four-layer risk loop and a 12-by-6 shock grid that treat broker margin as a claim, abort on schema drift, and finish a pre-market audit in seconds rather than hours.
What changed. Pre-market risk scoring that took about three hours of sheets now runs in about ten seconds, with a missing stress field treated as a failed run rather than a green PASS.
Stack. layered monitors · Taylor stress grid · margin-capacity limit · schema falsifier
Context
On a quiet day, broker initial margin can sit at a comfortable fraction of equity and look like spare capacity. In a gap, negative gamma, a volatility jump, and a tighter clearing model can raise the requirement while equity falls. Linear VaR and a static broker print do not see that shape in time. Worse, the analytics that should have seen it can go silent: a dropped field, an unchanged schema version, a report that still says PASS.
The studio built a stress-testing contour for a derivatives book. This is an engineering case about measurement, limits, and honest failure. It is not an investment product and it does not report returns, yield, or a survived drawdown as a performance claim.
Task
Keep a continuous read on margin capacity. Recompute when the underlyings move, not only at a pretty interval. Compare today’s book to yesterday’s without drowning the operator in noise. Map combined price and volatility shocks before the open. Never trust a broker API figure that violates a structural bound. If a stress field disappears from the file, the run must die loudly.
What we built
Four layers.
L0 — intraday snapshot every thirty minutes, or immediately on a move_watch trigger when named underlyings move beyond a set threshold. Hard lines on utilisation, cumulative gamma, and one-day volatility; an alert on Telegram within seconds of a breach.
L1 — deterministic pre-market audit of the open book (forty-plus lines): net and beta-weighted delta, gamma, vega, theta, concentration, a HEALTHY / WARN / CRITICAL status, and a de-risking queue. The same pass that used to take about three hours of sheets now finishes in about ten seconds.
L2 — material diff against the previous report. Only changes that clear a threshold reach the operator.
L3 — a 12-by-6 stress map: price shocks against implied-vol shocks, with a short theta horizon, using a quadratic Taylor expansion so the grid does not wait on a full reprice of every leg. The operating rule on the book is a utilisation cap (U_max at 60%): the remainder is reserved as shock headroom, compared continuously to the worst cell on the grid.
Broker margin is checked against a structural upper bound computed from the book. A print above that bound, or a suspiciously low print, invalidates the snapshot and blocks automated action.
Schema versioning, fail-loud field checks, and a deprecation log were installed after a real miss: a developer removed a stale stress block, left schema_version at 1.0, and downstream scoring treated the missing key as PASS with a flat zero. The monitor was green while the test was not running.
What changed
The morning audit is a ten-second artefact, not a three-hour collage. Combined shocks are visible as a grid, not as a single VaR number. A missing or drifted field fails the job. The broker figure is a claim until it sits inside the structural bound.
What we would do differently
Install the structural-bound falsifier and the schema pin before the shock grid. The 12-by-6 map is the interesting picture. The incident that actually blinds an operator is a green PASS on an empty test. We built the theatre of scenarios, then discovered the lights were not wired to the stage.
Related service: AI agents and automation