5.0 | 2 ratings Rate this file 89 Downloads (last 30 days) File Size: 6.79 KB File ID: #29446

Heston Model Calibration and Simulation



18 Nov 2010 (Updated )

Calibrated the Heston Model to market Option prices

| Watch this File

File Information

This code calibrates the heston model to any dataset of the form
of the marketdata.txt file.

Provides analytical heston and MCMC heston pricing of Option

To see an example, run the hestoncalibrationexample.m code

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (18)
06 Dec 2014 boulala666

nice code. but is the problem fixed that "mj" mentioned?

15 Jun 2014 jie

very good

18 Mar 2014 mj

Dear Moeti,
In Heston model, If the parameters obey 2*kappa*theta> sig (known as the Feller condition) then the process volatility is strictly positive. When I run your codes even using your marketdata, calibrated parameters violate the feller condition. Could you please explain why it is so and probably fix it if possible.
Thanks in advance

19 Nov 2013 Carlos AY  
04 Aug 2013 Fanghua

Where is the "MCMC heston pricing" part of pricing because it seems that there is only the analytical approach, or am I missing something here?

Many thanks for anyone who could help me.

25 May 2012 københavner

Hey every one I am trying to run this code as it is but I get the message " Undefined function 'lsqnonlin' for input arguments of type'function_handle'.
Error in hestoncalibrationexample (line 36)
x = lsqnonlin(@costf2,x0,lb,ub);

Any body can help me with this problem?
thanks in advance

22 Oct 2011 TingFu

Dear Moeti Ncube
Thanks for your code, it does help me a lot!
But I have a question for results.
In general, the simulated price should be very close to the Heston model price, right?
But why it seem that there is a gap between "simhes" and "modhes"?

25 Apr 2011 Tilburg University  
03 Mar 2011 Moeti Ncube

Yankun, sorry I could never get your code to work. Perhaps you can send folder in zip format with your revision and I will try to run again.

23 Feb 2011 Yankun

Sorry, I made a mistake.
I mean your HestonCall.m doesn't work correctly when parameters such as St,K,r,T,vt,kap,th,sig,rho,lda are vectors instead of scalars.

23 Feb 2011 Yankun

Dear Moeti Ncube
Thanks for your code.
But I think your HestonCalibration.m doesn't work correctly when parameters such as St,K,r,T,vt,kap,th,sig,rho,lda are vectors instead of scalars.
I've mailed you my modification based on your code.
Thank you.

10 Feb 2011 Catherine

Dear Moeti NCube
I have read several discussions of
pricing and calibration of Heston model and I am wondering if you have encountered the problems alluded to in the following comments on calibrating Heston and pricing Heston calls given parameters:
(1) pricing the option using Heston' formulas " gives rise to an inherent numerical instability as a
consequence of which most implementations of Heston’s formulæ are not robust for moderate to long dated maturities or strong mean reversion."
(2) the calibration can get bogged down in local minima and can take a long time

06 Jan 2011 Moeti Ncube

Hi, and thanks for your questions

Some of the variables you discussed are vectors in the code:

So if you want to modify the strikes and maturities consider you should adjust the marketdata.txt file

St and r is the current value of underlying and risk free rate respectively which will always be scalars. You can't have multiple values for the underlying spot price or risk free rate (technically).

05 Jan 2011 me1 k

Hi moeti, thnx for the code. It gave me the opportunity to understand better the calibration procedure.
However, I am wondering how can the HestonCall(St,K,r,T,vt,kap,th,sig,rho,lda) for example work for vectors.
I mean how can I input St,K,r,T as vectors? What modifications are needed to be done in the code? Thank you in advance.

10 Dec 2010 tbfanso ??

Oh,I see.Thanks for you help!

10 Dec 2010 Moeti Ncube

Correction: volatility equation should be the following
vhes(j+1)=vhes(j)*exp(((kappa*(theta - vhes(j))-0.5*vsigma^2)*dt)/vhes(j) + vsigma*(1/sqrt(vhes(j)))*sqrt(dt)*r2);

10 Dec 2010 Moeti Ncube

Hi, and thanks for comments.

The second column is not needed in the calibration as it was a column I created, for data extraction purposes, to represent how far away from the spot month the contract was. So for example if the value is '1' this mean this contract is 1 month away from expiry, if it has a value of '2', this means the contract is 2 months away from expiry.

Hope this helps.

08 Dec 2010 tbfanso ??

I have read your great code seriously,but I have a some questions.First,about the marketdata the calibration used,the marketdata's first column is strike,and third is implied volatility,the fourth is time to maturity(days),but it seem that the third column data not used in the calibration? and what is the third column data?

Thank you for your time

15 Jun 2011

Corrected volatility simulation to following:

vhes(j+1)=vhes(j)*exp(((kappa*(theta - vhes(j))-0.5*vsigma^2)*dt)/vhes(j) + vsigma*(1/sqrt(vhes(j)))*sqrt(dt)*r2);

Contact us