Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Good-Till-Trade Order Service

Design durable long-lived orders that survive daily exchange expiry, preserve intermediate history, and recover uncertain replacement attempts.

Problem statement

For this exercise, assume customers submit good-till-trade orders that remain active through an explicit expiry date even though the exchange expires each child order at the end of a trading day.

The service stores the authoritative customer order and every child exchange attempt, consumes accepted, partially filled, filled, cancelled, rejected, and expired exchange events, and replaces only the remaining quantity on the next eligible trading day.

Each customer command and exchange attempt has a stable identity. Duplicate events and exact command retries are harmless. An ambiguous place or cancel response is reconciled against the broker before any replacement is authorized, and a customer cancellation races safely with fills and the daily rollover.

Assume 20 million open customer orders, 30,000 exchange events per second at peak, a five-minute market-open recovery objective, and complete seven-year order history. Price discovery, portfolio accounting, settlement, and exchange matching are outside scope.

What to build

  1. A customer can idempotently create, inspect, and cancel a good-till-trade order whose durable record is authoritative.
  2. The service records every exchange child attempt and applies duplicate or out-of-order lifecycle events without losing fills or regressing state.
  3. After daily exchange expiry, the service replaces only eligible remaining quantity on the next trading day and never creates two live children for one order generation.
  4. Ambiguous broker outcomes, cancellation races, and rollover failures become explicit reconciliation states with auditable recovery.

At scale

  • Twenty million open customer orders and 30,000 exchange events per second are authored practice assumptions.
  • Market-open recovery completes within five minutes after a regional failover.
  • Customer and child-order history is retained for seven years.