Login  Register

Re: Error when using a Cubic interpolator for PiecewiseYieldCurve

Posted by Kim Kuen Tang on Jul 29, 2010; 8:08pm
URL: http://quantlib.414.s1.nabble.com/Error-when-using-a-Cubic-interpolator-for-PiecewiseYieldCurve-tp7607p7610.html

Robert Philipp schrieb:

> I'm just starting out with QuantlLib and started going through the
> examples . In an attempt to get smoother forwards, I would like to use
> a cubic (or log-cubic, or monotonic) interpolator instead of the
> log-linear interpolator. So I modified the example code
> "swapvaluation.cpp" by replacing
>
>         boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(
>             new PiecewiseYieldCurve< Discount, *LogLinear*>(
>                                        settlementDate,
> depoFutSwapInstruments,
>                                        termStructureDayCounter,
>                                        tolerance));
>
> with
>         boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(
>             new PiecewiseYieldCurve< Discount, *Cubic *>(
>                                        settlementDate,
> depoFutSwapInstruments,
>                                        termStructureDayCounter,
>                                        tolerance));
>
> I get the following error message:
>         1st iteration: failed at 10th instrument, maturity December
> 20th, 2006, reference date September 22nd, 2004:
>         root not bracketed: f[2.22045e-016,0.932437] ->
> [-3.323214e+018,-3.911669e+000]
This can be a design or implementation issue. solver1d.hpp  uses
assertions to detect ill-posed problems and throws an error if the code
is being misused. Take a look at lines 195 :

            QL_REQUIRE(fxMin_*fxMax_ < 0.0,
                       "root not bracketed: f["
                       << xMin_ << "," << xMax_ << "] -> ["
                       << std::scientific
                       << fxMin_ << "," << fxMax_ << "]");

For testing you can comment it out, and calculate the results. It might
be that the assertion is being too restrictive.
Do you mind to supply the data that you want to bootstrapp? (
Instrument, Maturity,value,...)
HTH
-Kim

>
> The full output is:
>         Today: Monday, September 20th, 2004
>         Settlement date: Wednesday, September 22nd, 2004
>        
> ====================================================================
>         5-year market swap-rate = 4.43 %
>        
> ====================================================================
>                 5-years swap paying 4.00 %
>         term structure | net present value | fair spread | fair fixed
> rate |
>        
> --------------------------------------------------------------------
>              depo-swap |          19065.88 |     -0.42 % |          
> 4.43 % |
>         1st iteration: failed at 10th instrument, maturity December
> 20th, 2006, reference date September 22nd, 2004:
>         root not bracketed: f[2.22045e-016,0.932437] ->
> [-3.323214e+018,-3.911669e+000]
>
> Is there something additional I must do when using an interpolator
> other than LogLinear?
>
> Thanks,
> --
> Robert Philipp
> Synapse Financial Engineering
> 703.623.4063 (mobile)
> 703.573.0119 (fax)
>
> [hidden email]
> www.synapsefe.com
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://p.sf.net/sfu/dev2dev-palm
> ------------------------------------------------------------------------
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>  


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users