|
From: Luigi B. <lui...@gm...> - 2020-11-27 08:35:51
|
Hello Jack,
the Heston process is two-dimensional (it models both underlying and
vol) so you'll need to use a multi-path generator. The error you're
getting is the generator trying to cast the process to a one-dimensional
one and failing.
Luigi
On Fri, Nov 27, 2020 at 4:13 AM Jack G <jac...@gm...> wrote:
> 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
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|