Debug a Matching Test That Fails on Floating-Point Prices

Last updated: November 29, 2026

Quick Overview

A unit test for a simulated order matcher fails intermittently because a bid at 100.07 sometimes does not cross an ask at 100.07. Find the root cause, fix the price representation, and describe the tests you would add so the bug cannot return.

Hudson River Trading
Software Engineering Fundamentals
Software Engineer
Hudson River Trading
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


A unit test for a simulated order matcher fails intermittently because a bid at 100.07 sometimes does not cross an ask at 100.07. Find the root cause, fix the price representation, and describe the tests you would add so the bug cannot return.

Hudson River Trading engineers write the matching simulators and backtesting tools that strategies run against, and a wrong cross in a simulator silently corrupts research results. This phone-screen style question checks whether a candidate can reason from a flaky symptom to a root cause, and whether they know why trading systems store prices as integer ticks.

What the Interviewer Expects
  • Identify binary floating-point representation as the root cause, with a concrete example such as 0.1 + 0.2 != 0.3
  • Propose integer tick prices at the system boundary rather than epsilon comparisons scattered through the code
  • Reject or flag prices that are off the instrument's tick grid instead of silently rounding them
  • Explain why the failure looked intermittent (prices arrive from different parse or arithmetic paths)
  • Describe targeted regression tests plus a property-based test over many prices
Key Topics to Cover
floating-point representation
fixed-point prices
root cause debugging
regression testing
property-based testing
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Why is comparing with an epsilon a weaker fix than integer ticks in a matcher?
  • How would you handle an instrument whose tick size changes with price level?
  • Where in the pipeline should the conversion happen, and what happens to PnL calculations?
  • How would you find every other place in the codebase with the same bug?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

The matcher must decide bid >= ask exactly. A bid and ask quoted at the same displayed price must always cross. The fix should also make it impossible to represent a price that is not a legal tick, ...

High-Level Design

Root cause: prices are Python floats (or C++ double). 100.07 is not exactly representable in binary, and a price computed as 100.00 + 7 * 0.01 lands on a different nearby double than one parsed ...


Submit Your Answer
Markdown supported