Loading
Learn how Value at Risk (VaR) estimates potential financial loss: Parametric, Historical, and Monte Carlo VaR methods with Python code.
Value at Risk (VaR) is a statistical metric that measures the maximum financial loss expected on a portfolio over a defined period (e.g., 1 day) at a specified confidence level (e.g., 95% or 99%).
Financial regulators and bank risk committees rely on VaR and Expected Shortfall to establish mandatory capital adequacy reserves.
import numpy as np
def historical_var(returns, confidence_level=0.95):
"""Calculate Historical Value at Risk (VaR)."""
return -np.percentile(returns, (1 - confidence_level) * 100)
returns = np.random.normal(0.0005, 0.015, 10000)
var_95 = historical_var(returns, 0.95)
print(f"95% 1-Day VaR: {var_95:.2%}")VaR gives the cutoff loss threshold at a confidence level. Expected Shortfall measures the average loss in cases where VaR is exceeded.