Lab / Order book demo
Order book demo
Send orders to a matching engine I wrote in C++ and see what it does with them: what trades, what rests and how the depth changes. It takes the five order types from the case study, and a small neural network inside the book learns from every trade.
How it works
The page loads OrderbookSim’s order book, compiled from C++ to WebAssembly with Emscripten 6.0.13. It runs only in this browser tab: nothing you enter is sent anywhere, and the book is not shared with other visitors. Reloading the page or pressing Reset starts a new book.
It behaves as the C++ code does, including three of that code’s own rules: a Market order is given the worst price on the other side before it matches; a trade is recorded at the buy order’s price; and a Market order larger than the other side rests the remainder as Good-Till-Cancel at that price. Good-For-Day orders are cleared only by End of day here; the native book also clears them at 16:00.
Limits keep the tab responsive: prices from 1 to 200, because the network’s output cannot exceed 500; quantities up to 1,000; at most 200 resting orders; and 10,000 orders per book, because the module keeps a record of every order and the browser never hands WebAssembly memory back.