strange output from zeroRate() ?

Posted by Venkatesh Rao on
URL: http://quantlib.414.s1.nabble.com/strange-output-from-zeroRate-tp15113.html

Hi, the zeroRate() function (applied to YieldTermStructure object) appears to be returning zero rates that are too large.  To illustrate, I constructed a simple example based largely on code snippets from /testsuite/piecewiseyieldcurve.cpp.  In brief:

 

* Input  a flat term structure of  deposit + swap rates of 5.0% out to 30 years.

 

    Datum depositData[] = { { 1, Weeks,  5.0 }};

    Datum swapData[] = {

        {  1, Years, 5.0 }, {  2, Years, 5.0 },  {  3, Years, 5.0 },

        ....         { 30, Years, 5.0 }     };

 

* Very minor changes to settings in CommonVars, to construction of "rates" and "instruments" vectors  [adpated to USDLibor rather than Euribor---conclusions are unaffected by that switch]. 

 -> all the info from this stage goes into "vars".

 

*   PiecewiseYieldCurve set up as follows:

    template <class T, class I, template<class C> class B>

    CommonVars CurveMake(CommonVars& vars,

           const I& interpolator = I(),  Real tolerance = 1.0e-9) {

 

        vars.termStructure = boost::shared_ptr<YieldTermStructure>(new

            PiecewiseYieldCurve<T,I,B>(vars.settlement, vars.instruments,

                                       Actual360(), interpolator));

     ...etc....

 

*  Called CurveMake as follows (from main):

     CommonVars varsOut =

      CurveMake<ZeroYield,Linear,IterativeBootstrap>(vars);

 

*  Retrieve  curve info via:

     boost::shared_ptr<YieldTermStructure> yc=  varsOut.termStructure;

 

* For output, set up  vector of target dates (rTdates), and called zeroRate() and discount(); & computed implied zero from discount() as follows:

 

     d0=varsOut.settlement;

     for (Size i=0; i<rtDates.size(); i++) {

         Real rx, df;     dx=rtDates[i];

         rx = Rate(yc->zeroRate(dx,dc, Simple, Annual, true));

         df = yc->discount(dx, true);

         Real zeroFromDf= -log(df)/((dx-d0)/365.);

         wtfil2 <<  std::setw(7) <<std::setprecision(2) << (dx-d0)/365.

                << std::setw(10) <<  std::setprecision(4) << rx

                <<std::setw(10) <<  std::setprecision(6) << df

                << std::setw(10) << std::setprecision(4) <<  zeroFromDf

                <<std::endl;

     }

 

*  OUTPUT:

 

[DayCounter= Actual/Actual (ISDA]

 

                                                         Implied

                                                        Zero rate from

t (Yrs)  zeroRate()  discount()  discount()

    0.5       0.0507  0.975209     0.05007

      1      0.05069  0.951751     0.04945

      2        0.052  0.905711     0.04945

      5      0.05614  0.780837     0.04945

     10      0.06402  0.609626     0.04945

     20      0.08447  0.371827     0.04943

     30       0.1138  0.226552     0.04946

     35       0.1331  0.176776     0.04948

********************************************

 

So,  the implied zero from discount() is close to (but not dead on) the expected 5.0%, but the zeroRate() seems to drift away considerably.  Similar patterns are observed after toggling various settings and parameters (e.g., DayCounters, call CurveMake with Discount instead of ZeroYield, etc.)

 

Am I doing something wrong or misunderstanding what zeroRate() is supposed to be returning?

Any help appreciated.   Thanks

 

P.C. Venkatesh 
Stress Testing
Division of Banking Supervision & Regulation
Board of Governors of the Federal Reserve System
vox: 202 452 3847
email: [hidden email]


 


------------------------------------------------------------------------------

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users