Skip to main content
allows developers to implement their own maturity converters based on the IMaturityConverter interface. This page will walk you through the process of implementing a converter than can be configured in a properties file.

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 a String tenor to a LocalDate object
  • toYearFraction() to return the year fraction between a LocalDate as-of-date and a String maturity
The MaturityConverterConfig class is used to expose (as a bean) the implementation of the interface that is used throughout the project. The default implementation is Actual360MaturityConverter , based on the Actual/360 day count convention. The example implementation below does not use the 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
Then add the week, month and year values to the application.properties file, which is loaded by default into the Spring environment:
To take advantage of the 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:
The 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).
In this example, the conversion of the tenor into a number of days is handled in the static 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.
To use the ConfigurableMaturityConverter, the MaturityConverterConfig class must autowire the environment and initialise the converter, exposing it as a bean: