The IMaturityConverter interface and the MaturityConverterConfig class
Any implementation of a maturity converter implements the IMaturityConverter interface. These implementations must be autowirable through Spring, as well as usable as an extended plugin. The interface defines two methods:toDate()to convert aStringtenor to aLocalDateobjecttoYearFraction()to return the year fraction between aLocalDateas-of-date and aStringmaturity
leafCoordinates or
pivot parameters defined in the interface, as currently all conversion
is handled in the ETL.
Implementing a custom configurable converter
Although the default converter is hard-coded to the Actual/360 convention, you can easily implement a converter that uses the Spring environment to define the day counts. The static class constants must cover:- Defaults for the week, month and year day counts
- Keys for the Spring environment properties
- A
Map<String, Integer>to allow repeated retrieval of day values after initialisation
application.properties file,
which is loaded by default into the Spring environment:
LocalDate API, the toYearFraction()
method converts the String maturity into a LocalDate using
the toDate() method, and retrieves the year count directly from the
Map initialised above:
toDate() method has to handle both String representations of
dates, as well as tenors. One of the parameters of the method is a
LocalDateParser, which can be initialised to use any date format (with
the default being yyyy-MM-dd).
daysInTenor method. The example covers the
Tomorrow Next
tenor, and any combination of a number and one of D,W,M,Y in both
uppercase and lowercase. In the FRTB project, tenors expressed as
numbers without a period string are assumed to be fractions of a year.
Any special cases and error handling must be incorporated in this
conversion.
ConfigurableMaturityConverter, the
MaturityConverterConfig class must autowire the environment and
initialise the converter, exposing it as a bean: