Implementing delta-hedged options P&L attribution in Python
This medium-difficulty coding problem tests whether you can translate the Black-Scholes Greeks and daily P&L decomposition into clean, correct Python. It's the kind of task you'd encounter in a quant trading or options-analytics role: take raw Greeks from a market-data feed, apply the first-order P&L formula, and produce daily attribution breakdowns that traders use to understand where their money came from.
The core challenge is applying the formula accurately: theta decays by a fixed fraction of the year, gamma P&L is a quadratic function of the realized spot move, and vega P&L is linear in the vol change. Rounding and handling empty inputs matter for production robustness. Strong solutions compute all three components cleanly, return the correct structure, and handle the time-scaling constant without mistakes.
- Greeks and their units in options markets
- First-order P&L decomposition and the Greeks formula
- Time-value conventions (252 trading days per year)
- Precision and data structure handling