IntroducingHow to implement Realized Volatility python

How to implement Realized Volatility python

Volatility estimators are especially valuable in modelling financial returns and capturing time-variability of financial series.

In this article, we discuss advanced metrics of volatility and measures of integrated quarticity. Besides, we implement the estimators in Pandas, NumPy and SciPy python libraries.

Quarticity and Realized Volatility python

The libraries that we are using in the implementation of the math formulas are

from scipy.special import gamma
import numpy as np
import pandas as pd

Furthermore, we estimate additional volatility estimators that we build upon realized quarticity, realized quad-power quarticity and realized tri-power quarticity.

The realized fourth-power variation or realized quarticity is a consistent estimator of the integrated quarticity

consistent estimator of the integrated quarticity

A more robust estimator, particularly in the presence of jumps, is the realized quad-power quarticity

realized quad-power quarticity

Similarly robust estimator is also the realized tri-power quarticity

realized tri-power quarticity

In python an implementation looks as following

Moreover, these estimates assist in estimation of three additional realized volatility estimators:

realized volatility estimators

Further Ideas to explore

Corsi et al. (2008) research paper suggests that we can optimize our strategy by taking into account residuals from GARCH model. In particular, they demonstrate that the residuals of the commonly used time–series models for realized volatility exhibit non–Gaussian properties and volatility clustering. To accommodate these properties, authors extend models for realized volatility by replacing the Gaussian with the more flexible normal inverse Gaussian (NIG) distribution to allow for fat–tails and skewness.

From this paper we also reference the idea of less well-known time-series model, auto-regressive fractionally integrated moving average (ARFIMA), which they claimed in 2005 was a promising strategy for modeling and predicting volatility.

Additionally, we might include current and lagged variables as proxies for the information arrival process which potentially can add insight on future volatility.

Finally, we can explicitly separate quadratic variation into continuous and jump components in order to increase the robustness.

References

Corsi, Fulvio & Mittnik, Stefan & Pigorsch, Christian & Pigorsch, Uta. (2008). The Volatility of Realized Volatility. Econometric Reviews. 27. 46-78.