Welcome to the team that runs the order book. A single-symbol limit order book matches incoming orders against resting ones with price-time priority: best price first and, within a price level, oldest order first. Partia…
Welcome to the team that runs the order book. A single-symbol limit order book matches incoming orders against resting ones with price-time priority: best price first and, within a price level, oldest order first. Partial fills reduce the resting quantity; the unfilled remainder of an incoming order rests.
This repository has three reported problems, listed below as tickets. Fix as many tickets as you can in 45 minutes. Each ticket is checked separately, and you are not expected to finish every one.
You may use the AI assistant and normal repository tools. Treat the assistant like a junior developer: establish a plan, inspect its work, run the tests, and retain ownership of the result.
matching/
models.py domain types (Resting, Trade)
errors.py ValidationError
book.py the order book: limit() matching and cancel()
service.py MatchingService: submit() (validates) and cancel()
tests/visible/ shipped regression tests
conftest.py puts the repository root on the import path for pytest
When two resting orders sit at the same price, an incoming order matches the newer one first. Traders who posted earlier at a price are being skipped, which breaks the fairness guarantee of the book.
Do not change validation or the cancel path as part of this ticket.
A partial fill removes the whole resting order instead of reducing its quantity, so the unfilled remainder vanishes from the book. Liquidity disappears after a small incoming order.
Do not change price-time ordering as part of this ticket.
cancel is a no-op: a cancelled order still rests and still matches. Traders are getting fills on orders they pulled.
cancel(order_id), the order no longer rests on either side.Do not change the matching algorithm as part of this ticket.
pytest tests/visible. Every shipped test fails on the starter code and passes once the bugs it covers are fixed.matching/ are submitted; the shipped tests in tests/visible run as they are.Adapted from treasure567/bloomberg-practice (round-2/kestrel @ 8de07d5), used with the author's permission.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
order-book-queue-jumping-lost-partial-fills-and-dead-cancels
Changes under src/ are evaluated.