Serving the Quantitative Finance Community

 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

December 14th, 2003, 7:49 pm

I'm having problems with the Heston Model:According to Heston's paper, the correlation, rho, should affect the skew of the PDF, and the vol of variance, sigma, should give fat tails.I'm just not getting that effect with sigma. Sigma is affecting the skew, and does not seem to be giving me fat tails. The attached spreadsheet implements this using Monte Carlo, as it is the most intuitive to understand. I know there are other implementations out there, but I'd like to understand why the mechanical monte carlo approach isn't working.If anyone can help out and suggest what is happening, or if I've made a fundamental error in my coding then it would be very much appreciated.thanks,dS
Attachments
HestonMonteCarlo.zip
(64.35 KiB) Downloaded 111 times
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Help with Heston Monte Carlo Spreadsheet

December 15th, 2003, 7:57 pm

Nice sheet, dS! But proper checks are beyond intuition :-) So only some thoughts: inwww.wilmott.com/messageview.cfm?catid=8&threadid=11125&FTVAR_MSGDBTABLE=i posted you a formula to compute it, this would be one way (ok, it is ugly and somewhat on the fly, but it should be possible with lots of paper & pencil + using Gaussintegration - and it would avoid simulation. Hmm, i hope it is correct ... please noteit is without discounting).The next is http://www.math.nyu.edu/fellows_fin_math/gatheral/h2.c giving you acode in C and i want to bet: it works & is ok. You may want to check you VBA codeagainst it.And some vague by looking at your source: you use Rnd() which i never do feelingunsave with it (ok, you use a modification due to Marsaglia ...). There was a posting'normsinv not so random' with some reasonable and fast alternative. The point mayalso be that you do not enough simulations (100 steps ?), but may be here i simplydid not see what you are doing in detail.Hope that helps, even if it does not really solve it. But it is likely Heston is right :-)And finally: if you want to fight those questions more often you may want to thinknot to use only Excel for that, look for a computer algebra system (i used Mapleto get my above formula, but other CAS should work as well).
 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

December 15th, 2003, 9:23 pm

Thanks for the feedback AVt. You're always helpful on this stuff.The spreadsheet is a conversion of some code I wrote in C++ ...I thought it would expecting a bit too much of people to trawl through my C++, and to then plot the results! ...So I don't *think* it is a problem with the random number generator, as I get the same results in C++.The VBA Rnd() function cycles at around 16,000,000 - but my MC isn't reaching that limit. I don't think Rnd() is autocorrelated, but haven't done the testing - but as I say, I'm getting comparable results with my C++ implementation.My original C++ code was heavily influenced by Gatheral - but I will test his code. For his default settings, he uses about the same number of paths as me (he has 30000 with antithetic variables, I have 50000), but 150 steps instead of my 100 steps. In my C++, I run a lot more paths, but generally keep the steps the same - I'll try increasing these.I've got access to Mathematica, so will try to get things working there.If I'm backed into a corner, then I'll go into the maths!One of the things that MC has to deal with (which Gatheral's code has) is what to do if the variance goes negative. As the stochastic eqns for both dS and dv contain sqrt(v), a negative v is clearly a problem. Gatheral says either reflect (v = -v) or absorb (v=0) when v goes negative. Now, I wonder if this actually causes errors in Monte Carlo.The closed form solution just doesn't have to do this. The fact that Monte Carlo has to deal with it suggests to me that it is more and more of an approximation when it has to start manipulating the results (?)
 
User avatar
asd
Posts: 17
Joined: August 15th, 2002, 9:50 pm

Help with Heston Monte Carlo Spreadsheet

December 16th, 2003, 5:13 am

dS, Thanks for posting out your excellent code!It does work as per theory, only thing is I tried with steps =1000 and reduced the paths by 1/10. Rho will change the skew, and sigma makes the curve fatter. I guess, this is what you want.I think, this is because reducing the timestep will reduce the probability of getting negative volatilties for CIR dynamics. Please correct me if I am wrong.It is also a better idea to check the values with Avt's code out there in there in software forum.Hope it helps,asd
Last edited by asd on December 15th, 2003, 11:00 pm, edited 1 time in total.
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Help with Heston Monte Carlo Spreadsheet

December 16th, 2003, 7:29 am

I see ... looking at your plots i am not sure whether you dont miss a factor,the pdf of a lognormal is not pdfN(z): cdfN(ln(x))' = 1/x * pdfN(ln(x)) ...May be asd has the easiest way: either increasing step numbers or use pricesand numerical differentiate twice to get the density (that should be fast).
 
User avatar
hazerider
Posts: 0
Joined: July 24th, 2003, 3:45 pm

Help with Heston Monte Carlo Spreadsheet

December 16th, 2003, 3:03 pm

Slightly off-topic: why do you call a straightforward Box-Muller transform the Marsaglia method?
Last edited by hazerider on December 15th, 2003, 11:00 pm, edited 1 time in total.
 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

December 16th, 2003, 9:14 pm

Increasing the steps doesn't seem to make a difference - I'm still getting more skew as I decrease sigma, which I don't understand.AVt, can you explain a bit more about the pdf - I don't entirely follow you. Surely for the pdf of the returns, all I need to do is:1. Generate lots of expiry stock prices using Monte Carlo of Heston's model2. Calculate the return by dividing by S(0)3. Collect everything up into bins, and calculate the bin frequency (i.e. create a histogram)4. Divide each bin frequency by the total number of results (i.e. the no. of paths in Monte Carlo) to re-scale5. Plot bin frequency vs. bin value - this is my pdfhazerider: For some info of Marsaglia's development of Box-Muller, I've found this:http://ct.radiology.uiowa.edu/~jiangm/c ... ode41.html
 
User avatar
asd
Posts: 17
Joined: August 15th, 2002, 9:50 pm

Help with Heston Monte Carlo Spreadsheet

December 16th, 2003, 11:35 pm

"Increasing the steps doesn't seem to make a difference - I'm still getting more skew as I decrease sigma, which I don't understand"Sorry, I had tried it with large value of sigma around 0.9 and it seemed stable without skew.The skew is indeed still there for sigma around 0.1.Actually, the problem might not be related to Heston's model because if the value of V(0) is set to theta and sigma=0, it is simply a case of lognormal distribution of returns. This itself seems to be skewed.Hope it helps,asd
 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

December 17th, 2003, 6:38 am

Yes of course!As you both point out - I've been plotting the distribution of S(T)/S(0) - which will be lognormal. I should be plotting ln[S(T)/S(0)]I'm getting the right results now - Hooray!...a basic error, which I might have picked up if I had started by plotting the standard Black-Scholes as well. I'll post a corrected spreadsheet over the next day or two.
 
User avatar
robertral
Posts: 0
Joined: March 6th, 2003, 7:12 am

Help with Heston Monte Carlo Spreadsheet

December 17th, 2003, 8:20 am

dS...excellent sheet. I await the updated sheet
 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

December 17th, 2003, 7:34 pm

This is the corrected spreadsheet showing results in line with Heston. Thanks for all of your help.BTW, if you want to understand more about the reflection/absorption issues with the Heston Monte Carlo, then Gatheral has some stuff about it, as does Uwe Wystup in his formula catalogue:http://www.mathfinance.de/
Attachments
HestonMonteCarlo2.zip
(76.03 KiB) Downloaded 92 times
 
User avatar
AVt
Posts: 90
Joined: December 29th, 2001, 8:23 pm

Help with Heston Monte Carlo Spreadsheet

December 25th, 2003, 2:59 pm

If one can give prices (like for the Heston model) there is no need to do MCto produce the pdf, since up to a discounting factor it is the 2nd derivativew.r.t. strike. I did the differentiation numerical (Lagrange method, 5 points,see Abramowitz & Stegun) to get the Heston pdf over logarithmic moneyness =- log(forward/strike) (use chain rule). Who prefers it over the strikes justdo it there (but note that numerical diff one needs equal spacing, so startover the strikes and things become even simplier).It is compared to BS by using the implied vol of the Heston price at ATM(to be understood as strike=forward) using the same method (as a test).The advantage is speed and exactness, but one needs a dense grid of prices.One can choose the grid. If the curves start to jitter integration has tobe improved (larger intervall, smaller subintervalls - in the last sheetjust check what's going on to help yourself ... ). With minor modificationsi used the solution i once uploaded to the software forum (and recognizedthat i forgot to handle the case VolVol=0, so just use a small value like0.001 instead of 0 if neccessary ... ahem).The smile is plotted at the same time. If strikes are extreme than the simplesolution in Excel fails, so do not worry in that case.
Attachments
Heston93_pdf.zip
(95 KiB) Downloaded 90 times
 
User avatar
Demian
Posts: 0
Joined: August 29th, 2004, 3:33 pm

Help with Heston Monte Carlo Spreadsheet

September 6th, 2004, 9:45 am

Hello,With regards to your attachment "HestonMonteCarlo2.zip"...may I ask why you multiply cdf of normal distribution by 2041?I dont understand that part. I appreciate your reppliesdemian
 
User avatar
dS
Topic Author
Posts: 2
Joined: June 10th, 2003, 11:23 am

Help with Heston Monte Carlo Spreadsheet

September 6th, 2004, 10:04 am

...that was a *long* time ago - from memory, it was probably so that the graphs matched up - i.e. created by trial and error in order to produce a reasonable looking report
 
User avatar
Forde
Posts: 1
Joined: November 27th, 2002, 7:45 pm

Help with Heston Monte Carlo Spreadsheet

October 11th, 2004, 12:17 pm

Hi Avt, can u remember where was the thread describing the methodology used to compute vanilla prices under Heston (think it was Gauss Laguerre quadrature)thx