简体   繁体   中英

SABR Model Implied Volatility in VBA

I am trying to write a code that is going to calculate the implied volatility according to the SABR Model given the the mentioned parameters. However, I always get NA for ATM vol. Implied volatility formula being used is this one: 在此处输入图片说明

Function SABRIV(alpha As Double, beta As Double, v As Double, rho As Double, f As Double, k As Double, T As Double) As Double
Dim z As Double
Dim x As Double
Dim numerator As Double
Dim denominator As Double

z = (v / alpha) * ((f * k) ^ ((1 - beta) / 2)) * Application.Ln(f / k)
x = Application.Ln((Sqr(1 - 2 * rho * z + z ^ 2) + z - rho) / (1 - rho))
numerator = ((1 - beta) ^ 2 / 24) * ((alpha ^ 2) / ((f * k) ^ (1 - beta))) + 1 / 4 * (rho * beta * v * alpha) / ((f * k) ^ ((1 - beta) / 2)) + (((2 - 3 * rho ^ 2) * v ^ 2) / 24)
denominator = (((f * k) ^ ((1 - beta) / 2)) * (1 + (((1 - beta) ^ 2) / 24) * (Application.Ln(f / k) ^ 2) + (((1 - beta) ^ 4) / 1920) * (Application.Ln(f / k) ^ 4)))

SABRIV = (alpha * (1 + numerator) * T) / denominator * z / x
End Function

Volatility ATM(when f==K) has a special case formula. Looking at your function, z/x(z)==1 , the denominator reduces to f**(1 - beta) since log(f/K) vanishes so you get:

SABRIV = (alpha * (1 + numerator) * T) / denominator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM