Design Classes for an Options Position and Delta Tracker
Last updated: November 29, 2026
Quick Overview
Design the classes for tracking positions in stocks and options from fills, computing realized PnL with average cost, and aggregating delta per underlying.
Akuna Capital
November 29, 20260
0
0 solved
Design the classes for tracking positions in stocks and options from fills, computing realized PnL with average cost, and aggregating delta per underlying.
Akuna Capital's risk and trading tools all rest on position keeping that is exactly right across stocks and options. The interviewer checks object-oriented modeling (instruments vs positions vs a book), correct handling of fills that reduce or flip a position, contract multipliers, and where Greeks should come from.
What the Interviewer Expects
- Separate immutable instrument definitions from mutable positions
- Handle opening, adding, reducing and flipping fills
- Apply contract multipliers in PnL and delta
- Use polymorphism for instrument-specific delta
- Keep the Greeks source outside the position model
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you add gamma and vega aggregation by expiry bucket?
- How do you make this safe when fills arrive from multiple threads?
- Would you use average cost or FIFO lots, and why might accounting care?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Fills arrive as (instrument, signed qty, price). Track quantity, average price and realized PnL per instrument. Report net delta per underlying in shares, using deltas supplied by a pricing model....
High-Level Design
Instrument is a frozen dataclass with symbol, underlying and multiplier, and a delta() method returning 1 for stock. Option extends it with strike, expiry and call/put, and looks up its delta fr...