Provide a parameterized day-count convention implementation.
More...
Namespaces |
namespace | bbldc |
Detailed Description
- Outline
-
-
- Purpose:
- Provide a parameterized day-count convention implementation.
-
- Classes:
-
-
- Description:
- This component provides a parameterized (template) implementation,
bbldc::TerminatedBasicDayCountAdapter
, of the bbldc::BasicDayCount
protocol that allows for special handling of a termination date (e.g., maturity date). The template argument can be any type supporting the following two class methods. The template class bbldc::TerminatedBasicDayCountAdapter
provides convenient support for run-time polymorphic choice of day-count conventions (via conventional use of a base-class pointer or reference) without having to implement each derived type explicitly. In this sense, bbldc::TerminatedBasicDayCountAdapter
adapts the various concrete "terminated" day-count convention classes (e.g., bbldc::TerminatedIsda30360Eom
) to a run-time binding mechanism.
-
- Usage:
- This section illustrates intended use of this component.
-
- Example 1: Adapting bbldc::TerminatedIsda30360Eom:
- This example shows the procedure for using
bbldc::TerminatedBasicDayCountAdapter
to adapt the bbldc::TerminatedIsda30360Eom
day-count convention to the bbldc::BasicDayCount
protocol, and then the use of the day-count methods.
- First, we define an instance of the adapted
bbldc::TerminatedIsda30360Eom
day-count convention and obtain a reference to the bbldc::BasicDayCount
: Then, create two bdlt::Date
variables, d1
and d2
, with which to use the day-count convention methods: Now, use the base-class reference to compute the day count between the two dates: const int daysDiff = dcc.daysDiff(d1, d2);
assert(72 == daysDiff);
Finally, use the base-class reference to compute the year fraction between the two dates: const double yearsDiff = dcc.yearsDiff(d1, d2);
assert(0.1999 < yearsDiff && 0.2001 > yearsDiff);