Design an Online Stock Brokerage System Object-Oriented Design Interview
Design a brokerage domain model covering accounts and portfolios, instruments, a cash ledger, market and limit orders, immutable fills, derived positions, order state transitions, and an external exchange gateway boundary — without building a matching engine.
1. Problem Statement
Design an online stock brokerage system: customers place market and limit orders to buy or sell instruments, orders are routed to an exchange and come back as fills (possibly partial), and the account's positions and cash update accordingly. The brokerage does not match orders itself. Start by clarifying scope and the core objects.
2. Live Coding Format
Work in the provided coding workspace while explaining your decisions to the live interviewer. Validation may use inline tests, examples, comments, or a verbal walkthrough.
3. Key Focus Areas
- 1Order lifecycle with market/limit types and partial fills
- 2Immutable fills and positions derived from fills
- 3Cash ledger, reservation, and buying-power policy
- 4ExchangeGateway boundary (no matching engine)
4. What Strong Candidates Should Demonstrate
- ✓Model accounts, portfolios, orders, fills, and positions with a clear external market boundary.
- ✓Derive positions and cash from immutable fills rather than editing them independently.
- ✓Handle partial fills, cancels of remaining quantity, and a buying-power check.
- ✓Represent money precisely and route orders to an exchange gateway without matching them.
Want interactive feedback?
Practice this problem in the live coding workspace while the interviewer probes your clarification, implementation, trade-offs, and validation.
Start Interview