Why Garman–Klass, Realized Volatility, and GARCH Estimates Differ
Summary
The document presents a practitioner’s comparison of three volatility calculations on Tesla data: a realized-volatility measure based on close prices, the range-based Garman–Klass estimator using open, high, low, and close prices, and a fitted GARCH(1,1) forecast. The reported outputs differ substantially, motivating questions about estimator interpretation and the implementation of the GARCH model.
The code makes the comparison difficult to interpret as written. The functions do not clearly produce the same quantity or horizon: the realized and range-based calculations use different inputs and annualization treatments, while the GARCH result is drawn from a forecast variance after returns are scaled. The range-estimator expression and realized-volatility construction also warrant careful checking. The excerpt contains no accepted explanation or verified correction, so the reported values are not evidence that one estimator is wrong or superior. A fair comparison would align return definitions, units, sampling period, forecast horizon, and annualization, then validate each formula separately.
Key ideas
- The document compares close-to-close realized volatility, a range-based Garman–Klass estimate, and a GARCH forecast.
- These methods use different data inputs and describe different volatility quantities.
- Annualization, scaling, sampling windows, and forecast horizons must align for a meaningful comparison.
- The supplied code contains formula and implementation details that need independent verification.
- The reported values alone do not establish that any estimator is incorrect or preferable.
Tags
Full text
# Comparison of results given by volatility estimators: Garman-Klass Vs Garch(1,1)
# Comparison of results given by volatility estimators: Garman-Klass Vs Garch(1,1)
I am pretty new with volatility estimators and I am trying to see if Garman-Klass estimator and Garch(1,1)estimator are closed. So I implemented a python code for the two estimators (an also for the realized volatility estimator as standard deviation of squared returns), but testing it on Tesla data, I have a huge difference between them. That means that my understanding (or my implementation) of these estimators is false. I have unsuccessfully searched for errors.
Below is the python code:
```
import math
import pandas as pd
from pandas_datareader import data as pdr
import numpy as np
import matplotlib.pyplot as plt
from datetime import date
import yfinance as yf
from arch import arch_model
observation_period=10# number of months from the last available day
df = yf.download("TSLA")
df=df.last('%dm'%observation_period)
def annualized_realized_volatility_estimator(df,window_length=observation_period, unit_window_length='m', A=252):
temp=A*(1/len(df))*np.log(df.last('%d'%observation_period+unit_window_length)).diff().dropna()
V=temp['Adj Close'].sum()
return math.sqrt(V)
def Garman_Klass_estimator_row(H, L, O, C,T=len(df.index), A=252):
V=A*(1/T)*(1/2)*(math.log(H/L))**2 - (2*math.log(2)-1)*(math.log(C/O))**2
return V
def Garman_Klass_estimator(df):
vol=math.sqrt(df.apply(lambda row:Garman_Klass_estimator_row(row['High'], row['Low'], row['Open'], row['Close']),axis=1).sum())
return vol
def Garch_model(df,training_period,observation_period,horizon=1): #training_period is the number of months for training the Garch
df_garch=df.last('%dm'%(observation_period+training_period))
df_garch_train=df_garch.first('%dm'%training_period)
df_garch_predict=df_garch.last('%dm'%observation_period)
df_garch_train.loc[:,'Returns']=100 * df_garch_train.loc[:,'Adj Close'].pct_change().dropna()
garch11 = arch_model(df_garch_train.loc[:,'Returns'].dropna(), p=1, q=1)
res = garch11.fit(update_freq=10)
forecasts = res.forecast(horizon=horizon)
return 0.1*forecasts.residual_variance.iloc[-1].values[-1]
```
Calling the three functions with:
```
annualized_realized_volatility_estimator(df,window_length=10, unit_window_length='m', A=252)
Garman_Klass_estimator(df)
Garch_model(df,training_period=6,observation_period,horizon=1)
```
I obtained the following results:
annualized_realized_volatility_estimator=1.643
Garman_Klass_estimator=0.632
Garch_model=2.256
Could someone explain the notable differences between these estimators? Especially between the Garman Klass estimator and the Garch estimator?
Also the code python for the Garch(1,1) is it well-done?
Thanks a lot for your help!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.