Tenor Converter
The ITenorConverter
interface returns a date based on a given as-of-date, a duration, and some context.
warning
This interface is deprecated, please see IYearOrDayFractionRetriever
.
It can take any object type in entry for a duration. This is intended to maximize the cube performances, to avoid multiple string to specific object conversion at run-time. This conversion should be made once at loading time.
The tenor converter could take the datastore
and tenorSet
as a parameter to work in a database lookup mode where tenors are pre-converted and
stored on the database.
The bucketType
is intended to discriminate the axis where the conversion take place as it could change the returned date.
For instance “6M” of the product defines a real calendar date, in contrast to “6M” of the underlying, which is only a conventional duration and must always be 180 days.
If the IBusinessDayCalendar
and IBusinessDayConvention
are defined, the returned date will be a business day.
The SimpleTenorConverter
is the proposed default implementation. It will try by the order the following conversion.
1 => Overnight
First, the overnight maturities are checked:
- ‘ON’ or ‘O/N’ returns 1 day.
- ‘TN’ or ‘T/N’ returns 2 days.
2 => ISO 8601 time duration
If the string represents a duration with the format nYnMnWnD (with an optional P at start) as described here, or a java Period
object, this will be used to compute the target date.
The components of the duration are:
- Y: Years
- M: Months
- W: Weeks
- D: Days
For instance, 1Y2M3D is one year 2 months and 3 days, P1M3W will be one month and two weeks.
3 => Year fraction
If the input pillar is a double or a double string with an optional “Y” at the end:
[-+]?\d+\.?\d*Y?
then the input will be considered to be a year fraction. To be compatible with the day count conventions, it will be converted to a year/month/day duration with the following rules:
- The integer part will be the number of years.
- The 1/12 parts will be the months.
- The remaining multiplied by 365 will be the days. So with this convention, 1.25Y will be equivalent to 1Y3M.
4 => IMM Dates
The IMM Dates are dates that only hold the month and the year. The day is defined by the 3rd Wednesday of the month. The IMM date is following this regexp:
^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)[A-Z]*-?(\d{2}(\d{2})?)$
If the year is given with 2 digits, it’s assumed to be 20YY.
For instance:
Tenor | Date |
---|---|
MAY24 | 2024-05-15 |
OCT2024 | 2024-10-16 |
JAN-24 | 2024-01-17 |
SEP-2024 | 2024-09-18 |
June-24 | 2024-06-19 |
March-2024 | 2024-03-20 |
aug24 | 2024-08-21 |
5 => ISO 8601 date
The tenor could also be a date following the ISO 8601 standard: AAAA-MM-JJ
6 => Fallback
Lastly, the function notConverted
is called. This function is intended to be overridden to add extra conversion snippets to the end of the chain.
If the extra conversion has to be done at the beginning of the chain, just override the main method.
Pre-parsing of tenors at file upload
The function Object TenorParser::parse(Object tenorOrDate);
is intended to convert an input tenor string into a strong typed tenor.