Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bbldc_basicdaycountutil
[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::BasicDayCountUtil enum-specified day-count calculation procedures
See also:
Component bbldc_daycountconvention
Description:
This component provides a struct, bbldc::BasicDayCountUtil, that defines a suite of date-related functions used to compute the day count and the year fraction between two dates as prescribed by an enumerated day-count convention. Specifically, the daysDiff and yearsDiff methods defined in bbldc::BasicDayCountUtil 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::BasicDayCountUtil methods. First, create two bdlt::Date variables, d1 and d2:
  const bdlt::Date d1(2003, 10, 19);
  const bdlt::Date d2(2003, 12, 31);
Now, compute the day count between d1 and d2 according to the ISDA Actual/Actual convention:
  const int daysDiff = bbldc::BasicDayCountUtil::daysDiff(
                            d1,
                            d2,
                            bbldc::DayCountConvention::e_ISDA_ACTUAL_ACTUAL);
  assert(73 == daysDiff);
Finally, compute the year fraction between the two dates according to the ISDA Actual/Actual convention:
  const double yearsDiff = bbldc::BasicDayCountUtil::yearsDiff(
                            d1,
                            d2,
                            bbldc::DayCountConvention::e_ISDA_ACTUAL_ACTUAL);
  // Need fuzzy comparison since 'yearsDiff' is a 'double'.
  assert(0.1999 < yearsDiff && 0.2001 > yearsDiff);