Computing realized volatility in Python
This easy coding problem tests your ability to implement a core financial metric in clean, correct Python. Realized volatility—the observed price dispersion of an asset over a historical window—is a foundational concept in quantitative finance. Firms like HRT use it constantly for strategy calibration, position sizing, and comparing options valuations to actual market behaviour.
The problem walks you through the standard three-step pipeline: computing log returns from price series, measuring their sample dispersion, and annualizing to a standard yearly scale. Success requires careful handling of edge cases (short price series), correct application of the sample variance formula (degrees of freedom), and proper scaling. The focus is on translating a precise financial definition into bug-free code, not heavy numerical complexity.
- Log returns and their statistical properties
- Sample variance and degrees of freedom
- Annualization conventions in finance
- Edge-case handling and input validation