Day count convention Actual/Actual AFB; Factor for Date1 = 2004-02-28 and Date2 = 2008-02-28

The Actual/Actual AFB day count convention is explained on Wikipedia here. I'll condense the rules here the way I understood them.

• Factor = Days(Date1,Date2)/DiY
• If 29th february is in date range from Date1 (inclusive) to Date2 (exclusive), DiY=366 else DiY=365
• If date range from Date1 to Date2 spans multiple years, calculation is split in two parts:
• Number of complete years counted back from the last day in the period
• The remaining initial stub, calculated using the basic rule
• ISDA additional rule: If counting backwards for multiple years, if the last day of the relevant period is 28 February the full year should be counted back to 28 February unless 29 February exists in which case 29 February should be used.

Now consider the case Date1 = 2004-02-28 and Date2 = 2008-02-28. Applying the rules gives:

• 4 full years
• Date2' = 2004-02-29 [rebased Date2 by counting back + ISDA additional rule]
• DiY = 365, because: Date1 = 2004-02-28, Date2' = 2004-02-29; 29 February is not in date range from Date1 (inclusive) and Date2' (exclusive) i.e. the remaining initial stub
• Factor = 4 + 1/365

However, in the example on the Wikipedia page I linked to at the top it shows for those same two dates that Factor = 4 + 1/366. Which factor is correct? And if the result of the Wikipedia page is correct, where did I go wrong with my reasoning?

• Feb 29th 2004 is the day after Day1, so why would it not be in the date range?
– Olaf
Oct 15 '17 at 8:58
• @Olaf Because the rules state that the range excludes Date2, i.e. [Date1,Date2). Date1=2004-02-28, Date2'=2004-02-29, and since the interval excludes Date2, the 29th of february is not in the range.
– TT.
Oct 15 '17 at 9:01
• But Date2 occurs 4 years later, in 2008?
– Olaf
Oct 15 '17 at 9:03
• @Olaf I'm basing this on the way I understood things, which may be wrong. Since the range spans mutliple years: 1) number of complete years counted back from the last day in the period; this gives the 4 in the factor. 2) The remaining initial stub, calculated using the basic rule and applying the ISDA additional rule, give the last stub: Date1=2004-02-28 and Date2=2004-02-29. Since the range exludes the last day of the interval, the 29th is not in the range and DiY should be 365. Perhaps the remaining stub is not correct, and should be Date1=2004-02-28 and Date2=2004-03-01?
– TT.
Oct 15 '17 at 9:13
• I find it helpful to look at QuantLib's implementation in these cases: github.com/lballabio/QuantLib/blob/master/ql/time/daycounters/… Oct 16 '17 at 0:46

Looking at the link to QuantLib's implementation of Act/Act AFB posted by Helin Gai in comments, this would be the part that the determines DiY (variable den):

Real den = 365.0; // the DiY

if (Date::isLeap(newD2.year())) {
temp = Date(29, February, newD2.year());
if (newD2>temp && d1<=temp)
den += 1.0;
} else if (Date::isLeap(d1.year())) {
temp = Date(29, February, d1.year());
if (newD2>temp && d1<=temp)
den += 1.0;
}

d1 will be 2004-02-28 and newD2 will be 2004-02-29 after counting back complete years and applying the ISDA additional rule. Applying this bit of code:

• if (Date::isLeap(newD2.year())) > True
• temp = Date(29, February, newD2.year()); > temp = '2004-02-29'
• if (newD2>temp && d1<=temp) > False, since newD2>temp doesn't hold
• den is not incremented and remains 365;

So according to QuantLib's implementation, Factor will be 4 + 1/365. It seems my suspicion is true that the example on Wikipedia is incorrect.