FdHestonHullWhiteVanillaEngine [was Re: SwaptionVolatilityCube]

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

FdHestonHullWhiteVanillaEngine [was Re: SwaptionVolatilityCube]

Selene Makarios

Luigi Ballabio wrote:

> On Thu, 2010-09-23 at 23:46 -0700, Selene Makarios wrote:
>> In quantlib 1.0,
>>
>> swaptionvolcube.cpp, line 75, reads:
>>
>>          // register with SwapIndexBase
>>          if (!swapIndexBase_)
>>              registerWith(swapIndexBase_);
>>          if (!shortSwapIndexBase_)
>>              registerWith(swapIndexBase_);
>>
>> I'm guessing that registering twice with swapIndexBase_ is not intended.
>
> Yes. Also, the tests shouldn't even be there since both pointers are
> required later on in the code.

As I think I implied later on, the tests should be there but should be
logically inverted?

> P.S. If you have other reports, they are welcome but please send them to
> the mailing list...

I wasn't actually sure about the protocol for that...  I didn't know if
it was okay to send such things on a broadcast.  But if you say that's
the way to do it, no problem.

Compare the declaration of the constructor for
FdHestonHullWhiteVanillaEngine, at fdhestonhullwhitevanillaengine.hpp,
line 60:

     FdHestonHullWhiteVanillaEngine(
       const boost::shared_ptr<HestonModel>& model,
       const boost::shared_ptr<HullWhiteProcess>& hwProcess,
       Real corrEquityShortRate,
       Size tGrid = 50, Size xGrid = 100,
       Size vGrid = 40, Size rGrid = 20,
       Size dampingSteps = 0,
       bool controlVariate = true,
       FdmBackwardSolver::FdmSchemeType type
                   = FdmBackwardSolver::Hundsdorfer,
       Real theta = 0.5+std::sqrt(3.0)/6,
       Real mu = 0.5);

with the usage found at test-suite/hybridhestonhullwhiteprocess.cpp,
line 1089:

       new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
                     equityShortRateCorr,
                     tGrid, 61, 13, 9, true));

Note there are four int values, not five, before the bool, and it
appears as if perhaps dampingSteps was omitted, before true was passed
as the value of controlVariate.  So of course this behaves as if the
invocation was

       new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
                     equityShortRateCorr,
                     tGrid, 61, 13, 9, 1));

so that dampingSteps is taken as 1.  I guess the intent of the caller
was to get the default value of dampingSteps, which is 0, while passing
a controlVariate value of true, which could be done:

       new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
                     equityShortRateCorr,
                     tGrid, 61, 13, 9, 0, true));

But the combination of the default-parameter feature, the silent
cast-to-int feature, and the omitted parameter (dampingSteps) resulted
in something else happening.  The unit test here seems to pass like
this, though it's not clear that it tested what was intended.

Yours,
Selene


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: FdHestonHullWhiteVanillaEngine [was Re: SwaptionVolatilityCube]

Klaus Spanderen-2
Hi

you are  right, intended was
new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
                      equityShortRateCorr,
                      tGrid, 61, 13, 9, 0, true));

but the additional dumping step doesn't harm, so the test case passes.

Thanks for the hint, I'm going to change this.

regards
 Klaus


----- original message --------

Subject: [Quantlib-users] FdHestonHullWhiteVanillaEngine [was Re: SwaptionVolatilityCube]
Sent: Wed, 29 Sep 2010
From: Selene Makarios<[hidden email]>

>
> Luigi Ballabio wrote:
> > On Thu, 2010-09-23 at 23:46 -0700, Selene Makarios wrote:
> >> In quantlib 1.0,
> >>
> >> swaptionvolcube.cpp, line 75, reads:
> >>
> >>          // register with SwapIndexBase
> >>          if (!swapIndexBase_)
> >>              registerWith(swapIndexBase_);
> >>          if (!shortSwapIndexBase_)
> >>              registerWith(swapIndexBase_);
> >>
> >> I'm guessing that registering twice with swapIndexBase_ is not intended.
>
> >
> > Yes. Also, the tests shouldn't even be there since both pointers are
> > required later on in the code.
>
> As I think I implied later on, the tests should be there but should be
> logically inverted?
>
> > P.S. If you have other reports, they are welcome but please send them to
> > the mailing list...
>
> I wasn't actually sure about the protocol for that...  I didn't know if
> it was okay to send such things on a broadcast.  But if you say that's
> the way to do it, no problem.
>
> Compare the declaration of the constructor for
> FdHestonHullWhiteVanillaEngine, at fdhestonhullwhitevanillaengine.hpp,
> line 60:
>
>      FdHestonHullWhiteVanillaEngine(
>        const boost::shared_ptr<HestonModel>& model,
>        const boost::shared_ptr<HullWhiteProcess>& hwProcess,
>        Real corrEquityShortRate,
>        Size tGrid = 50, Size xGrid = 100,
>        Size vGrid = 40, Size rGrid = 20,
>        Size dampingSteps = 0,
>        bool controlVariate = true,
>        FdmBackwardSolver::FdmSchemeType type
>                    = FdmBackwardSolver::Hundsdorfer,
>        Real theta = 0.5+std::sqrt(3.0)/6,
>        Real mu = 0.5);
>
> with the usage found at test-suite/hybridhestonhullwhiteprocess.cpp,
> line 1089:
>
>        new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
>                      equityShortRateCorr,
>                      tGrid, 61, 13, 9, true));
>
> Note there are four int values, not five, before the bool, and it
> appears as if perhaps dampingSteps was omitted, before true was passed
> as the value of controlVariate.  So of course this behaves as if the
> invocation was
>
>        new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
>                      equityShortRateCorr,
>                      tGrid, 61, 13, 9, 1));
>
> so that dampingSteps is taken as 1.  I guess the intent of the caller
> was to get the default value of dampingSteps, which is 0, while passing
> a controlVariate value of true, which could be done:
>
>        new FdHestonHullWhiteVanillaEngine(fdmHestonModel, hwProcess,
>                      equityShortRateCorr,
>                      tGrid, 61, 13, 9, 0, true));
>
> But the combination of the default-parameter feature, the silent
> cast-to-int feature, and the omitted parameter (dampingSteps) resulted
> in something else happening.  The unit test here seems to pass like
> this, though it's not clear that it tested what was intended.
>
> Yours,
> Selene
>
>
> ----------------------------------------------------------------------------
> --
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

--- original message end ----


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users