Preview market data interpolation APIs

The preview market data API provides an interpolation API separated from the market data retrieval. The API is mostly contained in the mr-common-lib module, with Spring configuration classes available in the mr-common-config module.

Supported interpolation types

This API supports linear and spline interpolation, with the InterpolationMode enum in the com.activeviam.mr.common.services.marketdata.interpolation.intf package providing valid options.

Value Details
InterpolationMode.NO No interpolation is necessary. Provided for potential implementations with specific handling for non-interpolated market data.
InterpolationMode.LINEAR Linear interpolation is required for missing data points.
InterpolationMode.SPLINE Spline interpolation is required for missing data points.

Handling market data

The interpolation API does not handle data retrieval directly, and expects the known data points to be expressed as doubles. To correctly retrieve and convert market data, market data handlers are provided in the com.activeviam.mr.common.services.marketdata.interpolation.intf and com.activeviam.mr.common.services.marketdata.interpolation.impl packages.

Class Type Details
ICurveMarketDataHandler Interface Interface for retrieving CurveMarketData and converting tenors into doubles.
ISurfaceMarketDataHandler Interface Interface for retrieving SurfaceMarketData and converting tenor and moneyness values into doubles.
ICubeMarketDataHandler Interface Interface for retrieving CubeMarketData and converting tenor, moneyness and maturity values into doubles.
TenorLabelCurveMarketDataHandler Implementation Implementation of ICurveMarketDataHandler for tenors expressed as String objects.
TenorLabelMoneynessSurfaceMarketDataHandler Implementation Implementation of ISurfaceMarketDataHandler for tenor and moneyness values expressed as String objects.
TenorAndMaturityLabelMoneynessCubeMarketDataHandler Implementation Implementation of ICubeMarketDataHandler for tenor, moneyness, and maturity values expressed as String objects.

Interpolators

Interpolators are objects that will provide an interpolated point when provided with correctly configured known data points and the required indices. All interpolators must implement the IInterpolator interface.

Method Return type Details
getMode() InterpolationMode The type of interpolation performed by the interpolator object.
getAxis() int The number of axes of the known data points and the interpolation indices.
from(double[] values, double[]... indices) IInterpolator Sets up the interpolator with known data points. The implementation has to check that the number of index arrays matches the result of getAxis().
value(double... indices) double Returns the interpolated value given the indices. A helper default validateIndices(double... indices) method is provided in the interface to check the validity of the requested indices against the supported axes.

Alongside the base interface, specific interfaces are provided for the most commonly used number of axes, in the package com.activeviam.mr.common.services.marketdata.interpolation.interpolators.intf package.

Interface Details
IUnivariateInterpolator Returns 1 on getAxis().
IBicubicInterpolator Returns 2 on getAxis().
ITricubicInterpolator Returns 3 on getAxis().

The interpolators provided in Atoti Market Risk use the Apache Commons Math library. As the Apache library expects unflattened matrices, conversion and sorting is handled through data classes in the com.activeviam.mr.common.services.marketdata.interpolation.interpolators.commonsmath.data package:

Class Input Details
CurveInterpolationData Tenors and values Sorts the tenors as double[] and stores the associated values as double[].
SurfaceInterpolationData Tenors, moneyness, and values Sorts the tenors and moneyness as double[], and stores the associated values as double[][].
CubeInterpolationData Tenors, moneyness, maturities, and values Sorts the tenors, moneyness and maturities as double[], and stores the associated values as double[][][].

Several interpolators are provided in the com.activeviam.mr.common.services.marketdata.interpolation.interpolators.commonsmath.impl package. We do not provide a three-axis interpolator for SPLINE interpolation, as the Commons Math implementation is deprecated and considered invalid.

Interpolator Interpolation type Interface Details
LinearUnivariateInterpolator LINEAR IUnivariateInterpolator Extends the Commons Math LinearInterpolator.
SplineUnivariateInterpolator SPLINE IUnivariateInterpolator Extends the Commons Math SplineInterpolator.
LinearBicubicInterpolator LINEAR IBicubicInterpolator Extends the Commons Math BicubicIntepolator.
SplineBicubicInterpolator SPLINE IBicubicInterpolator Extends the Commons Math PiecewiseBicubicSplineInterpolator.
LinearTricubicInterpolator LINEAR ITricubicInterpolator Extends the Commons Math TricubicInterpolator.

Interpolation service

The interpolation service collects the interpolators and allows the retrieval of the correct interpolator for the given mode, values, and number of index axes. The retrieved interpolator is set up with the correct known data points - the from() method does not need to be called again, but can be used to set up the interpolator for a different set of points.

The service is found in the com.activeviam.mr.common.services.marketdata.interpolation.intf and com.activeviam.mr.common.services.marketdata.interpolation.impl packages.

Class Details
IInterpolationService Provides a single getInterpolator(InterpolationMode mode, double[] values, double[]... indices) method returning an IInterpolator.
InterpolationService Implementation of IInterpolationService that stores a set of interpolators and returns the correct interpolator for the given mode, values, and number of index axes.

Spring configuration classes

Several Spring configuration classes are provided in the com.activeviam.mr.common.services.marketdata.interpolation package of the mr-common-config module, providing an interpolation service and interpolator implementations as Spring beans.

Class Details
LinearUnivariateInterpolatorConfig Publishes a LinearUnivariateInterpolator as an IInterpolator bean.
SplineUnivariateInterpolatorConfig Publishes a SplineUnivariateInterpolator as an IInterpolator bean.
LinearBicubicInterpolatorConfig Publishes a LinearBicubicInterpolator as an IInterpolator bean.
SplineBicubicInterpolatorConfig Publishes a SplineBicubicInterpolator as an IInterpolator bean.
LinearTricubicInterpolatorConfig Publishes a LinearTricubicInterpolator as an IInterpolator bean.
AllInterpolatorsConfig Imports all other *InterpolatorConfig classes.
InterpolationServiceConfig Collects all IInterpolator beans and publishes an InterpolationService instance as an IInterpolationService bean.