Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bbldc_terminateddaycountutil
[Package bbldc]

Support for day-count calculations of enum-specified conventions. More...

Namespaces

namespace  bbldc

Detailed Description

Outline
Purpose:
Support for day-count calculations of enum-specified conventions.
Classes:
bbldc::TerminatedDayCountUtil enum-specified day-count calculations
See also:
Component bbldc_daycountconvention, bbldc_terminatedbus252
Description:
This component provides a struct, bbldc::TerminatedDayCountUtil, that defines a suite of date-related functions used to compute the day count and the year fraction between two dates, with potential special handling of a termination date (e.g., maturity date), as prescribed by an enumerated day-count convention. Specifically, the daysDiff and yearsDiff methods defined in bbldc::TerminatedDayCountUtil take a trailing DayCountConvention::Enum argument indicating which particular day-count convention to apply.
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::TerminatedDayCountUtil methods. First, create three bdlt::Date variables, d1, d2, and dt:
  const bdlt::Date d1(2003, 10, 18);
  const bdlt::Date d2(2003, 12, 31);
  const bdlt::Date dt(2004,  2, 29);
Then, compute the day count between d1 and d2 according to the ISDA 30/360 EOM day-count convention with termination date dt:
  const int daysDiff = bbldc::TerminatedDayCountUtil::daysDiff(
                               d1,
                               d2,
                               dt,
                               bbldc::DayCountConvention::e_ISDA_30_360_EOM);
  assert(72 == daysDiff);
Finally, compute the year fraction between the two dates according to the ISDA 30/360 EOM day-count convention with termination date dt:
  const double yearsDiff = bbldc::TerminatedDayCountUtil::yearsDiff(
                               d1,
                               d2,
                               dt,
                               bbldc::DayCountConvention::e_ISDA_30_360_EOM);

  // Need fuzzy comparison since 'yearsDiff' is a 'double'.
  assert(0.1999 < yearsDiff && 0.2001 > yearsDiff);