Re: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

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

Re: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Nicholas Manganaro

Resend from other e-mail account.

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

I am using QLXL I compiled from QuantLib 1.2.1. I am running it on a machine with Windows 7 Ultimate & SP1.

I am trying to confirm that some basic calculations make sense before generating results to use as the basis for another line of analysis.

I want to thank Jean-Mattieu and Senevi for their thread, and pursue a line of inquiry on Duration and Convexity using Senevi’s sample security.

 

In using Senevi’s terms and conditions, including the move to “Unadjusted” for BDC, I get the yield he sourced from Bloomberg (to 6 digits),  without creating a new compounding convention. That said, I admire the thoroughness displayed in creating the smarter input, and wonder if/how I might be able to implement such a change with QLXL as part of a function, so I will still be able to match the market yield as the bonds I analyze get closer to maturity without having to rely on a VBA if/then. Nonetheless, I do not see the SimpleThenCompounded convention made available through the interface, so perhaps the question is moot.

 

I get the Macaulay duration and convexity values from QLXL Senevi shows as his outputs, which do not match the Bloomberg values. It is interesting to note that the built-in Excel Macaulay duration function does match the Bloomberg values to 3 digits:

B’berg Macaulay Dur’n                  1.928

Excel Macaulay Dur’n                     1.9275741842

QLXL Macaulay Dur’n from yld   1.9129221698

QLXL Modified Dur’n from yld    1.91003

Effective duration, from bumping the yield up + down 5 bps, recalculating the bond prices  and dividing the difference in the prices by 0.1 = 1.923.

 

While it may be that there is a problem applying the appropriate discounting factors in calculating the QuantLib duration, these outputs seem to show that the QuantLib output to be overly discounted, not under-discounted.

 

I did some fiddling along the same line with convexity from yield. I get an effective convexity measure from the changes in QLXL Macaulay duration at the price points resulting from the yield bumping process which is not too far off from the B’berg result previously sited by Senevi:

Bloomberg cvx:                 0.047

“effective” cvx:                 0.0471389

QLXL cvx:                             4.6061

 

The QLXL convexity number does not tie out with the other two, but if derived from an interim QL duration result, that is not a huge surprise.

 

I would appreciate any tips to overcome these relatively small frustrations. Would compiling QLXL 1.3 bring me closer to reliable outputs for these basic calculations?

 

-Nick

 

From: Senevi J Kankanamge Don [[hidden email]]
Sent: Friday, November 08, 2013 5:55 AM
To: Jean-Mathieu Vermosen; [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi,

 

Thanks for your response.

 

We compare true yield in BBG.

 

As you said, I had to set BusinessDayConvention paymentConvention = Unadjusted to avoid discrepancies.

 

 

Ultimately we implemented a new method isSettlementLastCouponPeriod() in ql/instruments/bonds/fixedratebond.hpp which returns whether the settlement falls into the last coupon period or not.

 

Then we did…

 

bool bIsSettlementLastCouponPeriod = bond.isSettlementLastCouponPeriod(settlementDate);

            Compounding compoundingMethod = bIsSettlementLastCouponPeriod ? SimpleThenCompounded : Compounded;

 

            Real ql_clean_price = BondFunctions::cleanPrice( bond, ql_yield, bondDayCount, compoundingMethod, frequency, settlementDate);

 

Now QuantLib yield match 100% with Bloomberg.

 

 

Duration and convexity don’t match with Bloomberg. It appears that QuantLib doesn’t take the weight of present values into account in computing these two figures whereas Bloomberg does.

 

Thanks

-Senevi

 

From: Jean-Mathieu Vermosen [[hidden email]]
Sent: Wednesday, November 06, 2013 2:37 PM
To:
[hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hey there,

 

Which yield are you comparing to in BBG ? Treasury yield convention doesn’t adjust payments for holidays, so make sure that

 

BusinessDayConvention paymentConvention = ModifiedFollowing;

 

you passed to the FixedRateBond constructor is not creating discrepancies in the cash-flow table (Just checked the code, it’s used in FixedRateLeg class for cash-flow generation). Otherwise you would prefer to compare to the true yield under the YA screen (after turning the flag to Following: ModifiedFollowing is for the swap guy).

 

The duration/convexity figures looks quite far from there target. As far as I remember Bloomberg is not adjusting for convention across bonds of different setup (except for the frequency in some screens). Then it might requires further investigation or to contact our friends from the hep desk to check the convention behind...

 

Best,

 

Jean-Mathieu Vermosen

 

 

On Nov 4, 2013, at 10:25 AM, Senevi J Kankanamge Don <[hidden email]> wrote:

 

Hi,

 

I am attempting to use QuantLib library in order to calculate yield, Macaulay duration and convexity for US Treasury Notes and Bonds.

 

This is how the values compare in Bloomberg and QuantLib for one example where the price is 99.8984375.

 

Bloomberg                          QuantLib

Yield                                      0.302775                              0.3027679582

Macaulay Duration          1.928                                     1.9129221698

Convexity                            0.047                                     0.0460608896

 

Can you please let me know what I need to change in my code in order to get the results matching with Bloomberg?

 

This is a snippet of my code.

 

 

        double ql_price = 99.8984375;

 

        Date settlementDate = Date(25, Oct, 2013);

        Date firstCouponDate = Date(31, Mar, 2014);

        Date datedDate = Date(30, Sep, 2013);

        Date maturityDate = Date(30, Sep, 2015);

 

        //

        // Parameters required to define the bond

        //

        Natural settlementDays = 0;

        Real faceAmount = 100;

        DayCounter bondDayCount = ActualActual(ActualActual::Bond);

        BusinessDayConvention paymentConvention = ModifiedFollowing;

        Real redemption = 100.0;

        Compounding compoundingMethod = SimpleThenCompounded;

        DateGeneration::Rule dateGeneration = DateGeneration::Forward;

        Frequency frequency = Semiannual;

        Real accuracy = 1.0e-11;

        Size maxEvaluations = 100;

 

 

        //

        // Create the Schedule

        //

        Schedule fixedBondSchedule(

                                    datedDate,                                  // Dated Date

                                    maturityDate,                               // Maturity Date

                                    Period(Semiannual),                         // Period

                                    UnitedStates(UnitedStates::GovernmentBond), // Calendar

                                    Unadjusted,                                 // BusinessDayConvention - convention

                                    Unadjusted,                                 // BusinessDayConvention - terminationDateConvention

                                    dateGeneration,                             // DateGeneration::Rule rule

                                    false,                                      // endOfMonth

                                    firstCouponDate);                           // First Date

 

 

        //

        // Create the Fixed Rate Bond

        //

        FixedRateBond bond(

                            settlementDays,                        // Settlement Days

                            faceAmount,                            // Face Amount

                            fixedBondSchedule,                     // Schedule

                            std::vector<Rate>(1, ql_coupon),       // Coupons

                            bondDayCount,                          // DayCounter

                            paymentConvention,                     // BusinessDayConvention

                            redemption);                           // Redemption

 

 

        Real ql_yield       = BondFunctions::yield( bond, ql_price, bondDayCount, compoundingMethod, frequency, settlementDate, accuracy, maxEvaluations);

 

        InterestRate interestRate(ql_yield, bondDayCount, compoundingMethod, frequency );

        Real ql_convexity = BondFunctions::convexity( bond, interestRate, settlementDate );

 

        Compounding compoundingMethod4Duration = Compounded;

        Time ql_duration = BondFunctions::duration( bond, ql_yield, bondDayCount, compoundingMethod4Duration, frequency, Duration::Macaulay, settlementDate );

 

 

Thanks

-Senevi

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&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: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Jean-Mathieu Vermosen-2
Hi Nick,

not quite sure about the 1.2.1, but it’s defined in the current quantlibobject version:

create.registerType("SimpleThenCompounded", new QuantLib::Compounding(QuantLib::SimpleThenCompounded));

It’s supposed to be defined somewhere in the qlo/enumerations/register/register_types.cpp

Rgds,

JM

On Dec 9, 2013, at 3:29 PM, Nicholas Manganaro <[hidden email]> wrote:

Resend from other e-mail account.
--------------------------------------------------------------------
I am using QLXL I compiled from QuantLib 1.2.1. I am running it on a machine with Windows 7 Ultimate & SP1.
I am trying to confirm that some basic calculations make sense before generating results to use as the basis for another line of analysis.
I want to thank Jean-Mattieu and Senevi for their thread, and pursue a line of inquiry on Duration and Convexity using Senevi’s sample security.
 
In using Senevi’s terms and conditions, including the move to “Unadjusted” for BDC, I get the yield he sourced from Bloomberg (to 6 digits),  without creating a new compounding convention. That said, I admire the thoroughness displayed in creating the smarter input, and wonder if/how I might be able to implement such a change with QLXL as part of a function, so I will still be able to match the market yield as the bonds I analyze get closer to maturity without having to rely on a VBA if/then. Nonetheless, I do not see the SimpleThenCompounded convention made available through the interface, so perhaps the question is moot.
 
I get the Macaulay duration and convexity values from QLXL Senevi shows as his outputs, which do not match the Bloomberg values. It is interesting to note that the built-in Excel Macaulay duration function does match the Bloomberg values to 3 digits:
B’berg Macaulay Dur’n                  1.928
Excel Macaulay Dur’n                     1.9275741842
QLXL Macaulay Dur’n from yld   1.9129221698
QLXL Modified Dur’n from yld    1.91003
Effective duration, from bumping the yield up + down 5 bps, recalculating the bond prices  and dividing the difference in the prices by 0.1 = 1.923.
 
While it may be that there is a problem applying the appropriate discounting factors in calculating the QuantLib duration, these outputs seem to show that the QuantLib output to be overly discounted, not under-discounted.
 
I did some fiddling along the same line with convexity from yield. I get an effective convexity measure from the changes in QLXL Macaulay duration at the price points resulting from the yield bumping process which is not too far off from the B’berg result previously sited by Senevi:
Bloomberg cvx:                 0.047
“effective” cvx:                 0.0471389
QLXL cvx:                             4.6061
 
The QLXL convexity number does not tie out with the other two, but if derived from an interim QL duration result, that is not a huge surprise.
 
I would appreciate any tips to overcome these relatively small frustrations. Would compiling QLXL 1.3 bring me closer to reliable outputs for these basic calculations?
 
-Nick
 
From: Senevi J Kankanamge Don [[hidden email]] 
Sent: Friday, November 08, 2013 5:55 AM
To: Jean-Mathieu Vermosen; [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds
 
Hi,
 
Thanks for your response.
 
We compare true yield in BBG.
 
As you said, I had to set BusinessDayConvention paymentConvention = Unadjusted to avoid discrepancies.
 
 
Ultimately we implemented a new method isSettlementLastCouponPeriod() in ql/instruments/bonds/fixedratebond.hpp which returns whether the settlement falls into the last coupon period or not.
 
Then we did…
 
bool bIsSettlementLastCouponPeriod = bond.isSettlementLastCouponPeriod(settlementDate);
            Compounding compoundingMethod = bIsSettlementLastCouponPeriod ? SimpleThenCompounded : Compounded;
 
            Real ql_clean_price = BondFunctions::cleanPrice( bond, ql_yield, bondDayCount, compoundingMethod, frequency, settlementDate);
 
Now QuantLib yield match 100% with Bloomberg.
 
 
Duration and convexity don’t match with Bloomberg. It appears that QuantLib doesn’t take the weight of present values into account in computing these two figures whereas Bloomberg does.
 
Thanks
-Senevi
 
From: Jean-Mathieu Vermosen [[hidden email]] 
Sent: Wednesday, November 06, 2013 2:37 PM
To: 
[hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds
 
Hey there,
 
Which yield are you comparing to in BBG ? Treasury yield convention doesn’t adjust payments for holidays, so make sure that
 
BusinessDayConvention paymentConvention = ModifiedFollowing;
 
you passed to the FixedRateBond constructor is not creating discrepancies in the cash-flow table (Just checked the code, it’s used in FixedRateLeg class for cash-flow generation). Otherwise you would prefer to compare to the true yield under the YA screen (after turning the flag to Following: ModifiedFollowing is for the swap guy).
 
The duration/convexity figures looks quite far from there target. As far as I remember Bloomberg is not adjusting for convention across bonds of different setup (except for the frequency in some screens). Then it might requires further investigation or to contact our friends from the hep desk to check the convention behind...
 
Best,
 
Jean-Mathieu Vermosen
 
 
On Nov 4, 2013, at 10:25 AM, Senevi J Kankanamge Don <[hidden email]> wrote:

 

Hi,
 
I am attempting to use QuantLib library in order to calculate yield, Macaulay duration and convexity for US Treasury Notes and Bonds.
 
This is how the values compare in Bloomberg and QuantLib for one example where the price is 99.8984375.
 
Bloomberg                          QuantLib
Yield                                      0.302775                              0.3027679582
Macaulay Duration          1.928                                     1.9129221698
Convexity                            0.047                                     0.0460608896
 
Can you please let me know what I need to change in my code in order to get the results matching with Bloomberg?
 
This is a snippet of my code.
 
 
        double ql_price = 99.8984375;
 
        Date settlementDate = Date(25, Oct, 2013);
        Date firstCouponDate = Date(31, Mar, 2014);
        Date datedDate = Date(30, Sep, 2013);
        Date maturityDate = Date(30, Sep, 2015);
 
        //
        // Parameters required to define the bond
        //
        Natural settlementDays = 0;
        Real faceAmount = 100;
        DayCounter bondDayCount = ActualActual(ActualActual::Bond);
        BusinessDayConvention paymentConvention = ModifiedFollowing;
        Real redemption = 100.0;
        Compounding compoundingMethod = SimpleThenCompounded;
        DateGeneration::Rule dateGeneration = DateGeneration::Forward;
        Frequency frequency = Semiannual;
        Real accuracy = 1.0e-11;
        Size maxEvaluations = 100;
 
 
        //
        // Create the Schedule
        //
        Schedule fixedBondSchedule(
                                    datedDate,                                  // Dated Date
                                    maturityDate,                               // Maturity Date
                                    Period(Semiannual),                         // Period
                                    UnitedStates(UnitedStates::GovernmentBond), // Calendar
                                    Unadjusted,                                 // BusinessDayConvention - convention
                                    Unadjusted,                                 // BusinessDayConvention - terminationDateConvention
                                    dateGeneration,                             // DateGeneration::Rule rule
                                    false,                                      // endOfMonth
                                    firstCouponDate);                           // First Date
 
 
        //
        // Create the Fixed Rate Bond
        //
        FixedRateBond bond(
                            settlementDays,                        // Settlement Days
                            faceAmount,                            // Face Amount
                            fixedBondSchedule,                     // Schedule
                            std::vector<Rate>(1, ql_coupon),       // Coupons
                            bondDayCount,                          // DayCounter
                            paymentConvention,                     // BusinessDayConvention
                            redemption);                           // Redemption
 
 
        Real ql_yield       = BondFunctions::yield( bond, ql_price, bondDayCount, compoundingMethod, frequency, settlementDate, accuracy, maxEvaluations);
 
        InterestRate interestRate(ql_yield, bondDayCount, compoundingMethod, frequency );
        Real ql_convexity = BondFunctions::convexity( bond, interestRate, settlementDate );
 
        Compounding compoundingMethod4Duration = Compounded;
        Time ql_duration = BondFunctions::duration( bond, ql_yield, bondDayCount, compoundingMethod4Duration, frequency, Duration::Macaulay, settlementDate );
 
 
Thanks
-Senevi
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
 
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&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: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Nicholas Manganaro

Jean-Mathieu,

Thanks for your speedy response.

While I see your reference in the QuantLibAddin folder, I could not something similar in the QuantLibXL folder generated during the compilation process.

As a result, the type did not work as an input for QLXL in my recent experiment using MS Office 2010, 32 bit.

Is there a reference source for a way to create or expose the enumerations through the QL_XL add-in?

-Nick

 

From: Jean-Mathieu Vermosen [mailto:[hidden email]]
Sent: Monday, December 09, 2013 4:42 PM
To: Nicholas Manganaro
Cc: [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi Nick,

 

not quite sure about the 1.2.1, but it’s defined in the current quantlibobject version:

 

create.registerType("SimpleThenCompounded", new QuantLib::Compounding(QuantLib::SimpleThenCompounded));

 

It’s supposed to be defined somewhere in the qlo/enumerations/register/register_types.cpp

 

Rgds,

 

JM

 

On Dec 9, 2013, at 3:29 PM, Nicholas Manganaro <[hidden email]> wrote:



Resend from other e-mail account.

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

I am using QLXL I compiled from QuantLib 1.2.1. I am running it on a machine with Windows 7 Ultimate & SP1.

I am trying to confirm that some basic calculations make sense before generating results to use as the basis for another line of analysis.

I want to thank Jean-Mattieu and Senevi for their thread, and pursue a line of inquiry on Duration and Convexity using Senevi’s sample security.

 

In using Senevi’s terms and conditions, including the move to “Unadjusted” for BDC, I get the yield he sourced from Bloomberg (to 6 digits),  without creating a new compounding convention. That said, I admire the thoroughness displayed in creating the smarter input, and wonder if/how I might be able to implement such a change with QLXL as part of a function, so I will still be able to match the market yield as the bonds I analyze get closer to maturity without having to rely on a VBA if/then. Nonetheless, I do not see the SimpleThenCompounded convention made available through the interface, so perhaps the question is moot.

 

I get the Macaulay duration and convexity values from QLXL Senevi shows as his outputs, which do not match the Bloomberg values. It is interesting to note that the built-in Excel Macaulay duration function does match the Bloomberg values to 3 digits:

B’berg Macaulay Dur’n                  1.928

Excel Macaulay Dur’n                     1.9275741842

QLXL Macaulay Dur’n from yld   1.9129221698

QLXL Modified Dur’n from yld    1.91003

Effective duration, from bumping the yield up + down 5 bps, recalculating the bond prices  and dividing the difference in the prices by 0.1 = 1.923.

 

While it may be that there is a problem applying the appropriate discounting factors in calculating the QuantLib duration, these outputs seem to show that the QuantLib output to be overly discounted, not under-discounted.

 

I did some fiddling along the same line with convexity from yield. I get an effective convexity measure from the changes in QLXL Macaulay duration at the price points resulting from the yield bumping process which is not too far off from the B’berg result previously sited by Senevi:

Bloomberg cvx:                 0.047

“effective” cvx:                 0.0471389

QLXL cvx:                             4.6061

 

The QLXL convexity number does not tie out with the other two, but if derived from an interim QL duration result, that is not a huge surprise.

 

I would appreciate any tips to overcome these relatively small frustrations. Would compiling QLXL 1.3 bring me closer to reliable outputs for these basic calculations?

 

-Nick

 

From: Senevi J Kankanamge Don [[hidden email]] 
Sent: Friday, November 08, 2013 5:55 AM
To: Jean-Mathieu Vermosen; [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi,

 

Thanks for your response.

 

We compare true yield in BBG.

 

As you said, I had to set BusinessDayConvention paymentConvention = Unadjusted to avoid discrepancies.

 

 

Ultimately we implemented a new method isSettlementLastCouponPeriod() in ql/instruments/bonds/fixedratebond.hpp which returns whether the settlement falls into the last coupon period or not.

 

Then we did…

 

bool bIsSettlementLastCouponPeriod = bond.isSettlementLastCouponPeriod(settlementDate);

            Compounding compoundingMethod = bIsSettlementLastCouponPeriod ? SimpleThenCompounded : Compounded;

 

            Real ql_clean_price = BondFunctions::cleanPrice( bond, ql_yield, bondDayCount, compoundingMethod, frequency, settlementDate);

 

Now QuantLib yield match 100% with Bloomberg.

 

 

Duration and convexity don’t match with Bloomberg. It appears that QuantLib doesn’t take the weight of present values into account in computing these two figures whereas Bloomberg does.

 

Thanks

-Senevi

 

From: Jean-Mathieu Vermosen [[hidden email]] 
Sent: Wednesday, November 06, 2013 2:37 PM
To: 
[hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hey there,

 

Which yield are you comparing to in BBG ? Treasury yield convention doesn’t adjust payments for holidays, so make sure that

 

BusinessDayConvention paymentConvention = ModifiedFollowing;

 

you passed to the FixedRateBond constructor is not creating discrepancies in the cash-flow table (Just checked the code, it’s used in FixedRateLeg class for cash-flow generation). Otherwise you would prefer to compare to the true yield under the YA screen (after turning the flag to Following: ModifiedFollowing is for the swap guy).

 

The duration/convexity figures looks quite far from there target. As far as I remember Bloomberg is not adjusting for convention across bonds of different setup (except for the frequency in some screens). Then it might requires further investigation or to contact our friends from the hep desk to check the convention behind...

 

Best,

 

Jean-Mathieu Vermosen

 

 

On Nov 4, 2013, at 10:25 AM, Senevi J Kankanamge Don <[hidden email]> wrote:

 

Hi,

 

I am attempting to use QuantLib library in order to calculate yield, Macaulay duration and convexity for US Treasury Notes and Bonds.

 

This is how the values compare in Bloomberg and QuantLib for one example where the price is 99.8984375.

 

Bloomberg                          QuantLib

Yield                                      0.302775                              0.3027679582

Macaulay Duration          1.928                                     1.9129221698

Convexity                            0.047                                     0.0460608896

 

Can you please let me know what I need to change in my code in order to get the results matching with Bloomberg?

 

This is a snippet of my code.

 

 

        double ql_price = 99.8984375;

 

        Date settlementDate = Date(25, Oct, 2013);

        Date firstCouponDate = Date(31, Mar, 2014);

        Date datedDate = Date(30, Sep, 2013);

        Date maturityDate = Date(30, Sep, 2015);

 

        //

        // Parameters required to define the bond

        //

        Natural settlementDays = 0;

        Real faceAmount = 100;

        DayCounter bondDayCount = ActualActual(ActualActual::Bond);

        BusinessDayConvention paymentConvention = ModifiedFollowing;

        Real redemption = 100.0;

        Compounding compoundingMethod = SimpleThenCompounded;

        DateGeneration::Rule dateGeneration = DateGeneration::Forward;

        Frequency frequency = Semiannual;

        Real accuracy = 1.0e-11;

        Size maxEvaluations = 100;

 

 

        //

        // Create the Schedule

        //

        Schedule fixedBondSchedule(

                                    datedDate,                                  // Dated Date

                                    maturityDate,                               // Maturity Date

                                    Period(Semiannual),                         // Period

                                    UnitedStates(UnitedStates::GovernmentBond), // Calendar

                                    Unadjusted,                                 // BusinessDayConvention - convention

                                    Unadjusted,                                 // BusinessDayConvention - terminationDateConvention

                                    dateGeneration,                             // DateGeneration::Rule rule

                                    false,                                      // endOfMonth

                                    firstCouponDate);                           // First Date

 

 

        //

        // Create the Fixed Rate Bond

        //

        FixedRateBond bond(

                            settlementDays,                        // Settlement Days

                            faceAmount,                            // Face Amount

                            fixedBondSchedule,                     // Schedule

                            std::vector<Rate>(1, ql_coupon),       // Coupons

                            bondDayCount,                          // DayCounter

                            paymentConvention,                     // BusinessDayConvention

                            redemption);                           // Redemption

 

 

        Real ql_yield       = BondFunctions::yield( bond, ql_price, bondDayCount, compoundingMethod, frequency, settlementDate, accuracy, maxEvaluations);

 

        InterestRate interestRate(ql_yield, bondDayCount, compoundingMethod, frequency );

        Real ql_convexity = BondFunctions::convexity( bond, interestRate, settlementDate );

 

        Compounding compoundingMethod4Duration = Compounded;

        Time ql_duration = BondFunctions::duration( bond, ql_yield, bondDayCount, compoundingMethod4Duration, frequency, Duration::Macaulay, settlementDate );

 

 

Thanks

-Senevi

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&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: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Nicholas Manganaro-2

Digging around, I found the following reference in the document for QuantLibAddin, which I’m trying to follow:

http://quantlib.org/quantlibaddin/extend_enum_tutorial.html               

Since the type is in ..\QuantLibAddin\gensrc\metadata\enumerations\enumeratedtypes.xml and ..\QuantLibAddin\gensrc\metadata\types\types.xml, I do not think I have to add anything under instruction #2 to get “SimpleThenCompounded” to be exposed to Excel, but when I look at

..\QuantLib\ql\pricingengines\bond\bondfunctions.hpp there are only three compounded conventions in the description (which may well just be a text string), and only 3 work in the QLXL function.

Where would the exclusion of the “SimpleThenCompounded” element of the “Compounded” type happen? And how can I undo the exclusion once identified?

 

Digging, but not buried.

-Nick

 

From: Nicholas Manganaro [mailto:[hidden email]]
Sent: Monday, December 09, 2013 5:51 PM
To: 'Jean-Mathieu Vermosen'
Cc: [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Jean-Mathieu,

Thanks for your speedy response.

While I see your reference in the QuantLibAddin folder, I could not something similar in the QuantLibXL folder generated during the compilation process.

As a result, the type did not work as an input for QLXL in my recent experiment using MS Office 2010, 32 bit.

Is there a reference source for a way to create or expose the enumerations through the QL_XL add-in?

-Nick

 

From: Jean-Mathieu Vermosen [[hidden email]]
Sent: Monday, December 09, 2013 4:42 PM
To: Nicholas Manganaro
Cc: [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi Nick,

 

not quite sure about the 1.2.1, but it’s defined in the current quantlibobject version:

 

create.registerType("SimpleThenCompounded", new QuantLib::Compounding(QuantLib::SimpleThenCompounded));

 

It’s supposed to be defined somewhere in the qlo/enumerations/register/register_types.cpp

 

Rgds,

 

JM

 

On Dec 9, 2013, at 3:29 PM, Nicholas Manganaro <[hidden email]> wrote:

 

Resend from other e-mail account.

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

I am using QLXL I compiled from QuantLib 1.2.1. I am running it on a machine with Windows 7 Ultimate & SP1.

I am trying to confirm that some basic calculations make sense before generating results to use as the basis for another line of analysis.

I want to thank Jean-Mattieu and Senevi for their thread, and pursue a line of inquiry on Duration and Convexity using Senevi’s sample security.

 

In using Senevi’s terms and conditions, including the move to “Unadjusted” for BDC, I get the yield he sourced from Bloomberg (to 6 digits),  without creating a new compounding convention. That said, I admire the thoroughness displayed in creating the smarter input, and wonder if/how I might be able to implement such a change with QLXL as part of a function, so I will still be able to match the market yield as the bonds I analyze get closer to maturity without having to rely on a VBA if/then. Nonetheless, I do not see the SimpleThenCompounded convention made available through the interface, so perhaps the question is moot.

 

I get the Macaulay duration and convexity values from QLXL Senevi shows as his outputs, which do not match the Bloomberg values. It is interesting to note that the built-in Excel Macaulay duration function does match the Bloomberg values to 3 digits:

B’berg Macaulay Dur’n                  1.928

Excel Macaulay Dur’n                     1.9275741842

QLXL Macaulay Dur’n from yld   1.9129221698

QLXL Modified Dur’n from yld    1.91003

Effective duration, from bumping the yield up + down 5 bps, recalculating the bond prices  and dividing the difference in the prices by 0.1 = 1.923.

 

While it may be that there is a problem applying the appropriate discounting factors in calculating the QuantLib duration, these outputs seem to show that the QuantLib output to be overly discounted, not under-discounted.

 

I did some fiddling along the same line with convexity from yield. I get an effective convexity measure from the changes in QLXL Macaulay duration at the price points resulting from the yield bumping process which is not too far off from the B’berg result previously sited by Senevi:

Bloomberg cvx:                 0.047

“effective” cvx:                 0.0471389

QLXL cvx:                             4.6061

 

The QLXL convexity number does not tie out with the other two, but if derived from an interim QL duration result, that is not a huge surprise.

 

I would appreciate any tips to overcome these relatively small frustrations. Would compiling QLXL 1.3 bring me closer to reliable outputs for these basic calculations?

 

-Nick

 

From: Senevi J Kankanamge Don [[hidden email]] 
Sent: Friday, November 08, 2013 5:55 AM
To: Jean-Mathieu Vermosen; [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi,

 

Thanks for your response.

 

We compare true yield in BBG.

 

As you said, I had to set BusinessDayConvention paymentConvention = Unadjusted to avoid discrepancies.

 

 

Ultimately we implemented a new method isSettlementLastCouponPeriod() in ql/instruments/bonds/fixedratebond.hpp which returns whether the settlement falls into the last coupon period or not.

 

Then we did…

 

bool bIsSettlementLastCouponPeriod = bond.isSettlementLastCouponPeriod(settlementDate);

            Compounding compoundingMethod = bIsSettlementLastCouponPeriod ? SimpleThenCompounded : Compounded;

 

            Real ql_clean_price = BondFunctions::cleanPrice( bond, ql_yield, bondDayCount, compoundingMethod, frequency, settlementDate);

 

Now QuantLib yield match 100% with Bloomberg.

 

 

Duration and convexity don’t match with Bloomberg. It appears that QuantLib doesn’t take the weight of present values into account in computing these two figures whereas Bloomberg does.

 

Thanks

-Senevi

 

From: Jean-Mathieu Vermosen [[hidden email]] 
Sent: Wednesday, November 06, 2013 2:37 PM
To: 
[hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hey there,

 

Which yield are you comparing to in BBG ? Treasury yield convention doesn’t adjust payments for holidays, so make sure that

 

BusinessDayConvention paymentConvention = ModifiedFollowing;

 

you passed to the FixedRateBond constructor is not creating discrepancies in the cash-flow table (Just checked the code, it’s used in FixedRateLeg class for cash-flow generation). Otherwise you would prefer to compare to the true yield under the YA screen (after turning the flag to Following: ModifiedFollowing is for the swap guy).

 

The duration/convexity figures looks quite far from there target. As far as I remember Bloomberg is not adjusting for convention across bonds of different setup (except for the frequency in some screens). Then it might requires further investigation or to contact our friends from the hep desk to check the convention behind...

 

Best,

 

Jean-Mathieu Vermosen

 

 

On Nov 4, 2013, at 10:25 AM, Senevi J Kankanamge Don <[hidden email]> wrote:

 

Hi,

 

I am attempting to use QuantLib library in order to calculate yield, Macaulay duration and convexity for US Treasury Notes and Bonds.

 

This is how the values compare in Bloomberg and QuantLib for one example where the price is 99.8984375.

 

Bloomberg                          QuantLib

Yield                                      0.302775                              0.3027679582

Macaulay Duration          1.928                                     1.9129221698

Convexity                            0.047                                     0.0460608896

 

Can you please let me know what I need to change in my code in order to get the results matching with Bloomberg?

 

This is a snippet of my code.

 

 

        double ql_price = 99.8984375;

 

        Date settlementDate = Date(25, Oct, 2013);

        Date firstCouponDate = Date(31, Mar, 2014);

        Date datedDate = Date(30, Sep, 2013);

        Date maturityDate = Date(30, Sep, 2015);

 

        //

        // Parameters required to define the bond

        //

        Natural settlementDays = 0;

        Real faceAmount = 100;

        DayCounter bondDayCount = ActualActual(ActualActual::Bond);

        BusinessDayConvention paymentConvention = ModifiedFollowing;

        Real redemption = 100.0;

        Compounding compoundingMethod = SimpleThenCompounded;

        DateGeneration::Rule dateGeneration = DateGeneration::Forward;

        Frequency frequency = Semiannual;

        Real accuracy = 1.0e-11;

        Size maxEvaluations = 100;

 

 

        //

        // Create the Schedule

        //

        Schedule fixedBondSchedule(

                                    datedDate,                                  // Dated Date

                                    maturityDate,                               // Maturity Date

                                    Period(Semiannual),                         // Period

                                    UnitedStates(UnitedStates::GovernmentBond), // Calendar

                                    Unadjusted,                                 // BusinessDayConvention - convention

                                    Unadjusted,                                 // BusinessDayConvention - terminationDateConvention

                                    dateGeneration,                             // DateGeneration::Rule rule

                                    false,                                      // endOfMonth

                                    firstCouponDate);                           // First Date

 

 

        //

        // Create the Fixed Rate Bond

        //

        FixedRateBond bond(

                            settlementDays,                        // Settlement Days

                            faceAmount,                            // Face Amount

                            fixedBondSchedule,                     // Schedule

                            std::vector<Rate>(1, ql_coupon),       // Coupons

                            bondDayCount,                          // DayCounter

                            paymentConvention,                     // BusinessDayConvention

                            redemption);                           // Redemption

 

 

        Real ql_yield       = BondFunctions::yield( bond, ql_price, bondDayCount, compoundingMethod, frequency, settlementDate, accuracy, maxEvaluations);

 

        InterestRate interestRate(ql_yield, bondDayCount, compoundingMethod, frequency );

        Real ql_convexity = BondFunctions::convexity( bond, interestRate, settlementDate );

 

        Compounding compoundingMethod4Duration = Compounded;

        Time ql_duration = BondFunctions::duration( bond, ql_yield, bondDayCount, compoundingMethod4Duration, frequency, Duration::Macaulay, settlementDate );

 

 

Thanks

-Senevi

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&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: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Nicholas Manganaro-2
In reply to this post by Nicholas Manganaro

Sorry for the barrage, but . .

Should I expect the 1.2.0 versions of gensrc and ObjectHandler to work with QuantLib 1.3 to allow me to compile a fully featured, 32 bit update to the QuantLibXL add-in, providing I am using a supported version of Visual Studio, i.e. 2008 or 2010?

Or is this perceived problem actually controlled by a setting that controls the way the Framework exposes the types through the interface?

-Nick

 

From: Nicholas Manganaro [mailto:[hidden email]]
Sent: Monday, December 09, 2013 11:18 PM
To: '[hidden email]'
Subject: RE: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Digging around, I found the following reference in the document for QuantLibAddin, which I’m trying to follow:

http://quantlib.org/quantlibaddin/extend_enum_tutorial.html               

Since the type is in ..\QuantLibAddin\gensrc\metadata\enumerations\enumeratedtypes.xml and ..\QuantLibAddin\gensrc\metadata\types\types.xml, I do not think I have to add anything under instruction #2 to get “SimpleThenCompounded” to be exposed to Excel, but when I look at

..\QuantLib\ql\pricingengines\bond\bondfunctions.hpp there are only three compounded conventions in the description (which may well just be a text string), and only 3 work in the QLXL function.

Where would the exclusion of the “SimpleThenCompounded” element of the “Compounded” type happen? And how can I undo the exclusion once identified?

 

Digging, but not buried.

-Nick

 

From: Nicholas Manganaro [[hidden email]]
Sent: Monday, December 09, 2013 5:51 PM
To: 'Jean-Mathieu Vermosen'
Cc: [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Jean-Mathieu,

Thanks for your speedy response.

While I see your reference in the QuantLibAddin folder, I could not something similar in the QuantLibXL folder generated during the compilation process.

As a result, the type did not work as an input for QLXL in my recent experiment using MS Office 2010, 32 bit.

Is there a reference source for a way to create or expose the enumerations through the QL_XL add-in?

-Nick

 

<SNIP>


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&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: Yield, Macaulay duration and Convexity calculation for Notes/Bonds

Senevi J Kankanamge Don
In reply to this post by Nicholas Manganaro

Hi Nick,

 

Thanks for your feedback.

 

I was doing my testing on QuantLib-1.3 and I found that I could not get modified duration, Macaulay duration and convexity to match with Bloomberg no matter what parameters are changed. I attribute this to the fact that Bloomberg uses different formulae compared to QuantLib. Further if the settlement is in the final period, Bloomberg uses a different formula but QuantLib does not.

 

Although I have never built QLXL, I don’t believe building on QLXL 1.3 will bring you closer to Bloomberg.

 

Thanks

-Senevi

 

From: Nicholas Manganaro [mailto:[hidden email]]
Sent: Monday, December 09, 2013 8:29 PM
To: [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Resend from other e-mail account.

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

I am using QLXL I compiled from QuantLib 1.2.1. I am running it on a machine with Windows 7 Ultimate & SP1.

I am trying to confirm that some basic calculations make sense before generating results to use as the basis for another line of analysis.

I want to thank Jean-Mattieu and Senevi for their thread, and pursue a line of inquiry on Duration and Convexity using Senevi’s sample security.

 

In using Senevi’s terms and conditions, including the move to “Unadjusted” for BDC, I get the yield he sourced from Bloomberg (to 6 digits),  without creating a new compounding convention. That said, I admire the thoroughness displayed in creating the smarter input, and wonder if/how I might be able to implement such a change with QLXL as part of a function, so I will still be able to match the market yield as the bonds I analyze get closer to maturity without having to rely on a VBA if/then. Nonetheless, I do not see the SimpleThenCompounded convention made available through the interface, so perhaps the question is moot.

 

I get the Macaulay duration and convexity values from QLXL Senevi shows as his outputs, which do not match the Bloomberg values. It is interesting to note that the built-in Excel Macaulay duration function does match the Bloomberg values to 3 digits:

B’berg Macaulay Dur’n                  1.928

Excel Macaulay Dur’n                     1.9275741842

QLXL Macaulay Dur’n from yld   1.9129221698

QLXL Modified Dur’n from yld    1.91003

Effective duration, from bumping the yield up + down 5 bps, recalculating the bond prices  and dividing the difference in the prices by 0.1 = 1.923.

 

While it may be that there is a problem applying the appropriate discounting factors in calculating the QuantLib duration, these outputs seem to show that the QuantLib output to be overly discounted, not under-discounted.

 

I did some fiddling along the same line with convexity from yield. I get an effective convexity measure from the changes in QLXL Macaulay duration at the price points resulting from the yield bumping process which is not too far off from the B’berg result previously sited by Senevi:

Bloomberg cvx:                 0.047

“effective” cvx:                 0.0471389

QLXL cvx:                             4.6061

 

The QLXL convexity number does not tie out with the other two, but if derived from an interim QL duration result, that is not a huge surprise.

 

I would appreciate any tips to overcome these relatively small frustrations. Would compiling QLXL 1.3 bring me closer to reliable outputs for these basic calculations?

 

-Nick

 

From: Senevi J Kankanamge Don [[hidden email]]
Sent: Friday, November 08, 2013 5:55 AM
To: Jean-Mathieu Vermosen; [hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hi,

 

Thanks for your response.

 

We compare true yield in BBG.

 

As you said, I had to set BusinessDayConvention paymentConvention = Unadjusted to avoid discrepancies.

 

 

Ultimately we implemented a new method isSettlementLastCouponPeriod() in ql/instruments/bonds/fixedratebond.hpp which returns whether the settlement falls into the last coupon period or not.

 

Then we did…

 

bool bIsSettlementLastCouponPeriod = bond.isSettlementLastCouponPeriod(settlementDate);

            Compounding compoundingMethod = bIsSettlementLastCouponPeriod ? SimpleThenCompounded : Compounded;

 

            Real ql_clean_price = BondFunctions::cleanPrice( bond, ql_yield, bondDayCount, compoundingMethod, frequency, settlementDate);

 

Now QuantLib yield match 100% with Bloomberg.

 

 

Duration and convexity don’t match with Bloomberg. It appears that QuantLib doesn’t take the weight of present values into account in computing these two figures whereas Bloomberg does.

 

Thanks

-Senevi

 

From: Jean-Mathieu Vermosen [[hidden email]]
Sent: Wednesday, November 06, 2013 2:37 PM
To:
[hidden email]
Subject: Re: [Quantlib-users] Yield, Macaulay duration and Convexity calculation for Notes/Bonds

 

Hey there,

 

Which yield are you comparing to in BBG ? Treasury yield convention doesn’t adjust payments for holidays, so make sure that

 

BusinessDayConvention paymentConvention = ModifiedFollowing;

 

you passed to the FixedRateBond constructor is not creating discrepancies in the cash-flow table (Just checked the code, it’s used in FixedRateLeg class for cash-flow generation). Otherwise you would prefer to compare to the true yield under the YA screen (after turning the flag to Following: ModifiedFollowing is for the swap guy).

 

The duration/convexity figures looks quite far from there target. As far as I remember Bloomberg is not adjusting for convention across bonds of different setup (except for the frequency in some screens). Then it might requires further investigation or to contact our friends from the hep desk to check the convention behind...

 

Best,

 

Jean-Mathieu Vermosen

 

 

On Nov 4, 2013, at 10:25 AM, Senevi J Kankanamge Don <[hidden email]> wrote:

 

Hi,

 

I am attempting to use QuantLib library in order to calculate yield, Macaulay duration and convexity for US Treasury Notes and Bonds.

 

This is how the values compare in Bloomberg and QuantLib for one example where the price is 99.8984375.

 

Bloomberg                          QuantLib

Yield                                      0.302775                              0.3027679582

Macaulay Duration          1.928                                     1.9129221698

Convexity                            0.047                                     0.0460608896

 

Can you please let me know what I need to change in my code in order to get the results matching with Bloomberg?

 

This is a snippet of my code.

 

 

        double ql_price = 99.8984375;

 

        Date settlementDate = Date(25, Oct, 2013);

        Date firstCouponDate = Date(31, Mar, 2014);

        Date datedDate = Date(30, Sep, 2013);

        Date maturityDate = Date(30, Sep, 2015);

 

        //

        // Parameters required to define the bond

        //

        Natural settlementDays = 0;

        Real faceAmount = 100;

        DayCounter bondDayCount = ActualActual(ActualActual::Bond);

        BusinessDayConvention paymentConvention = ModifiedFollowing;

        Real redemption = 100.0;

        Compounding compoundingMethod = SimpleThenCompounded;

        DateGeneration::Rule dateGeneration = DateGeneration::Forward;

        Frequency frequency = Semiannual;

        Real accuracy = 1.0e-11;

        Size maxEvaluations = 100;

 

 

        //

        // Create the Schedule

        //

        Schedule fixedBondSchedule(

                                    datedDate,                                  // Dated Date

                                    maturityDate,                               // Maturity Date

                                    Period(Semiannual),                         // Period

                                    UnitedStates(UnitedStates::GovernmentBond), // Calendar

                                    Unadjusted,                                 // BusinessDayConvention - convention

                                    Unadjusted,                                 // BusinessDayConvention - terminationDateConvention

                                    dateGeneration,                             // DateGeneration::Rule rule

                                    false,                                      // endOfMonth

                                    firstCouponDate);                           // First Date

 

 

        //

        // Create the Fixed Rate Bond

        //

        FixedRateBond bond(

                            settlementDays,                        // Settlement Days

                            faceAmount,                            // Face Amount

                            fixedBondSchedule,                     // Schedule

                            std::vector<Rate>(1, ql_coupon),       // Coupons

                            bondDayCount,                          // DayCounter

                            paymentConvention,                     // BusinessDayConvention

                            redemption);                           // Redemption

 

 

        Real ql_yield       = BondFunctions::yield( bond, ql_price, bondDayCount, compoundingMethod, frequency, settlementDate, accuracy, maxEvaluations);

 

        InterestRate interestRate(ql_yield, bondDayCount, compoundingMethod, frequency );

        Real ql_convexity = BondFunctions::convexity( bond, interestRate, settlementDate );

 

        Compounding compoundingMethod4Duration = Compounded;

        Time ql_duration = BondFunctions::duration( bond, ql_yield, bondDayCount, compoundingMethod4Duration, frequency, Duration::Macaulay, settlementDate );

 

 

Thanks

-Senevi

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

 


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users