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

Detailed Description

Outline

Purpose

Provide stateless functions for PSA 30/360 end-of-month convention.

Classes

Description

This component provides a struct, bbldc::BasicPsa30360Eom, that serves as a namespace for defining a suite of date-related functions used to compute the day count and year fraction between two dates as prescribed by the Public Securities Association (PSA) 30/360 day-count convention with end-of-month (eom) adjustments.

PSA 30360-eom Day Count Algorithm

Given beginDate and endDate, let:

Ye = year of earlier date Yl = year of later date
Me = month of earlier date Ml = month of later date
De = day of earlier date Dl = day of later date
o If De is the last day of February (29 in a leap year, else 28),
change De to 30.
o If De is 31, change De to 30.
o If at this point De is 30 and Dl is 31, change Dl to 30.
daysDiff ::= sign(endDate - beginDate) *
max((Yl - Ye) * 360 + (Ml - Me) * 30 + Dl - De, 0)

The max function is required because Dl has no February adjustment and simple differences like (19990228 - 19990228) produce -2 without max.

Reference: PSA Standard Formulas, page SF-17

The year fraction is simply the day count divided by 360.

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::BasicPsa30360Eom methods. First, create two bdlt::Date variables, d1 and d2:

const bdlt::Date d1(2004, 9, 30);
const bdlt::Date d2(2004, 12, 31);
Definition bdlt_date.h:294

Then, compute the day count between the two dates:

const int daysDiff = bbldc::BasicPsa30360Eom::daysDiff(d1, d2);
assert(90 == daysDiff);
static int daysDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)

Finally, compute the year fraction between the two dates:

const double yearsDiff = bbldc::BasicPsa30360Eom::yearsDiff(d1, d2);
assert(0.25 == yearsDiff);
static double yearsDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)