Question about a formula of calculation of Yield of Bond in Quantlib

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

Question about a formula of calculation of Yield of Bond in Quantlib

Xu Tao
Hello, everyone,

Recently, I have found a problem which confuses me, it's about the formula of Yield of Bond,

I don't understand how the Quantlib calculate this Yield of Bond, is there anyone can give some help to give me a complete formula of this Yield, Thanks very much.

Have a nice day.

Best Regards.

--
Xu TAO

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Question about a formula of calculation of Yield of Bond in Quantlib

giambologna
In the most general cases there isn't an explicit formula. Through a solver, you look for the rate r such that the sum of discounted cashflows (discount factors being function of r) is equal to the dirty price of the bond.

GB
Reply | Threaded
Open this post in threaded view
|

Re: Question about a formula of calculation of Yield of Bond in Quantlib

Luigi Ballabio
In reply to this post by Xu Tao
Which part of the code are you referring to, exactly? And what is the problem?

Later,
    Luigi


On Wed, Apr 5, 2017 at 11:59 AM Xu Tao <[hidden email]> wrote:
Hello, everyone,

Recently, I have found a problem which confuses me, it's about the formula of Yield of Bond,

I don't understand how the Quantlib calculate this Yield of Bond, is there anyone can give some help to give me a complete formula of this Yield, Thanks very much.

Have a nice day.

Best Regards.

--
Xu TAO
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Question about a formula of calculation of Yield of Bond in Quantlib

Luigi Ballabio
Ok, but what is the problem you're having?

Luigi

P.S. Please keep the mailing list in cc


On Wed, Apr 5, 2017 at 12:51 PM Xu Tao <[hidden email]> wrote:
The parts of codes Bond::Yield (BondsFunctions)-> CashFlows::Yield , in these functions, the formula to calculate the result of yield.

2017-04-05 12:30 GMT+02:00 Luigi Ballabio <[hidden email]>:
Which part of the code are you referring to, exactly? And what is the problem?

Later,
    Luigi


On Wed, Apr 5, 2017 at 11:59 AM Xu Tao <[hidden email]> wrote:
Hello, everyone,

Recently, I have found a problem which confuses me, it's about the formula of Yield of Bond,

I don't understand how the Quantlib calculate this Yield of Bond, is there anyone can give some help to give me a complete formula of this Yield, Thanks very much.

Have a nice day.

Best Regards.

--
Xu TAO
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Question about a formula of calculation of Yield of Bond in Quantlib

Luigi Ballabio
In reply to this post by Luigi Ballabio
It's not a formula, it's the application of an iterative solver.  The functions use one of the root solvers available in the library to find the zero of the CashFlows::IrrFinder::operator()(Rate y) method.  In short: given a guess for the yield, the IrrFinder class calculates the corresponding price of the bond (see the call to CashFlows::npv in the IrrFinder::operator() method) and returns the difference between the calculation and the target price.  The used solver iteratively changes the guess and tries to find the value for which difference is zero, that is, the yield for which the calculated price equals the target price.

Luigi


On Wed, Apr 5, 2017 at 12:51 PM Xu Tao <[hidden email]> wrote:
The parts of codes Bond::Yield (BondsFunctions)-> CashFlows::Yield , in these functions, the formula to calculate the result of yield.

2017-04-05 12:30 GMT+02:00 Luigi Ballabio <[hidden email]>:
Which part of the code are you referring to, exactly? And what is the problem?

Later,
    Luigi


On Wed, Apr 5, 2017 at 11:59 AM Xu Tao <[hidden email]> wrote:
Hello, everyone,

Recently, I have found a problem which confuses me, it's about the formula of Yield of Bond,

I don't understand how the Quantlib calculate this Yield of Bond, is there anyone can give some help to give me a complete formula of this Yield, Thanks very much.

Have a nice day.

Best Regards.

--
Xu TAO
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users