QuantLib XL implied volatility

Asked by At

I am using QuantLib to price various equity options. I am using both Python and QuantLib XL. In Python, it is easy to construct an option, create a Black Scholes process and then calculate either a price or calculate implied volatility from a price.


from QuantLib import *

exercise = EuropeanExercise(Date(3,August,2019))
payoff = PlainVanillaPayoff(Option.Call, 105.0)
option = EuropeanOption(payoff,exercise)

S = QuoteHandle(SimpleQuote(100.0))
#risk free
r = YieldTermStructureHandle(FlatForward(0, TARGET(), 0.03, 
q = YieldTermStructureHandle(FlatForward(0, TARGET(), 0.01, 
#vol handle
sigma = BlackVolTermStructureHandle(BlackConstantVol(0, 
                                     TARGET(), 0.20, 
#BS process    
process = BlackScholesMertonProcess(S,q,r,sigma)

#Now calculate implied volatility
option.impliedVolatility(25.0, process)

engine = AnalyticEuropeanEngine(process)

This can be done in XL in a similar way using =qlGeneralizedBlackScholesProcess(). Pricing and Greeks are straightforward using =qlInstrumentNPV() and qlVega(), etc. However, it isn't clear how you calculate implied volatility from price. What is the best way to do this?

0 Answers