1

I have recently started exploring the QuantLib option pricing libraries for python and have come across an error that I don't seem to understand. Basically, I am trying to price an Up&Out Barrier option using the Heston model. The code that I have written has been taken from examples found online and adapted to my specific case. Essentially, the problem is that when I run the code below I get an error that I believe is triggered at the last line of the code, i.e. the european_option.NPV() function

*** RuntimeError: wrong argument type

Can someone please explain me what I am doing wrong?

# option inputs
maturity_date = ql.Date(30, 6, 2020)
spot_price = 969.74
strike_price = 1000
volatility = 0.20
dividend_rate = 0.0
option_type = ql.Option.Call
risk_free_rate = 0.0016
day_count = ql.Actual365Fixed()
calculation_date = ql.Date(26, 6, 2020)
ql.Settings.instance().evaluationDate = calculation_date

# construct the option payoff
european_option = ql.BarrierOption(ql.Barrier.UpOut, Barrier, Rebate,
                      ql.PlainVanillaPayoff(option_type, strike_price),
                      ql.EuropeanExercise(maturity_date))

# set the Heston parameters
v0 = volatility*volatility # spot variance
kappa = 0.1
theta = v0
hsigma = 0.1
rho = -0.75
spot_handle = ql.QuoteHandle(ql.SimpleQuote(spot_price))

# construct the Heston process
flat_ts = ql.YieldTermStructureHandle(ql.FlatForward(calculation_date,
                                                     risk_free_rate, day_count))

dividend_yield = ql.YieldTermStructureHandle(ql.FlatForward(calculation_date,
                                                            dividend_rate, day_count))
heston_process = ql.HestonProcess(flat_ts, dividend_yield,
                                  spot_handle, v0, kappa,
                                  theta, hsigma, rho)

# run the pricing engine
engine = ql.AnalyticHestonEngine(ql.HestonModel(heston_process),0.01, 1000)
european_option.setPricingEngine(engine)

h_price = european_option.NPV()
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Lorenzo R
  • 11
  • 2

1 Answers1

2

The problem is that the AnalyticHestonEngine is not able to price Barrier options.

Check here https://www.quantlib.org/reference/group__barrierengines.html for a list of Barrier Option pricing engines.

David Duarte
  • 644
  • 4
  • 11