Black-Scholes Implied Volatility

Introduction

The original Black-Scholes formula is given by

\[\begin{split}BS\left(S,K,\sigma,r,T\right) &=S\Phi\left(d_{1}\right)-e^{-rT}K\Phi\left(d_{2}\right),\\ d_{1}&=\frac{\log\left(S/K\right)+rT}{\sigma\sqrt{T}} +\frac{1}{2}\sigma\sqrt{T},\\ d_{2}&=d_{1}-\sigma\sqrt{T}.\end{split}\]

After normalization by the current asset price \(S\) it can be written as

\[\begin{split}\tilde{BS}\left(X,\sigma,T\right) &=\Phi\left(d_{1}\right)-e^{X}\Phi\left(d_{2}\right),\\ d_{1}&=-\frac{X}{\sigma\sqrt{T}}+\frac{1}{2}\sigma\sqrt{T},\\ d_{2}&=d_{1}-\sigma\sqrt{T},\end{split}\]

where \(X=\log\left(K/F\right)\) is log-forward moneyness, and forward price is given by \(F=Se^{rT}\).

Examples

>>> from impvol import imp_vol, lfmoneyness
>>> strike = [1, .95]
>>> premium = [.024, .057]
>>> price = 1
>>> riskfree = .02
>>> maturity = 30/365
>>> call = True
>>> moneyness = lfmoneyness(price, strike, riskfree, maturity)
>>> vol = imp_vol(moneyness, maturity, premium, call)
>>> print(vol)
[ 0.20277309  0.20093061]
>>> vol = impvol_bisection(moneyness, maturity, premium, call)
>>> print(vol)
[ 0.20270996  0.20095215]

Functions

impvol.impvol.imp_vol(moneyness, maturity, premium, call)[source]

Compute implied volatility given vector of option premium.

Parameters:
moneyness : array_like

Log-forward moneyness

maturity : array_like

Fraction of the year

premium : array_like

Option premium normalized by current asset price

call : bool array_like

Call/put flag. True for call, False for put

Returns:
array_like

Implied volatilities. Shape of the array is according to broadcasting rules.

Notes

This code relies on SciPy root method. Although vectorized, it is still very slow. Bisection method in this impvol library is substantially faster.

impvol.impvol.impvol_bisection(moneyness, maturity, premium, call, tol=1e-05, fcount=1000)[source]

Function to find BS Implied Vol using Bisection Method.

Parameters:
moneyness : array_like

Log-forward moneyness

maturity : array_like

Fraction of the year

premium : array_like

Option premium normalized by current asset price

call : array_like bool

Call/put flag. True for call, False for put

Returns:
array_like

Implied volatilities Shape of the array is according to broadcasting rules.

impvol.impvol.impvol_table(data)[source]

Implied volatility for structured data.

Parameters:
data : pandas DataFrame, record array, or dictionary of arrays

Mandatory labels: moneyness, maturity, premium, call

Returns:
array

Implied volatilities

Notes

‘premium’ should be normalized by the current asset price.

impvol.impvol.lfmoneyness(price, strike, riskfree, maturity)[source]

Compute log-forward moneyness.

Parameters:
price : array_like

Underlying prices

strike : array_like

Option strikes

riskfree : array_like

Annualized risk-free rate

maturity : array_like

Time horizons, in shares of the calendar year

Returns:
array_like

Log-forward moneyness

impvol.impvol.blackscholes_norm(moneyness, maturity, vol, call)[source]

Standardized Black-Scholes Function.

Parameters:
moneyness : array_like

Log-forward moneyness

maturity : array_like

Fraction of the year, i.e. = 30/365

vol : array_like

Annualized volatility (sqrt of variance), i.e. = .15

call : bool array_like

Call/put flag. True for call, False for put

Returns:
array_like

Option premium standardized by current asset price