Re: Net yield (after taxes) of a Bond. How to differentiate on cashflow type?

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/Re-Net-yield-after-taxes-of-a-Bond-How-to-differentiate-on-cashflow-type-tp433p434.html

On Sun, 2011-01-02 at 14:11 +0100, Matteo Zandi wrote:
> I'm also interested in calculating the net yield of Italian Government fixed rate bonds (BTP), especially I would like to check my own calculations against QuantLib. By using python tests I came up with the following code, for calculating the gross yield (before taxes) for IT0004656275, BTP 3% 01 Nov 2015 with last price of 96,43.
> QuantLib gives me 3,69% while Excel's XIRR function returns 3,86% for same cashflows.
> What am I doing wrong?

Well, to begin with, this...

> flat_forward = QuantLib.FlatForward(issue_date+settlement_days*QuantLib.Days,
> coupons[0], day_counter,
> QuantLib.Compounded, QuantLib.Semiannual)

...doesn't do what you think.  In C++, Days is an enumeration, so it's a
different type and we can overload on it so that 2*Days returns a
Period.  In Python, there's no such thing and QuantLib.Days is just the
integer 0, so you're not setting the date you wanted.  Also, just adding
the settlement days doesn't do the correct thing (even in C++) since it
disregards holidays.  You really want

calendar.advance(issue_date, settlement_days, QuantLib.Days)

instead.

However, that's likely not the problem. One is that, according to the
cashflows you reported, you want to pass Date(2,1,2011) to
bondYield--you're passing 2010 instead.  This brings the yield to 3.82%,
which is more in line with what you're expecting.  
Another issue might be your initial coupons:

03/01/2011  -96,39
02/05/2011    0,98

You're going to receive 1.5 on May 2nd, not 0.98, so that's what the
library will use for that date.  The 0.52 accrued until now should be
included in the clean price passed to the bondYield method.

Luigi


--

Age is an issue of mind over matter. If you don't mind, it doesn't
matter.
-- Mark Twain



------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users