> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Datastore Helper implementation within MR

This page provides implementation details about the usage of the
Datastore Helper
3.4.0-AS6.1
library within Atoti Market Risk, focusing on the wiring between
different datastore definitions and customizations. For documentation of
the library itself, see the [Datastore
Helper Documentation](https://docs.activeviam.com/products/tools/dash/3.4.0-AS6.1/online-help/).

## Implementations of the AConfigurableSchema class

All the MR libraries datastores are provided as
extensions of the `AConfigurableSchema` and `ATenorAwareSchema` classes. These classes are exposed as individual beans or annotated as `@Configuration`,
then collected and applied to the `IDatastoreConfigurator` object in the `DatastoreConfiguratorSetup` class.

The full list of store definitions is as follows:

<table><thead><tr><th>Class</th><th>Datastore contents</th><th>Exposed as</th></tr></thead><tbody><tr><td><code>CubeMarketDataStore</code></td><td>Cube market data.</td><td>A bean in the <code>CubeMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>CurveMarketDataStore</code></td><td>Curve market data.</td><td>A bean in the <code>CurveMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>FxRateMarketDataStore</code></td><td>FX rates.</td><td>A bean in the <code>FxRateMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>SpotMarketDataStore</code></td><td>Spot market data.</td><td>A bean in the <code>SpotMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>SurfaceMarketDataStore</code></td><td>Surface market data.</td><td>A bean in the <code>SurfaceMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>BookHierarchyStoreConfig</code></td><td>A multi-level book hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>BookParentChildStoreConfig</code></td><td>A parent-child book hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CounterpartyHierarchyStoreConfig</code></td><td>A multi-level counterparty hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CounterpartyParentChildStoreConfig</code></td><td>A parent-child counterparty hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CounterpartyStoreConfig</code></td><td>Counterparty information.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CountryStoreConfig</code></td><td>Country information.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>LegalEntityHierarchyStoreConfig</code></td><td>A multi-level legal entity hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>LegalEntityParentChildStoreConfig</code></td><td>A parent-child legal entity hierarchy.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>MarketShiftStoreConfig</code></td><td>Market shifts.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>RiskFactorsCatalogueStoreConfig</code></td><td>Risk factors information.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>ScenariosStoreConfig</code></td><td>Scenarios per set.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeAttributesStoreConfig</code></td><td>Trade attributes.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CounterpartyToCountryReferenceConfig</code></td><td>References between the Counterparty and Country stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeAttributesToBookHierarchyReferenceConfig</code></td><td>References between the Trade Attributes and Book Hierarchy stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeAttributesToCounterpartyHierarchyReferenceConfig</code></td><td>References between the Trade Attributes and Counterparty Hierarchy stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeAttributesToCounterpartyReferenceConfig</code></td><td>References between the Trade Attributes and Counterparty stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeAttributesToLegalEntityHierarchyReferenceConfig</code></td><td>References between the Trade Attributes and Legal Entity Hierarchy stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>PnLStoreConfig</code></td><td>Standard PnL store.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>PnLAggregatedStoreConfig</code></td><td>Denormalized store for PnL aggregated imports.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>CorrelationMarketDataStore</code></td><td>Correlation market data.</td><td>A bean in the <code>CorrelationMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>DividendMarketDataStore</code></td><td>Dividend market data.</td><td>A bean in the <code>CorrelationMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>DynamicTenorsStoreConfig</code></td><td>Dynamic tenors for rebucketing.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>SensiLaddersStoreConfig</code></td><td>Sensitivity ladders.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>SplitRatioMarketDataStore</code></td><td>Split ratios for equity instruments.</td><td>A bean in the <code>CorporateActionMarketDataRetrievalConfig</code> class.</td></tr><tr><td><code>TradeSensitivitiesStoreConfig</code></td><td>Standard sensitivity data.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>SensiAggregatedStoreConfig</code></td><td>Denormalized store for sensitivity aggregated imports.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>SensiFlatStoreConfig</code></td><td>Denormalized store for sensitivity store-level imports.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeSensitivitiesToRiskFactorsCatalogueReferenceConfig</code></td><td>References between the Trade Sensitivities and Risk Factors Catalogue stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>TradeSensitivitiesToTradeAttributesReferenceConfig</code></td><td>References between the Trade Sensitivities and Trade Attributes stores.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>VaRStoreConfig</code></td><td>Standard VaR data.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>VaRAggregatedStoreConfig</code></td><td>Denormalized store for VaR aggregated imports.</td><td><code>@Configuration</code> class wired directly.</td></tr><tr><td><code>VaRFlatStoreConfig</code></td><td>Denormalized store for VaR store-level imports.</td><td><code>@Configuration</code> class wired directly.</td></tr></tbody></table>

Several additional classes are provided to allow groups of stores and references to be imported together:

<table><thead><tr><th>Class</th><th>Details</th><th>Imported classes</th></tr></thead><tbody><tr><td><code>AllCommonStoresConfig</code></td><td>Stores used in multiple cubes.</td><td><code>MarketShiftStoreConfig</code>.</td></tr><tr><td><code>AllStandardStoresConfig</code></td><td>Stores used regardless of cube.</td><td><code>BookHierarchyStoreConfig</code>, <code>BookParentChildStoreConfig</code>, <code>CounterpartyHierarchyStoreConfig</code>, <code>CounterpartyParentChildStoreConfig</code>, <code>CounterpartyStoreConfig</code>, <code>LegalEntityHierarchyStoreConfig</code>, <code>LegalEntityParentChildStoreConfig</code>, <code>MarketDataSetStoreConfig</code>, <code>RiskFactorsCatalogueStoreConfig</code>, <code>ScenariosStoreConfig</code>, <code>TradeAttributesStoreConfig</code>.</td></tr><tr><td><code>AllStandardReferencesConfig</code></td><td>References used regardless of cube.</td><td><code>CounterpartyToCountryReferenceConfig</code>, <code>TradeAttributesToBookHierarchyReferenceConfig</code>, <code>TradeAttributesToCounterpartyReferenceConfig</code>, <code>TradeAttributesToCounterpartyHierarchyReferenceConfig</code>, <code>TradeAttributesToLegalEntityHierarchyReferenceConfig</code>.</td></tr><tr><td><code>AllSensiStoresConfig</code></td><td>Stores used for the sensitivity cube.</td><td><code>DynamicTenorsStoreConfig</code>, <code>SensiLaddersStoreConfig</code>, <code>TradeSensitivitiesStoreConfig</code>.</td></tr><tr><td><code>AllSensiReferencesConfig</code></td><td>References used for the sensitivity cube.</td><td><code>TradeSensitivitiesToRiskFactorsCatalogueReferenceConfig</code>, <code>TradeSensitivitiesToTradeAttributesReferenceConfig</code>.</td></tr></tbody></table>

## The DatastoreConfiguratorSetup class

All Spring beans are collected in the DatastoreConfiguratorSetup class. The`@Configuration` classes are expected to be made
conditional on application properties and thus result in the correct set of datastores for each run mode.

Customizations should be created as `DatastoreConfiguratorConsumer` beans, which are then collected by the class constructor:

```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
        public DatastoreConfiguratorSetup(
            List<IConfigurableSchema> schemas,
            @Autowired(required = false) List<DatastoreConfiguratorConsumer> customisations) {
        this.schemas = schemas;
        this.customisations = customisations;
    }
```

## Customizations classes

Atoti Market Risk contains two customization classes that
instantiate `DatastoreConfiguratorConsumer` beans.

<table><thead><tr><th>Class</th><th>Usage</th></tr></thead><tbody><tr><td>DatastoreCustomisations</td><td>Empty class intended to provide a place to define simple customizations.</td></tr><tr><td>ProductControlDatastoreCustomisations</td><td>Operates on the PnL base store. Makes the <code>Type</code> field a key field and adds <code>Monthly</code>, <code>Yearly</code> and <code>Lifetime</code> value fields.</td></tr></tbody></table>
