Kernel VaR

The Kernel VaR is a smoothed Historical VaR: the alpha quantile of a Gaussian kernel density of the returns.

The formula for the Kernel VaR first sets the bandwidth h, how far each return is smoothed out, with Silverman’s rule from the sample standard deviation Std of the n returns:

\[h = \text{Std} \cdot \left(\frac{4}{3 \cdot n}\right)^{1/5}\]

Each return \(\text{Return}_{i}\) then becomes a small normal curve of width h around it, and the Kernel VaR is the level below which these curves together hold the tail probability alpha (0.05 for the 95% confidence level), with NormalCDF the standard normal distribution function:

\[\operatorname{mean}\left(\text{NormalCDF}\left(\frac{\text{Kernel VaR} - \text{Return}_{i}}{h}\right)\right) = \alpha\]

It keeps the shape of the history but moves less from one window to the next than the Historical VaR.

The Value at Risk (VaR) is a risk measure: the return that a period only falls below with a small probability alpha, so a 5% VaR of -0.03 means a loss of more than 3% in about one period out of twenty. It is the most widely used measure of downside risk in banking and asset management: risk managers set limits with it and the Basel rules built banks’ market-risk capital on it (their current framework uses the Expected Shortfall), because it sums up the risk of a position in one number in the unit that matters, the loss. The VaR is a return (negative for a loss). The methods differ in how they estimate the tail of the returns, from the plain history to fitted distributions and volatility models.

A VaR says how bad a period gets at the chosen confidence level, not how bad the periods beyond it are, so two assets with the same VaR can have very different tails (see the Conditional Value at Risk for that). Compare assets over the same period and confidence level. Scaling a daily VaR to a longer horizon with the square root of time assumes independent returns, which tends to understate risk when volatility clusters.

Also known as: kernel density VaR, smoothed historical VaR.

In the Finance Toolkit this is get_value_at_risk with method="kernel", the same function as Value at Risk (VaR).

Example · BTCUSD, ETHUSD, ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_value_at_risk:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["BTCUSD", "ETHUSD", "^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.risk.get_value_at_risk(method="kernel", period="yearly", within_period=True)

Which returns:

References

  • Paper Gourieroux, C., Laurent, J.P. and Scaillet, O. (2000). “Sensitivity Analysis of Values at Risk.” Journal of Empirical Finance, 7(3-4), 225-245.
  • Paper Silverman, B.W. (1986). “Density Estimation for Statistics and Data Analysis.” Chapman and Hall.
  • Library Referenced against scipy’s gaussian_kde (Kernel VaR)
Share