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:
The negative counterpart is equally important for DVA. When you default, your counterparty suffers a loss proportional to the amount you owe them:
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:
In a Monte Carlo simulation with $N$ paths, the estimator is:
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:
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:
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:
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:
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.
Risk-neutral vs. real-world measure
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.
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.
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.
# ── 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)$:
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:
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
- Gregory, J. (2020). The xVA Challenge: Counterparty Risk, Funding, Collateral, Capital and Initial Margin, 4th ed. Wiley.
- Crépey, S. (2015). Bilateral counterparty risk under funding constraints, Part I and II. Mathematical Finance, 25(1).
- Brigo, D., Morini, M. & Pallavicini, A. (2013). Counterparty Credit Risk, Collateral and Funding. Wiley.
- Cesari, G., Aquilina, J., Charpillon, N., Filipovic, Z., Lee, G. & Manda, I. (2009). Modelling, Pricing, and Hedging Counterparty Credit Exposure. Springer.
- Basel Committee on Banking Supervision (2014). BCBS 279: The standardised approach for measuring counterparty credit risk exposures.
- Pykhtin, M. & Zhu, S. (2007). A guide to modelling counterparty credit risk. GARP Risk Review, July/August.
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.