# QuantLib - Help buiding a simple T-Bond (Mischievous Pricing Conventions)

Im having a problem getting the right price for a simple T-Bond, maybe a Mischievous Pricing Conventions like Luigi says in his book. Im tying to price "912810SZ Govt"

def t_bond(iss, mat, coup):
calendar = ql.UnitedStates()
sett = 1
face = 100.
freq = ql.Period(ql.Semiannual)
schedule = ql.Schedule(iss, \
mat, \
freq, calendar, busconv, busconv, \
ql.DateGeneration.Backward, True)
bond = ql.FixedRateBond(sett, face, schedule, [coup/2/100], \
return bond

bond = t_bond(ql.Date(15, 8, 2021), ql.Date(15, 8, 2051), 2.)
rate = ql.InterestRate(0.01, ql.ActualActual(), ql.SimpleThenCompounded, ql.Annual)
ql.BondFunctions.cleanPrice(bond, rate)

>>> 100.00006747141342


Tell me if im worg, but it should return 100.0, right?

When I inspect the cashflows it seems correct

coupons = [ql.as_coupon(c) for c in bond.cashflows()[:-1]]
dados = [(c.date(), c.rate(), c.accrualPeriod(), c.accruedAmount(c.date())) for c in coupons]
pd.DataFrame(dados, columns=["Date", "Rate", "Acc Period", "AccAmount"], index=range(1, len(coupons)+1))


What am I doing wrong? Thanks in advance.

EDIT

I got the right par value of the bond by setting the global evaluation date to a coupom payment date and by passing a Schedule instance with act/act daycount convention in the bond object and on the discount curve object

ql.ActualActual(ql.ActualActual.ISMA, schedule)


This discussion helped me to arive at the right answer for my problem: Difference arising between Dirty Price and NPV using QuantLib Python Thanks!

• It's just a 30-year U.S. treasury, T 2 08/15/2051. What's mischievous about that? SIFMA has a nice discussion sifma.org/resources/general/… of what happens if they don't pay. :) I don't think you mean that. Oct 1 at 21:14
• I just wish to test the 30y T-bond priced at par with QuantLib.
– SRqt
Oct 4 at 12:55
• I see a few other things wrong in your code. For example, ql.UnitedStates() is almost as bad as FinCalendar(FinCalendarTypes.UNITED_STATES) in FinancePy :) There is no such thing as a "U.S. calendar" in real life. It only exists in the confused minds of European programmers. Is Good Friday a holiday in your "U.S. calendar"? Oct 4 at 14:00
• These are the holidays in ql.UnitedStates() calendar in 2021: (Date(1,1,2021), Date(18,1,2021), Date(15,2,2021), Date(31,5,2021), Date(5,7,2021), Date(6,9,2021), Date(11,10,2021), Date(11,11,2021), Date(25,11,2021), Date(24,12,2021), Date(31,12,2021))
– SRqt
Oct 4 at 17:40
• Comparing your list to nyse.com/markets/hours-calendars and cmegroup.com/tools-information/holiday-calendar.html , I don't see Date(2,4,2021), which illustrates my point - never use a "U.S. Calendar". Oct 4 at 18:16