Posted by
Matteo Zandi on
URL: http://quantlib.414.s1.nabble.com/Re-Net-yield-after-taxes-of-a-Bond-How-to-differentiate-on-cashflow-type-tp433.html
On Tue, 2010-12-14 at 15:20 +0100, Martino Fornasa wrote:
> I'm trying to build a function to calculate the net yield (after taxes)
> of a fixed rate bond. In order to do that, I need to differentiate
> between coupon-cashflows and, for example, redemption cashflows.
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?
Thanks,
Matteo
#!/usr/bin/python
import QuantLib
settlement_days = 3
face_amount = 100.0
redemption = 100.0
issue_date = QuantLib.Date(1,11,2000)
maturity_date = QuantLib.Date(1,11,2015)
calendar = QuantLib.Italy(1) # Milan stock exchange
day_counter = QuantLib.ActualActual(QuantLib.ActualActual.Bond)
sched = QuantLib.Schedule(issue_date, maturity_date,
QuantLib.Period(QuantLib.Semiannual), calendar,
QuantLib.Unadjusted, QuantLib.Unadjusted,
QuantLib.DateGeneration.Backward, False)
coupons = [0.03]
bond = QuantLib.FixedRateBond(settlement_days, face_amount,
sched, coupons, day_counter,
QuantLib.Following, redemption,
issue_date)
flat_forward = QuantLib.FlatForward(issue_date+settlement_days*QuantLib.Days,
coupons[0], day_counter,
QuantLib.Compounded, QuantLib.Semiannual)
term_structure_handle = QuantLib.RelinkableYieldTermStructureHandle(flat_forward)
bondEngine = QuantLib.DiscountingBondEngine(term_structure_handle)
bond.setPricingEngine(bondEngine)
print bond.bondYield(96.39, day_counter, QuantLib.Compounded, QuantLib.Semiannual, QuantLib.Date(2,1,2010))
Cashflows:
03/01/2011 -96,39
02/05/2011 0,98
01/11/2011 1,5
02/05/2012 1,5
01/11/2012 1,5
02/05/2013 1,5
01/11/2013 1,5
01/05/2014 1,5
01/11/2014 1,5
01/05/2015 1,5
01/11/2015 101,5
------------------------------------------------------------------------------
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