Calculating Volatility using heston Model

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

Calculating Volatility using heston Model

johari_gaurav
Hi, I am new to Quant lib and now confused with big set of classes and structures. My aim is to calculate option volatility using Heston model. I have all other data related like stirke price, dividend, option price etc. I want to calculate it for both European and American options. Could some one point me to any sample code, which can help me in this regard. Thanks, Gaurav
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Volatility using heston Model

MH_quant

Hello Gaurav,

 

What exactly do you mean by calculating option volatility using Heston model? Do you want to calculate vega sensitivities in the Heston Model? Or do you want to calculate implied volatilities from a given Heston Model for a special option? Or do you just want to calibrate the Heston model?

 

In the Heston Model you have 5 parameters that you can fit  (in Quantlib this would be: v0, theta, kappa, sigma and rho; see documentation). In general you calibrate these parameters to the market implied volatility surface. Once done so you can use the Heston Model to calculate your option prices and sensitivities.

 

I can help you with Heston model, since I gained quite a bit experience with heston models in Quantlib. But for the beginning, I would recommend you to have a look at the Quantlib TestSuit. There is a Class called hestonmodel.cpp   There you can find already a lot.

 

Regards,

Michael

 


From: johari_gaurav [mailto:[hidden email]]
Sent: Donnerstag, 16. April 2009 14:30
To: [hidden email]
Subject: [Quantlib-users] Calculating Volatility using heston Model

 

Hi, I am new to Quant lib and now confused with big set of classes and structures. My aim is to calculate option volatility using Heston model. I have all other data related like stirke price, dividend, option price etc. I want to calculate it for both European and American options. Could some one point me to any sample code, which can help me in this regard. Thanks, Gaurav


View this message in context: Calculating Volatility using heston Model
Sent from the quantlib-users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Volatility using heston Model

johari_gaurav
Thanks Michael.

Apology if I was not clear. This is what I want to do:
(1) calibrate the heston model using market data & historical volatility.
              When I say, calibration of heston model, I mean to estimate kappa, theta, rho, sigma and v0. I will provide the other parameter like dividend rate, interest rate, strike price, option price, maturity Date. Is it possible? Is there any sample code for the same?

(2) Once model is calibrated we want to draw the stochastic volatility surface.
              I will be giving some strike price and would try to get stochastic volatility for some periods like volatility at 15 days, 1 months, 2 months, 3 month (100 points like) so that I can plot that curve on the screen for each strike price. Once plotted for various various strike prices, it will look like surface. Is there any sample for that? I am not sure, how would I get stochastic volatility from calibrated heston model? which function to use? I don't see any function returning "volatility"?

Thanks,
Gaurav


MH_quant wrote
Hello Gaurav,

 

What exactly do you mean by calculating option volatility using Heston
model? Do you want to calculate vega sensitivities in the Heston Model? Or
do you want to calculate implied volatilities from a given Heston Model for
a special option? Or do you just want to calibrate the Heston model?

 

In the Heston Model you have 5 parameters that you can fit  (in Quantlib
this would be: v0, theta, kappa, sigma and rho; see documentation). In
general you calibrate these parameters to the market implied volatility
surface. Once done so you can use the Heston Model to calculate your option
prices and sensitivities.

 

I can help you with Heston model, since I gained quite a bit experience with
heston models in Quantlib. But for the beginning, I would recommend you to
have a look at the Quantlib TestSuit. There is a Class called
hestonmodel.cpp   There you can find already a lot.

 

Regards,

Michael

 

  _____  

From: johari_gaurav [mailto:gaurav.johari@tcs.com]
Sent: Donnerstag, 16. April 2009 14:30
To: quantlib-users@lists.sourceforge.net
Subject: [Quantlib-users] Calculating Volatility using heston Model

 

Hi, I am new to Quant lib and now confused with big set of classes and
structures. My aim is to calculate option volatility using Heston model. I
have all other data related like stirke price, dividend, option price etc. I
want to calculate it for both European and American options. Could some one
point me to any sample code, which can help me in this regard. Thanks,
Gaurav

  _____  

View this message in context: Calculating
<http://www.nabble.com/Calculating-Volatility-using-heston-Model-tp23076316p
23076316.html>  Volatility using heston Model
Sent from the quantlib-users
<http://www.nabble.com/quantlib-users-f18375.html>  mailing list archive at
Nabble.com.


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Volatility using heston Model

MH_quant

Hello Gaurav,


--------- citation --------
Apology if I was not clear. This is what I want to do:
(1) calibrate the heston model using market data & historical volatility.
              When I say, calibration of heston model, I mean to estimate
kappa, theta, rho, sigma and v0. I will provide the other parameter like
dividend rate, interest rate, strike price, option price, maturity Date. Is
it possible? Is there any sample code for the same?
----------------------------

Well, that is the normal approach. You provide the parameters like dividend
rate, interest rate, strike prices, option prices and maturities for a set
of liquid market instruments. Then you can calibrate (i.e. estimate) the
heston parameters. You find a sample code for that in the testsuit.

What I don't really understand is why you want to use historical volatility?
When calibrating Heston Model to market data, you normally use the implied
volatilities. What you really need is a set of option prices for liquid
market instruments on your underlying with different strikes and maturities.
But those are in general expressed in BlackScholes implied volatilities.

I will try to roughly explain how the Heston calibration works:

1) You take a set of liquid market options on your underlying (in general
this are plain vanilla call options)

2) You can get the prices from the market and express it in Black Scholes
implied volatilities. (you don't really need the black scholes, but it is
market convention to express plain vanilla option prices in black scholes
implied volatility. Nevertheless, what you need are the option prices)

3) you ably choose a starting set of the Heston parameters. I.e. you set
kappa, theta, rho, sigma and v0 to some arbitrary values. But be aware the
better you choose the starting parameters the better your calibration
success will be. Although the non-linear optimization algorithm used is the
Levenberg-Marquardt algorithm and it is known for producing good calibration
results independently of how good you chose the starting parameters, I
personally figured that the smarter you chose the starting parameters, the
better the calibration will be. You can control the calibration success by
checking the calibrationErrors provided by Quantlib. (if you wonder how to
chose the starting parameters clever, I can write you some extra mails with
references etc. but this would be to much for one email ...)

4) In plain terms what happens next when you start the calibration of your
heston model is the following. The calibration process tries to reproduce
the given option prices of your liquid market instrument with your Heston
Model. If it cant reproduce them properly it adjusts the Heston Parameters
in the right direction and tries again, till it can reproduce the option
prices of your liquid market instruments sufficiently good (or one of the
other End-Criterias forced our calibration process to stop). You will end up
with a calibrated Heston Model.


Once again: where and how are you planning on using the historical
volatilities? I still didn't get that part??




--------- citation --------
(2) Once model is calibrated we want to draw the stochastic volatility
surface.
              I will be giving some strike price and would try to get
stochastic volatility for some periods like volatility at 15 days, 1 months,
2 months, 3 month (100 points like) so that I can plot that curve on the
screen for each strike price. Once plotted for various various strike
prices, it will look like surface. Is there any sample for that? I am not
sure, how would I get stochastic volatility from calibrated heston model?
which function to use? I don't see any function returning "volatility"?
----------------------------



What exactly do you mean by stochastic volatility surface? I have never
heard of the term stochastic volatility surface. The volatility in the
Heston model is a stochastic process. And since it is stochastic it does not
produce one single surface. One could take the risk-neutral conditional
expectation of the stochastic volatility process forward ATM (i.e. S(T)=K)
and you would end up with the local variance at point (K,T). You could then
produce a local variance or a local volatility surface. From there you get
to the implied volatility surface. That works some how with path-integral
representations (that is a bit tricky and I therefore decide to omit it
here).

But why do you want to go such a sophisticated approach. You can just
extract the implied volatilities from the prices of your liquid market
instruments that you were using for the calibration process by numerically
solving the Black Scholes closed form solution for the implied volatility.
Then you can interpolate (extrapolate) to get a complete surface. This is if
the implied volatility surface is what you are looking for??  If not I need
some more information what you mean by the "stochastic volatility surface".


What you can do easily in quantlib is (once you have a calibrated heston
model) use the calibration helpers to get out the implied volatility for a
arbitrary plain vanilla European call/put option with any strike or
maturity.


If you like and you don't get along with the quantlib testsuit, I can
quickly create a little program for you that calibrates a heston model to
liquid market instruments, controls the calibration error and returns you
the Heston Model implied volatility for a arbitrary call option with some
random strike and maturity??

Greetings,
Michael


------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Volatility using heston Model

dhoorens

MH_quant wrote
If you like and you don't get along with the quantlib testsuit, I can
quickly create a little program for you that calibrates a heston model to
liquid market instruments, controls the calibration error and returns you
the Heston Model implied volatility for a arbitrary call option with some
random strike and maturity??
Hi
I'm not the original author, but I will definitively be interested by such a code :-)
Thanks

Regards
David
Reply | Threaded
Open this post in threaded view
|

Re: Calculating Volatility using heston Model

asasi
In reply to this post by MH_quant
Hi, I would be interested in the sample code you mentioned. thanks. AS

MH_quant wrote
--------- citation --------
If you like and you don't get along with the quantlib testsuit, I can
quickly create a little program for you that calibrates a heston model to
liquid market instruments, controls the calibration error and returns you
the Heston Model implied volatility for a arbitrary call option with some
random strike and maturity??
----------------------------
Reply | Threaded
Open this post in threaded view
|

Making Heston Model available in QuantlibXL

Bhavna J
Hello,

Can someone guide me on making Heston model available to QuantlibXL? Which files need to be added to quantlibAddIn etc.
I would like to calibrate the model in excel.

Thanks,
Bhavna

asasi wrote
Hi, I would be interested in the sample code you mentioned. thanks. AS

MH_quant wrote
--------- citation --------
If you like and you don't get along with the quantlib testsuit, I can
quickly create a little program for you that calibrates a heston model to
liquid market instruments, controls the calibration error and returns you
the Heston Model implied volatility for a arbitrary call option with some
random strike and maturity??
----------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Making Heston Model available in QuantlibXL

Luigi Ballabio
On Wed, 2011-10-19 at 02:45 -0700, Bhavna J wrote:
> Can someone guide me on making Heston model available to QuantlibXL? Which
> files need to be added to quantlibAddIn etc.
> I would like to calibrate the model in excel.

Hello,
        I'm not extremely familiar with the Excel addin, but did you have a
look at <http://quantlib.org/quantlibaddin/tutorials.html> already?

Luigi


--

Blessed is the man who, having nothing to say, abstains from giving
wordy evidence of the fact.
-- George Eliot



------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Making Heston Model available in QuantlibXL

Bhavna J
Yes, I have gone through that link, what I need to know is what classes would I need to expose in order to get the entire Heston functionality available.
Currently, I do not even see the Heston Process available in QuantlibAddIn.

Thanks,
Bhavna

On Thu, Oct 20, 2011 at 2:06 PM, Luigi Ballabio <[hidden email]> wrote:
On Wed, 2011-10-19 at 02:45 -0700, Bhavna J wrote:
> Can someone guide me on making Heston model available to QuantlibXL? Which
> files need to be added to quantlibAddIn etc.
> I would like to calibrate the model in excel.

Hello,
       I'm not extremely familiar with the Excel addin, but did you have a
look at <http://quantlib.org/quantlibaddin/tutorials.html> already?

Luigi


--

Blessed is the man who, having nothing to say, abstains from giving
wordy evidence of the fact.
-- George Eliot




------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Ciosco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users