progrunners.comenergy & technology
progrunners / Intraday order book

Rebuilding an order book from deltas

Exchanges do not send you the book. They send you what changed, and you are expected to hold the rest in memory correctly, for days at a time, without drifting. This is the part that separates a live tool from a chart of yesterday.

Running in production against the Czech intraday market, which is coupled to the European XBID platform.
On this page
  1. Why not just poll an API
  2. Getting connected
  3. Reconstructing the book
  4. What it is used for
  5. Stack and effort

Why not just poll an API

Because the useful state of an intraday market is the book, and the book changes faster than any polling interval you would be allowed. Published snapshots arrive late and aggregated; by the time you see one, the order you wanted is gone.

Market participants get a different route: a message queue carrying every change as it happens. In the Czech market that is an AMQP interface authenticated with a client certificate. Other European exchanges expose comparable feeds.

Getting connected

The silent-success failure is the dangerous one. A misconfigured subscription looks identical to a quiet market. We watch message rate per channel and alarm on silence, because "no trades" and "no connection" must never look the same.

Reconstructing the book

Each message is a change: an order added, amended or cancelled. The consumer keeps the book and applies them in order.

  1. Track order identifiers. An amendment references the original; losing that mapping means a stale order sits in your book forever.
  2. Handle cancels explicitly. The most common bug in home-grown consumers is a cancelled order that never leaves the depth, quietly inflating liquidity.
  3. Watch sequence numbers. A gap means you have lost state and the only honest response is to resynchronise, not to carry on.
  4. Rebuild on reconnect. After a drop, the book must be discarded and rebuilt rather than patched — the alternative is a book that looks plausible and is wrong.

From a correct book, the useful numbers fall out: best bid and ask, spread, depth at a price, volume-weighted average price, and the spread of intraday against the day-ahead result for the same delivery period.

What it is used for

Archived books are worth more than archived prices. A backtest against a price series assumes you could always trade at that price. Against a recorded book, you can check whether the volume was there.

Stack and effort

Connection and a correct book is typically three to four weeks, most of it spent on reconnection behaviour and edge cases rather than on the happy path. The happy path takes an afternoon; it is the other 5 % of messages that decide whether you can trust the thing.

Frequently asked questions

Do we need to be a market participant?
For the exchange feed, yes — access is issued to participants and authenticated with a certificate. Published aggregated data is available to everyone via ENTSO-E, later and coarser.
Does this work outside Czechia?
The approach does. European intraday trading runs through the shared XBID platform, and national exchanges expose comparable participant feeds with their own protocols and quirks.
Why archive every message?
Because a recorded book lets you replay the market exactly as it was, including available volume. A price series cannot tell you whether your hypothetical trade would have filled.
How long does it take to build?
Three to four weeks for a connection and a book you can trust, most of it spent on reconnection and edge cases rather than the normal path.

Explore the rest of the site

Need a live book?

If you are looking at an exchange feed and wondering what it takes, we have done it — connection, reconstruction, archive and the signals on top.

Get in touch