Market Data Retrieval Service
The market data retrieval service is a Spring Bean intended to provide market data for the market data postprocessors and the PnL explain postprocessors. It also provides market shift vectors for the Taylor VaR computation. It is intended to be customizable.
Spring
The market data retrieval service provides the
com.activeviam.accelerator.common.services.IMarketDataRetrievalService
interface as a Spring Bean. The Bean is instantiated on the
com.activeviam.mr.application.measures.MarketDataRetrievalServiceConfig
Spring configuration file. It has several implementations depending on
the Spring configuration.
Services
- getMarketData: returns a list of market data.
- getPnlVector: returns a list of PnL vectors used for the Taylor VaR.
- getCorporateAction: returns any corporate action related to the market data, such as dividend, coupon, or split.
Multi-dimension handling
The services are able to handle multi-dimension market data. The size of the IPillarSet[] requestedPillars
on the services input parameters provides the number of requested dimensions. The returned array will contain the values for all the requested coordinates.
For instance, for a 3 dimensions request, the values for (x, y, z) will be at the location:
(x * requestedPillars[1].getSize() + y) * requestedPillars[2].getSize() + z
For a scalar setup, the request provides a pillar set of size 1 and then get back a single value.
Customization
Most of the customization should be performed on the
IInterpolationConfiguration
Bean that is injected to the service.
If you need to rely on additional parameters (extra levels for
instance), the property List<Object> ServiceContext.leafCoordinates;
can be used. It is filled by the custom user service Bean
com.activeviam.accelerator.common.services.ICustomParameters
, instantiated in
com.activeviam.mr.application.measures.CustomParametersConfig
.
If the input data need to be retrieved elsewhere or in a different way
than the standard one, you can override or replace
com.activeviam.mr.common.services.impl.MarketDataRetrievalService
or
com.activeviam.mr.common.services.impl.ScalarMarketDataRetrievalService
for the service implementation.
If the non-interpolated way of matching pillars needs to be changed, the
class com.activeviam.accelerator.common.utils.ModifiedPillarSetOfPillar
should
be used to encapsulate the requested pillar set. It overrides the
equality between pillars by a custom lambda function. This has to be
done on the InterpolationConfiguration.fixPillarSet(…)
method.
The default double value for empty slots can be set on the constructor of the service Bean.
Interpolation
We can choose to interpolate or not a dataset on the configuration Bean. We can set the following options:
-
Enable or disable the interpolation.
-
Set the interpolation order.
-
Specify a transformation to apply to a specific axis before the interpolation:
$ y = f(pillar, x) $
and
$ x = f^{-1}(pillar, y) $
have to be provided.
The interpolation logic is embedded on the class:
-
com.activeviam.accelerator.common.services.impl.marketdataretrieval.InterpolationDouble
for double interpolation. -
com.activeviam.accelerator.common.services.impl.marketdataretrieval.InterpolationVector
for IVector interpolation.
Nominal, absolute or relative price
The service can handle absolute or relative price. Take the following example of a bond:
Instrument | Price | Nominal |
---|---|---|
CREDIT AGRICOLE 2% 02/05/27 EUR | 107.44 % | 15000.00 EUR |
We can see that the MtM of the Bond is Price * Nominal / 100 = 16116.00
EUR. For PnL computation we need to use the MtM, absolute price. To
achieve this, the following must be configured in the
InterpolationConfiguration
class:
Method | Expected return for the bond price | Explanation |
---|---|---|
isRelativeMarketData | true | Must return true for risk factor with relative price, so the formula is applied correctly |
relativeToAbsoluteMarketDataOperator | (nominal, md) -> md * nominal / 100 | Transforms relative price to absolute price |
absoluteToRelativeMarketDataOperator | (nominal, md) -> md / nominal * 100 | Transforms absolute price to relative price |
relativeToAbsoluteShiftOperator | (md, shift) -> shift * md / 100 | Transforms the market shift used for VaR from relative to absolute |
absoluteToRelativeShiftOperator | (md, shift) -> shift / md * 100 | Transforms the market shift used for VaR from absolute to relative |
Retrieving the market price
The service and, by extension, the MarketDataPostProcessor can retrieve
the market data as an absolute or relative price. This is done with the
MarketType typeOfMarketData
parameter.
MarketType | How Market Data is expressed |
---|---|
ABSOLUTE | An absolute price in currency. |
RELATIVE | A price relative to the nominal price. |
RAW | An absolute or relative price, depending on the way it is stored. The nominal is not used. |
For PnL explain and VaR, the market data must be expressed in absolute price.
Corporate Action
The corporate action can be stored in the CorporateAction store or via any customization. The Accelerator handles two corporate actions: dividend and split.Use the getCorporateAction function to retrieve these input data.
Split
The market price retrieval service provides an option to integrate
corporate splits into the market price to calculate PnL. This
integration is defined by the function corporateActionOperator in
the InterpolationConfiguration
class.
Method | Expected return for the bond price | Explanation |
---|---|---|
corporateActionOperator | (value, action) -> value * action.getSplitRatio() | Defines how to integrate the corporate action into the market price |
Dividend or coupon
The dividend is not integrated by default into the market price because it can interfere with the PnL calculation. Instead it is handled in a specific metric that assumes PnL = sensitivity * dividend. The formula used is defined in the PnL Explain service.
Shift vector normalization
You can compute the market shift vector with a different sensitivity convention. In this case, the vector should be normalized to fit on the sensitivity stored on the Cube. This is defined by the function normalizationShiftOperator in
the InterpolationConfiguration
class. If no normalization is required, the function MUST return null
.
Method | Expected return | Explanation |
---|---|---|
normalizationShiftOperator | (md, shift) -> normalized shift | Transforms the input shift into a shift fitted for the sensitivity stored in the Sensitivity Cube |