Trouble with HestonProcess Evolve for custom MC in Python/SWIG

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with HestonProcess Evolve for custom MC in Python/SWIG

kmclaugh
Hi all. I'm having some trouble using the evolve() method for a HestonProcess, it causes an Access violation and crashes. Here is an example. I'm not sure if I'm doing something wrong, or if perhaps something is wrong with my installation. I'm using QuantLib-1.9, QuantLib-SWIG-1.9, swigwin-3.0.12, and boost_1_63_0-msvc-10.0-32.

  today = Date(30, 12, 2016)
  Settings.instance().evaluationDate = today
  option = EuropeanOption(PlainVanillaPayoff(Option.Call, 100.0), EuropeanExercise(Date(30,1,2017)))
 
  u = SimpleQuote(100.0)
  r = SimpleQuote(0.01)
  sigma = SimpleQuote(0.20)
 
  riskFreeCurve=FlatForward(0, TARGET(), QuoteHandle(r), Actual360())
  volatility = BlackConstantVol(0, TARGET(), QuoteHandle(sigma), Actual360())
 
  process = HestonProcess(YieldTermStructureHandle(riskFreeCurve),
                                    YieldTermStructureHandle(FlatForward(0, TARGET(), 0.0, Actual360())),
                                    QuoteHandle(u),
                                    0.04, 0.1, 0.01, 0.05, 0.75)

It prices fine if I add the following lines
model = HestonModel(process)
engine = AnalyticHestonEngine(model)
option.setPricingEngine(engine)
print option.NPV()

but if I call the following
process.evolve(0,25,0.01,0.5)


I already have working code to price an exotic product that works perfectly if I use
BlackProcess()
, so I could just replace the process with Heston, that would be ideal.

I tried looking into
MultiPathGenerator
 also, but the constructor doesn't appear to be exposed through SWIG. Again, perhaps it's a problem with my install.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with HestonProcess Evolve for custom MC in Python/SWIG

kmclaugh
Obviously I strugged for 3 hours before posting this, and then figured it out about 5 min later. :-)

x0, and dw should be arrays for heston, since I need to evolve the vol and spot

BTW, thanks Luigi for the incredible support.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with HestonProcess Evolve for custom MC in Python/SWIG

Luigi Ballabio
Thanks for the kind words :)

Strange that the wrappers let you pass a number when an array was expected, though.  I thought SWIG took care of that and gave a decent error.  What language are you using?

Luigi


On Fri, Feb 24, 2017 at 11:08 PM kmclaugh <[hidden email]> wrote:
Obviously I strugged for 3 hours before posting this, and then figured it out
about 5 min later. :-)

x0, and dw should be arrays for heston, since I need to evolve the vol and
spot

BTW, thanks Luigi for the incredible support.



--
View this message in context: http://quantlib.10058.n7.nabble.com/Trouble-with-HestonProcess-Evolve-for-custom-MC-in-Python-SWIG-tp18110p18111.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with HestonProcess Evolve for custom MC in Python/SWIG

kmclaugh
I'm using Python 2.7 x32.

Seems like the error is unhandled. No error message, just crashes and my IDE (pyscripter) throws a stream EOF error.