Lesson 1 of 15
Historical VaR
Historical VaR
Value at Risk (VaR) answers: "What is the most I can lose over a given period at a given confidence level?"
The historical simulation approach uses actual past returns — no distributional assumptions needed. You simply sort your return series and read off the appropriate percentile.
Algorithm
Given a list of returns and a confidence level c:
- Sort returns in ascending order
- Compute the index:
idx = int((1 - c) * n) - The VaR is the negative of the return at that index (so VaR is expressed as a positive loss)
For 95% confidence on 7 observations, idx = int(0.05 * 7) = 0, so we take the worst return.
Formula
VaR = -sorted_returns[int((1 - confidence) * n)]
Example
Returns: [-0.05, -0.03, -0.01, 0.01, 0.02, 0.03, 0.04]
Sorted (already sorted), 95% confidence:
idx = 0 → worst return = -0.05 → VaR = 0.05 (5%)
Python runtime loading...
Loading...
Click "Run" to execute your code.