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

Detailed Description

Outline

Purpose

Provide stateless functions for the Actual/360 convention.

Classes

Description

This component provides a struct, bbldc::BasicActual360, 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 Actual/360 day-count convention. In this day-count convention, we simply measure the number of days occurring in a time period, and to calculate years, divide that by 360. Note that this means the number of years between January 1, 2005 and January 1, 2006 is about 1.0139. No end-of-month rule adjustments are made. Given beginDate and endDate:

yearsDiff ::= sign(endDate - beginDate) *
(days between beginDate and endDate) / 360.0

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::BasicActual360 methods. First, create four bdlt::Date variables:

const bdlt::Date dA(2004, 2, 1);
const bdlt::Date dB(2004, 3, 1);
const bdlt::Date dC(2004, 5, 1);
const bdlt::Date dD(2005, 2, 1);
Definition bdlt_date.h:294

Then, compute the day count between some pairs of these dates:

int daysDiff;
assert( 29 == daysDiff);
assert( 90 == daysDiff);
assert(366 == daysDiff);
assert( 61 == daysDiff);
static int daysDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)
Definition bbldc_basicactual360.h:148

Finally, compute the year fraction between some of the dates:

double yearsDiff;
assert(0.25 == yearsDiff);
// Need fuzzy comparison since 'yearsDiff' is a 'double'.
assert(yearsDiff < 1.0167 && yearsDiff > 1.0166);
static double yearsDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)