One market, three views
One simulated market, drawn three ways in the same frame as it runs in your browser: its order book, a year of its futures and the volatility surface its stress drives. A liquidity shock lands in all three at once; what follows is the model’s own.
| Events a second, over the last ten simulated seconds | 294.1 |
|---|---|
| The model’s stationary rate | 300.1 |
What it shows
The three views are one market, not three pictures of similar ones. The surface, the order book and the futures (simulated paths of the price, a year of them) are drawn from one copy of the market in one animation frame, so they are never out of step: read the book at a moment, and the futures and the surface show the market as it was then. Press Liquidity shock and the sweep lands in all three in the frame it arrives, the book drained at the touch, the futures lit and widening, the surface lifting at its short end. Everything after that is the model’s own, and the numbers below are measured over twenty seeds, not chosen for the picture.
The market
It is the order book paper’s market: the same seed and the same Hawkes order flow into the same limit order book, advanced in whole quanta of 1/60 of a simulated second. Three numbers are read from it for the other two views, each on the market’s own clock.
Realised volatility is the square root of an exponentially weighted mean of squared one-second log-returns of the mid, with a sixty-second half-life, annualised over 252 trading days of 6.5 hours. The futures are drawn at it.
Stress runs from 0 to 1 and combines four signals a trader watches, each 0 across the calm market’s range and 1 at its extreme: the intensity of market sells against its stationary rate (0 at 1.6 times it, 1 at 2.2); realised volatility against a calm 25.0% (0 at 1.2 times, 1 at 4); the spread (0 at 2 ticks, 1 at 7); and the shares within three ticks of the touch on the book’s thinner side (0 at 45, 1 at none). They combine as an “or”,s = 1 − (1 − p)(1 − a)(1 − b)(1 − c),so any one alone can carry the market to full stress, and the result follows on a 0.35-second half-life. Over ten calm seeds of ten simulated minutes, it averages under 0.05.
The surface is the IV paper’s own family of shocks, with the stress as the shock’s size: at calm it is exactly that paper’s calm surface, at a stress of one its full shock, and at every stress between it is free of static arbitrage.
A liquidity shock
Pressing Liquidity shock does two things at the start of the next quantum. A market sell takes every bid within 20 ticks of the best at once, level by level, each fill a trade on the tape. And the Hawkes state takes an exogenous lift: market sells arrive 60 a second faster and bid cancellations 180 a second faster, both fading as a market sell’s own excitation does, with a third of a second’s half-life. Nothing after that is scripted.
Over twenty seeds, within a second the spread opens, for a moment, to at least four ticks, the touch loses four fifths of its shares and the stress passes 0.8; realised volatility is up by a quarter within two seconds and 1.4 to 5.6 times within ten; the spread is back within two ticks inside two seconds, and the stress below 0.05 inside five minutes. Shocks stack only up to one: what is still in the market is absorbed on a 5-second half-life, and a press tops it up to one whole shock, so fifty presses in a second deliver at most 1.14 shocks.
The market, and its futures
- Hawkes order flow into a limit order book, in quanta of 1/60 of a second
- its realised volatility, its stress, and the liquidity shock
- a fan of 4,096 futures each simulated second, a slice a frame
Three views, one animation frame
- the vol surface (WebGL2), from the stress
- the order book, from its rows, its trades and its depth now
- the futures, from the fan, the price and the volatility
| To the worker | a request for the market at the page’s clock, with an empty buffer; a reader’s shock, pause or reset |
|---|---|
| To the page | the buffer, filled: the market’s state, the book at now, the rows and trades since the last frame; and each new fan of futures |
Where it runs, and what is the same everywhere
The market runs in a worker, a thread of its own, so the page’s thread only draws. Each animation frame the page asks for the market at its own clock; the worker moves it on by the time since the last frame, never more than 0.1 of a second, so a tab left in the background finds the market where it left it, and answers in one buffer the page lends it and gets back. It also draws the futures, 4,096 paths each simulated second, 512 a frame, for a price of one, which the page scales by the price now, exact for geometric Brownian motion, so the fan moves with the price in the frame the price moves. The fan carries the realised volatility of the moment for the whole year, as its readout says; just after a shock it runs wider than the surface’s implied volatility, which prices the shock fading.
The market itself, its events, its book, its realised volatility, its stress and the shock still in it, comes out the same to the bit on every engine, from the same seed and the same log of shocks, each stamped with the quantum it took effect at: the clock moves in whole quanta, the market computes its own exponentials and logarithms, and a shock is an action taken at a quantum’s start, not a moment of the wall clock. The futures are the one part drawn with the platform’s own exponential: they keep the home figure’s arithmetic, path for path, and feed nothing back.
How it is tested
- Over twenty seeds, the shock’s claims above: the spread, the touch and the stress within a second, realised volatility within two and ten, the spread back inside two seconds and the stress inside five minutes.
- The same seed and the same log of shocks are the same market however it is stepped; without the shock, another market.
- Fifty presses in a second deliver no more than one shock and the second’s absorption, and leave the market’s selling pressure, spread, fall and volatility within stated bounds.
- The stress rises with each of its four signals, is nothing across the calm market’s range, stays between 0 and 1 whatever it is given, and averages under 0.05 over ten calm seeds.
- The surface is the IV paper’s calm surface at calm, its at-the-money volatility rises with the stress, and at every stress in steps of 0.05 it passes the butterfly, calendar and Gatheral–Jacquier checks.
- The futures’ paths are the home figure’s bit for bit; their percentiles are the lognormal’s within Monte Carlo error, their mean a year out is the price grown at the rate within four standard errors, the at-the-money call is within its error of Black–Scholes, and a fan drawn at one volatility maps exactly onto the fan drawn at another.
- The worker’s own core, in Node: the same market at 60 and at 120 frames a second, never more than a tenth of a second caught up, held while paused, a shock taken at the next frame’s first quantum.
- Each frame carries the market as it is, the book now laid out as a row is, and the rows and trades since the last frame, and says what it had to leave out.
- tests/market-shock.test.ts · tests/market-stress.test.ts · tests/market-host.test.ts · tests/futures-fan.test.ts
- synthetic; parameters set by hand
- Hawkes, Spectra of some self-exciting and mutually exciting point processes, Biometrika 58(1), 1971 · Gatheral and Jacquier, Arbitrage-free SVI volatility surfaces, Quantitative Finance 14(1), 2014 · Glasserman, Monte Carlo Methods in Financial Engineering, Springer, 2003