# Using DayCounter ActualActual.ISMA in QuantLib

Suppose we have a semiannual coupon bond. The calculation date is 5/8 2017. The ex-coupon date is 4/20 2017 and next coupon date is 10/20 2017.

    issue_date= Date(20,10,2001)
maturity_date=Date(20, 10, 2021)
tenor=Period(2)
calendar=China()
date_generation=DateGeneration.Backward
month_end=False
day_count= ActualActual(ActualActual.ISMA,schedule)


When I define the day_count, I specify the type and the coupon schedule. There are 165 days between 5/8 2017 and 10/20 2017, and 183 days in this period. This should be 0.4508(which is divided by frequency). Actually, I can get this by defining the coupon period:

    day_count.yearFraction(calc_date,Date(20,10,2017),Date(20,4,2017),Date(20,10,2017))
Out[1]: 0.45081967213114754


However, when I directly enter the calc_date, it returns a strange result.

    day_count.yearFraction(calc_date,Date(20,10,2017))
Out[2]: 0.4166666666666667


I think this will change the npv when I construct FlatForward yield curve and FixedRateBond.

In your second example (when no period is specified), the ActualActual.ISMA DayCounter basically returns

  RoundedNumberOfMonthsBetween(date1,date2) / 12 = 5 / 12 = 0.41666


whereas in the first one (when there is a specific period) some fancy adjustments are made based on the difference in days (20 - 8 + halfday = 12.5):

  RoundedNumberOfMonthsBetween(date1,date2) / 12 + 12.5/365 ≈ 0.4508


I am not entirely familiar with the exact adjustment. But for more details have a look at

• This makes sense, thank you! But it seems that scheduledoesn't work as I thought. It should use the schedule and fill out refPeriodStart. When I use this day_count in FixedRateBond, there is no place to enter refPeriodStart, right? – Lindsey Jin Jun 7 '18 at 10:28
• The fixed-rate bond knows the reference periods of its coupons and will pass them to the day counter. – Luigi Ballabio Jun 12 '18 at 10:53