public void testActualActual() { SingleCase[] testCases = { // 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) }; int n = testCases.Length; /// sizeof(SingleCase); for (int i = 0; i < n; i++) { ActualActual dayCounter = new ActualActual(testCases[i]._convention); Date d1 = testCases[i]._start; Date d2 = testCases[i]._end; Date rd1 = testCases[i]._refStart; Date rd2 = testCases[i]._refEnd; double calculated = dayCounter.yearFraction(d1, d2, rd1, rd2); if (Math.Abs(calculated - testCases[i]._result) > 1.0e-10) { Assert.Fail(dayCounter.name() + "period: " + d1 + " to " + d2 + " calculated: " + calculated + " expected: " + testCases[i]._result); } } }