Fix a Flaky Prime Broker P&L Reconciliation Test

Last updated: November 29, 2026

Quick Overview

A nightly test that reconciles internal book P&L against the prime broker's file passes most runs but fails a few times a week with one-cent differences; find the likely causes and make the code and test deterministic.

Point72
Software Engineering Fundamentals
Software Engineer
Point72
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


A nightly test that reconciles internal book P&L against the prime broker's file passes most runs but fails a few times a week with one-cent differences; find the likely causes and make the code and test deterministic.

Reconciliation against prime brokers is daily work for Point72 middle-office and platform engineers, and a test that cries wolf gets ignored until a real break slips through. The interviewer is checking whether you debug systematically (reproduce, isolate, fix the root cause) instead of loosening the assertion until it goes green.

What the Interviewer Expects
  • Name concrete sources of nondeterminism: unordered iteration, parallel reductions, unseeded randomness, wall clock and timezone
  • Explain why float summation order changes the result
  • Move money math to Decimal with an explicit rounding mode
  • Make the test reproduce failures with a fixed seed
  • Use a business tolerance for comparisons with the broker, not a bigger epsilon to hide bugs
Key Topics to Cover
flaky tests
floating point error
Decimal arithmetic
determinism
reconciliation
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
  • How would you prove the flake is fixed rather than just rarer?
  • The broker rounds each trade and you round the total. What do you do?
  • How do you quarantine a flaky test without losing its signal?
  • Which of these causes could also affect production numbers, not just the test?
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

Book P&L is the sum over fills of qty x (mark - price). It is compared per book with the prime broker. The test fails intermittently by a cent, which points to nondeterminism rather than a logic error...

High-Level Design

First reproduce: rerun the test in a loop and log the inputs of a failing run. Common causes, roughly in order: (1) fills come from a set or a dict built in hash order, or from a parallel groupby, s...


Submit Your Answer
Markdown supported