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()
    busconv = ql.Unadjusted
    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], \
                            ql.ActualActual(ql.ActualActual.Bond), ql.Unadjusted)
    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.


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!

  • $\begingroup$ 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. $\endgroup$ Oct 1 at 21:14
  • $\begingroup$ I just wish to test the 30y T-bond priced at par with QuantLib. $\endgroup$
    – SRqt
    Oct 4 at 12:55
  • $\begingroup$ 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"? $\endgroup$ Oct 4 at 14:00
  • $\begingroup$ 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)) $\endgroup$
    – SRqt
    Oct 4 at 17:40
  • $\begingroup$ 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". $\endgroup$ Oct 4 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.