Datastore Helper Examples

This page provides a description of the functionality of Datastorehelper. It features multiple example of common use cases for modifications to the Reference Implementation. The techniques employed are generic examples that can be extended, adapted and repeated for any use case that we need. In all cases, we make minimal changes to the Accelerator Reference Implementation.

All of the project customisations will be defined in the loadCustomisations() method in the DatastoreCustomisations class.

The DatastoreHelper class contains helper methods for

Configuration options can be split into the following categories:

  1. D the CustomisableStoreDescriptionBuilder object.
  2. Custom global configuration - defined via the DatastoreHelper.addConfiguration() method, using the ConfigurationConstants.ALL_STORES constant as the store name. These options will apply to all customisable stores across the entire project.
  3. Multi-store custom configuration - defined via the DatastoreHelper.addConfiguration(), with a list of store names passed in. These options will apply to all the stores in the list.
  4. Individual custom configuration - defined via the DatastoreHelper.addConfiguration(), with a single store name.

Most store configuration options will follow a standard order of precedence (custom configuration for the store, custom global configuration, default store configuration), except for:

The order of precedence does not differentiate between configuration options defined as part of multi-store or individual custom configurations. If configuration options are defined multiple times for the same stores, the ordering will be chronological.

Inserting two fields into a TradeStore, after the TradeId field:

Map<String, CustomField> customFields = new HashMap<>();

customFields.put("TradeId", new CustomField("TradeLeg", ILiteralType.STRING).asKeyField());
customFields.add("TradeLeg", new CustomField("Theta", ILiteralType.DOUBLE).asNullable());

DatastoreHelper.insertFields("TradeStore", customFields);

Appending a vector field to the end of the Delta store:

DatastoreHelper.appendField("Delta", new CustomField("Interpolated Delta", ILiteralType.DOUBLE, new double[]{-1.0}).asVectorField().swap());
Removing the RiskClass field from the TradePnLs store:
DatastoreHelper.removeField("TradePnLs","RiskClass");

Changing the TradeLeg field in the TradeStore from a String to a Double:

DatastoreHelper.updateField("TradeStore", new CustomField("TradeLeg", ILiteralType.DOUBLE).asKeyField());
Including a field into the reference between the TradeStore and the MarketDataStore:
DatastoreHelper.addReference("TradeStore", "MarketDataStore", new Pair("TradeLeg","TradeLeg"));

** Removing two fields from the reference between the TradeBase and the Delta stores:**

List<IPair<String, String>> referencesToRemove; referencesToRemove.add(new Pair("RiskClass", "RiskClass")); referencesToRemove.add(new Pair("RiskMeasure", "RiskMeasure")); DatastoreHelper.removeReferences("TradeBase", "Delta", referencesToRemove);

Adding an index on the Trade Attributes store. Setting a global config for the chunksize, overridden by the TradeAttributes configuration:

CustomisableStoreConfig config = new CustomisableStoreConfig(); config .withIndexOn(StoreFieldNames.INSTRUMENT_CLASS, StoreFieldNames.AS_OF_DATE); config .withChunkSize(2048); CustomisableStoreConfig globalConfig = new CustomisableStoreConfig(); globalConfig .withChunkSize(1024); DatastoreHelper.addConfiguration(StoreNames.TRADE_ATTRIBUTE_STORE_NAME, config); DatastoreHelper.addConfiguration(ConfigurationConstants.ALL_STORES, globalConfig);

For more usage examples, refer to the test classes in the com.activeviam.tools.datastore package.

search.js