Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bbldc_basicactual365fixed
[Package bbldc]

Provide stateless functions for the Actual/365 (fixed) convention. More...

Namespaces

namespace  bbldc

Detailed Description

Outline
Purpose:
Provide stateless functions for the Actual/365 (fixed) convention.
Classes:
bbldc::BasicActual365Fixed Actual/365 fixed convention stateless functions
Description:
This component provides a struct, bbldc::BasicActual365Fixed, 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 per the Actual/365 (fixed) 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 365. Note that this means the number of years between January 1, 2004 and January 1, 2005 comes out to about 1.00274. No end-of-month rule adjustments are made. Given beginDate and endDate:
  yearsDiff ::= sign(endDate - beginDate) *
                                 (days between beginDate and endDate) / 365.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::BasicActual365Fixed 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);
Then, compute the day count between some pairs of these dates:
  int daysDiff;
  daysDiff = bbldc::BasicActual365Fixed::daysDiff(dA, dB);
  assert( 29 == daysDiff);
  daysDiff = bbldc::BasicActual365Fixed::daysDiff(dA, dC);
  assert( 90 == daysDiff);
  daysDiff = bbldc::BasicActual365Fixed::daysDiff(dA, dD);
  assert(366 == daysDiff);
  daysDiff = bbldc::BasicActual365Fixed::daysDiff(dB, dC);
  assert( 61 == daysDiff);
Finally, compute the year fraction between some of the dates:
  double yearsDiff;
  yearsDiff = bbldc::BasicActual365Fixed::yearsDiff(dA, dC);
  // Need fuzzy comparison since 'yearsDiff' is a 'double'.
  assert(yearsDiff > 0.2465 && yearsDiff < 0.2466);
  yearsDiff = bbldc::BasicActual365Fixed::yearsDiff(dA, dD);
  assert(yearsDiff > 1.0027 && yearsDiff < 1.0028);