# How to calculate premium in Black Scholes model with quantlib?

I am new to quantlib as well as option price modelling. I need to get premium from black scholes model and found this code in internet

import QuantLib as ql

S=1100
strike=[1000,1100,1110,1120]
v=0.2
ri=0.04

for K in strike:
today = ql.Date(20, 7, 2019)
ql.Settings.instance().evaluationDate = today
# The Instrument
option = ql.EuropeanOption( ql.PlainVanillaPayoff(ql.Option.Call, K),
ql.EuropeanExercise(ql.Date(25, 7, 2019)))
# The Market
u = ql.SimpleQuote(S)      # set todays value of the underlying
r = ql.SimpleQuote(ri)       # set risk-free rate
sigma = ql.SimpleQuote(v)   # set volatility
riskFreeCurve = ql.FlatForward(0, ql.TARGET(), ql.QuoteHandle(r), ql.Actual360())
volatility = ql.BlackConstantVol(0, ql.TARGET(), ql.QuoteHandle(sigma), ql.Actual360())
# The Model
process = ql.BlackScholesProcess( ql.QuoteHandle(u),
ql.YieldTermStructureHandle(riskFreeCurve),
ql.BlackVolTermStructureHandle(volatility))
# The Pricing Engine
engine = ql.AnalyticEuropeanEngine(process)
# The Result
option.setPricingEngine(engine)
print(option.NPV())


With output

100.33327806116641
8.195213254652364
4.131971032227009
1.7912417047751839


But when I did a comparison study with an online Black Scholes calculator, I got differen result

100.55
10.57
6.29
3.43


What is wrong with my code? How to I properly model for premium in quantlib? Did quantlib implementblack76 model?

• What is the expiration ?
– dm63
Jul 20, 2019 at 12:24
• its 25th july 2019
– Eka
Jul 20, 2019 at 14:01
• Your code says European exercise. Do you know what black76 is using? Jul 20, 2019 at 14:25
• I see it is a 5 day option. Perhaps one of the models is using calendar time, meaning that the time to expiration is 5/365 years, whereas the other model is using business days, so it is 5/262 years. Just a guess.
– dm63
Jul 20, 2019 at 19:53
• Hard to say without knowing how the online calculator converts dates into time. Aug 13, 2019 at 12:39

2019-07-20 is a Saturday and 2019-07-21 is a Sunday, so basically you're looking on a 4 day option. Furthermore use ql.Actual365Fixed() to get the same results from the online calculator.