QL.info("Testing actual/actual day counters...");
final SingleCase testCases[] = new SingleCase[] {
// first example
new SingleCase(ActualActual.Convention.ISDA,
new Date(1,Month.November,2003), new Date(1,Month.May,2004),
0.497724380567),
new SingleCase(ActualActual.Convention.ISMA,
new Date(1,Month.November,2003), new Date(1,Month.May,2004),
new Date(1,Month.November,2003), new Date(1,Month.May,2004),
0.500000000000),
new SingleCase(ActualActual.Convention.AFB,
new Date(1,Month.November,2003), new Date(1,Month.May,2004),
0.497267759563),
// short first calculation period (first period)
new SingleCase(ActualActual.Convention.ISDA,
new Date(1,Month.February,1999), new Date(1,Month.July,1999),
0.410958904110),
new SingleCase(ActualActual.Convention.ISMA,
new Date(1,Month.February,1999), new Date(1,Month.July,1999),
new Date(1,Month.July,1998), new Date(1,Month.July,1999),
0.410958904110),
new SingleCase(ActualActual.Convention.AFB,
new Date(1,Month.February,1999), new Date(1,Month.July,1999),
0.410958904110),
// short first calculation period (second period)
new SingleCase(ActualActual.Convention.ISDA,
new Date(1,Month.July,1999), new Date(1,Month.July,2000),
1.001377348600),
new SingleCase(ActualActual.Convention.ISMA,
new Date(1,Month.July,1999), new Date(1,Month.July,2000),
new Date(1,Month.July,1999), new Date(1,Month.July,2000),
1.000000000000),
new SingleCase(ActualActual.Convention.AFB,
new Date(1,Month.July,1999), new Date(1,Month.July,2000),
1.000000000000),
// long first calculation period (first period)
new SingleCase(ActualActual.Convention.ISDA,
new Date(15,Month.August,2002), new Date(15,Month.July,2003),
0.915068493151),
new SingleCase(ActualActual.Convention.ISMA,
new Date(15,Month.August,2002), new Date(15,Month.July,2003),
new Date(15,Month.January,2003), new Date(15,Month.July,2003),
0.915760869565),
new SingleCase(ActualActual.Convention.AFB,
new Date(15,Month.August,2002), new Date(15,Month.July,2003),
0.915068493151),
// long first calculation period (second period)
/* Warning: the ISDA case is in disagreement with mktc1198.pdf */
new SingleCase(ActualActual.Convention.ISDA,
new Date(15,Month.July,2003), new Date(15,Month.January,2004),
0.504004790778),
new SingleCase(ActualActual.Convention.ISMA,
new Date(15,Month.July,2003), new Date(15,Month.January,2004),
new Date(15,Month.July,2003), new Date(15,Month.January,2004),
0.500000000000),
new SingleCase(ActualActual.Convention.AFB,
new Date(15,Month.July,2003), new Date(15,Month.January,2004),
0.504109589041),
// short final calculation period (penultimate period)
new SingleCase(ActualActual.Convention.ISDA,
new Date(30,Month.July,1999), new Date(30,Month.January,2000),
0.503892506924),
new SingleCase(ActualActual.Convention.ISMA,
new Date(30,Month.July,1999), new Date(30,Month.January,2000),
new Date(30,Month.July,1999), new Date(30,Month.January,2000),
0.500000000000),
new SingleCase(ActualActual.Convention.AFB,
new Date(30,Month.July,1999), new Date(30,Month.January,2000),
0.504109589041),
// short final calculation period (final period)
new SingleCase(ActualActual.Convention.ISDA,
new Date(30,Month.January,2000), new Date(30,Month.June,2000),
0.415300546448),
new SingleCase(ActualActual.Convention.ISMA,
new Date(30,Month.January,2000), new Date(30,Month.June,2000),
new Date(30,Month.January,2000), new Date(30,Month.July,2000),
0.417582417582),
new SingleCase(ActualActual.Convention.AFB,
new Date(30,Month.January,2000), new Date(30,Month.June,2000),
0.41530054644)
};
for (int i=0; i<testCases.length-1; i++) {
final ActualActual dayCounter = new ActualActual(testCases[i].convention);
final Date d1 = testCases[i].start;
final Date d2 = testCases[i].end;
final Date rd1 = testCases[i].refStart;
final Date rd2 = testCases[i].refEnd;
QL.info(testCases[i].toString());
/*@Time*/ final double calculated = dayCounter.yearFraction(d1, d2, rd1, rd2);