Re: How to calculate bond yield

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/How-to-calculate-bond-yield-tp786p789.html

On Thu, 2007-04-19 at 17:06 +0200, Enrico Gargiulo wrote:

> Luigi,
> my problem is that when I create the object without curve I have the
> following results:
>
>         std::cout << "Underlying bond clean price: " << bot.cleanPrice() <<
> std::endl;
>
> The results are:
>
> Underlying bond clean price: no discounting term structure set
>
> Where is the mistake?

btp.cleanPrice(), without any arguments, calculates the theoretical
price on a given term structure. But I was under the impression that you
wanted to calculated the yield given a price, or viceversa. For
calculating the yield, you can use

btp.yield(price, compounding);

(where compounding is the way you compound the yield---most likely
you'll use Simple.) For calculating the price, you can use

btp.cleanPrice(yield, compounding);

Neither of them requires a term structure as far as I recall (and both
of them will take and return yields as decimal numbers, i.e., 0.05 for a
5% yield.)

Hope this helps,
        Luigi


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

Do the right thing. It will gratify some people and astonish the rest.
-- Mark Twain



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users