BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bbldc_periodicmaactualactual

Detailed Description

Outline

Purpose

Provide stateless functions for period-based ICMA Actual/Actual.

Classes

Description

This component provides a struct, bbldc::PeriodIcmaActualActual, that serves as a namespace for defining a suite of date-related functions used to compute the day count and the year fraction between two dates as per the ICMA Actual/Actual day-count convention. In this day-count convention, the day count between two dates is exactly the number of days occurring in the time period and the year fraction is the number of full periods multiplied by the period weighting (periodYearDiff) plus front-stub and back-stub adjustments. The periods are defined by the periodDate elements representing, say, bond coupon payment dates with the first period starting on periodDate[0] and ending on periodDate[1], the second period starting onperiodDate[1]' and ending on periodDate[2], and thei'-th period starting on periodDate[i - 1] and ending on periodDate[i].

Usage

This section illustrates intended use of this component.

Example 1: Computing Day Count and Year Fraction

The following snippets of code illustrate how to use bbldc::PeriodIcmaActualActual methods. First, create two bdlt::Date variables, d1 and d2:

const bdlt::Date d1(2003, 10, 19);
const bdlt::Date d2(2003, 12, 31);
Definition bdlt_date.h:294

Then, create a schedule of period dates, sched, corresponding to a quarterly payment (periodYearDiff == 0.25):

sched.push_back(bdlt::Date(2003, 10, 1));
sched.push_back(bdlt::Date(2004, 1, 1));
Definition bslstl_vector.h:1025
void push_back(const VALUE_TYPE &value)
Definition bslstl_vector.h:3760

Next, compute the day count between d1 and d2:

const int daysDiff = bbldc::PeriodIcmaActualActual::daysDiff(d1, d2);
assert(73 == daysDiff);
static int daysDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)
Definition bbldc_periodicmaactualactual.h:200

Finally, compute the year fraction between the two dates:

const double yearsDiff = bbldc::PeriodIcmaActualActual::yearsDiff(d1,
d2,
sched,
0.25);
// Need fuzzy comparison since 'yearsDiff' is a 'double'.
assert(yearsDiff > 0.1983 && yearsDiff < 0.1985);
static double yearsDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate, const bdlt::Date *periodDateBegin, const bdlt::Date *periodDateEnd, double periodYearDiff)