Date Conversion
Atoti Common Library provides several services for converting a pillar value into a duration.
Maturity converter
The maturity converter service converts any pillar value into a duration, expressed in number of days,
year fraction or a date relative to the current date.
The interface of the bean is IMaturityConverter
.
It can be injected into any Atoti plugin that extends the IMaturityConverterAware
interface.
The interface provides the following services:
toYearFraction
converts a pillar into number of years.toFraction
converts a pillar into a number of days.toDate
converts a pillar into a future date relative to the as of date.updateLeafCoordinatesFunction
is a technical function that provides the extra leafs needed for the conversion.
Here are the parameters needed to make a conversion:
Parameter | Type | Example | Meaning |
---|---|---|---|
pivot | IActivePivot | The current cube | Used to pass the current cube to the service. |
databaseVersion | IDatabaseVersion | The current database | Used to pass the current database to the service. |
asOfDate | LocalDate | 2023-02-27 | The current date used to find the right duration. |
bucketType | BucketType | TENOR_INPUT | The kind of pillar, used to differentiate the tenor for the (underlying) maturity. |
tenorSet | String | “Simple” | Use to select a specific set of tenors. |
maturity | Object | 6M | The pillar to convert. |
leafCoordinates | List | [] | Additional data to help the conversion. |
The default implementation provided is SimpleMaturityConverter
that can be overridden to fit extra requirements.
By default, the maturity converter relies on several sub-services to perform the conversion:
IDayCountConvention
defines the way of counting the number of days between two dates.ITenorConverter
transforms a tenor and an as of date into a new date.IBusinessDayConventionFactory
finds the business day that matches the specified date.IBusinessDayCalendarFactory
tells if the current day is a business day.
If a double held by a String
or Double
object is passed to the toYearFraction
function, it is directly returned. To activate the day count logic, it has to
be passed with the “Y” suffix. So “0.25” will return “0.25” and “0.25Y” will return “0.254…”
IDayCountConvention
This service converts an interval between two dates into a number of days by taking into account the convention used to define the number of days in a month and in a year. It provides two implementations, one to count the number of days and one to count the number of years. Several implementations are provided:
DayCountA365Fixed
: the real number of days between the start and the end using the Gregorian calendar, a year has 365 days.DayCountA360
: the real number of days, where a year has 360 days.DayCount30on360ISDA
: Every month has 30 days and the year has 360 days. The 31st of a month is the same day as the 30th.DayCountActualActualISDA
: A008 rule. The days and years are exact. A year is 366 or 365 days, depending on whether the current year is leap.DayCountActualActual
: A009 rule. The days and years are exact. A year is 366 or 365 days, depending on whether the last year is leap.
ITenorConverter
This service is used to transform a Pillar and an as of date into the target date regardless of the day convention and the business dates.
The default implementation SimpleTenorConverter
handles several pillar types:
Type | Containing | Explanation | Examples |
---|---|---|---|
LocalDate | Date | The tenor is a fixed date. | 2035-03-12 |
String | Date | The tenor is a fixed date. | “2035-03-12” |
String | Overnight | One business day duration. | “ON”, “O/N” |
String | Two nights | Two business days duration. | “TN”, “T/N” |
Double | Years | A year fraction. | 1.5 |
String | Years | A year fraction. | “1.5”, “1.5Y” |
Period | A duration | A duration following ISO8601. | P1Y6M2D |
String | A duration | A duration. | “3D”, “6M”, “2W”, “1Y6M” |
It is intended to be overridden in case of a specific pillar format.
To do this you can either override the interface method ITenorConverter::convert
and add your extra conversion first, or you can override the
method SimpleTenorConverter::notConverted
and do it at the end.
IBusinessDayConvention
From a LocalDate
and an IBusinessDayCalendar
this service finds the matching business day.
The default implementation NextBusinessDayConvention
returns the closest next day.
IBusinessDayCalendar
This service tells if a day is closed or open.
Atoti Common Libraryprovides the Target calendar TargetBusinessDayConvention
as an implementation that will give the open days on the target system based on the official calendar
of the Target2 settlement system calendar.
You can also find an implementation that relies on a database in the FRTB project.
TenorComparator
Plugin used to compare tenors together.