Re: Modifying FittedBondDiscountCurve - 1st Mystery

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

Re: Modifying FittedBondDiscountCurve - 1st Mystery

Nicholas Manganaro-2

In response to Allen’s advice, I went looking into the best method of modeling a discount instrument as a fixed rate bond with a 0% coupon and ran into what seems an inconsistency.

 

I used the terms for a T-Bill, then modeled it as a 0% note with a 6m tenor and another with a 1Y tenor. The yields are not the same, even though I confirmed the cash flows are. I got the following results whether I used the most recent version of the add-in for QuantLibXL 1.4.0 I built with Visual Studio 2012 or the xll add-in downloaded from GitHub.

Results:

 

Not happy with that, I tried in using the QuantLibXL I built from the version of Quantlib from February 27, 2014, also named 1.4.0, but using Visual Studio 2010.

Results:

 

The same pattern of results is evident if I use Semiannual compounding, although the numbers themselves are different. At least the bill’s yield is the same from version to version.

On the plus side, if I think the new results are accurate, I can go forward using the fake note with 1Y tenor approach to try out the curve fitting, as it leads me to expect results that are more representative of the discount instruments I want to add to the curve fitting process.

On the down side, the fact that the yields are not uniform and that there are changes from the old to the new version make one wonder what is really going on here.

 

Any insights? I’d be happy to forward my spreadsheet if there is interest.

 

Cheers!

-Nick

 

From: Allen Kuo [mailto:[hidden email]]
Sent: Friday, July 04, 2014 8:10 AM
To: [hidden email]; [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve

 

Nick: I haven't looked at this in a long time but could you created instances of discount bonds as  special cases of a fixed rate bonds with a single cash flow, i.e. would the current code still work with FixedRateBondHelpers ?

 

If so, then I probably should change the To Do in the documentation.

 

Allen

 

On Friday, 4 July 2014, 19:54, Nicholas Manganaro <[hidden email]> wrote:

 

I was taking a look at <ql/termstructures/yield/fittedbonddiscountcurve.hpp> and saw the note:

       \todo refactor the bond helper class so that it is pure

              virtual and returns a generic bond or its cash

              flows. Derived classes would include helpers for

              fixed-rate and zero-coupon bonds. In this way, both

              bonds and bills can be used to fit a discount curve

              using the exact same machinery. At present, only

              fixed-coupon bonds are supported. An even better way to

              move forward might be to get rate helpers to return

              cashflows, in which case this class could be used to fit

              any set of cash flows, not just bonds.

 

I would like to include discount instruments in curve construction, if possible. Has anyone made progress along that path, perhaps on the line of the steps identified in this note?

I would appreciate advice or comments on the work necessary to use generic cash flows in this process, if it would not require a major re-write of the library.

Thanks.

-Nick


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying FittedBondDiscountCurve - 1st Mystery

Allen Kuo-2
Hi Nick :

1. Note the yield to maturities for each bond, calculated by hand, but assuming slight number
of difference in days as the tenors (which I define as "remaining maturity") :

yield to maturity    tenor (days)
5.69530%           364  [date diff between 8/22/1996 and 8/21/1997]
5.67926%           365
5.66331%           366

2. Tho I don't have excel addin installed or any of the latest quantlib versions, in your excel addin,
I see you specified both maturity date and "tenor" (6M or 1Y). Though you can construct a bond's cash flows
using either, see if you can leave out the "tenor" and to get the excel addin to give you a response just
based on the maturity date you input. This will reduce the number of variables we are looking at. It could be
that because you specified a 1Y tenor for your "fake" bill, QuantLib 1.4.0/VS2010  assumed the tenor was
exactly one year, and thus gave you the 5.67926% response above. For your real zero coupon bond, appears
you only specified the exact maturity date, and are thus getting the the 5.69530% number above.

3. This doesn't explain the Github / VS 2012 results but lets take it a step at a time. I don't understand
the "6M tenor" fake bond- no real need to test with that bond either, because if the tenor (defining
tenor as "remaining maturity") were 6M, the yield to maturity would be very different than your real zero
coupon bond of tenor 1Y (remaining maturity), assuming both have the same prices. Or I just don't understand
"tenor" in Excel add-in....


Allen

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying FittedBondDiscountCurve - 1st Mystery

Luigi Ballabio
Hi,
    just to add another possibility: in principle, you might be able to use discount instruments directly by instantiating the bond and passing it to the base BondHelper class. In C++, you would do something like:

    boost::shared_ptr<Bond> bond(
        new ZeroCouponBond(bondSettlementDays, calendar, 100.0, maturity));
    boost::shared_ptr<BondHelper> helper(
        new BondHelper(quoteHandle[j], bondA));

In Excel, you should be able to do the same with the 'qlZeroCouponBond' and 'qlBondHelper' functions.
I haven't tried it, so it might not actually work. But the functionality should be there (and in fact, I'd be interested in knowing if it does work or not).

Luigi




On Mon, Jul 7, 2014 at 3:00 PM, Allen Kuo <[hidden email]> wrote:
Hi Nick :

1. Note the yield to maturities for each bond, calculated by hand, but assuming slight number
of difference in days as the tenors (which I define as "remaining maturity") :

yield to maturity    tenor (days)
5.69530%           364  [date diff between 8/22/1996 and 8/21/1997]
5.67926%           365
5.66331%           366

2. Tho I don't have excel addin installed or any of the latest quantlib versions, in your excel addin,
I see you specified both maturity date and "tenor" (6M or 1Y). Though you can construct a bond's cash flows
using either, see if you can leave out the "tenor" and to get the excel addin to give you a response just
based on the maturity date you input. This will reduce the number of variables we are looking at. It could be
that because you specified a 1Y tenor for your "fake" bill, QuantLib 1.4.0/VS2010  assumed the tenor was
exactly one year, and thus gave you the 5.67926% response above. For your real zero coupon bond, appears
you only specified the exact maturity date, and are thus getting the the 5.69530% number above.

3. This doesn't explain the Github / VS 2012 results but lets take it a step at a time. I don't understand
the "6M tenor" fake bond- no real need to test with that bond either, because if the tenor (defining
tenor as "remaining maturity") were 6M, the yield to maturity would be very different than your real zero
coupon bond of tenor 1Y (remaining maturity), assuming both have the same prices. Or I just don't understand
"tenor" in Excel add-in....


Allen
On Monday, 7 July 2014, 15:38, Nicholas Manganaro <[hidden email]> wrote:


Hi, Allen.
Thanks for getting back to me.
I’ve attached my small test worksheet so you can see it for what it is. There are 2 pages: one with formulae; and one with the values saved so you can still see it if you do not have the xll add-in.
The bill yield of 5.69530% is the cash flow yield from qlBondYieldFromCleanPrice from .\QuantLibXL\qlxl\functions\bonds.cpp, as are the others. That seems to call QuantLib::BondFunctions::yield.
The “fake” notes with the 0% coupons were constructed using qlFixedRateBond. The bill was created with qlZeroCouponBond.
The maturities are the same for all, despite the differences in the tenor. I used the same price for all as well, calculated from the pricing discount quote on the bill.
The cash flows are the same, since the periodicity of receiving a 0% coupon does not change the amounts or actual timing of the cash flows to be received, as you can see in the attached sheet.
The compounding frequency input does not affect whether the bill and the fake note with the 1Y tenor have the same yield, which you can play with on the spreadsheet.
With the same cash flows and the same prices, I am perplexed that I am not getting the same yields while using the same function with the same compounding, day count and frequency inputs.
-Nick
 
From: Allen Kuo [mailto:[hidden email]]
Sent: Monday, July 07, 2014 1:14 AM
To: [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve - 1st Mystery
 
one thing I'm not understanding is that if you have the exact same price for a 6M and 1Y tenor bill, the yield to maturity (annualized) should be quite different, assuming they both pay par at their respective maturities. You confirmed the final cash flows were the same ?

For your analysis below, what was your constructor or function to obtain the  "BILL" yield of 5.69530% (or is that a Bloomberg yield) ?   And for the "Fake" bills, you were using the FixedRateBond constructor ?

On 7/7/2014 4:25 AM, Nicholas Manganaro wrote:
In response to Allen’s advice, I went looking into the best method of modeling a discount instrument as a fixed rate bond with a 0% coupon and ran into what seems an inconsistency.
 
I used the terms for a T-Bill, then modeled it as a 0% note with a 6m tenor and another with a 1Y tenor. The yields are not the same, even though I confirmed the cash flows are. I got the following results whether I used the most recent version of the add-in for QuantLibXL 1.4.0 I built with Visual Studio 2012 or the xll add-in downloaded from GitHub.
Results:
 
Not happy with that, I tried in using the QuantLibXL I built from the version of Quantlib from February 27, 2014, also named 1.4.0, but using Visual Studio 2010.
Results:
 
The same pattern of results is evident if I use Semiannual compounding, although the numbers themselves are different. At least the bill’s yield is the same from version to version.
On the plus side, if I think the new results are accurate, I can go forward using the fake note with 1Y tenor approach to try out the curve fitting, as it leads me to expect results that are more representative of the discount instruments I want to add to the curve fitting process.
On the down side, the fact that the yields are not uniform and that there are changes from the old to the new version make one wonder what is really going on here.
 
Any insights? I’d be happy to forward my spreadsheet if there is interest.
 
Cheers!
-Nick
 
From: Allen Kuo [[hidden email]]
Sent: Friday, July 04, 2014 8:10 AM
To: [hidden email]; [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve
 
Nick: I haven't looked at this in a long time but could you created instances of discount bonds as  special cases of a fixed rate bonds with a single cash flow, i.e. would the current code still work with FixedRateBondHelpers ?
 
If so, then I probably should change the To Do in the documentation.
 
Allen
 
On Friday, 4 July 2014, 19:54, Nicholas Manganaro <[hidden email]> wrote:
 
I was taking a look at <ql/termstructures/yield/fittedbonddiscountcurve.hpp> and saw the note:
       \todo refactor the bond helper class so that it is pure
              virtual and returns a generic bond or its cash
              flows. Derived classes would include helpers for
              fixed-rate and zero-coupon bonds. In this way, both
              bonds and bills can be used to fit a discount curve
              using the exact same machinery. At present, only
              fixed-coupon bonds are supported. An even better way to
              move forward might be to get rate helpers to return
              cashflows, in which case this class could be used to fit
              any set of cash flows, not just bonds.
 
I would like to include discount instruments in curve construction, if possible. Has anyone made progress along that path, perhaps on the line of the steps identified in this note?
I would appreciate advice or comments on the work necessary to use generic cash flows in this process, if it would not require a major re-write of the library.
Thanks.
-Nick

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


 



------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Modifying FittedBondDiscountCurve - 1st Mystery

Nicholas Manganaro-2

Thanks, Luigi.

I will test out the BondHelper approach to gain greater familiarity with it and get back to you.

In the meantime, I contacted a friend with a Bloomberg terminal who ran one coupon-bearing T-note and one discount T-bill at specific prices and settlement dates for comparison purposes. We found that QLXL yields matched (checked to 6 decimal places) B-berg US Govt quotation convention if the discount T-bill was modeled as a coupon bearing note with a 6M tenor, only using 0% as the coupon level and SimpleThenCompounded compounding.

So creating a schedule for a zero coupon should work as a FixedRateBond surrogate in this process, if need be.

-Nick

 

From: Luigi Ballabio [mailto:[hidden email]]
Sent: Friday, July 18, 2014 9:26 AM
To: Allen Kuo
Cc: [hidden email]; [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve - 1st Mystery

 

Hi,

    just to add another possibility: in principle, you might be able to use discount instruments directly by instantiating the bond and passing it to the base BondHelper class. In C++, you would do something like:

 

    boost::shared_ptr<Bond> bond(

        new ZeroCouponBond(bondSettlementDays, calendar, 100.0, maturity));

    boost::shared_ptr<BondHelper> helper(

        new BondHelper(quoteHandle[j], bondA));

 

In Excel, you should be able to do the same with the 'qlZeroCouponBond' and 'qlBondHelper' functions.

I haven't tried it, so it might not actually work. But the functionality should be there (and in fact, I'd be interested in knowing if it does work or not).

 

Luigi

 

 

 

On Mon, Jul 7, 2014 at 3:00 PM, Allen Kuo <[hidden email]> wrote:

Hi Nick :

1. Note the yield to maturities for each bond, calculated by hand, but assuming slight number
of difference in days as the tenors (which I define as "remaining maturity") :

yield to maturity    tenor (days)
5.69530%           364  [date diff between 8/22/1996 and 8/21/1997]
5.67926%           365
5.66331%           366

2. Tho I don't have excel addin installed or any of the latest quantlib versions, in your excel addin,
I see you specified both maturity date and "tenor" (6M or 1Y). Though you can construct a bond's cash flows
using either, see if you can leave out the "tenor" and to get the excel addin to give you a response just
based on the maturity date you input. This will reduce the number of variables we are looking at. It could be
that because you specified a 1Y tenor for your "fake" bill, QuantLib 1.4.0/VS2010  assumed the tenor was
exactly one year, and thus gave you the 5.67926% response above. For your real zero coupon bond, appears
you only specified the exact maturity date, and are thus getting the the 5.69530% number above.

3. This doesn't explain the Github / VS 2012 results but lets take it a step at a time. I don't understand
the "6M tenor" fake bond- no real need to test with that bond either, because if the tenor (defining
tenor as "remaining maturity") were 6M, the yield to maturity would be very different than your real zero
coupon bond of tenor 1Y (remaining maturity), assuming both have the same prices. Or I just don't understand
"tenor" in Excel add-in....


Allen

On Monday, 7 July 2014, 15:38, Nicholas Manganaro <[hidden email]> wrote:

 

Hi, Allen.

Thanks for getting back to me.

I’ve attached my small test worksheet so you can see it for what it is. There are 2 pages: one with formulae; and one with the values saved so you can still see it if you do not have the xll add-in.

The bill yield of 5.69530% is the cash flow yield from qlBondYieldFromCleanPrice from .\QuantLibXL\qlxl\functions\bonds.cpp, as are the others. That seems to call QuantLib::BondFunctions::yield.

The “fake” notes with the 0% coupons were constructed using qlFixedRateBond. The bill was created with qlZeroCouponBond.

The maturities are the same for all, despite the differences in the tenor. I used the same price for all as well, calculated from the pricing discount quote on the bill.

The cash flows are the same, since the periodicity of receiving a 0% coupon does not change the amounts or actual timing of the cash flows to be received, as you can see in the attached sheet.

The compounding frequency input does not affect whether the bill and the fake note with the 1Y tenor have the same yield, which you can play with on the spreadsheet.

With the same cash flows and the same prices, I am perplexed that I am not getting the same yields while using the same function with the same compounding, day count and frequency inputs.

-Nick

 

From: Allen Kuo [mailto:[hidden email]]
Sent: Monday, July 07, 2014 1:14 AM
To: [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve - 1st Mystery

 

one thing I'm not understanding is that if you have the exact same price for a 6M and 1Y tenor bill, the yield to maturity (annualized) should be quite different, assuming they both pay par at their respective maturities. You confirmed the final cash flows were the same ?

For your analysis below, what was your constructor or function to obtain the  "BILL" yield of 5.69530% (or is that a Bloomberg yield) ?   And for the "Fake" bills, you were using the FixedRateBond constructor ?

On 7/7/2014 4:25 AM, Nicholas Manganaro wrote:

In response to Allen’s advice, I went looking into the best method of modeling a discount instrument as a fixed rate bond with a 0% coupon and ran into what seems an inconsistency.

 

I used the terms for a T-Bill, then modeled it as a 0% note with a 6m tenor and another with a 1Y tenor. The yields are not the same, even though I confirmed the cash flows are. I got the following results whether I used the most recent version of the add-in for QuantLibXL 1.4.0 I built with Visual Studio 2012 or the xll add-in downloaded from GitHub.

Results:

 

Not happy with that, I tried in using the QuantLibXL I built from the version of Quantlib from February 27, 2014, also named 1.4.0, but using Visual Studio 2010.

Results:

 

The same pattern of results is evident if I use Semiannual compounding, although the numbers themselves are different. At least the bill’s yield is the same from version to version.

On the plus side, if I think the new results are accurate, I can go forward using the fake note with 1Y tenor approach to try out the curve fitting, as it leads me to expect results that are more representative of the discount instruments I want to add to the curve fitting process.

On the down side, the fact that the yields are not uniform and that there are changes from the old to the new version make one wonder what is really going on here.

 

Any insights? I’d be happy to forward my spreadsheet if there is interest.

 

Cheers!

-Nick

 

From: Allen Kuo [[hidden email]]
Sent: Friday, July 04, 2014 8:10 AM
To: [hidden email]; [hidden email]
Subject: Re: [Quantlib-users] Modifying FittedBondDiscountCurve

 

Nick: I haven't looked at this in a long time but could you created instances of discount bonds as  special cases of a fixed rate bonds with a single cash flow, i.e. would the current code still work with FixedRateBondHelpers ?

 

If so, then I probably should change the To Do in the documentation.

 

Allen

 

On Friday, 4 July 2014, 19:54, Nicholas Manganaro <[hidden email]> wrote:

 

I was taking a look at <ql/termstructures/yield/fittedbonddiscountcurve.hpp> and saw the note:

       \todo refactor the bond helper class so that it is pure

              virtual and returns a generic bond or its cash

              flows. Derived classes would include helpers for

              fixed-rate and zero-coupon bonds. In this way, both

              bonds and bills can be used to fit a discount curve

              using the exact same machinery. At present, only

              fixed-coupon bonds are supported. An even better way to

              move forward might be to get rate helpers to return

              cashflows, in which case this class could be used to fit

              any set of cash flows, not just bonds.

 

I would like to include discount instruments in curve construction, if possible. Has anyone made progress along that path, perhaps on the line of the steps identified in this note?

I would appreciate advice or comments on the work necessary to use generic cash flows in this process, if it would not require a major re-write of the library.

Thanks.

-Nick


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 

 


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



 

--
<https://implementingquantlib.blogspot.com>
<https://twitter.com/lballabio>


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users