Market data retrieval in the market data API data model

The market data API allows the retrieval of either:

  • a single market data corresponding to a key defining the market data
  • all the market data corresponding to a curve, a surface, or a cube

Market data retrieval interfaces

Interfaces for market data retrieval are defined in the packages com.activeviam.marketdata.api.retrievers.intf and com.activeviam.marketdata.api.retrievers.contextual.intf.

Interface Description Methods
IMarketDataRetriever<C, V> Interface for a market data retriever that retrieves a single market data value based on the coordinates passed in. getMarketData(coordinates)
IDefaultMarketDataRetriever Interface for a market data retriever that retrieves a single market data Double value based on the coordinates passed in as a List<Object>. None, aliasing IMarketDataRetriever<List<Object>, Double>
ICurveMarketDataRetriever Interface for a market data retriever for curve (1-axis) market data, extending IDefaultMarketDataRetriever. getCurve(asOfDate, marketDataSet, curveId)
ISurfaceMarketDataRetriever Interface for a market data retriever for surface (2-axis) market data, extending IDefaultMarketDataRetriever. getSurface(asOfDate, marketDataSet, surfaceId)
ICubeMarketDataRetriever Interface for a market data retriever for cube (3-axis) market data, extending IDefaultMarketDataRetriever. getCube(asOfDate, marketDataSet, cubeId)
IFxRateMarketDataRetriever Interface for a market data retriever that retrieves FX rates, extending IDefaultMarketDataRetriever. Provides a way to retrieve all the currencies loaded into the FX rate market data store. getAvailableCurrencies()
IContextualMarketDataRetriever Interface for a market data retriever that retrieves a single market data value based on the coordinates passed in. The retrieval may be modified by a provided MarketDataRetrieverContext, and a name can be associated with the retriever. getName(), getMarketData(coordinates, context)
IDefaultContextualMarketDataRetriever<C, V> Interface for a market data retriever that retrieves a single market data Double value based on the coordinates passed in as a List<Object>. The retrieval may be modified by a provided MarketDataRetrieverContext, and a name can be associated with the retriever. None, aliasing IContextualMarketDataRetriever<List<Object>, Double>

Market data retrieval implementations

Implementations for market data retrieval are defined in the package com.activeviam.marketdata.api.retrievers.impl. All retrievers provide Lombok builders.

Class Description Details
TableSingleMarketDataRetriever Implements IDefaultMarketDataRetriever. Returns a single market data Double value.
TableFxRateMarketDataRetriever Extends TableSingleMarketDataRetriever, implements IFxRateMarketDataRetriever. Returns FX rates and available currencies.
TableCurveMarketDataRetriever Extends TableSingleMarketDataRetriever, implements ICurveMarketDataRetriever. Returns single market dates values from a curve, or whole curves.
TableSurfaceMarketDataRetriever Extends TableSingleMarketDataRetriever, implements ISurfaceMarketDataRetriever. Returns single market dates values from a surface, or whole surfaces.
TableCubeMarketDataRetriever Extends TableSingleMarketDataRetriever, implements ICubeMarketDataRetriever. Returns single market dates values from a cube, or whole cubes.
SingleMarketDataRetriever Implements IDefaultContextualMarketDataRetriever. Returns spot market data values after applying a shift to the provided asOfDate. Provides an interpolation method to be overridden by any extension.
FxMarketDataRetriever Extends SingleMarketDataRetriever. Returns FX rates after applying a shift to the provided asOfDate as well as all available currencies.
InterpolatingCurveMarketDataRetriever Extends SingleMarketDataRetriever. Returns single market dates values from a curve, interpolating values from the whole curve when necessary, after applying a shift to the provided asOfDate.
InterpolatingSurfaceMarketDataRetriever Extends SingleMarketDataRetriever. Returns single market dates values from a surface, interpolating values from the whole surface when necessary, after applying a shift to the provided asOfDate.
InterpolatingCubeMarketDataRetriever Extends SingleMarketDataRetriever. Returns single market dates values from a cube, interpolating values from the whole cube when necessary, after applying a shift to the provided asOfDate.

Market data retriever factories

To support creating retrievers with instantiation split between Spring @Configuration classes and the post-processors using the retrievers, we have introduced factories that return partially filled-in retriever builders.

Class Description
IMarketDataRetrieverFactory<R> An interface with methods for creating a generic, named retriever builder.
AMarketDataRetrieverFactory<T, R> An abstract class wrapping a simple retriever (without caching and interpolation) and a coordinate translator.
SingleMarketDataRetrieverFactory Returns a builder for a SingleMarketDataRetriever.
FxMarketDataRetrieverFactory Returns a builder for an FxMarketDataRetriever.
AInterpolatingMarketDataRetrieverFactory<T, R> Extension of AMarketDataRetrieverFactory<T, R> for retrievers that required an IInterpolationService.
CurveMarketDataRetrieverFactory Returns a builder for an InterpolatingCurveMarketDataRetriever.
SurfaceMarketDataRetrieverFactory Returns a builder for an InterpolatingSurfaceMarketDataRetriever.
CubeMarketDataRetrieverFactory Returns a builder for an InterpolatingCubeMarketDataRetriever.
IMarketDataRetrieverFactoryService<R> A service for getting retriever factories, used by the SingleMarketDataPostProcessor to create the correct retriever through a property.
MarketDataRetrieverFactoryService<R> Implementation of IMarketDataRetrieverFactoryService<R> that collects IMarketDataRetrieverFactory objects and allows selection by name.
IMarketDataRetrieverFactoryServiceAware<R> Interface for allowing the injection of an IMarketDataRetrieverFactoryService<R> into a post-processor.
MarketDataRetrieverFactoryServiceConfig @Configuration class for exposing an IMarketDataRetrieverFactoryServive<IDefaultContextualMarketDataRetriever> as a @Bean.
CoordinatesToMapper<C, K> Alias for a function that takes the coordinates for market data retrieval and returns a mapper for a specific coordinate. Useful in cases where the mapping for a specific coordinate requires information from a different coordinate (e.g. converting a tenor for interpolation requires the as-of date).

MarketDataDateShift

The MarketDataDateShift defined in the package com.activeviam.marketdata.api.dates.impl is an enum with the following values:

Value Details
CURRENT_DAY Used to retrieve the current day with regard to a base date.
NEXT_DAY Used to retrieve the next day with regard to a base date.
PREVIOUS_DAY Used to retrieve the previous day with regard to a base date.

Retrieval context

The market data retrieval context is defined in the class MarketDataRetrieverContext in the package com.activeviam.marketdata.api.retrievers.intf. It is used to define:

  • the name of the retrieval
  • the query cache that is used
  • the MarketDataDateShift (see above).

Date retrieval interfaces

Interfaces for date retrieval are defined in the package com.activeviam.marketdata.api.dates.intf

Interface Description Details
IDateRetriever Interface to retrieve all the asOfDates present in market data inputs. Used for the retrieval of the previous or the next day with regards to a given asOfDate.
IContextualDateRetriever Interface for the retrieval of the current, previous or the next day with regard to a given asOfDate. Takes an asOfDate and a MarketDataRetrieverContext object as inputs.

Date retrieval implementations

Implementations for date retrieval are defined in the package com.activeviam.mr.common.services.marketdata.dates.impl.

Interface Description Details
TableDateRetriever Implementation of IDateRetriever. Returns all the dates present in a given table in an IDatabase object.
DateShiftingDateRetriever Implementation of IContextualDateRetriever. Returns a shifted date (i.e. the current, next or previous date) with an asOfDate and a MarketDataRetrieverContext object as inputs.

Coordinate Translator Interface

The interface used to translate market data coordinates used to retrieve market data (i.e. modify the coordinates based on a given MarketDataRetrieverContext (see above)) is defined in the package com.activeviam.marketdata.api.translators.intf.

The translation is meant to modify the asOfDate passed in the coordinates in order to return a key containing the previous or next day with regard to the original asOfDate.

Interface Description Details
IMarketDataCoordinateTranslator Interface for market data coordinates translators Uses IContextualDateRetriever to translate a key based on a MarketDataRetrieverContext.

Key Translator Implementation

The implementation used to translate a coordinates used to retrieve market data is defined in the package com.activeviam.marketdata.api.translators.impl.

Interface Description Details
DateShiftTranslator Implementation of IMarketDataCoordinateTranslator. Shifts the provided date by using an underlying IContextualDateRetriever.

Spring configuration classes

To configure the retrieval from a market data store, we now create:

  • The store, as an AConfigurableSchema @Bean used by the IDatastoreConfigurator
  • A TableDateRetriever on the configured store
  • A DateShiftingDateRetriever wrapping the TableDateRetriever with caching and date shifting
  • An IMarketDataCoordinateTranslator<List<Object>>, usually an implementation of DateShiftingTranslator, using the DateShiftingDateRetriever, to shift the market data retrieval coordinates to the correct date
  • A retriever of the appropriate type (e.g. a TableCubeMarketDataRetriever as an ICubeMarketDataRetriever<String, String, String>)
  • A retriever factory of the appropriate type (e.g. a CubeMarketDataRetrieverFactory using the TableCubeMarketDataRetriever, specifying a name, coordinate translator and interpolation service to use in the resulting retriever)

The factories can be wired up by type, in post-processors where the full functionality is required (e.g. CubePostProcessor uses a CubeMarketDataRetrieverFactory to create retrievers that handle cube interpolation), or as a collection through an IMarketDataRetrieverFactoryService, allowing generic retrieval by name (e.g. for retrieving a point on a curve without interpolation, the SingleMarketDataPostProcessor can be instantiated with the CURVE_MARKET_DATA_RETRIEVER property).

The post-processor using the factory is responsible for calling the context-specific builder methods to correctly configure the resulting retriever. In the case of the InterpolatingCubeMarketDataRetriever, the post-processor needs to define:

  • A CoordinatesToMapper object for tenors
  • A CoordinatesToMapper object for moneynesses
  • A CoordinatesToMapper object for maturities
  • The required interpolation mode

Several Spring configuration classes are provided in the com.activeviam.marketdata.api.configuration.retrievers package of the market-data-api-spring-boot-starter module, providing Datastore Helper (DASH) stores and retrievers as Spring beans. When you add the starter as a dependency in your project, the CubeMarketDataRetrievalConfig, CurveMarketDataRetrievalConfig, FxRateMarketDataRetrievalConfig, InstrumentMarketDataRetrievalConfig, and SurfaceMarketDataRetrievalConfig classes will be auto-configured.

Class Details
SpotMarketDataStoreConfig Publishes a spot store bean along with associated date retrievers and translators. This also configures an SingleMarketDataRetrieverFactory for a retriever on the spot store.
FxRateMarketDataStoreConfig Publishes an FX rate store bean along with associated date retrievers and translators. This also configures an SingleMarketDataRetrieverFactory for a retriever on the FX store.
CurveMarketDataStoreConfig Publishes a curve store bean along with associated date retrievers and translators. This also configures an CurveMarketDataRetrieverFactory for a retriever on the curve store.
SurfaceMarketDataStoreConfig Publishes a surface store bean along with associated date retrievers and translators. This also configures an SurfaceMarketDataRetrieverFactory for a retriever on the surface store.
CubeMarketDataStoreConfig Publishes a cube store bean along with associated date retrievers and translators. This also configures an CubeMarketDataRetrieverFactory for a retriever on the cube store.
MarketDataRetrieverFactoryServiceConfig Publishes an IMarketDataRetrieverFactoryService collecting all implementations of IMarketDataRetrieverFactory published by the individual configuration classes.
AllMarketDataRetrievalConfig Collects all configuration classes in a single class.