Sanjaay Gowda T S
The Goldman Sachs Group, Inc. practice

ORIGINAL COMPANY-CONTEXT PRACTICE

Reconcile a simulated order lifecycle

Software engineeringHardConcept

Original practice scenario: A fictional market simulator receives order acknowledgements, fills and cancellations out of order, sometimes more than once. How should its state machine behave?

Written for independent practice using company context; this is not a verified question from a company interview.

A REASONED APPROACH

Model answer.

Represent orders as a constrained event-driven state machine, with execution quantities separate from request status. Arrival order must not erase a valid fill or apply an event twice.

Work through it

  1. Assign stable order and event identities, record source sequence information and reject events that cannot belong to the referenced order.
  2. Apply deduplicated events under explicit transitions, maintaining cumulative filled quantity and pending cancellation rather than assuming cancellation removes earlier executions.
  3. Replay shuffled and duplicated streams, including partial fills during cancellation and sequence gaps; compare reconstructed state with a trusted synthetic ledger.

Tradeoffs to discuss

  • Waiting for missing sequence events improves certainty but delays visibility; provisional state requires clearly recorded unresolved gaps.

Common pitfalls

  • A cancel request is not a cancellation acknowledgement.
  • Do not decrement inventory twice when the same execution is redelivered.

KEEP PRACTISING

Related questions.

Keep learning beyond the interview.

Explore the Learning Hub