Skip to main content
An application can add collateral algorithms to the cubes that use Netting Set Analytics. An algorithm decides how much collateral a credit support annex (CSA) holds at each time point. The library subtracts the collateral of the CSAs from the exposure of the master agreement. This page describes the configurer, the evaluator contract, and the ways to select an algorithm. Understanding collateral algorithms is a prerequisite for this page.

How does an application add an algorithm?

The application declares at most one ICollateralConfigurer bean. A second bean makes the application fail at startup. Declare the bean with a static @Bean method, because the cubes are built from what the configurer declares, so it cannot depend on a cube. Netting Set Analytics calls the configurer once for each cube. The configurer receives an ICollateralConfigurator. Its cube(String cubeName) method returns the ICollateralCubeConfigurator of that cube, so each cube gets its own algorithms and cashflows. The name is the cube name that the cube properties return from getName(), which a static @Bean method can take as a parameter, for example IPfeCubeProperties or IXvaCubeProperties. Declarations made for a cube that the application does not have are ignored, so one configurer can serve applications that have only some of the cubes. When a name matches none of the cubes of the application, the application logs a warning at startup, because a misspelled or renamed cube would otherwise silently get no custom algorithm and no cashflows. Within a cube, a later declaration of an algorithm with the same name replaces an earlier one, and a later call to cashflows(...) replaces an earlier one. The ICollateralCubeConfigurator has the following methods: ICollateralServices has one method, scenarioCount(). It returns the number of scenarios of the cube, which is the length that every vector must have. The following configurer adds the evaluator described in the next section and a cashflows service to the PFE cube:

What must an algorithm implement?

An algorithm implements ICollateralEvaluator<T>. The type T is the data point that the algorithm builds for each time point. It extends CollateralEvaluationData.DataPoint, which is serializable and returns its time point. Every vector has one value per scenario. The evaluator does not need to be serializable. The cube keeps the evaluators in a registry for each cube and looks them up by name when it evaluates.

Which inputs does an algorithm receive?

The library computes the collateralized exposure from the balances that the algorithm returns. The algorithm does not compute it. See How is collateralized exposure computed?. The cube assembles the CsaParameters from the CollateralAgreements table and the CSA parameter measures. See What are the CSA parameter measures?.

What does an example algorithm look like?

The following evaluator is a one-way algorithm named Threshold CSA. The counterparty posts the exposure above its threshold. The data point holds the gross MtM of the time point.

How to replace a built-in algorithm

An evaluator whose algoName() equals the name of a built-in algorithm replaces that algorithm. The built-in names are Bilateral CSA and Unilateral (Bank) CSA. When two declarations use the same name, the later one replaces the earlier one.

How to select the algorithm

Every algorithm is a member of the Collateral Algorithm hierarchy. The atoti.solution.model.cubes.<cube>.collateral.default-evaluator property names the default member. A query that selects no member uses it. The default must be a built-in algorithm or one that the configurer adds, otherwise the application fails at startup with an error that names the cube. To evaluate another algorithm, select its member in the query. A slicing hierarchy has no [ALL].[AllMember] segment in its member path:
To compare algorithms, put the hierarchy on an axis:
The exposure metrics, the inframarginal and incremental contribution measures, and the measures that the consuming cube builds on the collateralized exposure all follow the selected member.

How to choose the algorithm per CSA

The hidden measure Collateral Algorithm returns the selected member, and the collateral measures read it for every cell. An application redefines this measure to choose the algorithm by another rule. The application does this in its model configurer, the IModelConfigurer bean that every application has once, usually named ModelConfigurer. Its configureCubes method receives the ICubeManagerConfigurator. The method calls updateMeasure on the measures configurator of the cube, with the name of the measure and a function that receives the measure that selects the algorithm and returns the replacement. The name is cube.measures().collateralizedMeasures().exposureMeasures().techCollateralMeasures().collateralAlgorithm().getName(), so the application does not hard-code it. The following model configurer is written for the PFE cube, which it receives as the cube bean IPfeCube. The xVA cube has the same shape with IXvaCube. The configurer reads the CSA of each cell. It returns the algorithm Flat CSA for one CSA, and the selected algorithm for every other CSA. The constant FLAT_CSA is the ID of an application CSA, and Flat CSA is the name of an algorithm that the collateral configurer adds.
The algorithm must not be null for a CSA that has an agreement, because the measures then fail with an error that names the missing algorithm.