0
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ What is the expiration ? $\endgroup$
    – dm63
    Commented Jul 20, 2019 at 12:24
  • $\begingroup$ its 25th july 2019 $\endgroup$
    – Eka
    Commented Jul 20, 2019 at 14:01
  • $\begingroup$ Your code says European exercise. Do you know what black76 is using? $\endgroup$
    – rajah9
    Commented Jul 20, 2019 at 14:25
  • 1
    $\begingroup$ 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. $\endgroup$
    – dm63
    Commented Jul 20, 2019 at 19:53
  • $\begingroup$ Hard to say without knowing how the online calculator converts dates into time. $\endgroup$ Commented Aug 13, 2019 at 12:39

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.