Custom side store and custom post-processor
This is a worked example showing how to extend Atoti Market Data with a custom market data type - Dividends. It shows how to define the new store, how to retrieve data from the store, and how to configure new measures. Finally we show you how use this new market data type in a DirectQuery application.Step 1: Define the Custom Store
The custom store will contain the fields:AsOfDate(LocalDate) - keyMarketDataSet(String) - keyInstrumentId(String) - keyExecutionDate(LocalDate) - keyQuote(Double)
ApplicationConfig:
Step 2: Retrieval Configuration & Post-Processor
In order to retrieve the data from the custom side store, we need to:- Create a retriever class and the associated configuration class.
- Create a post-processor injection configuration so that the retriever can be used in our post-processor.
- Implement the
IDirectQueryCachingPostProcessorinterface to use the cache.
SingleTableMarketDataRetriever:
IMarketDataRetrievalContainerService into our post-processor:
ApplicationConfig class:
ADirectQueryCachingMarketDataPostProcessor which conforms to design patterns laid out by Atoti Market Data. Note that this will provide built-in support for DirectQuery caching.
In this example, we extend SingleMarketDataPostProcessor (which itself extends ADirectQueryCachingMarketDataPostProcessor).
In addition, we have an internal class which extends ADefaultContextualMarketDataRetriever. Market data retrieval implementations
Step 3: the Measure configuration
Using Copper andMarketDataMeasureBuilderHelper create the measure in your measure configuration.
Read more about MarketDataMeasureBuilderHelper
Usage in a DirectQuery application
Defining a DQ cache
In a DirectQuery application, defining a cache will allow us to retrieve the data efficiently. In order to define the cache, we need to:- Specify the side store for which the caching is used (it will be the custom store we defined in our worked example).
- Specify the partitioning fields (here we will use the
AsOfDateandMarketDataSetfields). - Specify the capacity of the cache (we will set it to 6 partitions here as an example).
ADirectQueryCachingMarketDataPostProcessor which implements IDirectQueryCachingPostProcessor,
which means that it will automatically work with our configured cache.
We will create the cache description as a @Configuration class in the package com.activeviam.application.workedexample.dqcache:
Note: The cache size is being set to 6 just as an example, in a real project the size will depend on the specific needs of the project.
ApplicationConfig class: