Portfolio Risk Engine: VaR, Expected Shortfall, and Backtesting
A production-quality risk engine computing Value-at-Risk three ways (historical, parametric, Monte Carlo) with GARCH(1,1) volatility modeling, formal backtests, and an interactive Streamlit dashboard.
The Question
How should a portfolio manager quantify the tail risk of a portfolio — and how do you know if your risk model is any good?
VaR is the industry standard for tail risk measurement, but it comes in several flavors with very different assumptions. Historical simulation makes no distributional assumptions; parametric VaR assumes normality; Monte Carlo can handle complex dependency structures. Each has different failure modes under market stress. The backtesting question — whether the model was right — is equally important and frequently neglected.
Approach (In Progress)
VaR computation:
- Historical simulation: empirical quantile of the return distribution
- Parametric (delta-normal): VaR = μ − z_α · σ, with EWMA and GARCH(1,1) volatility estimates
- Monte Carlo: Cholesky decomposition of the covariance matrix, 10,000 paths per period
Backtesting:
- Kupiec proportion-of-failures test (unconditional coverage)
- Christoffersen interval forecast test (conditional coverage — tests for clustering of violations)
- Basel traffic-light backtesting framework (green/yellow/red zones)
Expected Shortfall (CVaR): Mean loss conditional on exceeding VaR, reported alongside VaR at 95% and 99% confidence levels.
Stress testing: Historical scenario application (2008 GFC, COVID March 2020) to estimate tail behavior under known crises.
Status
Core VaR and backtesting modules complete. GARCH integration in progress. Streamlit dashboard being built for interactive portfolio construction and scenario analysis. Target completion: July 2026.