Markets, lesson 5
Data feeds and rebuilding the book
Every change goes out as a numbered message, and you rebuild the book.
You know how orders rest, match, get cancelled and get amended in a book.
Part 1. Messages, not the book
Nobody outside the exchange can see its book. What you get is a stream of short messages, one for each change, and your program builds its own copy from them. Run the feed and keep your copy right.
Each message said one small thing: an order was added, traded or cancelled. Your program applied them in order and held anything that came after a skip. Applying past the gap didn't crash anything. It quietly left shares at 100 that weren't there, and a program trading on that book would trade on a price that doesn't exist.
Market data feed and sequence number
The market data feed is the stream of messages an exchange sends for every change to its book. Each message carries a sequence number, one higher than the last. A skip means you missed something. A repeat means a copy.
Your turn
You've received every message up to 1043. The next one is 1046. How many are missing?
Part 2. Ask again, or start over
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Ask again, or start over
- What your program must remember
- How much detail you get
- A worked problem
- The same thing, for real
Markets overviewSpotted a mistake? Tell us.