Skip to main content

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) - key
  • MarketDataSet (String) - key
  • InstrumentId (String) - key
  • ExecutionDate (LocalDate) - key
  • Quote (Double)
We also need to import the configuration class that we have just created in our application config class for example, 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 IDirectQueryCachingPostProcessor interface to use the cache.
Create the retrieval interface to be called in the post-processor which we will create later:
Implement the retrieval interface in a class that extends SingleTableMarketDataRetriever:
Create the injection configuration class which will inject the IMarketDataRetrievalContainerService into our post-processor:
Create the retrieval configuration class:
We now want to include the retrieval configuration we created in the ApplicationConfig class:
Create the postprocessor that will use the retriever we have configured. Use the abstract 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 and MarketDataMeasureBuilderHelper 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 AsOfDate and MarketDataSet fields).
  • Specify the capacity of the cache (we will set it to 6 partitions here as an example).
The postprocessor we created in the worked example extends 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.
We also need to import the configuration class that we have just created in the ApplicationConfig class:

Populating the database table

Here we take the example of a Databricks database in which we want to create our custom table and populate some sample data in it. We use the following SQL script:
The way you populate your database may be specific to your project, so the actions you need to take to create and populate the custom table in the database may vary compared to this example.