> ## 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.

# Incremental contribution measures

> How the framework computes each trade's incremental contribution to its netting-set metric, and the hidden inframarginal exposure vectors this computation relies on.

Incremental contribution measures decompose netting-set-level or portfolio-level exposure into per-trade contributions. The visible incremental contribution metric is derived from hidden inframarginal exposure vectors.

Understanding [exposure measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-measures.md) is a prerequisite for this page.

## What is the incremental contribution measure?

The incremental contribution expresses, as a signed scalar in the same unit as the underlying metric (for example, PFE or EE), how much a trade adds to its parent's metric. It is the difference between the parent metric and the corresponding metric computed on the [inframarginal exposure](#what-is-inframarginal-exposure), evaluated per the trade level and not aggregated above it:

$\text{IncrementalContribution}_{\text{trade}} = \text{Metric}_{\text{parent}} - \text{Metric}^{\,\text{inframarginal}}_{\text{trade}}$

where $\text{Metric}^{\,\text{inframarginal}}_{\text{trade}}$ is the metric computed on the inframarginal exposure (the parent aggregate excluding the current trade). Both terms of the difference honor the query filters: when the query restricts the trades in scope, the parent aggregate and the inframarginal value are both computed on the visible trades only, keeping the contribution consistent with the displayed totals. The result is a signed amount, not a ratio: positive when the trade increases the parent's exposure, negative when it provides a netting benefit. Unlike the inframarginal exposure it is derived from, the incremental contribution measure is visible to cube end-users. It is available through `IInframarginalExposureAndMetricsMeasures.incrementalContributions()`. The PFE cube builds the incremental contributions, for the PFE, EE, ES and ENE metrics only: PFE Scenario Index and PFE Scenario Name have none. The xVA cube has incremental contributions of its xVA measures, not of PFE, EE, ES or ENE.

## What is inframarginal exposure?

Inframarginal exposure is the value of the aggregate excluding a single trade: it answers the question *"what would the netting-set exposure be if this trade were removed?"* It is an intermediate quantity that end-users do not query directly. The cube hides it and exposes the incremental contribution computed from it instead.

Every inframarginal measure is built by one measure factory, registered under the plugin key `Inframarginal`. Its input holds one of three strategies, and the strategy decides how the value on the parent without the trade is obtained:

| Strategy | Used for | How it computes the inframarginal |
| - | - | - |
| Linear | Measures that add up over the marginal level: the gross exposure vectors | Subtracts the trade's own value from the value of its parent. |
| Delegated | Measures that do not add up: the netted exposures, with and without break dates, the collateralized exposures, and measures built from an inframarginal exposure, such as the xVA present value | Takes the inframarginal from an input whose own factory computes it. |
| Filter | Any other measure | Runs one filtered retrieval per trade, with the parent excluding the current trade. |

No cube measure uses the filter strategy at present. Its cost grows with the number of trades in the parent, so use it only for small parents.

All three strategies yield the same quantity, the underlying measure evaluated on the parent excluding the trade. Both the parent value and the trade's own value honor the query filters.

## How is linear inframarginal computed?

Linear inframarginal subtracts the trade's own value from the value of its parent:

$\text{Inframarginal}_{\text{trade}} = E_{\text{parent}} - E_{\text{trade}}$

The parent value honors the query filters, so both terms agree on which trades make up the parent. This is exact only for a measure that adds up over the marginal level, such as the gross exposure vectors. It follows that where the linear form applies, the incremental contribution reduces to the trade's own value, since $E_{\text{parent}} - (E_{\text{parent}} - E_{\text{trade}}) = E_{\text{trade}}$.

## How is the inframarginal computed with a member exclusion?

Netting is non-linear, so the netted value of a master agreement without a trade cannot be obtained by subtracting the trade's own netted value. The delegated strategy passes the measure's own input, with a member exclusion, to the measure's factory, which computes the value on the parent without the trade. The factory reads the trade's level and a presence measure from a member exclusion. It returns:

* the measure's value on the parent scope of the trade without the trade;
* written only where the presence measure of the trade is not empty.

The calculation takes the value of the parent and corrects it for the master agreement the trade belongs to:

$E_{\text{parent} \setminus \text{trade}} = E_{\text{parent}} - E_{\text{MA}} + E_{\text{MA} \setminus \text{trade}}$

Only the master agreement of the trade is recomputed, so the cost does not depend on the number of trades in the parent. The calculation takes the following into account:

* The mark-to-market vectors of a master agreement's trades add up, so the master agreement's mark-to-market without the trade is its mark-to-market minus the trade's own. The netted exposure applies the exposure floor of the exposure's side (bank or counterparty) to the result.
* A trade whose master agreement does not net, because its `Netted` value is false, removes its own exposure. This includes the default `N/A` master agreement, which uses the same strategy as every other master agreement.
* The collateralized exposure of the master agreement without the trade is computed once per trade, time point and master agreement. The balance of the credit support annex (CSA) is evaluated on the data points of the CSA without the trade's inputs, and the latest maturity is taken without the trade for the cut that leaves no collateral after the latest maturity.
* A trade must belong to exactly one master agreement. A trade under two master agreements fails the calculation.
* With break dates, the same exclusion runs over inputs restricted to the trades within their break date. A trade with no value at a time point, because it is past its break date, takes the master agreement's value there, so its incremental contribution at that time point is zero.
* When the query does not include the master agreement, the master agreements that the trade does not belong to keep their exposure.

The netted exposure, with and without break dates, and the collateralized exposure compute their inframarginal this way. Any other measure takes the linear strategy if it adds up over the trade level, the delegated strategy if it is a formula over another inframarginal, or the filter strategy otherwise.

## Which time points does the inframarginal exposure cover?

The gross and netted inframarginal exposures exist at the time points where the trade has an MtM. When the trade is the only contributor to its parent, they are zero vectors.

A `MarkToFuture` row with a blank vector reads as a zero vector, so the trade is present at that time point with a zero MtM. A missing row means the trade is absent. The gross and netted metrics, and their incremental contributions, are the same either way. The collateralized exposure is not: the blank row still counts the trade as a contributor of its CSA at that time point and toward the latest maturity of the CSA. When another trade of the CSA is left out, a CSA whose remaining trades are blank at that time point is still present with a zero MtM, and its collateral (the initial collateral, the independent amounts and the balance at t - MPOR) still produces exposure. When those rows are missing, the CSA has no exposure without that trade. To have a trade not count at a time point, leave its row out instead of loading a blank vector.

The collateralized inframarginal exposure exists at every time point of the master agreement, not only up to the trade's maturity. After maturity, it still differs from the master agreement's exposure for up to one holding period, because the collateral at a time point reads the MtM of an earlier time point. After that, it equals the master agreement's exposure.

The hidden `countAtEveryTimePoint()` measure of `INettingTechMeasures` is the trade's contributor count over all time points. It is written at every time point of the trade's master agreement, including those after the trade matures. The incremental contributions read their parent values where it exists.

At a time point where the trade is absent and its inframarginal exposure is empty, the inframarginal metrics (PFE, EE, ENE and ES) take the parent's metric at that time point. They then aggregate over every time point of the parent, as the parent's metrics do: the maximum, or the minimum for ENE. The exposure vectors are not evaluated again after maturity.

With a time point on the query, the incremental contribution at a time point after the trade matures is 0 for the gross and netted metrics. For the collateralized metrics, it can differ from 0 for up to a holding period after maturity.

A filter on the time points, in the `WHERE` clause or in a sub-select, does not hide a trade that matured before the selected time points. Its gross and netted contributions there are 0.

## How do these measures relate to the public API?

The `IInframarginalExposureMeasures` interface gives access to the hidden inframarginal exposure vectors:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
public interface IInframarginalExposureMeasures {
  @Nullable IExposureVectorMeasures inframarginalExposureVectorsMeasures();
}
```

The `IInframarginalExposureAndMetricsMeasures` interface extends this with inframarginal metrics and the incremental contribution metric:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
public interface IInframarginalExposureAndMetricsMeasures extends IInframarginalExposureMeasures {
  @Nullable IExposureMetrics inframarginalExposureMetrics();
  @Nullable IExposureMetrics incrementalContributions();
}
```

Both `IGrossMeasures` and `INettedMeasures` extend `IInframarginalExposureMeasures`. `ICollateralizedExposureMeasures` also extends `IInframarginalExposureMeasures`, so all three exposure families carry inframarginal measures.

## Related pages

* [Exposure measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-measures.md)
* [Exposure metrics](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-metrics.md)
* [Public API](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/reference/public-api.md)
