Technical indicators Garmin-Klass Volatility


Parkinson volatility

Before talk about Garmin-Klass volatility, it is better to understand Parkinson volatility.

Parkinson volatility is a volatility measure that uses the stock’s high and low price of the day. The main difference between regular volatility and Parkinson volatility is that the latter uses high and low prices for a day, rather than only the closing price. A large price movements could happen during the day and if only the close prices are used, it could lose a lot information. Therefore Pakinson’s volatility is considered to be more precise.

The following formula shows the calculation of Parkinson volatility, where $T$ is the number of days in the sample period, $h_t$ is the high price on day t and $l_t$ is the low price on day t.

Parkinson volatility

One main drawback of this estimator is that it doesn’t take into account price movements after market close, that’s why we need to consider Garmin-Klass’s volatility estimator.

Garmin-Klass’s volatility

Garmin-Klass volatility extends Parkinson’s volatility by taking into account the opening and clossing prices. As markets are most active during the opening and closing of a trading day, it makes volatility estimation more accurate.

The following formula shows the calculation of Garming-Klass volatility, where $o_t$ is the open price on day t, $c_t$ is the close price on day t.

Garmin-Klass volatility

We will try to implement Garmin-Klass’s volatility in Python.

import pandas as pd
import sqlite3

# load S&P500 data from stored database
sp500_db = sqlite3.connect(database="sp500_data.sqlite")

df = pd.read_sql_query(sql="SELECT * FROM SP500",
                       con=sp500_db,
                       parse_dates={"Date"})
df.head()

DateTickerAdj CloseCloseHighLowOpenVolume
02014-04-29A35.04953438.12589338.30472237.17453438.1187404688612.0
12014-04-29AAL33.47674235.50999835.65000234.97000135.2000018994200.0
22014-04-29AAPL18.63333321.15464221.28500021.05392821.205000337377600.0
32014-04-29ABBV34.03498551.36999951.52999950.75999850.9399995601300.0
42014-04-29ABT31.83151838.54000138.72000138.25999838.3699994415600.0
# calculate Garmin-Klass volatility
import numpy as np
df['garmin_klass_vol'] = ((np.log(df['High'])-np.log(df['Low']))**2)/2 - (2*np.log(2)-1)*(np.log(df['Adj Close'])-np.log(df['Open']))**2

df.head()

DateTickerAdj CloseCloseHighLowOpenVolumegarmin_klass_vol
02014-04-29A35.04953438.12589338.30472237.17453438.1187404688612.0-0.002274
12014-04-29AAL33.47674235.50999835.65000234.97000135.2000018994200.0-0.000788
22014-04-29AAPL18.63333321.15464221.28500021.05392821.205000337377600.0-0.006397
32014-04-29ABBV34.03498551.36999951.52999950.75999850.9399995601300.0-0.062705
42014-04-29ABT31.83151838.54000138.72000138.25999838.3699994415600.0-0.013411
# update the database
df.to_sql(name="SP500",
          con=sp500_db,
          if_exists="replace",
          index=True)
sp500_db.close()

Author: wenvenn
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source wenvenn !