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

> How the framework computes the PFE, EE, ENE, and ES scalar metrics plus the PFE scenario index and name from exposure vectors, including the rule for the PFE scenario position.

Exposure metrics are scalar measures derived from the scenario distribution of an exposure vector at each time point. The framework provides PFE, EE, ENE, and ES as numeric metrics, plus PFE Scenario Index and PFE Scenario Name as diagnostic metrics.

Understanding [exposure concepts](../../introduction/exposure-concepts) is a prerequisite for this page.

## What metrics does the framework provide?

| Metric | Enum constant | Label | Type | Description |
| - | - | - | - | - |
| Expected Exposure | `ExposureMetric.EE` | `"EE"` | `Numeric` | Mean of the discounted positive bank-side exposure across scenarios. |
| Expected Negative Exposure | `ExposureMetric.ENE` | `"ENE"` | `Numeric` | Mean of counterparty-side exposure across scenarios. |
| Potential Future Exposure | `ExposureMetric.PFE` | `"PFE"` | `Numeric` | Quantile of bank-side exposure at the configured confidence level. |
| Expected Shortfall | `ExposureMetric.ES` | `"ES"` | `Numeric` | Mean of the bank-side exposure over the tail scenarios, the largest values. |
| PFE Scenario Index | `ExposureMetric.PFE_INDEX` | `"PFE Scenario Index"` | `Integer` | Index of the scenario that produced the PFE value, starting at 1 with the default `index-offset`. |
| PFE Scenario Name | `ExposureMetric.PFE_SCENARIO_NAME` | `"PFE Scenario Name"` | `String` | Human-readable name of the PFE scenario. |

The `ExposureMetric.isNumeric()` method returns `true` for PFE, EE, ES, and ENE. PFE\_INDEX and PFE\_SCENARIO\_NAME are not numeric metrics.

The `IExposureMetrics` interface provides typed access to each metric. The convenience methods (`getPotentialFutureExposure()`, `getExpectedExposure()`, and so on) delegate to `getExposureMetric(...)`:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
public interface IExposureMetrics {
  @Nullable NamedCopperMeasure getExposureMetric(final ExposureMetric exposureMetric);
  @Nullable
  @MeasureMetadata(
      "{action} potential future exposure, the bank-side exposure at the selected confidence"
          + " level for each simulation time point.")
  default NamedCopperMeasure getPotentialFutureExposure() {
    return getExposureMetric(ExposureMetric.PFE);
  }
  @Nullable
  @MeasureMetadata(
      "{action} expected exposure, the average of the positive bank-side exposures at each"
          + " simulation time point.")
  default NamedCopperMeasure getExpectedExposure() {
    return getExposureMetric(ExposureMetric.EE);
  }
  @Nullable
  @MeasureMetadata(
      "{action} expected negative exposure, the average of the counterparty-side exposures at"
          + " each simulation time point.")
  default NamedCopperMeasure getExpectedNegativeExposure() {
    return getExposureMetric(ExposureMetric.ENE);
  }
  @Nullable
  @MeasureMetadata(
      "{action} expected shortfall of the bank-side exposure, the average of the exposures"
          + " beyond the potential future exposure threshold.")
  default NamedCopperMeasure getExpectedShortfall() {
    return getExposureMetric(ExposureMetric.ES);
  }
  @Nullable
  @MeasureMetadata(
      "{action} index position of the scenario driving the potential future exposure within the"
          + " sorted exposure vector.")
  default NamedCopperMeasure getPfeIndex() {
    return getExposureMetric(ExposureMetric.PFE_INDEX);
  }
  @Nullable
  @MeasureMetadata(
      "{action} name of the scenario driving the potential future exposure at each simulation"
          + " time point.")
  default NamedCopperMeasure getPfeScenarioName() {
    return getExposureMetric(ExposureMetric.PFE_SCENARIO_NAME);
  }
}
```

## How are the metrics computed?

Each metric is computed per time point from the exposure vector of the selected family, which holds one value per scenario. The sections below name each metric by its plugin key.

### ExpectedExposure (plugin key: `ExpectedExposure`)

EE is the mean, across the scenarios, of the positive part of the bank-side exposure vector multiplied element by element by the scenario discount factor vector, then multiplied by the discount factor. It is computed per time point. When no scenario discount factor vector is available, the exposure vector is used as is.

### ExpectedNegativeExposure (plugin key: `ExpectedNegativeExposure`)

ENE is computed like EE, from the counterparty-side exposure vector.

### PotentialFutureExposure (plugin key: `PotentialFutureExposure`)

PFE is the $K$-th largest value of the exposure vector at a time point. The rule is:

1. Read the confidence level $\alpha$ from the Confidence Levels dimension member.
2. Compute $K$ from the number of scenarios $N$ and $\alpha$, rounded with the configured rounding method: $K = \text{round}\bigl(N \times (100 - \alpha) / 100\bigr)$. If $K$ is 0, $K$ is 1.
3. PFE at the time point is the $K$-th largest exposure value.
4. Where the measure aggregates time points, the result is the maximum PFE across the time points.

The rounding method is set per cube. See [Configuration](../../reference/configuration). For the formula and a worked explanation, see [How is PFE calculated?](../../../../solutions/counterparty-credit-risk/pfe/user-guide/calculations).

### ExpectedShortfall (plugin key: `ExpectedShortfall`)

ES is the mean of the $K$ largest values of the bank-side exposure vector at a time point, the tail scenarios. $K$ follows the same rule as for PFE, including the configured rounding method. Where the measure aggregates time points, the result is the maximum across the time points.

### PFEIndex (plugin key: `PFEIndex`)

PFE Scenario Index is the position, in the exposure vector, of the scenario that gives the PFE value. It uses the same $K$ as PFE. The cube adds the `index-offset` setting of the scenarios properties to the index, so that, with the default offset of 1, scenarios are numbered from 1. See the [scenarios properties](../../../../common/reference/configuration-properties#scenarios). The measure is not aggregated above the time point level.

### PFEScenarioName (plugin key: `PFEScenarioName`)

PFE Scenario Name maps the PFE Scenario Index to the name that the cube assigns to that scenario. The names come from the scenarios properties. See the [scenarios properties](../../../../common/reference/configuration-properties#scenarios).

## How are metrics applied to each exposure family?

Each metric applies to whichever exposure vector family it is computed from. The same definitions produce EE, PFE, and ES for gross, netted, and collateralized exposure. The measure name in the cube reflects the family (for example, gross PFE vs. netted PFE).

The `IExposureAndMetricsMeasures` interface combines an exposure vector family with its metrics:

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

The `IInframarginalExposureAndMetricsMeasures` interface adds 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();
}
```

## Related pages

* [Exposure concepts](../../introduction/exposure-concepts)
* [Exposure measures](./exposure-measures)
* [Incremental contribution measures](./incremental-contribution-measures)
* [Enums reference](../../reference/enums)
* [Configuration](../../reference/configuration)
