Data retrieval

The Atoti Market Data Library can retrieve the following:

  • 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.lib.retrievers.intf and com.activeviam.marketdata.lib.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>
ISpotMarketDataRetriever Interface for a market data retriever for spot data, extending IDefaultMarketDataRetriever. getMarketData(LocalDate asOfDate, String marketDataSet, String instrumentId)
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)
IFxMarketDataRetriever Interface for a market data retriever for FX rates, extending IDefaultMarketDataRetriever. Provides a way to retrieve all currencies loaded into the FX rate market data store. getAvailableCurrencies()
IContextualMarketDataRetriever<C, V> Interface for a market data retriever for single market data values 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 Interface for a market data retriever for single market data Double values 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 com.activeviam.marketdata.lib.retrievers.impl and com.activeviam.marketdata.lib.retrievers.contextual.impl packages. All retrievers provide Lombok builders.

Class Description Details
SingleTableMarketDataRetriever Implements IDefaultMarketDataRetriever. Returns a single market data Double value.
SpotTableMarketDataRetriever Extends SingleTableMarketDataRetriever, implements ISpotMarketDataRetriever. Returns spot market data.
FxRateTableMarketDataRetriever Extends SingleTableMarketDataRetriever, implements IFxRateMarketDataRetriever. Returns FX rates and available currencies.
CurveTableMarketDataRetriever Extends SingleTableMarketDataRetriever, implements ICurveMarketDataRetriever. Returns single market dates values from a curve, or whole curves.
SurfaceTableMarketDataRetriever Extends SingleTableMarketDataRetriever, implements ISurfaceMarketDataRetriever. Returns single market dates values from a surface, or whole surfaces.
CubeTableMarketDataRetriever Extends SingleTableMarketDataRetriever, implements ICubeMarketDataRetriever. Returns single market dates values from a cube, or whole cubes.
AContextualMarketDataRetriever<C, V> Implements IContextualMarketDataRetriever<C, V>. Returns market data with caching, after translating the requested coordinates using a coordinates translator. Provides abstract methods for creating a cache key, executing the retrieval, and generating market data when it cannot be retrieved, to be overridden by any extension.
ADefaultContextualMarketDataRetriever Extends AContextualMarketDataRetriever<List<Object>, Double>, implements IDefaultContextualMarketDataRetriever. Creates a cache key based on the translated coordinates and the retriever name.
SingleContextualMarketDataRetriever<T extends IDefaultMarketDataRetriever> Extends ADefaultContextualMarketDataRetriever. Returns market data values using the underlying table retriever.
FxContextualMarketDataRetriever Extends SingleContextualMarketDataRetriever<IFxMarketDataRetriever>. Returns FX rates with support for inverse rates and pivot currencies. Allows for the retrieval of all available currencies in the table.
InterpolatingCurveContextualMarketDataRetriever Extends SingleContextualMarketDataRetriever<ICurveMarketDataRetriever<String>>. Returns single market data values from a curve, interpolating values from the whole curve when necessary.
InterpolatingSurfaceContextualMarketDataRetriever Extends SingleContextualMarketDataRetriever<ISurfaceMarketDataRetriever<String, String>>. Returns single market data values from a surface, interpolating values from the whole surface when necessary.
InterpolatingCubeContextualMarketDataRetriever Extends SingleContextualMarketDataRetriever<ICubeMarketDataRetriever<String, String, String>>. Returns single market data values from a cube, interpolating values from the whole cube when necessary.

Market data retrieval containers

All contextual market data retrievers are built using a name, table retriever, and coordinate translator. To facilitate their instantiation, we provide containers for the components and a service for their collection.

Class Description
IMarketDataRetrievalContainer<T> An interface for a container for a retriever of type T, with an associated IMarketDataCoordinateTranslator<List<Object>> and a name.
MarketDataRetrievalContainer<T> An implementation of IMarketDataRetrievalContainer<T> as a record.
IMarketDataRetrievalContainerService<T> An interface for a service allowing the selection of IMarketDataRetrievalContainer<T> by name.
MarketDataRetrievalContainerService<T> An implementation of IMarketDataRetrievalContainerService<T> collecting IMarketDataRetrievalContainer<T> objects.
MarketDataRetrievalContainerServiceConfig Spring @Configuration class publishing a MarketDataRetrievalContainerService<T> as an IMarketDataRetrievalContainerService<T> bean.

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 leverage the containers to instantiate retrievers that can be configured further.

Class Description
IContextualMarketDataRetrieverFactory<R> An interface with a method for creating an instance of a retriever (or a partial builder).
SingleMarketDataRetrieverFactory Returns a builder for a SingleMarketDataRetriever.
FxMarketDataRetrieverFactory Returns a builder for an FxMarketDataRetriever.
AInterpolatingContextualMarketDataRetrieverFactory<T, R> Implementation of IContextualMarketDataRetrieverFactory<R> for retrievers that require an ICachingInterpolationService.
CurveMarketDataRetrieverFactory Returns a builder for an InterpolatingCurveMarketDataRetriever.
SurfaceMarketDataRetrieverFactory Returns a builder for an InterpolatingSurfaceMarketDataRetriever.
CubeMarketDataRetrieverFactory Returns a builder for an InterpolatingCubeMarketDataRetriever.
CoordinateMapper<C> Alias for a function converts a coordinate from a given type to a double.
MapperFactory<C, K> Alias for a function that takes the coordinates for market data retrieval and returns a CoordinateMapper<C> 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.lib.dates.impl is an enum with the following values:

Value Details
CURRENT_DAY Retrieves the current day with regard to a base date.
NEXT_DAY Retrieves the next day with regard to a base date.
PREVIOUS_DAY Retrieves 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.lib.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.lib.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 for translating market data coordinates used to retrieve market data is defined in the package com.activeviam.marketdata.lib.translators.intf. This interface modifies the coordinates based on a given MarketDataRetrieverContext (see Retrieval context).

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.lib.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 a @Bean extending AMarketDataStore<T>, 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 CubeTableMarketDataRetriever as an ICubeMarketDataRetriever<String, String, String>)
  • A container wrapping the retriever and translator, with a name.
  • A retriever factory of the appropriate type (e.g. a CubeMarketDataRetrieverFactory using the CubeTableMarketDataRetriever, specifying a container and interpolation service to use for instantiating a contextual retriever)

In cases where the components held in a container are sufficient for instantiating a contextual retriever, the IMarketDataRetrievalContainerService should be used (e.g. for retrieving a point on a curve without interpolation, the SingleMarketDataPostProcessor can be instantiated with the CURVE_MARKET_DATA_RETRIEVER property). Most custom implementations of contextual retrievers are expected to use the container service rather than define specific factories.

The factories can be wired up by type, in post-processors where the full functionality is required (e.g. CubeMarketDataPostProcessor uses a CubeMarketDataRetrieverFactory to create retrievers that handle cube interpolation).

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 MapperFactory object for tenors
  • A MapperFactory object for moneynesses
  • A MapperFactory object for maturities
  • The required interpolation mode

Several Spring configuration classes are provided in the com.activeviam.marketdata.autoconfigure.retrievers package of the market-data-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.
MarketDataRetrievalContainerServiceConfig Publishes an IMarketDataRetrievalContainerService<T> collecting all implementations of IMarketDataRetrievalContainer<T> published by the individual configuration classes.
AllMarketDataRetrievalConfig Collects all configuration classes in a single class.