We can take the Heston equation, 'pde', from the previous post and do some neat calculations with it, via NDSolve[ ]. Now, I don't normally use NDSolve[ ] for this kind of stuff, so if there's a better way of doing things, please don't hesitate to let us know... And sorry, I still haven't gotten the hang of entering raw Mathematica code into this wiki environment, so I'm afraid I am going to use GIFs again.
Firstly, for convenience, assign some of Heston's 'classic' greek-style variables to ascii-based names (so that, eg, VBA & C++ code is somewhat interchangeable). And again I use some proprietary software to calculate the Heston and Black-Scholes-Merton option prices for the given parameters, but please see the references mentioned above in the previous post to download equivalent models. The last two prices of about 24.3 cents are the Heston price with negligible stochastic vol and std BSM respectively (i.e. essential equivalent), whereas the 3rd-last value of about 17.2 cents is the heston call price in the presence of significant stochastic vol...
So essentially our goal is to use NDSolve[ ] to replicate that heston price of about 17.2 cents.
Firstly, becauseBecause we are going to be using numerical methods, we need to have an idea of the space in which we are working. That is, the min and max asset prices and volatilities that we will be working within when calculating our solution. The following shows how to use ItoProcess[ ] to get an estimate of the "6 standard deviation" upper and lower bounds: SMin, SMax, VMin and VMax (the last two being variance rather than volatility). When taken with the time constraints of "now" (ie. t=0) and the option expiry, these bounds effectively put the Ito process in a 3D box (i.e. denote the boundary conditions) which is then solvable with NDSolve[ ]...
Now that we have the pde (which we've earlier mapped to "pde2" so we can use convenient symbols) constrained within reasonable bounds, it is then fairly trivial to put it into NDSolve[ ] and get a Heston option price. I'm pretty much a novice at using NDSolve[ ], so if you know of better, more accurate or efficient ways of doing this, please don't hesitate to jump in and let us know...
OK, there are some warnings - PLEASE HELP ME TO MAKE THEM GO AWAY! :) And the graphical surface of option value looks ghastly - help with that would be welcomed, too. But notwithstanding the awkwardness of the solution method, it gives a value close to the expected value of 17.2 cents (which is significantly different to the BSM value of 24.3 cents), so something must be working ok. You can see that I've also tried "method of lines" of the pseudospectral flavour, and I've tried a few other NDSolve options, though I've found (so far) that the extra computation time is not worth the additional precision (IMHO).
Well, this nice bottle of red is bottoming, so I'll leave it at that. Cheers.