Extremely sorry for bugging the community again, but I am struggling with finding proper documentation of QuantLib Python. I am trying to price Barrier Option using MC Simulation. Here is the code:
from QuantLib import *
import matplotlib.pyplot as plt
barrier, barrierType, optionType, rebate = (80.0, Barrier.DownIn, Option.Call, 0.0)
underlying, strike, rf, sigma, maturity, divYield = (100, 105, .05, 0.2, 12, 0.0)
Grids = (5, 10, 25, 50, 100, 1000, 50000)
maxG = Grids[-1]
today = Settings.instance().evaluationDate
maturity_date = today + int(maturity)
process = BlackScholesMertonProcess(QuoteHandle(SimpleQuote(underlying)),
YieldTermStructureHandle(FlatForward(today, divYield, Thirty360())),
YieldTermStructureHandle(FlatForward(today, rf, Thirty360())),
BlackVolTermStructureHandle(BlackConstantVol(
today, NullCalendar(), sigma, Thirty360())))
option = BarrierOption(barrierType, barrier, rebate,PlainVanillaPayoff(optionType, strike),
EuropeanExercise(maturity_date))
steps = 2
rng = "lowdiscrepancy"
numPaths = 500000
traits=50000
engine = MCBarrierEngine(process, traits)
option.setPricingEngine(engine)
trueValue = option.NPV()
print(trueValue)
Here is the output:
runfile('C:/Users/nitin.kapai/Documents/Exam_v1/QuantLib Code/Barrier_DownIn_MC_Simulation_QuantLib.py', wdir='C:/Users/nitin.kapai/Documents/Exam_v1/QuantLib Code')
Traceback (most recent call last):
File "C:\Users\nitin.kapai\Documents\Exam_v1\QuantLib Code\Barrier_DownIn_MC_Simulation_QuantLib.py", line 35, in <module>
engine = MCBarrierEngine(process, traits)
File "C:\Users\nitin.kapai\Anaconda3\lib\site-packages\QuantLib\QuantLib.py", line 12067, in MCBarrierEngine
traits = traits.lower()
AttributeError: 'int' object has no attribute 'lower'
Any suggestion/feedback would be greatly appreciated