cleoanka

an interactive page · market microstructure

Trading without seeing the future

How an order book works, and how a one-line peek into the future turns a backtest into a fake paradise.

canvas & code, no dependencies · kairos on GitHub


1

The order book: where prices are cooked

The single price you see on a screen is really the gap between two queues. On one side, limit orders waiting to buy at given prices; on the other, orders waiting to sell. Someone who wants to trade now sends a market order and eats the opposite queue from the best price outward. A big order consumes several levels and pushes the price: that is price impact.

FIG. 1 — A little book alive with random limit orders arriving and cancelling. The ladder on the left shows bid (blue) and ask (red) queues; on the right, mid price and trades. Send your own market order and see how many levels it eats and how much it slips.

Kairos’s perception layer (System 1) looks straight into this kitchen: how wide the spread is, whether the bid side is thicker, which way recent trades are flowing. Even a simple ratio called imbalance carries real information about which way the price will drift in the short run. These signals are fast, numeric and causal: they only see what has happened so far.

2

A one-line cheat

Testing a strategy on past data is called a backtest, and its most common bug is silent. You compute your signal from the closing price at time t, but you also score the profit on the return up to time t. In code this is a single index. The result: the strategy appears to profit from the very move that produced its decision. The future has leaked in.

FIG. 2 — A price series made by a random walk: unpredictable by definition. The same momentum signal is scored with three alignments. “New market” repeats it on another series. With CausalBus on, the strategy can only reach data stamped earlier than now; the faulty alignment becomes impossible to write.

With honest alignment, profit on an unpredictable series wanders around zero and turns negative once costs are added, as it should. With the one-line bug the same signal produces a shiny return on every series. Kairos closes this hole not by discipline but by design: the causal perception bus delivers data with timestamps, and showing the strategy something that has not happened yet is structurally impossible. The measured results are honest accordingly: profit only shows up in benign market conditions.

book
Bid and ask queues; a market order eats a queue and pushes the price.
system 1
Spread, imbalance, flow: fast, causal microstructure perception.
look-ahead
Deciding and scoring on the same data; a one-index bug, a fake paradise.