Interpolation APIs
The Atoti Market Data Library provides an interpolation API separated from the market data retrieval. The API is mostly contained in the market-data-lib
module, with Spring configuration classes available in the market-data-spring-boot-starter
module.
Supported interpolation types
This API supports linear, linear with volatility-to-variance transformations for surfaces, cubic and spline interpolation, with the InterpolationMode
class in the com.activeviam.marketdata.lib.interpolation.services.intf
package providing valid options.
Value | Details |
---|---|
InterpolationMode.LINEAR |
Linear interpolation is required for missing data points. |
InterpolationMode.VOL_TO_VARIANCE |
Linear interpolation with volatility-to-variance/variance-to-volatility pre- and post-interpolation transformations is required for missing data points. |
InterpolationMode.CUBIC |
Cubic interpolation is required for missing data points. |
InterpolationMode.SPLINE |
Spline interpolation is required for missing data points. |
Handling market data
The interpolation API expects the known data points to be expressed as an array of doubles with corresponding double arrays of coordinates (tenors/moneyness). The retrieval interfaces packaged with the market data API allow you to retrieve curves or surfaces as values and associated coordinates.
Market data values are always expressed as doubles, whereas coordinates will likely be expressed as other data types, based on the structure of the underlying market data store. The ICurveMarketData
, and ISurfaceMarketData
interfaces allow you to extract coordinates as doubles by providing a mapping function.
Interpolator Interfaces
Interpolators are objects that return an interpolated point when provided with correctly configured known data points and the required coordinates. All interpolators must implement the IInterpolator
interface:
Method | Return type | Details |
---|---|---|
value(double... coordinates) |
double |
Returns the interpolated value given the coordinates. A helper default validateCoordinates(double... coordinates) method is provided on the IInterpolatorSettings interface (see below) to check the validity of the requested coordinates against the supported axes. |
Each interpolator is constructed with a factory that formats the input data correctly for that specific interpolator. These factories implement the IInterpolatorFactory
interface:
Method | Return type | Details |
---|---|---|
from(double[] values, double[]... coordinates) |
IInterpolator |
Sets up the interpolator with known data points. The implementation has to check that the number of coordinate arrays matches the result of getAxis() . |
Both IInterpolator
and IInterpolatorFactory
interfaces extend the IInterpolatorSettings
interface, which contains methods that describe the type of interpolation handled by that interpolator.
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. |
You can also find a number of convenient interfaces, which extend the IInterpolationSettings
interface and provide common settings as default methods.
Interface | Details |
---|---|
IUnivariate |
Returns 1 on getAxis() . |
IBivariate |
Returns 2 on getAxis() . |
ILinear |
Returns InterpolationMode.LINEAR on getMode() . |
IVolToVariance |
Returns InterpolationMode.VOL_TO_VARIANCE on getMode() . |
ICubic |
Returns InterpolationMode.CUBIC on getMode() . |
ISpline |
Returns InterpolationMode.SPLINE on getMode() . |
ILinearUnivariateInterpolatorFactory |
Extends IInterpolatorFactory , ILinear , and IUnivariate . |
IBilinearInterpolatorFactory |
Extends IInterpolatorFactory , ILinear , and IBivariate . |
IVolToVarianceBilinearInterpolatorFactory |
Extends IInterpolatorFactory , IVolToVariance , and IBivariate . |
IBicubicInterpolatorFactory |
Extends IInterpolatorFactory , ICubic , and IBivariate . |
ISplineUnivariateInterpolatorFactory |
Extends IInterpolatorFactory , ISpline , and IUnivariate . |
ISplineBicubicInterpolatorFactory |
Extends IInterpolatorFactory , ISpline , and IBivariate . |
Interpolation transformation
For some use cases, both the input data for an interpolator and the result of the interpolation need to be transformed. To simplify the creation and configuration of transformations, we provide the following classes:
Class | Details |
---|---|
IInterpolationTransformation<T, U> |
An interface for an object that transforms a market data quote based on a coordinate. |
VolatilityToVarianceTransformation |
Applies the volatility-to-variance formula to a tenor and a market data quote. |
VarianceToVolatilityTransformation |
Applies the variance-to-volatility formula to a tenor and a market data quote. |
Interpolator Implementations
The majority of interpolators provided in Atoti Market Data 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.marketdata.lib.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[][] . |
Several interpolators are provided in the com.activeviam.marketdata.lib.interpolation.interpolators.commonsmath.impl
package.
Interpolator | Interpolation type | Axes | Interface | Details |
---|---|---|---|---|
BicubicInterpolator |
CUBIC |
2 | IInterpolator , ICubic , IBivariate |
Extends the Commons Math BicubicIntepolator . |
SplineUnivariateInterpolator |
SPLINE |
1 | IInterpolator , ISpline , IUnivariate |
Extends the Commons Math SplineInterpolator . |
SplineBicubicInterpolator |
SPLINE |
2 | IInterpolator , ISpline , IBivariate |
Extends the Commons Math PiecewiseBicubicSplineInterpolator . |
Further, custom interpolators let you carry out linear interpolation on any number of axes. You can find them in the com.activeviam.marketdata.lib.interpolation.interpolators.impl
package.
Interpolator | Interpolation type | Axes | Interface | Details |
---|---|---|---|---|
LinearInterpolator |
LINEAR |
any | IInterpolator , ILinear |
Custom implementation of a linear interpolator. |
PostTransformationLinearInterpolator |
Any type configured to provide a post-transformation linear interpolator. | any | IInterpolator , ILinear |
Custom implementation of a linear interpolator, which allows the definition of post-interpolation transformations on any axis. |
Interpolator factories
The following interpolator factory classes are available.
Implementations of IInterpolatorFactory
are available in the same package and these construct interpolators that work along one, two, or three axes, as follows:
InterpolatorFactory | Interpolation type | Axes | Interface | Details |
---|---|---|---|---|
LinearUnivariateInterpolatorFactory |
LINEAR |
1 | ILinearUnivariateInterpolatorFactory (IInterpolatorFactory , ILinear , IUnivariate ) |
Constructs linear interpolators that operate on a single axis. |
BilinearInterpolatorFactory |
LINEAR |
2 | IBilinearInterpolatorFactory (IInterpolatorFactory , ILinear , IBivariate ) |
Constructs linear interpolators that operate on two axes. |
VolToVarianceBilinearInterpolatorFactory |
VOL_TO_VARIANCE |
2 | IVolToVarianceBilinearInterpolatorFactory (IInterpolatorFactory , IVolToVariance , IBivariate ) |
Applies the volatility-to-variance pre-interpolation transformation to surface market data and constructs interpolators that apply the variance-to-volatility post-interpolation transformation on the tenor axis. |
BicubicInterpolatorFactory |
CUBIC |
1 | IBicubicInterpolatorFactory (IInterpolatorFactory , ICubic , IUnivariate ) |
Constructs cubic interpolators that operate on a single axis. |
SplineBicubicInterpolatorFactory |
SPLINE |
2 | ISplineBicubicInterpolatorFactory (IInterpolatorFactory , ISpline , IBivariate ) |
Constructs spline interpolators that operate on two axes. |
Interpolation service
Two interpolation services are available:
- The
IInterpolationService
interface, with correspondingInterpolationService
implementation, collects the interpolator factories and allows the retrieval of an interpolator for the given mode, values, and number of coordinate axes. The retrieved interpolator is constructed with the correct known data points. - The
ICachingInterpolationService
interface, with correspondingCachingInterpolationService
implementation, is constructed with an underlyingIInterpolationService
which it uses to retrieve interpolators, caching those interpolators within aConcurrentMap<Object, Object>
cache for faster retrieval.
The interfaces can be found in the com.activeviam.marketdata.lib.interpolation.services.intf
package with the implementations in the com.activeviam.marketdata.lib.interpolation.services.impl
package.
Class | Details |
---|---|
IInterpolationService |
Provides a single getInterpolator(InterpolationMode mode, double[] values, double[]... coordinates) 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 coordinate axes. |
ICachingInterpolationService |
Provides a single getInterpolator(ConcurrentMap<Object, Object> cache, CompositeKey cacheKey, InterpolationMode mode, double[] values, double[]... coordinates) method returning an IInterpolator . |
CachingInterpolationService |
Implementation of ICachingInterpolationService caches interpolator instances for fast retrieval. |
Spring configuration classes
Several Spring configuration classes are provided in the com.activeviam.marketdata.autoconfigure.interpolation
package of the market-data-spring-boot-starter
module, providing interpolation services and interpolator factory Spring beans. When you add the starter as a dependency in your project, the AllInterpolatorsConfig
class will be autoconfigured.
Class | Details |
---|---|
AllMarketDataInterpolationConfig |
Imports all other *InterpolatorConfig classes. |
InterpolationServiceConfig |
Collects all IInterpolatorFactory beans and publishes an IInterpolationService bean that can be overridden by creating a custom bean of the same type. A further ICachingInterpolationService bean is also provided. |
LinearUnivariateInterpolatorConfig |
Publishes a LinearUnivariateInterpolatorFactory as an ILinearUnivariateInterpolatorFactory bean that can be overridden by creating a custom bean of the same type. |
BilinearInterpolatorConfig |
Publishes a BilinearInterpolatorFactory as an IBilinearInterpolatorFactory bean that can be overridden by creating a custom bean of the same type. |
VolToVarianceBilinearInterpolatorConfig |
Publishes a VolToVarianceBilinearInterpolatorFactory as an IVolToVarianceBilinearInterpolatorFactory bean that can be overridden by creating a custom bean of the same type. |
BicubicInterpolatorConfig |
Publishes a BicubicInterpolatorFactory as an IBicubicInterpolatorFactoryFactory bean that can be overridden by creating a custom bean of the same type. |
SplineUnivariateInterpolatorConfig |
Publishes a SplineUnivariateInterpolatorFactory as an ISplineUnivariateInterpolatorFactory bean that can be overridden by creating a custom bean of the same type. |
SplineBicubicInterpolatorConfig |
Publishes a SplineBicubicInterpolatorFactory as an ISplineBicubicInterpolatorFactory bean that can be overridden by creating a custom bean of the same type. |