Questions / Quant development, Streaming market data
Recover a book after a gap
A book snapshot is valid through sequence 100. Deltas 101 and 103 arrive, but 102 is missing. What is a sound response for a feed requiring contiguous updates?
Answer it in the app It's free. You get hints, a second try if you miss, and a follow-up question.
Show the answer and worked solution
Answer: A. Detect the missing sequence and recover before declaring completeness.
- After snapshot 100, delta 101 can advance the state to 101. Receiving 103 reveals that update 102 has not been applied.
- The missing update may affect prices or quantities. Use the feed's recovery or resnapshot protocol before claiming state complete through 103.
Interview shortcut. A sequence gap means the book is unknown: recover.
Takeaway. A book requires contiguous state transitions, not just increasing labels.
Why the other choices fail
- Apply 103 because the sequence increased. Increasing sequence numbers establish order among received messages, not the absence of messages between them.
- Apply 103 and use its higher sequence as evidence of a complete book. The latest sequence number identifies a point in the stream, but does not establish that every earlier update was applied.
- Apply 103 after a short wait and treat 102 as skipped. Waiting without recovering still leaves 102 missing.
In the app this has a follow-up where one thing about the setup changes. Try the follow-up.