|
From: Jack G <jac...@gm...> - 2020-11-27 03:10:59
|
Dear QL Users, I'm getting a slightly cryptic error when I try to manually generate paths for Heston using LD numbers in Python. It works fine for BS: *import QuantLib as ql* *initialValue = ql.QuoteHandle(ql.SimpleQuote(100))* *sigma = 0.2* *today = ql.Date().todaysDate()* *riskFreeTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.0, ql.Actual365Fixed()))* *dividendTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.0, ql.Actual365Fixed()))* *volTS = ql.BlackVolTermStructureHandle(ql.BlackConstantVol(today, ql.NullCalendar(), sigma, ql.Actual365Fixed()))* *process = ql.BlackScholesProcess(initialValue, riskFreeTS, volTS)* *times = ql.TimeGrid(1, 12)* *rng = ql.UniformLowDiscrepancySequenceGenerator(12)* *seq = ql.GaussianLowDiscrepancySequenceGenerator(rng)* *path_gen = ql.GaussianSobolPathGenerator(process, times, seq, False)* *x = path_gen.next()* However, when I try the same with Heston, I get the following error: " RuntimeError: Boost assertion failed: px != 0" *v0 = 0.09 kappa = 0.8 theta = 0.09 rho = 0.4 sigma = 0.1 process = ql.HestonProcess(riskFreeTS, dividendTS, initialValue, v0, kappa, theta, sigma, rho) times = ql.TimeGrid(1, 12) rng = ql.UniformLowDiscrepancySequenceGenerator(12) seq = ql.GaussianLowDiscrepancySequenceGenerator(rng) path_gen = ql.GaussianSobolPathGenerator(process, times, seq, False) x = path_gen.next()* My working hypothesis is that the rng needs to be dimension 24 instead of 12 because of the second vol process that needs to be simulated, but when I change the dimension to 24 I get the following error: "RuntimeError: sequence generator dimensionality (24) != timeSteps (12)" I've looked through the QuantLib-SWIG code but not got too far... any pointers about how I might deal with this? Or have I done something stupid somewhere? Thanks, Jack |