Skip to content
All library documents

Estimating Implied Volatility Mean-Reversion Speed with Python

Article Quant Q&A · Author: Merlin

Summary

The document shows how to estimate mean reversion in an implied volatility series using a linear regression in Python. It regresses changes in volatility on the prior volatility level; the intercept and slope can then be used to estimate the long-run mean, reversion speed, and half-life. It also points to ordinary least squares through statsmodels as an alternative to calculating the regression coefficients directly.

The example uses simulated data and reports illustrative coefficient and half-life estimates. It does not provide evidence that implied volatility follows this process in live markets or that the estimates predict when a particular option’s volatility will return to its mean. The question mentions a 30-day average and a one-standard-deviation threshold, but the example does not implement that trigger or estimate a conditional return time. The approach depends on the series being adequately described by a linear mean-reverting model and on the sampling interval used for the observations.

Key ideas

  • Regress changes in the volatility series on its lagged level to estimate mean-reversion parameters.
  • Use the fitted intercept and slope to derive the implied long-run mean and reversion speed.
  • The half-life estimate depends on the regression slope and observation interval.
  • The provided Python example uses simulated data and does not validate the model on market observations.

Tags

Full text
# How to approximate the time to mean reversion for implied volatility in python


# How to approximate the time to mean reversion for implied volatility in python












Its the same question as previous, except I am looking for code in python verses R. How to approximate the time to mean reversion for implied volatility

Given an option and its implied volatility, and also the mean value of the implied volatility over the last 30 days, if we find that the current IV is significantly (> 1 std dev.) away from the mean, then:

How to approximate the time for the IV to mean revert in vectorized python?

## Answer by piRSquared (score 2, accepted)

https://quant.stackexchange.com/a/30293

This is a python duplication with some modeled data

```
import pandas as pd
import numpy as np
from statsmodels.formula import api

n = 1000
x = pd.date_range('2010-12-31', periods=n)
y = np.random.randn(n)
s = pd.Series(y, x)
s = np.clip(abs(s.rolling(5).mean()) + .19, 0, 1.2) * 100

df = pd.concat([s.diff(), s.shift()], axis=1, keys=['diff', 'level']).dropna()

Y = df.iloc[:, [0]].values
X = df.iloc[:, [1]].values
X = np.concatenate([np.ones_like(X), X], axis=1)

beta = np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y)
print(beta)

[[ 21.79316927]
 [ -0.41239735]]
```

calculations

```
long_run_mean = -beta[0, 0] / beta[1, 0]
mean_reversion_speed = -beta[1, 0] * 100
halflife = -np.log(2) / beta[1, 0]

print(long_run_mean)
print(mean_reversion_speed)
print(halflife)

53.359813861
46.3557243425
1.49527850204
```

Use `statsmodels`

```
results = api.ols('diff ~ level', df).fit()
results.params

Intercept    24.735328
level        -0.463557
dtype: float64
```

## Answer by sgdata (score 0)

https://quant.stackexchange.com/a/30236

Can't take credit for this but Stuart Reid over at Turing Finance (great resource) has a great post and notebook on this. Might give you a good starting point.

## Answer by Alex C (score 0)

https://quant.stackexchange.com/a/30246

This post gives an overview of two methods to calibrate an OU process (least squares and max likelihood) and gives some code in Matlab. https://www.sitmo.com/?p=134

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.