Prerequisites

This chapter requires:

  • IR-08 (draft): the mark-to-market matrix $V(t, \omega)$: value of a derivative at each simulation date $t$ and path $\omega$
  • XVA-00: the XVA pipeline overview

You should understand what mark-to-market means. No prior knowledge of exposure metrics (EE, EPE, PFE) or regulatory capital frameworks is assumed.

By the end, you can compute EE, EPE, PFE, and EEPE from a simulated mark-to-market matrix.

What is exposure?

Consider a derivative contract between two counterparties, with mark-to-market value $V(t)$ from your perspective. If your counterparty defaults at time $t$ while $V(t) > 0$, you have a claim against the estate for the amount $V(t)$, but you will only recover a fraction. If $V(t) < 0$ when your counterparty defaults, you owe them; the full liability is preserved by the administrator. The loss is therefore asymmetric.

This asymmetry defines exposure. On a single simulated path, the exposure at time $t$ is the loss you would suffer if default happened then:

Single-path exposure $$E(t) = \max(V(t),\, 0)$$
$V(t)$: mark-to-market value of the position at time $t$, from the perspective of the surviving party. $E(t) \geq 0$ always: if $V(t) < 0$ you owe the counterparty, so there is no credit exposure.

The negative counterpart is equally important for DVA. When you default, your counterparty suffers a loss proportional to the amount you owe them:

Negative exposure (feeds DVA) $$E^{-}(t) = \max(-V(t),\, 0) = (-V(t))^+$$

On a single path these are easy to compute. The challenge, and the whole point of XVA, is that we do not know which path the market will take. We need to aggregate across scenarios.

Expected Exposure and EPE

The Expected Exposure at time $t$ is the risk-neutral expectation of the single-path exposure, averaged over the full distribution of paths:

Expected Exposure $$\text{EE}(t) = \mathbb{E}^{\mathbb{Q}}\!\left[\max(V(t),\, 0)\right]$$

In a Monte Carlo simulation with $N$ paths, the estimator is:

Monte Carlo estimator $$\widehat{\text{EE}}(t_j) = \frac{1}{N} \sum_{i=1}^{N} \max(V_i(t_j),\, 0)$$
$V_i(t_j)$: MtM on path $i$ at time grid point $t_j$. $N$: number of simulated paths. In production, $N \geq 5{,}000$; 2,000 is adequate for illustration.

The EE profile for an interest rate swap has a characteristic hump shape. At inception, the swap is at-market so $V(0) = 0$ and EE is small. Uncertainty builds as rates diffuse away from their initial values, so EE rises through the first few years. Eventually the remaining cashflows diminish and EE collapses back toward zero near maturity. The hump peaks at roughly one-third to one-half of the swap tenor.

The Expected Positive Exposure (EPE) summarises the entire EE profile as a single number, the time-average:

Expected Positive Exposure (EPE) $$\text{EPE} = \frac{1}{T} \int_0^T \text{EE}(t)\, dt$$
$T$: trade maturity. The integral is approximated by the trapezoidal rule over the simulation time grid. EPE is used as a summary measure of credit exposure for loan equivalent calculations and internal risk limits.
Expected Exposure profile: 10Y payer IRS (illustrative)
Stylised EE(t) shape for a 10-year payer swap: the hump peaks around year 4 as rate uncertainty accumulates before declining cashflows dominate. The curve is a closed-form analytic stand-in (not a Monte Carlo run) used purely to illustrate the qualitative shape; the genuine Hull-White EE profile, repriced path-by-path, is built in IR Chapter 08.

Effective EPE and regulatory capital

For regulatory capital under the Internal Model Method (IMM), Basel III imposes an additional non-decreasing constraint on the exposure profile. A bank cannot reduce its regulatory capital estimate simply because EE temporarily dips on the simulation grid. The Effective Expected Exposure takes the running maximum:

Effective Expected Exposure (EEE) $$\text{EEE}(t_j) = \max_{k \leq j}\, \text{EE}(t_k)$$

By construction, EEE is non-decreasing. It equals EE on the ascending portion of the hump, then freezes at the peak value as EE declines.

The Effective EPE then integrates EEE over the first year (or trade maturity if shorter), as specified in BCBS 279:

Effective EPE (BCBS 279, Basel III IMM) $$\text{EEPE} = \frac{1}{\min(1,T)} \int_0^{\min(1,T)} \text{EEE}(t)\, dt$$
The one-year cap is a Basel III requirement: long-dated trades do not get capital relief simply by having a low short-term exposure profile. EEPE $\geq$ EPE always. The exposure-at-default in the IMM capital formula is $\alpha_{\text{IMM}} \cdot \text{EEPE}$ where the supervisory scaling factor $\alpha_{\text{IMM}} = 1.4$ (BCBS 279, paragraph 37). The subscript distinguishes this constant from the PFE quantile level $\alpha$ defined later in this chapter.
EE vs. EEE: running-maximum envelope
EEE (red) is the running maximum of EE (grey). It freezes at the peak value as EE declines. The EEPE integrates EEE over the first year.

Potential Future Exposure

EE is a mean. For credit limit management, a mean is not conservative enough: a counterparty who exceeds a credit limit 50% of the time is not well-managed. Potential Future Exposure is the exposure at a high confidence level:

Potential Future Exposure $$\text{PFE}(t,\, \alpha) = Q_{\alpha}\!\left[\max(V(t),\, 0)\right]$$
$Q_\alpha$: the $\alpha$-quantile of the cross-sectional distribution at time $t$. $\alpha = 97.5\%$ is the standard for credit limit management (Gregory 2020, ch. 7). Some desks use 99% for stress. PFE$(t, \alpha) \geq$ EE$(t)$ for all $\alpha > 0.5$, since EE is the mean and PFE is a tail quantile.

In the Monte Carlo estimator, sort the $N$ values $\{\max(V_i(t_j),\, 0)\}$ in ascending order and take the $\lceil \alpha N \rceil$-th order statistic (counting from the smallest). For $N = 2{,}000$ paths at $\alpha = 97.5\%$, that is the $1{,}950$-th value in ascending order, i.e. the $51$-st largest. Equivalently, only $50$ paths exceed it. The library uses torch.quantile, which linearly interpolates between adjacent order statistics and so returns a value strictly between the $1{,}950$-th and $1{,}951$-st of the sorted positive exposures; for tail quantiles on $N = 2{,}000$ samples the discrepancy with the pure order-statistic estimator is sub-percent.

All exposure metrics: 10Y payer IRS
EE (grey), EEE running maximum (dashed crimson), PFE 97.5% (solid crimson), and ENE (teal). PFE sits well above EE; the ratio depends on model volatility $\sigma$. ENE is the mirror image feeding DVA.

Risk-neutral vs. real-world measure

The most frequently misunderstood point in XVA

CVA is computed under the risk-neutral measure $\mathbb{Q}$. Regulatory capital uses real-world exposure. These are different numbers, produced by different models, and must not be conflated.

CVA pricing uses $\mathbb{Q}$. CVA is a derivative price: the cost of hedging the counterparty default risk embedded in a portfolio. Like any derivative price, it must be arbitrage-free with respect to observable market instruments. The EE profiles used in CVA pricing are therefore computed under the risk-neutral measure calibrated to market implied vols and CDS spreads. Real-world drift has no place in a CVA calculation: a risk manager who replaces $\mathbb{Q}$ with $\mathbb{P}$ in the CVA integral will systematically misprice the hedge.

Regulatory capital uses $\mathbb{P}$. IMM capital is meant to reflect the real-world likelihood of large exposures occurring, and Basel III explicitly requires stress-period historical calibration for the IMM exposure-at-default (BCBS 279, paragraph 32). PFE for internal limit management is a desk choice on which industry practice is divided: many large dealers run PFE under $\mathbb{P}$ to align with capital and stress narratives, while others stay in $\mathbb{Q}$ for engine consistency with the front-office pricing chain (Gregory 2020, ch. 8). The two answers are not the same number; the choice should be stated explicitly in any limit framework.

In practice, large XVA desks maintain two separate simulation engines running in parallel: a risk-neutral engine for CVA/DVA/FVA pricing, and a real-world engine for IMM capital and credit limit monitoring. The code in this series computes the risk-neutral version throughout.

SA-CCR as the standardised alternative. Banks without IMM approval use the Standardised Approach for Counterparty Credit Risk (SA-CCR), introduced in BCBS 279 as a replacement for CEM and SM. SA-CCR uses regulatory add-ons per asset class and netting set rather than internal simulation. It is simpler but structurally less sensitive to portfolio composition and collateral than an IMM model.

Exposure profiles by product type

Each product class produces a structurally distinct EE shape. Understanding these shapes is essential for building intuition about where XVA costs concentrate.

EE profiles: rates products (10Y tenor, illustrative)
An IRS has a hump-shaped EE (rate diffusion builds, then remaining cashflows shrink). A CCS shows a similar hump but spikes at maturity due to the notional re-exchange in a foreign currency.
EE profiles: non-rates products (illustrative)
An FX forward has monotonically growing exposure driven by FX diffusion toward a single settlement date. A bought European option (e.g. a swaption) has maximum exposure at inception, decaying as time value erodes.

The CCS spike is the canonical example of why product shape matters for CVA. A 10-year EUR/USD CCS with $100M notional re-exchange at maturity carries a PFE at year 9.9 that dwarfs the entire IRS profile. XVA desks managing mixed portfolios must account for this heterogeneity rather than using a uniform exposure estimate.

Computing exposure in code

The library provides all exposure functions in xvafoundations.xva.exposure. The worked example below uses 2,000 illustrative random-walk MtM paths to keep this chapter self-contained; the genuine Hull-White repricing of a 10-year payer swap is built in IR Chapter 08 and the resulting MtM tensor can be substituted directly into the same exposure pipeline.

Python · PyTorch
import torch
from xvafoundations.xva.exposure import (
    compute_ee, compute_ene, compute_eee, compute_eepe, compute_pfe
)

# ── Simulate MtM paths under Hull-White 1F ──────────────────────────
# Assume `simulate_hw1f` returns (num_paths, num_times) MtM tensor
# for a 10Y payer IRS with notional=1, strike=0.03, dt=0.25
# (see Ch.08 of the IR series for the full simulation code)

num_paths = 2000
times = torch.arange(0.25, 10.25, 0.25, dtype=torch.float64)  # quarterly, 10Y

# mtm_paths: shape (2000, 40)
# Simplified diffusion paths for illustration; in production, use HW simulation from IR Chapter 08.
torch.manual_seed(42)
increments = torch.randn(num_paths, len(times), dtype=torch.float64) * 0.02
mtm_paths = increments.cumsum(dim=1)  # simplified; use HW paths in practice

# ── Compute exposure metrics ─────────────────────────────────────────
ee   = compute_ee(mtm_paths)            # EE(t_j): shape (40,)
ene  = compute_ene(mtm_paths)           # ENE(t_j): shape (40,)
eee  = compute_eee(ee)                  # EEE(t_j): running maximum
eepe = compute_eepe(ee, times, cap=1.0) # EEPE: scalar
pfe  = compute_pfe(mtm_paths, alpha=0.975)  # PFE(97.5%): shape (40,)

print(f"EEPE = {eepe.item():.6f}")
print(f"Peak EE at t = {times[ee.argmax()].item():.2f}Y: {ee.max().item():.6f}")
print(f"Peak PFE at t = {times[pfe.argmax()].item():.2f}Y: {pfe.max().item():.6f}")

The functions operate on any (num_paths, num_times) MtM tensor. In production you would replace the random-walk paths with paths from a properly calibrated Hull-White simulation as built in IR Chapter 08 (Draft). The exposure functions are pure PyTorch and autodifferentiable, so XVA sensitivities (CS01, IR delta) can be obtained by backpropagating through the full chain: rates → HW paths → MtM → EE → CVA.

Python · full metric output
# ── All metrics on a single time grid ───────────────────────────────
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(10, 5))
t = times.numpy()
ax.plot(t, ee.numpy(),  color='#9E978B', lw=1.5, label='EE')
ax.plot(t, eee.numpy(), color='#B91C2F', lw=1.5, linestyle='--', label='EEE')
ax.plot(t, pfe.numpy(), color='#B91C2F', lw=2.0, label='PFE 97.5%')
ax.plot(t, ene.numpy(), color='#0f766e', lw=1.5, linestyle=':', label='ENE')
ax.set_xlabel('Time (years)'); ax.set_ylabel('Exposure')
ax.set_title('Full exposure profile: 10Y payer IRS')
ax.legend(); plt.tight_layout(); plt.show()

Negative exposure and DVA

ENE is the expected value of the negative part of $V(t)$:

Expected Negative Exposure $$\text{ENE}(t) = \mathbb{E}^{\mathbb{Q}}\!\left[\max(-V(t),\, 0)\right]$$

ENE is to DVA what EE is to CVA. DVA is the value of your own default optionality: if you default while you owe the counterparty, you effectively have a claim on your own liability. The DVA formula is structurally identical to the CVA formula with EE replaced by ENE and the counterparty's survival curve replaced by your own:

DVA (unilateral, symmetric form) $$\text{DVA} = (1 - R_{\text{own}}) \sum_{j=1}^{n} P(0, t_j)\cdot \text{ENE}(t_j)\cdot \text{PD}_{\text{own}}(t_{j-1}, t_j)$$

For a payer swap, the holder benefits from rising rates, so $V(t) > 0$ more often than $V(t) < 0$. EE exceeds ENE, and CVA exceeds DVA. A receiver swap is the mirror image. A symmetric product like a cross-currency swap with zero initial value has EE $\approx$ ENE in the risk-neutral measure. These relationships are explored in detail in Chapter 03: CVA, where the bilateral valuation adjustment $V^{\text{bilateral}} = V^{\text{rf}} - \text{CVA} + \text{DVA}$ is derived and computed end-to-end.

Summary

This chapter defined the full family of exposure metrics from first principles: expected exposure (EE), expected positive exposure (EPE), effective expected positive exposure (EEPE), potential future exposure (PFE), expected negative exposure (ENE), and effective expected exposure (EEE). Each metric was computed on simulated mark-to-market paths using pure PyTorch operations, making the entire chain autodifferentiable for downstream XVA sensitivity computation.

References

The exposure profiles (EE$(t)$, EPE, PFE) for a single trade are now in hand. In XVA-02, we extend to a full portfolio: multiple trades under a netting agreement, with collateral reducing net exposure. Netting can dramatically reduce EPE; the magnitude depends on trade correlation within the portfolio.