Comparing VIX with Historical Volatility Estimates
Summary
The document discusses how to compare the VIX with realized volatility calculated from daily S&P 500 index prices. The questioner computes rolling volatility from log returns, annualizes it using the square root of 252, and asks whether a 30-day or roughly monthly window is appropriate. The reply highlights a key mismatch: VIX represents a constant 30-day expected volatility measure derived from near-term options, while a rolling historical estimate uses a fixed lookback window of past returns.
Because listed options expire, the maturities contributing to VIX change over time. As the near-term contract approaches expiration its remaining term shrinks, then the index rolls into a later contract, changing the effective maturity. This can affect a direct comparison with rolling realized volatility. The response points to the VIX calculation methodology but does not validate the supplied function, settle the choice of historical window, or provide a historical volatility data source. The comparison therefore needs a clearly defined horizon and awareness that implied and realized volatility measure different things.
Key ideas
- VIX is derived from options and reflects expected volatility over a 30-day horizon.
- A rolling historical volatility estimate uses past returns over a chosen lookback window.
- VIX's input option maturities decline over time and change when the index rolls to later contracts.
- Differences in horizon and construction can complicate comparisons between VIX and realized volatility.
Tags
Full text
# VIX vs historical volatility
# VIX vs historical volatility
I'm relatively new to this field and would like to ask a couple of questions.
I'm doing some analysis and I would like to compare/plot VIX vs historical volatility of SPX. I have daily VIX and SPX data. So the first thing I tried to do was to compute historical volatility, I came up with the following function
```
from numpy import sqrt,mean,log,diff
def get_historical_volatility(df, days):
close = df['Close']
r = diff(log(close))
volatility = []
for index in range(days, len(r)):
range_r = r[index-days:days+index]
r_mean = mean(range_r)
diff_square = [(range_r[i]-r_mean)**2 for i in range(0,len(range_r))]
std = sqrt(sum(diff_square)*(1.0/(len(range_r)-1)))
volatility.append(std*sqrt(252)*100)
return volatility
```
Does this function look right?
How many days should I use for historical volatility calculation in order to compare it to VIX? 30 or 21 (average trading days per month)?
This is the current plot I get when plotting VIX vs Historical volatility of 30 days.
Is there any tool/data provider where could I get the historical volatility of SPX so I could compare it with the results I have got?
## Answer by AlRacoon (score 2)
https://quant.stackexchange.com/a/58277
Echoing @noob2 's comments. Additionally, one of the things you might want to be aware of is there is a time to maturity difference between VIX and your calculation of historical volatility. While you are using a constant time frame (30 day) for your volatility calculation, VIX utilizes the near term options contracts for its calculation. As options have an expiration, there is a roll down effect as each day the options have one less day of time left, until the VIX calculation rolls over into the next near term contract. At this point, the time jumps by difference between the maturity of the two contracts. This may or may not make a difference for the intended purpose of your study.
A detailed explanation of the calculation can be found on the CBOE website, http://www.cboe.com/products/vix-index-volatility/vix-options-and-futures/vix-index/the-vix-index-calculation).Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.