↓ Skip to main content

Value at Risk

Value at Risk Backtesting in Python: Comparing Historical, Parametric, and Monte Carlo Methods

Value at Risk Backtesting in Python: Comparing Historical, Parametric, and Monte Carlo Methods

Value at Risk (VaR) is the most widely used measure of market risk in finance. It answers a simple question: What is the worst loss I can expect over a given horizon with a certain confidence level? For example, a 1-day 99% VaR of $1M means that, on average, only 1 out of 100 days should see a loss exceeding $1M. But VaR is only useful if it actually captures real losses at the claimed frequency. This is where backtesting comes in: we check whether the number of exceedances (days when losses exceeded the VaR forecast) matches the confidence level. In this post, we implement three VaR estimation methods from scratch in NumPy: Historical VaR — ranking past returns and picking the quantile Parametric (Delta-Normal) VaR — assuming returns are normally distributed Monte Carlo VaR — simulating future paths from a calibrated model We then backtest each method against a known portfolio and verify that the coverage rates match the claimed confidence levels.