Hull - White Calibration

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

Hull - White Calibration

Perissin Francesco
public: Hull - White Calibration

Hi there,
I am calibrating my Hull-White model in QL 0.3.1 using more or less the same code given in bermudan swaption example. This means considering a set of calibration helpers, and finding the parameters alfa and sigma that minimize the error function, via the simplex optimization method.

Now I'd like to modify slightly this code, in order to keep a given alfa and to find the best sigma. Clearly, this is a much simpler problem since I have a single parameter to calibrate. Unfortunately, I am not an expert user of the library and I'd need some hints in order to reach the goal in a "decent" way...

The code I am currently using is more or less the following:

    CalibrationSet calibrationInstruments;

    .............

    Handle<Model> modelHW(new HullWhite(rhTermStructure));
    Handle<Optimization::Method> om(new Optimization::Simplex(0.25, 1e-9));
    om->setEndCriteria(Optimization::EndCriteria(10000, 1e-7));
    modelHW->calibrate(calibrationInstruments, om);


The modified code should work with a model defined as

    double givenAlfa;
    Handle<Model> modelHW(new HullWhite(rhTermStructure, givenAlfa));


Thanks for the help


Francesco Perissin
Derivatives & Structured Products
Banca del Gottardo
+41 91 808 3730

############################### DISCLAIMER #################################

This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change. Banca del
Gottardo (including its group companies) shall not be liable for the
improper or incomplete transmission of the information contained in this
communication nor for any delay in its receipt or damage to your system.
Banca del Gottardo (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.

############################################################################
Reply | Threaded
Open this post in threaded view
|

Re: Hull - White Calibration

Luigi Ballabio-2
At 03:16 PM 9/16/03, Perissin Francesco wrote:

>I am calibrating my Hull-White model in QL 0.3.1 using more or less the
>same code given in bermudan swaption example. This means considering a set
>of calibration helpers, and finding the parameters alfa and sigma that
>minimize the error function, via the simplex optimization method.
>
>Now I'd like to modify slightly this code, in order to keep a given alfa
>and to find the best sigma. Clearly, this is a much simpler problem since
>I have a single parameter to calibrate. Unfortunately, I am not an expert
>user of the library and I'd need some hints in order to reach the goal in
>a "decent" way...

Hi Francesco,
     long time no see. Upon a superficial inspection of the code, it seems
to me that Sad didn't leave a hook for doing what you need. Were I to
tackle it, I would do something like:

1) create a new class:

         class FixedAlphaHullWhite : public HullWhite { ... };

2) inside the new class, define an inner class:

         class FixedAlphaConstraint : public Constraint { ... };

    equal to Model::PrivateConstraint, but whose method test() works as:

         if (params[0] != fixedAlpha_)
             return false;
         else {
             ... // same as PrivateConstraint
         }

     and whose constructor accepts and store the fixed alpha value besides the
     other parameters;

3) define the constructor of the FixedAlphaHullWhite class as:

         FixedAlphaHullWhite(const RelinkableHandle<TermStructure>& ts,
                             double a, double sigma = 0.01)
         : HullWhite(ts,a,sigma) {
             constraint_ = Handle<Constraint>(
                 new FixedAlphaConstraint(a, arguments_));
         }

4) cross your fingers, compile and hope for the best as the above is highly
    untested.

5) add a feature request to the QuantLib tracker
    (https://sourceforge.net/tracker/?group_id=12740&atid=362740)
    called "Adding custom constraints to short-rate model calibration" or
    something of the kind. Describe the problem shortly.

Hope this helps,
                 Luigi



Reply | Threaded
Open this post in threaded view
|

RE: Hull - White Calibration

Perissin Francesco
In reply to this post by Perissin Francesco
public:RE: [Quantlib-users] Hull - White Calibration

Hi Luigi, Sad, everybody.

Following the precious suggestions given by Luigi, I added the attached module to my QuantLib project.

Unfortunately, the calibration does not work as expected. This is visible after running the following test:

1) calibrate the standard Hull-White model with a termstructure and a set of calibration helpers. Use Simplex optimization algorithm as in BermudanSwaption example.

2) store the resulting parameters, alpha and sigma
3) calibrate the FixedAlphaHullWhite built with the stored alpha, using the same helpers.

After the 2nd calibration, you wil get the stored alpha, as expected, but the sigma is quite different from the one calibrated previously.

I have big trouble in debugging the code. Maybe that somebody who knows better than me the architecture and the mathematics of this part of QuantLib can help me?

Thanks
Francesco




-----Original Message-----
From: Luigi Ballabio [[hidden email]]
Sent: martedì, 16 settembre 2003 16:49
To: Perissin Francesco; '[hidden email]'
Subject: Re: [Quantlib-users] Hull - White Calibration


At 03:16 PM 9/16/03, Perissin Francesco wrote:
>I am calibrating my Hull-White model in QL 0.3.1 using more or less the
>same code given in bermudan swaption example. This means considering a set
>of calibration helpers, and finding the parameters alfa and sigma that
>minimize the error function, via the simplex optimization method.
>
>Now I'd like to modify slightly this code, in order to keep a given
>alfa
>and to find the best sigma. Clearly, this is a much simpler problem since
>I have a single parameter to calibrate. Unfortunately, I am not an expert
>user of the library and I'd need some hints in order to reach the goal in
>a "decent" way...

Hi Francesco,
     long time no see. Upon a superficial inspection of the code, it seems
to me that Sad didn't leave a hook for doing what you need. Were I to
tackle it, I would do something like:

1) create a new class:

         class FixedAlphaHullWhite : public HullWhite { ... };

2) inside the new class, define an inner class:

         class FixedAlphaConstraint : public Constraint { ... };

    equal to Model::PrivateConstraint, but whose method test() works as:

         if (params[0] != fixedAlpha_)
             return false;
         else {
             ... // same as PrivateConstraint
         }

     and whose constructor accepts and store the fixed alpha value besides the
     other parameters;

3) define the constructor of the FixedAlphaHullWhite class as:

         FixedAlphaHullWhite(const RelinkableHandle<TermStructure>& ts,
                             double a, double sigma = 0.01)
         : HullWhite(ts,a,sigma) {
             constraint_ = Handle<Constraint>(
                 new FixedAlphaConstraint(a, arguments_));
         }

4) cross your fingers, compile and hope for the best as the above is highly
    untested.

5) add a feature request to the QuantLib tracker
    (https://sourceforge.net/tracker/?group_id=12740&atid=362740)
    called "Adding custom constraints to short-rate model calibration" or
    something of the kind. Describe the problem shortly.

Hope this helps,
                 Luigi

  ############################### DISCLAIMER #################################

This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change. Banca del
Gottardo (including its group companies) shall not be liable for the
improper or incomplete transmission of the information contained in this
communication nor for any delay in its receipt or damage to your system.
Banca del Gottardo (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.

############################################################################


fixedalphahullwhite.hpp (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Hull - White Calibration

Perissin Francesco
In reply to this post by Perissin Francesco
public:RE: [Quantlib-users] Hull - White Calibration

Hi all, after some debuggin I finally solved my problem in calibrating Hull & White model with one free parameter. THe characteristic length lambda, given to the constructor of Simplex, was too high, i.e. 0.25. Setting it to 0.05 resolves the problem. Due to unknown (to me) gemoetrical reasons, the "amoeba" present in the Simplex was adapting itself in the correct way in the 2dim problem even with that big length, but was not able to do the same in 1dim ....



Please note that the BermudanSwaption example is using the high value 0.25, therefore I would suggest to replace it with a lower value, maybe 0.05 itself.

If everybody agrees, I will file my patch on Sourceforge, otherwise please let me know


ciao
Francesco

############################### DISCLAIMER #################################

This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change. Banca del
Gottardo (including its group companies) shall not be liable for the
improper or incomplete transmission of the information contained in this
communication nor for any delay in its receipt or damage to your system.
Banca del Gottardo (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.

############################################################################
Reply | Threaded
Open this post in threaded view
|

RE: Hull - White Calibration

Ferdinando M. Ametrano-3
In reply to this post by Perissin Francesco
At 09:05 AM 9/24/2003 +0200, you wrote:

>after some debuggin I finally solved my problem in calibrating Hull &
>White model with one free parameter. THe characteristic length lambda,
>given to the constructor of Simplex, was too high, i.e. 0.25. Setting it
>to 0.05 resolves the problem. [...]
>Please note that the BermudanSwaption example is using the high value
>0.25, therefore I would suggest to replace it with a lower value, maybe
>0.05 itself.
>
>If everybody agrees, I will file my patch on Sourceforge, otherwise please
>let me know
that would be perfect. Thank you very much Francesco

ciao -- Nando



Reply | Threaded
Open this post in threaded view
|

RE: Hull - White Calibration

Luigi Ballabio-2
In reply to this post by Perissin Francesco
At 09:05 AM 9/24/03, Perissin Francesco wrote:
>Please note that the BermudanSwaption example is using the high value
>0.25, therefore I would suggest to replace it with a lower value, maybe
>0.05 itself.

Francesco,
         did you try and see what happens if you do?

Just curious,
                 Luigi




Reply | Threaded
Open this post in threaded view
|

RE: Hull - White Calibration

Perissin Francesco
In reply to this post by Perissin Francesco
public:RE: [Quantlib-users] Hull - White Calibration

Yes,
I tried it on a series of real historical data of the USD curves and swaptions, and also on the current USD data. With the modification suggested, the 1-dim calibration works perfectly, otherwise it does not.

On the other hand, you should consider that the calibration always runs properly with a 2-dim calibration, which is the one available in current QuantLib version, and consequently in BermudanSwaption example. The incorrect behaviour is only visible if one is using a 1-dim Hull&White, which is the piece of code that you suggested me some days ago.

Francesco
 

-----Original Message-----
From: Luigi Ballabio [[hidden email]]
Sent: mercoledì, 24 settembre 2003 12:07
To: Perissin Francesco; '[hidden email]'; 'Sadruddin Rejeb ([hidden email])'
Subject: RE: [Quantlib-users] Hull - White Calibration


At 09:05 AM 9/24/03, Perissin Francesco wrote:
>Please note that the BermudanSwaption example is using the high value
>0.25, therefore I would suggest to replace it with a lower value, maybe
>0.05 itself.

Francesco,
         did you try and see what happens if you do?

Just curious,
                 Luigi

############################### DISCLAIMER #################################

This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change. Banca del
Gottardo (including its group companies) shall not be liable for the
improper or incomplete transmission of the information contained in this
communication nor for any delay in its receipt or damage to your system.
Banca del Gottardo (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.

############################################################################