Implementing a limit order book matching engine in Python
This easy coding problem tests your ability to simulate the core logic of an exchange's order-matching system. It is representative of the kind of finance-domain coding round used by quant trading firms to assess whether you understand market microstructure and can implement a greedy matching algorithm correctly.
The problem requires you to maintain two data structures—one for resting buy orders and one for resting sell orders—and apply price-time priority matching rules as each new order arrives. Key challenges include tracking unfilled quantities, efficiently retrieving the best counterparty order at each step, and accumulating the total filled quantity. A clean solution focuses on choosing the right data structures (such as heaps or sorted containers) to make best-order retrieval fast and keeping the matching loop simple and obviously correct.
- Greedy matching and order priority
- Maintaining multiple order books by side
- Heap or priority-queue operations in Python
- Handling partial fills and resting quantity