Gamma distribution-related Models¶
-
class
InvGam
(sigma, intr=0.0, divr=0.0, is_fwd=False)[source] Option pricing model with the inverse gamma (reciprocal gamma) distribution.
The parameters (alpha, beta) is from Wikipedia. https://en.wikipedia.org/wiki/Inverse-gamma_distribution Note that the n-th moment of the inverse gamma RV is beta^n / (alpha-1)*…*(alpha-n). Alpha and beta is calibrated to match the first two moments of the lognormal distribution with volatility sigma so that the option price is similar to that of the BSM model with volatility sigma.
Examples
>>> import numpy as np >>> import pyfeng as pf >>> m = pf.InvGam(sigma=0.2, intr=0.05, divr=0.1) >>> m.price(np.arange(80, 121, 10), 100, 1.2) array([15.49803779, 9.53595458, 5.49889751, 3.02086661, 1.60505654])
-
alpha_beta
(spot, texp)[source] Computes the inverse gamma distribution parameters (alpha, beta) from sigma, spot, texp.
m1 = beta/(alpha-1)
m2/m1^2 = exp(sigma^2 T) = (alpha-1)/(alpha-2)
- Parameters
spot – spot (or forward) price
texp – time to expiry
- Returns
(alpha, beta)
-
price
(strike, spot, texp, cp=1)[source] Call/put option price.
- Parameters
strike – strike price.
spot – spot (or forward) price.
texp – time to expiry.
cp – 1/-1 for call/put option.
- Returns
option price
-