Svensson overshooting when fitting the bond yield curve.

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

Svensson overshooting when fitting the bond yield curve.

SteveGe
We use below 5 bonds to fit a yield curve. and then calculate the YTM curve by calculating some fake bond from 1Y to 10Y with 0.5 year each step.  and Svensson YTM are off a lot between 1.5Y and 2.5Y.
As evidenced the curve shape is weird.  Is it known issue or I did not use it properly ?

Date settlementDate = new Date(26, September, 2014);
Settings.instance().setEvaluationDate(settlementDate)
Bond:(effectiveDate:2014-09-26, Period:1Y, Frequency:Annual, coupon:3.79, yield:3.79)
Bond:(effectiveDate:2014-09-26, Period:3Y, Frequency:Annual, coupon:3.97, yield:3.97)
Bond:(effectiveDate:2014-09-26, Period:5Y, Frequency:Annual, coupon:3.99, yield:3.99)
Bond:(effectiveDate:2014-09-26, Period:7Y, Frequency:Annual, coupon:4.16, yield:4.16)
Bond:(effectiveDate:2014-09-26, Period:10Y, Frequency:Annual, coupon:4.26, yield:4.26)

Term     YTM
1Y 3.79
1.5Y     4.113
2Y 4.105
2.5Y     4.038
3Y       3.9698
3.5Y     3.94
4Y       3.935498
4.5Y     3.9584
5Y       3.99
5.5Y     4.0346
6Y       4.0768
6.5Y     4.1224
7Y       4.1598
7.5Y     4.1959
8Y 4.22
8.5Y     4.24
9Y 4.25
9.5Y     4.26
10Y      4.257
KK
Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

KK
Hi SteveGe

What did you get as your parameters? Using excel I managed to get this as a fitted curve - which looks optically ok.

1 3.79% 0.037938
1.5 0.038223
2 0.038586
2.5 0.038958
3 3.97% 0.039314
3.5 0.039648
4 0.03996
4.5 0.040251
5 3.99% 0.040524
5.5 0.040779
6 0.041017
6.5 0.041241
7 4.16% 0.041451
7.5 0.041647
8 0.041831
8.5 0.042004
9 0.042166
9.5 0.042318
10 4.26% 0.04246


beta1 0.045887
beta2 -0.0072
beta3 -0.00558
beta4 -0.00376
lambda1 2.676766
lambda2 0.582564

On Mon, Sep 29, 2014 at 4:39 AM, SteveGe <[hidden email]> wrote:
We use below 5 bonds to fit a yield curve. and then calculate the YTM curve
by calculating some fake bond from 1Y to 10Y with 0.5 year each step.  and
Svensson YTM are off a lot between 1.5Y and 2.5Y.
As evidenced the curve shape is weird.  Is it known issue or I did not use
it properly ?

Date settlementDate = new Date(26, September, 2014);
Settings.instance().setEvaluationDate(settlementDate)
Bond:(effectiveDate:2014-09-26, Period:1Y, Frequency:Annual, coupon:3.79,
yield:3.79)
Bond:(effectiveDate:2014-09-26, Period:3Y, Frequency:Annual, coupon:3.97,
yield:3.97)
Bond:(effectiveDate:2014-09-26, Period:5Y, Frequency:Annual, coupon:3.99,
yield:3.99)
Bond:(effectiveDate:2014-09-26, Period:7Y, Frequency:Annual, coupon:4.16,
yield:4.16)
Bond:(effectiveDate:2014-09-26, Period:10Y, Frequency:Annual, coupon:4.26,
yield:4.26)

Term     YTM
1Y               3.79
1.5Y     4.113
2Y               4.105
2.5Y     4.038
3Y       3.9698
3.5Y     3.94
4Y       3.935498
4.5Y     3.9584
5Y       3.99
5.5Y     4.0346
6Y       4.0768
6.5Y     4.1224
7Y       4.1598
7.5Y     4.1959
8Y               4.22
8.5Y     4.24
9Y               4.25
9.5Y     4.26
10Y      4.257



--
View this message in context: http://quantlib.10058.n7.nabble.com/Svensson-overshooting-when-fitting-the-bond-yield-curve-tp15926.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

SteveGe
Thanks a lot for your quick reply KK.

I modified the example code in QuantLib-1.4\Examples\FittedBondCurve to use my five bonds and coupons.
Code snippet as below.  The parameters I got is very different from yours.

solution_[0] = -0.260551     //this should be your beta1
solution_[1] = 0.249855     //this should be your beta2
solution_[2] = 0.512962    //this should be your beta3
solution_[3] = 0.131457     //this should be your beta4
solution_[4] = 0.0729963    // this might be your 1/lamada1
solution_[5] = 1.56969      // this might be your 1/lamada2


 const Size numberOfBonds = 5;
        Real cleanPrice[numberOfBonds];
        for (Size i=0; i<numberOfBonds; i++) {
            cleanPrice[i]=100.0;
        }
        std::vector< boost::shared_ptr<SimpleQuote> > quote;
        for (Size i=0; i<numberOfBonds; i++) {
            boost::shared_ptr<SimpleQuote> cp(new SimpleQuote(cleanPrice[i]));
            quote.push_back(cp);
        }
        RelinkableHandle<Quote> quoteHandle[numberOfBonds];
        for (Size i=0; i<numberOfBonds; i++) {
            quoteHandle[i].linkTo(quote[i]);
        }
                Integer lengths[] = { 1, 3, 5, 7, 10 };
                Real coupons[] = { 0.0379, 0.0397, 0.0399, 0.0416, 0.0426 };

                DayCounter dc = ActualActual(ActualActual::Bond);
                BusinessDayConvention accrualConvention = Unadjusted;
                BusinessDayConvention convention = Unadjusted;

Did I make any mistake here ?
Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

SteveGe
I suspect this is a bug in Quantlib code.  As in my solution b0 is negative, which should not be the case.
Long-run levels of interest rates b0
Short-run component b1
Medium-term component b2

Also in below paper, It require below constarints.
β1 > 0 , β1 + β2 > 0 .  We also need to have λ > 0.
http://comisef.eu/files/wps031.pdf

But in below code it has NoConstraint. it should have above constraints.

void FittedBondDiscountCurve::FittingMethod::calculate() {
        FittingCost& costFunction = *costFunction_;
        Constraint constraint = NoConstraint();
        // start with the guess solution, if it exists
        Array x(size(), 0.0);
        if (!curve_->guessSolution_.empty()) {
            x = curve_->guessSolution_;
        }


Thanks

Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

randomAlpha
In reply to this post by SteveGe
The betas are not stable so you may get significantly different answers depending on initial guess, tolerance, number of iterations. As long as the pricing errors are minimized you should have similar curves. You should also note that five bonds is not a well populated curve and if you don't include short rates it is possible to get negative values below your shortest maturity.

To compare two different curves it's generally best to diff the forwards as these will be the most sensitive components


> On Sep 29, 2014, at 10:42 PM, SteveGe <[hidden email]> wrote:
>
> Thanks a lot for your quick reply KK.
>
> I modified the example code in QuantLib-1.4\Examples\FittedBondCurve to use
> my five bonds and coupons.
> Code snippet as below.  The parameters I got is very different from yours.
>
> solution_[0] = -0.260551     //this should be your beta1
> solution_[1] = 0.249855     //this should be your beta2
> solution_[2] = 0.512962    //this should be your beta3
> solution_[3] = 0.131457     //this should be your beta4
> solution_[4] = 0.0729963    // this might be your 1/lamada1
> solution_[5] = 1.56969      // this might be your 1/lamada2
>
>
> const Size numberOfBonds = 5;
>        Real cleanPrice[numberOfBonds];
>        for (Size i=0; i<numberOfBonds; i++) {
>            cleanPrice[i]=100.0;
>        }
>        std::vector&lt; boost::shared_ptr&lt;SimpleQuote> > quote;
>        for (Size i=0; i<numberOfBonds; i++) {
>            boost::shared_ptr&lt;SimpleQuote> cp(new
> SimpleQuote(cleanPrice[i]));
>            quote.push_back(cp);
>        }
>        RelinkableHandle quoteHandle[numberOfBonds];
>        for (Size i=0; i<numberOfBonds; i++) {
>            quoteHandle[i].linkTo(quote[i]);
>        }
>        Integer lengths[] = { 1, 3, 5, 7, 10 };
>        Real coupons[] = { 0.0379, 0.0397, 0.0399, 0.0416, 0.0426 };
>
>        DayCounter dc = ActualActual(ActualActual::Bond);
>        BusinessDayConvention accrualConvention = Unadjusted;
>        BusinessDayConvention convention = Unadjusted;
>
> Did I make any mistake here ?
>
>
>
> --
> View this message in context: http://quantlib.10058.n7.nabble.com/Svensson-overshooting-when-fitting-the-bond-yield-curve-tp15926p15929.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

SteveGe
In reply to this post by KK
Hi KK,

How did you get the beta values? I suspect you used the solver in Excel instead of Quantlib. as Quantlib wouldn't not able to produce the correct solution.

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Svensson overshooting when fitting the bond yield curve.

SteveGe
In reply to this post by randomAlpha
We are talking about the overshooting of Svensson implementation. It is the easiest way we can demonstrate something wrong with the implementation in Quantlib.  

I know we should use more bonds/instruments if possible. That is another topic for discussion, but not for this one.