Logo

Coding preview

Implement an orderbook 2

What this preview is

About this preview

Implement an orderbook 2 is a medium quant coding problem on language knowledge in Cpp / Python.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Building a pro-rata matching orderbook in C++ or Python

This is a medium-difficulty coding problem that tests your ability to implement a realistic market microstructure component. It builds on the foundational orderbook and introduces pro-rata matching, a matching algorithm used in some electronic exchanges where order queue priority is determined by quantity rather than time of arrival.

The problem requires you to manage two sides of an orderbook (bids and asks), implement order matching with partial fills, track aggressor information, and handle order cancellation. The core challenge is choosing data structures that efficiently support priority-based matching (quantity first, then time), fast order lookup for cancellation, and correct trade generation. You'll need to reason about what happens when a new order arrives: which resting orders it can match against, in what sequence, and how to handle quantity mismatches.

  • Priority queues and custom comparators for non-standard ordering
  • Hash maps for O(1) order lookup and cancellation
  • Partial fill semantics and order state management
  • Aggressor determination and trade record structure