BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bbldc_basicsia30360neom.h
Go to the documentation of this file.
1/// @file bbldc_basicsia30360neom.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bbldc_basicsia30360neom.h -*-C++-*-
8#ifndef INCLUDED_BBLDC_BASICSIA30360NEOM
9#define INCLUDED_BBLDC_BASICSIA30360NEOM
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bbldc_basicsia30360neom bbldc_basicsia30360neom
15/// @brief Provide stateless functions for the SIA-30/360-neom convention.
16/// @addtogroup bbl
17/// @{
18/// @addtogroup bbldc
19/// @{
20/// @addtogroup bbldc_basicsia30360neom
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bbldc_basicsia30360neom-purpose"> Purpose</a>
25/// * <a href="#bbldc_basicsia30360neom-classes"> Classes </a>
26/// * <a href="#bbldc_basicsia30360neom-description"> Description </a>
27/// * <a href="#bbldc_basicsia30360neom-sia-30360-neom-day-count-algorithm"> SIA-30360-neom Day Count Algorithm </a>
28/// * <a href="#bbldc_basicsia30360neom-usage"> Usage </a>
29/// * <a href="#bbldc_basicsia30360neom-example-1-computing-day-count-and-year-fraction"> Example 1: Computing Day Count and Year Fraction </a>
30///
31/// # Purpose {#bbldc_basicsia30360neom-purpose}
32/// Provide stateless functions for the SIA-30/360-neom convention.
33///
34/// # Classes {#bbldc_basicsia30360neom-classes}
35///
36/// - bbldc::BasicSia30360Neom: SIA-30/360-neom convention stateless functions
37///
38/// # Description {#bbldc_basicsia30360neom-description}
39/// This component provides a `struct`, `bbldc::BasicSia30360Neom`,
40/// that serves as a namespace for defining a suite of date-related functions
41/// used to compute the day count and year fraction between two dates as
42/// prescribed by the Standard Industry Association (SIA) 30/360 no-end-of-month
43/// day-count convention. In this day-count convention (also known as "US
44/// 30/360 no-end-of-month" or just "30/360 no-end-of-month"), each year is
45/// assumed to have 12 months and 360 days, with each month consisting of
46/// exactly 30 days. No end-of-month rule adjustments are applied for the last
47/// day of any month (including February).
48///
49/// ## SIA-30360-neom Day Count Algorithm {#bbldc_basicsia30360neom-sia-30360-neom-day-count-algorithm}
50///
51///
52/// Given `beginDate` and `endDate`, let:
53/// @code
54/// Ye = year of earlier date Yl = year of later date
55/// Me = month of earlier date Ml = month of later date
56/// De = day of earlier date Dl = day of later date
57///
58/// o If De is 31, change De to 30.
59///
60/// o If at this point De is 30 and Dl is 31, change Dl to 30.
61///
62///
63/// daysDiff ::= sign(endDate - beginDate) *
64/// (Yl - Ye) * 360 + (Ml - Me) * 30 + Dl - De
65/// @endcode
66/// Reference: Standard Securities Calculation Methods (1996)
67/// ISBN 1-882936-01-9
68///
69/// The year fraction is simply the day count divided by 360.
70///
71/// ## Usage {#bbldc_basicsia30360neom-usage}
72///
73///
74/// This section illustrates intended use of this component.
75///
76/// ### Example 1: Computing Day Count and Year Fraction {#bbldc_basicsia30360neom-example-1-computing-day-count-and-year-fraction}
77///
78///
79/// The following snippets of code illustrate how to use
80/// `bbldc::BasicSia30360Neom` methods. First, create two `bdlt::Date`
81/// variables, `d1` and `d2`:
82/// @code
83/// const bdlt::Date d1(2004, 9, 30);
84/// const bdlt::Date d2(2004, 12, 30);
85/// @endcode
86/// Then, compute the day count between the two dates:
87/// @code
88/// const int daysDiff = bbldc::BasicSia30360Neom::daysDiff(d1, d2);
89/// assert(90 == daysDiff);
90/// @endcode
91/// Finally, compute the year fraction between the two dates:
92/// @code
93/// const double yearsDiff = bbldc::BasicSia30360Neom::yearsDiff(d1, d2);
94/// assert(0.25 == yearsDiff);
95/// @endcode
96/// @}
97/** @} */
98/** @} */
99
100/** @addtogroup bbl
101 * @{
102 */
103/** @addtogroup bbldc
104 * @{
105 */
106/** @addtogroup bbldc_basicsia30360neom
107 * @{
108 */
109
110#include <bblscm_version.h>
111
112
113namespace bdlt {
114
115class Date;
116
117} // close namespace bdlt
118
119namespace bbldc {
120
121 // ========================
122 // struct BasicSia30360Neom
123 // ========================
124
125/// This `struct` provides a namespace for a suite of pure functions that
126/// compute values based on dates according to the SIA-30/360-neom day-count
127/// convention.
129
130 // CLASS METHODS
131
132 /// Return the (signed) number of days between the specified `beginDate`
133 /// and `endDate` according to the SIA 30/360 no-end-of-month day-count
134 /// convention. If `beginDate <= endDate`, then the result is
135 /// non-negative. Note that reversing the order of `beginDate` and
136 /// `endDate` negates the result.
137 static int daysDiff(const bdlt::Date& beginDate,
138 const bdlt::Date& endDate);
139
140 /// Return the (signed fractional) number of years between the specified
141 /// `beginDate` and `endDate` according to the SIA 30/360
142 /// no-end-of-month day-count convention. If `beginDate <= endDate`,
143 /// then the result is non-negative. Note that reversing the order of
144 /// `beginDate` and `endDate` negates the result; specifically,
145 /// `|yearsDiff(b, e) + yearsDiff(e, b)| <= 1.0e-15` for all dates `b`
146 /// and `e`.
147 static double yearsDiff(const bdlt::Date& beginDate,
148 const bdlt::Date& endDate);
149};
150
151} // close package namespace
152
153
154#endif
155
156// ----------------------------------------------------------------------------
157// Copyright 2015 Bloomberg Finance L.P.
158//
159// Licensed under the Apache License, Version 2.0 (the "License");
160// you may not use this file except in compliance with the License.
161// You may obtain a copy of the License at
162//
163// http://www.apache.org/licenses/LICENSE-2.0
164//
165// Unless required by applicable law or agreed to in writing, software
166// distributed under the License is distributed on an "AS IS" BASIS,
167// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
168// See the License for the specific language governing permissions and
169// limitations under the License.
170// ----------------------------- END-OF-FILE ----------------------------------
171
172/** @} */
173/** @} */
174/** @} */
Definition bdlt_date.h:294
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bbldc_basicactual360.h:107
Definition bbldc_basicisma30360.h:112
Definition bbldc_basicsia30360neom.h:128
static double yearsDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)
static int daysDiff(const bdlt::Date &beginDate, const bdlt::Date &endDate)