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

# Exposure measures

> Exposure measures in the netting-set analytics framework, covering the gross, netted, and collateralized vector families, bank and counterparty sides, scenario-level expansion, and the CSA parameter measures that the collateral algorithms read.

The netting-set analytics framework provides three families of exposure measures: gross, netted, and collateralized. Each family produces exposure vectors (one double per scenario, per time point) for the bank side and the counterparty side. Within each family, a scenario-level expansion variant exposes the vector elements individually for scenario-level drill-down.

Understanding [exposure concepts](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/introduction/exposure-concepts.md) and the [data model](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/database/database-model.md) is a prerequisite for this page.

## What is an exposure vector measure?

An exposure vector measure is a measure whose value at a given cell is a `double[]` vector of length `scenariosCount`. Each element corresponds to one Monte-Carlo scenario. The exposure vector is computed at query time by aggregating the raw MtF vectors across all trades and time points in scope.

The `IExposureVectorMeasures` interface provides typed access to a family's vector measures:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
public interface IExposureVectorMeasures {
  NamedCopperMeasure getExposureVectors(Side side);
  NamedCopperMeasure getExposureVectorsScenarioLevel(Side side);
  /**
   * The exposure vectors of the side before conversion to the display currency, or null when they
   * are not converted.
   */
  @Nullable NamedCopperMeasure getRawExposureVectors(Side side);
  @MeasureMetadata(
      "Exposure vector seen from the bank side, in the currency of the mark-to-future data, before"
          + " conversion to the display currency. It has values at or below the MtF currency"
          + " level only.")
  default @Nullable NamedCopperMeasure getBankRawExposureVector() {
    return getRawExposureVectors(Side.BANK);
  }
  @MeasureMetadata(
      "Exposure vector seen from the cpty side, in the currency of the mark-to-future data, before"
          + " conversion to the display currency. It has values at or below the MtF currency"
          + " level only.")
  default @Nullable NamedCopperMeasure getCptyRawExposureVector() {
    return getRawExposureVectors(Side.CPTY);
  }
  @MeasureMetadata(
      "Exposure vector seen from the bank side, as a single vector value before scenario"
          + " expansion.")
  default NamedCopperMeasure getBankExposureVector() {
    return getExposureVectors(Side.BANK);
  }
  @MeasureMetadata(
      "Exposure vector seen from the cpty side, as a single vector value before scenario"
          + " expansion.")
  default NamedCopperMeasure getCptyExposureVector() {
    return getExposureVectors(Side.CPTY);
  }
  @MeasureMetadata(
      "Exposure vector seen from the bank side, expanded into individual scenario values along"
          + " the Scenarios dimension.")
  default NamedCopperMeasure getBankExposureVectorScenarioLevel() {
    return getExposureVectorsScenarioLevel(Side.BANK);
  }
  @MeasureMetadata(
      "Exposure vector seen from the cpty side, expanded into individual scenario values along"
          + " the Scenarios dimension.")
  default NamedCopperMeasure getCptyExposureVectorScenarioLevel() {
    return getExposureVectorsScenarioLevel(Side.CPTY);
  }
}
```

The `Side` enum has two values: `BANK` (label `"Bank"`) and `CPTY` (label `"Cpty"`). Convenience defaults `getBankExposureVector()` and `getCptyExposureVector()` delegate to the `Side`-parameterized methods. `getBankRawExposureVector()` and `getCptyRawExposureVector()` do the same for `getRawExposureVectors(Side)`, which returns the vector before conversion to the display currency, with values at or below the MtF currency level only, or `null` when the vector is not converted.

## What are the gross exposure measures?

Gross exposure measures operate on the raw MtF vectors without any netting or collateral adjustment. They form the foundation on which the other families are built.

### Base gross exposure measures (`IBaseGrossExposureMeasures`)

These measures are the building blocks of the gross exposure family.

| Measure | Description |
| - | - |
| `initialMtm` | The MtF value of a trade at time point zero (the as-of date), representing the initial mark-to-market. |
| `mtmSum` | The element-wise sum of MtF vectors across all trades in scope, aggregated up to the current query context. When the cube has an FX rate measure, the sum is converted to the display currency. |
| `mtmSumRaw` | The `mtmSum` aggregation before conversion to the display currency, per MtF currency. It has values at or below the MtF currency level only and is empty above it. It is a hidden measure, and `null` when the cube has no FX rate measure. |
| `cumulativeCashflow` | The projected cashflow of a trade, accumulated over the time points. It has values at the trade level only. No exposure formula reads it. See [Cashflow measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/cashflows.md). |
| `mtmSumScenarioLevel` | Scenario-level expansion of `mtmSum`. One row per scenario when the Scenarios dimension is in the query context. |
| `cumulativeCashflowScenarioLevel` | Scenario-level expansion of `cumulativeCashflow`. |

`mtmSum`, `cumulativeCashflow` and every exposure vector measure of the gross, netted and collateralized families are hidden. Their `(Scenario Level)` expansions are visible.

### Gross exposure vector family

Built from the MtF vectors of each trade, the gross exposure vectors represent the exposure of each trade or group of trades without netting. Two variants exist:

* **Gross** (standard): aggregates all time points.
* **Gross with break dates**: aggregates only time points before each trade's break date.

| Measure accessor | Description |
| - | - |
| `getExposureVectors(BANK)` | Bank-side gross exposure vector: the sum over the trades of the element-wise `max(0, MtF)` of each trade. The cumulative cashflow does not enter it. |
| `getRawExposureVectors(BANK)` | Bank-side gross exposure vector before conversion to the display currency, per MtF currency. It has values at or below the MtF currency level only and is empty above it. It is a hidden measure, and `null` when the cube has no FX rate measure or for the break-date variant. |
| `getExposureVectors(CPTY)` | Counterparty-side gross exposure vector: the sum over the trades of the element-wise `min(0, MtF)` of each trade. The cumulative cashflow does not enter it. |
| `getRawExposureVectors(CPTY)` | Counterparty-side gross exposure vector before conversion to the display currency. Same MtF currency level restriction as the bank side. Hidden, and `null` under the same conditions as the bank side. |
| `getExposureVectorsScenarioLevel(BANK)` | Scenario-level bank exposure. One element per scenario in the Scenarios dimension. |
| `getExposureVectorsScenarioLevel(CPTY)` | Scenario-level counterparty exposure. |

The full `IGrossMeasures` interface extends both `IExposureMeasures` (for exposure vectors) and `IInframarginalExposureMeasures` (for inframarginal vectors). It also exposes `baseGrossExposureMeasures()`.

## What are the netted exposure measures?

Netted exposure measures aggregate MtF vectors within a netting set before taking the positive or negative part. This reduces gross exposure by the netting benefit when trades have offsetting values.

The netted exposure is computed by the `NettedExposure` measure (plugin key `NettedExposure`) from the `MarkToFuture` values of each netting set, for the selected side, with an optional break-date restriction.

Two variants exist:

* **Netted**: standard aggregation.
* **Netted with break dates**: aggregation limited to time points before each trade's break date.

| Measure accessor | Description |
| - | - |
| `getExposureVectors(BANK)` | Bank-side netted exposure vector: `max(0, sum of MtF within netting set)`. |
| `getExposureVectors(CPTY)` | Counterparty-side netted exposure vector: `min(0, sum of MtF within netting set)`. |
| `getExposureVectorsScenarioLevel(BANK)` | Scenario-level bank netted exposure. |
| `getExposureVectorsScenarioLevel(CPTY)` | Scenario-level counterparty netted exposure. |

The `INettedMeasures` interface extends both `IExposureMeasures` and `IInframarginalExposureMeasures`.

## What are the collateralized exposure measures?

Collateralized exposure measures subtract a CSA-based collateral balance from the netted MtF sum before taking the positive or negative part. The collateral balance is computed per netting set per time point by a collateral algorithm.

The cube has one set of collateralized measures, in the `Collateralized Exposures` folder. They are evaluated with the algorithm selected on the `Collateral Algorithm` hierarchy, or with the default algorithm when the query selects none. See [Collateral algorithms](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/collateral-evaluator-framework.md#how-is-an-algorithm-selected).

The CSA parameters, and the `Netted` setting of each master agreement, are provided by a separate measures bundle. See [What are the CSA parameter measures?](#what-are-the-csa-parameter-measures).

### Independent amount measures (`IIndependentAmountMeasures`)

| Measure accessor | Description |
| - | - |
| `independentAmount()` | The sum of the `IndependentAmount` field of the `IndependentAmounts` table. It has values at or below the `Independent Amount Currency` level only. The collateral algorithms do not read it: they use the independent amounts of the CSA parameters. |

### Technical collateral measures (`ITechCollateralMeasures`)

These measures are produced by the selected collateral algorithm.

| Measure accessor | Description |
| - | - |
| `collateralAlgorithm()` | A hidden measure that returns the name of the selected member of the `Collateral Algorithm` hierarchy. The collateral data points, the collateral balance and the collateralized MtM read it for each cell. An application can redefine it. See [How to choose the algorithm per CSA](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/custom-collateral-algorithm.md#how-to-choose-the-algorithm-per-csa). |
| `collateralBalance()` | A hidden measure: the collateral balance vector at each time point, computed by the collateral algorithm. |
| `collateralBalanceScenarioLevel()` | Scenario-level expansion of the collateral balance. |
| `collateralizedMtm()` | A hidden measure: the gross MtM of the master agreement less the collateral balances of its CSAs, without a floor. |
| `collateralizedMtmScenarioLevel()` | Scenario-level expansion of the collateralized MtM. |
| `collateralDataPoints()` | The MtF values per time point that the algorithm reads for the holding-period look-back and interpolation. |
| `latestTradeMaturity()` | A hidden measure that returns the latest `TradeMaturityDate` of the trades at a location: the latest member of the `Trade Maturity` level there. The collateral balance of a CSA and the collateralized MtM of a master agreement are empty at the time points after it. |

### Collateralized exposure vectors (`ICollateralizedExposureMeasures`)

| Measure accessor | Description |
| - | - |
| `getExposureVectors(BANK)` | Bank-side collateralized exposure: `max(0, nettedMtF - collateralBalance)`. For a master agreement that does not net, `max(0, grossBankExposure - collateralBalance)`, where the gross exposure is the sum of each trade's positive MtF. |
| `getExposureVectors(CPTY)` | Counterparty-side collateralized exposure: `min(0, nettedMtF - collateralBalance)`. For a master agreement that does not net, `min(0, grossCptyExposure - collateralBalance)`, where the gross exposure is the sum of each trade's negative MtF. |
| `getExposureVectorsScenarioLevel(BANK)` | Scenario-level bank collateralized exposure. |
| `getExposureVectorsScenarioLevel(CPTY)` | Scenario-level counterparty collateralized exposure. |

The `ICollateralizedMeasures` interface groups all collateral-related measures. Its `exposureMeasures()` accessor returns the single set of collateralized exposure measures:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
public interface ICollateralizedMeasures<A extends ICollateralizedExposureMeasures> {
  @Nullable IIndependentAmountMeasures independentAmountMeasures();
  /**
   * Returns the collateralized exposure measures. They are evaluated with the algorithm selected on
   * the Collateral Algorithm hierarchy, the default algorithm when none is selected.
   *
   * @return the collateralized exposure measures
   */
  A exposureMeasures();
}
```

## What are the CSA parameter measures?

CSA parameter measures expose the fields of the `CollateralAgreements` table, one row per CSA, as cube measures. See the [data model](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/database/database-model.md) for the field definitions. The cube combines these fields into a single object measure that the collateral algorithms read.

### Per-field parameter measures (`ICsaParametersMeasures`)

For each CSA field, the cube publishes a per-field measure in the "CSA Parameters" folder. Each measure reads its field from the `CollateralAgreements` row of the queried as-of date and CSA. It has a value only where both levels are expressed and the CSA has trades on that date, and is computed at query time rather than stored in an aggregate provider.

A CSA without a `CollateralAgreements` row on an as-of date has no agreement on that date, as `N/A` has none: its per-field measures are empty, the hidden Has Netting Agreement measure is false, and it holds no collateral, so it does not reduce the collateralized exposure of its master agreement.

On a standalone cube, a continuous query refreshes when a `CollateralAgreements` row changes.

| Measure accessor | Description |
| - | - |
| `initialCollateral()` | The initial collateral balance, used when the holding-period look-back date is before the business date. |
| `bankThreshold()` | The exposure threshold above which the bank must post collateral to the counterparty. |
| `cptyThreshold()` | The exposure threshold above which the counterparty must post collateral to the bank. |
| `bankMinTransferAmount()` | The minimum amount below which no collateral transfer to the counterparty is called. |
| `cptyMinTransferAmount()` | The minimum amount below which no collateral transfer to the bank is called. |
| `bankHoldingPeriod()` | The margin period of risk for the bank side, in days. |
| `cptyHoldingPeriod()` | The margin period of risk for the counterparty side, in days. |
| `bankIndependentAmount()` | The fixed independent amount posted by the bank. |
| `bankScaleFactor()` | The scale factor applied to the bank independent amount. |
| `bankFloor()` | The floor on the bank independent amount. |
| `cptyIndependentAmount()` | The fixed independent amount posted by the counterparty. |
| `cptyScaleFactor()` | The scale factor applied to the counterparty independent amount. |
| `cptyFloor()` | The floor on the counterparty independent amount. |
| `hairCut()` | The haircut applied to the value of the posted collateral. The built-in collateral algorithms do not read it. |
| `parametersCurrency()` | The currency of the CSA threshold and minimum-transfer-amount parameters. |
| `hasNettingAgreement()` | Whether the CSA has a `CollateralAgreements` row on the queried as-of date. `false` for the default `N/A` CSA ID. |
| `netted()` | Whether the master agreement nets the exposures of its trades, from the `Netted` field of the `MasterAgreements` table. It is read at the master agreement level. |
| `additionalParameters(name)` | The measure for a configured, non-default parameter, by its field name. Throws `IllegalArgumentException` for a default or unconfigured name. |

### The CSA parameters object

The `"CSA Parameters"` object measure (plugin key `CsaParameters`) holds one value per CSA. It is built from the per-field measures listed above and is not read from a table.

An override applied to one per-field measure is therefore reflected in the object and flows into the collateral balance computed from it.

### How to add custom CSA parameters

The built-in parameter list can be extended through the `additional-csa-parameters` cube property, a list of entries that each pair a `field-name` with a data `type`. The property sits under the cube prefix, for example `atoti.solution.model.cubes.pfe`. For each configured parameter, the cube:

* Adds a field to the `CollateralAgreements` table.
* Publishes a per-field measure for it, alongside the built-in ones, in the "CSA Parameters" folder.
* Includes its value in the CSA parameters object, keyed by field name.

`ICsaParametersMeasures.additionalParameters(name)` resolves the measure for a configured parameter by its field name. It throws `IllegalArgumentException` for a name that is not configured. Default parameters are already reachable through their own accessors.

## How does the scenario expansion work?

Scenario-level measures are produced by the `ScenarioExpansion` measure (plugin key: `ScenarioExpansion`). They expose individual scenario values when the Scenarios dimension is included in the query context. Without the Scenarios dimension, these measures are not meaningful and typically return null.

## Related pages

* [Exposure metrics](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-metrics.md)
* [Collateral algorithms](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/collateral-evaluator-framework.md)
* [How to write your own collateral algorithm](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/custom-collateral-algorithm.md)
* [Incremental contribution measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/incremental-contribution-measures.md)
* [Cashflow measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/cashflows.md)
* [Public API](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/reference/public-api.md)
