Skip to main content

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.

This page describes the source topic descriptions defined in the application, and provides an example of adding customization.

Source Topic Descriptions

The Data Load Controller is used to define the source topics. The following descriptions are defined:
NameFile patternColumns (if explicitly defined)*Target description nameCustom fieldsConfiguration class
Countriesglob:**Countries*.csvCommonStoreCsvLoadConfig
CounterpartyParentChildglob:**CounterpartyParentChild*.csvCommonStoreCsvLoadConfig
Counterpartiesglob:**Counterparties*.csv CommonStoreCsvLoadConfig
TradeAttributesglob:**TradeAttributes*.csvCommonStoreCsvLoadConfig
RiskFactorsCatalogueglob:**RiskFactorsCatalog*.csvCommonStoreCsvLoadConfig
Scenariosglob:**Scenarios*.csvCommonStoreCsvLoadConfig
LegalEntityParentChildglob:**LegalEntityParentChild*.csvCommonStoreCsvLoadConfig
BookParentChildglob:**BookParentChild*.csvCommonStoreCsvLoadConfig
MarketShiftsglob:**MarketShifts*.csvCommonStoreCsvLoadConfig
PnLglob:**PLPC*.csvAsOfDate
TradeId
Daily
Monthly
Yearly
Lifetime
Type
PLDriver
IsFullReval
Ccy
MarketDataSet
Bucket
PnLTradeKeyPnLCsvLoadConfig
DynamicTenorsglob:**DynamicTenors*.csvTenorLabel
NumberOfDays
SensitivityName
TenorSet
DynamicTenorsTenorIndicesSensiCsvLoadConfig
DynamicMaturitiesglob:**DynamicMaturities*.csvMaturityLabel
NumberOfDays
SensitivityName
MaturitySet
DynamicMaturitiesMaturityIndicesSensiCsvLoadConfig
DynamicMoneynessglob:**DynamicMoneyness*.csv MoneynessLabel
Shift
SensitivityName
MoneynessSet
DynamicMoneynessMoneynessIndicesSensiCsvLoadConfig
CorrelationMarketDataglob:**Correlation_Market_Data*.csvSensiCsvLoadConfig
DividendMarketDataglob:**Dividends*.csvSensiCsvLoadConfig
SplitRatioMarketDataglob:**SplitRatio*.csvSensiCsvLoadConfig
SensiLaddersglob:**LadderDefinition*.csvSensiCsvLoadConfig
Deltaglob:**DeltaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
DeltaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Correlationglob:**CorrelationSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
RiskFactorId2
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
CorrelationTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
CrossGammaglob:**CrossGammaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactor
RiskFactor2
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
CrossGammaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Volgaglob:**VolgaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
VolgaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Vannaglob:**VannaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
RiskFactorId2
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
VannaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Vegaglob:**VegaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
VegaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Thetaglob:**ThetaSensitivities*.csvAsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
ThetaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
Gammaregex:(?i).*Gamma(?<!CrossGamma)Sensitivities.*.csv.*AsOfDate
TradeId
SensitivityName
RiskClass
MarketDataSet
RiskFactorId
TenorLabel
TenorDate
MaturityLabel
MaturityDate
Moneyness
Value
Ladder
Ccy
GammaTradeKey + 6 anonymous custom field descriptions to handle vectorized inputs if neededSensiCsvLoadConfig
SpotMarketDataglob:**Spot_Market_Data*.csvSpotMarketDataCsvLoadConfig
SurfaceMarketDataglob:**Surface_Market_Data*.csvSurfaceMarketDataCsvLoadConfig
CurveMarketDataglob:**Curve_Market_Data*.csvCurveMarketDataCsvLoadConfig
CubeMarketDataglob:**Cube_Market_Data*.csvCubeMarketDataCsvLoadConfig
FxRateMarketDataglob:**FX_Rate_Market_Data*.csvFxRateMarketDataCsvLoadConfig
TradePnLsglob:**TradePnLs*.csvAsOfDate
TradeId
ScenarioSet
CalculationId
MarketDataSet
RiskFactor
RiskClass
SensitivityName
Ccy
MTM
PnLVector
TradePnLsTradeKeyVaRCsvLoadConfig
SensiBaseStoreglob:**Sensitivity Cube*.csv*SensiSummaryCsvLoadConfig
BaseStoreglob:**VaR-ES Cube*.csv*VaRSummaryCsvLoadConfig
PnLBaseStoreglob:**PLCube*.csv*PnLSummaryCsvLoadConfig
*If no fields are present in the configuration, the datastore’s target store fields are taken into account.

Example

For the purposes of this example, we will add a column to the file DynamicTenors.csv and load the data from this column into the DynamicTenors store. In this case, our new column’s header is “TestField”, and all data in this column is “Testdata”. Here’s how the input file looks like:
TenorSetTenorLabelSensitivityNameNumberOfDaysTestField
DEFAULTN/AN/A0.0Testdata
DEFAULT0.25YN/A90.0Testdata
DEFAULT0.5YN/A180.0Testdata
DEFAULT1YN/A360.0Testdata
DEFAULT2YN/A720.0Testdata
DEFAULT3YN/A1080.0Testdata
DEFAULT5YN/A1800.0Testdata
DEFAULT10YN/A3600.0Testdata
DEFAULT15YN/A5400.0Testdata
DEFAULT20YN/A7200.0Testdata
REDUCEDN/AN/A0.0Testdata
REDUCED0.5YN/A180.0Testdata
REDUCED1YN/A360.0Testdata
REDUCED2YN/A720.0Testdata
REDUCED30YN/A10800.0Testdata
DECADE10YN/A3600.0Testdata
DECADE20YN/A7200.0Testdata
We will also attach a column calculator that multiplies the NumberOfDays by 2 into a new column, as well as a tuple publisher that will add a value into the SensitivityName field.

Step 1 - Defining customizations to datastore

Before we can load these new columns into our cube, we need to make sure that our datastore has fields that can accept them. To add new fields to an existing store, we need to create a DatastoreConfiguratorConsumer bean, which appends the required fields to the DynamicTenors store:
public static String DOUBLE_NUMBER_OF_DAYS = "DoubleNumberOfDays";
public static String TEST_FIELD = "TestData";

@Bean
public DatastoreConfiguratorConsumer addFieldToStore() {
    return configurator -> {
        configurator.appendFields(DYNAMIC_TENOR_STORE_NAME,
                List.of(
                        new CustomField(DOUBLE_NUMBER_OF_DAYS, ILiteralType.DOUBLE),
                        new CustomField(TEST_FIELD, ILiteralType.STRING)
                )
        );
    };
}
See Customizing the Datastore with the Datastore Helper for more information.

Step 2 - Implementing the column calculator and the tuple publisher

Now that we have modified our store, we need to make sure the ETL is correctly set up, so that the field will be properly populated. In most cases, the topic configuration uses the store fields as the expected file columns, which would require no further configuration. For the DynamicTenors store used in this example, file columns are defined explicitly, so any new columns are not auto-configured. The DynamicTenors store also has a previously defined column calculator creating indices for each of the tenors. To define the column calculator, we create the following bean, containing the required logic:
@Bean
public CustomFieldDescription dynamicTenorsColumnCalculator() {
    return CustomFieldDescription.of("MyCustomDynamicTenorColCalculator",
            scope -> new GenericLambdaCalculator<>(DOUBLE_NUMBER_OF_DAYS,
                    context -> {
                        Double originalValue = (Double) context.getValue(StoreFieldConstants.TENOR_NUMBER_OF_DAYS);
                        if (originalValue == null) {
                            return null;
                        }
                        return 2.0 * originalValue;
                    }
            )
    );
}
For the tuple publisher, a second bean is created, defining the publishing logic:
@Bean
public TargetDescription dynamicTenorsTarget(IDatastore datastore) {
    return TargetDescription.of("MyCustomDynamicTenors", DYNAMIC_TENOR_STORE_NAME,
            scope ->
                    new ITuplePublisher<>() {

                        @Override public void publish(IStoreMessage<?, ?> message, List<Object[]> tuples) {
                            // We use the expected index for the SensitivityName field here, while in a complete implementation the index would be an instance variable.
                            tuples.forEach(tuple -> tuple[2] = "TestValue");
                            datastore.getTransactionManager().addAll(StoreConstants.DYNAMIC_TENOR_STORE_NAME, tuples);
                        }

                        @Override
                        public Collection<String> getTargetStores() {
                            return Collections.singleton(DYNAMIC_TENOR_STORE_NAME);
                        }

                    });
}

Step 3 - Update the topic description

We now need to modify the DynamicTenors topic to include the column calculator and tuple publisher. This can either be done with properties, or in Java.

Properties

We add the following properties to our existing properties,to define:
  • the list of columns read from the input file,
  • the calculated column,
  • the tuple publisher.
  csv:
    topics:
      DynamicTenors:
        file-pattern: "glob:**DynamicTenors**.csv"
        parser:
          columns:
            - TenorLabel
            - NumberOfDays
            - SensitivityName
            - TenorSet
            - TestData
        channels:
            - target: MyCustomDynamicTenors
              custom-fields:
                - MyCustomDynamicTenorColCalculator
                - TenorIndices

Java

We create a new CsvTopicConfiguration Spring bean that will override the existing topic bean provided in Atoti Market Risk. We inject into the bean method:
  • Our previously defined target and custom field. These will be used to create the channel,
  • The existing tenorIndicesCalculator, defined in Atoti Market Risk. This will be used to create the channel,
  • The existing topic bean. This enables the default parser and file pattern to be reused.
The bean is annotated with @Order(1). This ensures it takes precedence over existing topics in Atoti Market Risk.
@Bean
@Order(1)
public CsvTopicDescription customDynamicTenorsTopic(
        TargetDescription dynamicTenorsTarget,
        CustomFieldDescription dynamicTenorsColumnCalculator,
        CustomFieldDescription tenorIndicesCalculator,
        CsvTopicDescription dynamicTenorsCsvLoadTopic) {
    ChannelDescription
            .builder(dynamicTenorsTarget)
            .customFields(Set.of(dynamicTenorsColumnCalculator, tenorIndicesCalculator))
            .build();
    return CsvTopicDescription
            .builder(StoreConstants.DYNAMIC_TENOR_STORE_NAME, dynamicTenorsCsvLoadTopic.filePattern())
            .parser(dynamicTenorsCsvLoadTopic.parser())
            .channel(dynamicTenorsChannel(StoreConstants.DYNAMIC_TENOR_STORE_NAME)).build();
}

Step 4 - Configuration classes

You can include the Beans detailed above in a single class within Atoti Market Risk.
@Configuration
public class CustomizationsConfig {

    public static String DOUBLE_NUMBER_OF_DAYS = "DoubleNumberOfDays";
    public static String TEST_FIELD = "TestData";

    @Bean
    public DatastoreConfiguratorConsumer addFieldToStore() {
        return configurator -> {
            configurator.appendFields(DYNAMIC_TENOR_STORE_NAME,
                    List.of(
                            new CustomField(DOUBLE_NUMBER_OF_DAYS, ILiteralType.DOUBLE),
                            new CustomField(TEST_FIELD, ILiteralType.STRING)
                    )
            );
        };
    }

    @Bean
    public CustomFieldDescription dynamicTenorsColumnCalculator() {
        return CustomFieldDescription.of("MyCustomDynamicTenorColCalculator",
                scope -> new GenericLambdaCalculator<>(DOUBLE_NUMBER_OF_DAYS,
                        context -> {
                            Double originalValue = (Double) context.getValue(StoreFieldConstants.TENOR_NUMBER_OF_DAYS);
                            if (originalValue == null) {
                                return null;
                            }
                            return 2.0 * originalValue;
                        }
                )
        );
    }

    @Bean
    public TargetDescription dynamicTenorsTarget(IDatastore datastore) {
        return TargetDescription.of("MyCustomDynamicTenors", DYNAMIC_TENOR_STORE_NAME,
                scope ->
                        new ITuplePublisher<>() {

                            @Override public void publish(IStoreMessage<?, ?> message, List<Object[]> tuples) {
                                // We use the expected index for the SensitivityName field here, while in a complete implementation the index would be an instance variable.
                                tuples.forEach(tuple -> tuple[2] = "TestValue");
                                datastore.getTransactionManager().addAll(StoreConstants.DYNAMIC_TENOR_STORE_NAME, tuples);
                            }

                            @Override
                            public Collection<String> getTargetStores() {
                                return Collections.singleton(DYNAMIC_TENOR_STORE_NAME);
                            }

                        });
    }

    // This bean is not required if you are using properties to define the topic.
    @Bean
    public CsvTopicDescription customDynamicTenorsTopic(
            TargetDescription dynamicTenorsTarget,
            CustomFieldDescription dynamicTenorsColumnCalculator,
            CustomFieldDescription tenorIndicesCalculator,
            CsvTopicDescription dynamicTenorsCsvLoadTopic) {
        ChannelDescription
                .builder(dynamicTenorsTarget)
                .customFields(Set.of(dynamicTenorsColumnCalculator, tenorIndicesCalculator))
                .build();
        return CsvTopicDescription
                .builder(StoreConstants.DYNAMIC_TENOR_STORE_NAME, dynamicTenorsCsvLoadTopic.filePattern())
                .parser(dynamicTenorsCsvLoadTopic.parser())
                .channel(dynamicTenorsChannel(StoreConstants.DYNAMIC_TENOR_STORE_NAME)).build();
    }
}
Then, include this configuration class in the @Import annotation of the MarketRiskConfig class:
@Import(value = {
        ...
		CustomizationsConfig.class

})
public class MarketRiskConfig {
    ...
}
Importing this customization class and modifying the input file will result in the following data being loaded into the store:
TenorSetTenorLabelSensitivityNameNumberOfDaysTenorIndicesDoubleNumberOfDaysTestData
DEFAULTN/ATestValue0.000.0Testdata
DEFAULT0.25YTestValue90.01180.0Testdata
DEFAULT0.5YTestValue180.02360.0Testdata
DEFAULT1YTestValue360.03720.0Testdata
DEFAULT2YTestValue720.041440.0Testdata
DEFAULT3YTestValue1080.052160.0Testdata
DEFAULT5YTestValue1800.063600.0Testdata
DEFAULT10YTestValue3600.077200.0Testdata
DEFAULT15YTestValue5400.0810800.0Testdata
DEFAULT20YTestValue7200.0914400.0Testdata
REDUCEDN/ATestValue0.000.0Testdata
REDUCED0.5YTestValue180.01360.0Testdata
REDUCED1YTestValue360.02720.0Testdata
REDUCED2YTestValue720.031440.0Testdata
REDUCED30YTestValue10800.0421600.0Testdata
DECADE10YTestValue3600.007200.0Testdata
DECADE20YTestValue7200.0114400.0Testdata
The configuration for this behavior is:
new ATableFormatTuplePublisher<>(datastore, Map.of(INSTRUMENT_ID, RISK_FACTOR)) {
  @Override
  public void publish(IStoreMessage<? extends I, ?> message, List<Object[]> tuples) {
      Queue<Object[]> storeTuples = new ConcurrentLinkedQueue<>();
      tuples.forEach(
              tuple -> {
                  if (checkNull(tmmProps, message, tuple, TENOR_LABELS, TENOR_DATES, MATURITY_LABELS, MATURITY_DATES, MONEYNESS_LABELS,
                          NOMINAL)) {
                      Queue<Object[]> extractedScalarTuples = new ConcurrentLinkedQueue<>();
                      devectorizer.extractScalarTuples(message, tuple, extractedScalarTuples);
                      extractedScalarTuples.forEach(
                              scalarTuple -> storeTuples.add(createTupleForTable(message, SPOT_MARKET_DATA_STORE, scalarTuple))
                      );
                  }
              }
      );
      datastore.getTransactionManager().addAll(SPOT_MARKET_DATA_STORE, storeTuples);
  }

  @Override
  public Collection<String> getTargetStores() {
      return Set.of(SPOT_MARKET_DATA_STORE);
  }
}
Within the createTupleForTable method, the publisher iterates over the table fields, attempting to retrieve a value in the input tuple by the mapped field (or directly if no mapping is available). If no value is available in the input tuple, or no matching field is found, the value will be empty. If a tuple field’s value isn’t requested by the publisher, it is ignored.

Suggested Further Reading