This chapter requires:
- XVA-01: Expected Exposure EE$(t)$ and EPE
- XVA-02: Netted/collateralised portfolio EE$(t)$ per netting set
You should understand what a CDS spread represents (introduced in this chapter). The CVA formula is derived from first principles; no credit derivatives background assumed.
By the end, you can compute CVA from an exposure profile and a hazard rate curve, and know which assumptions the formula requires.
The problem CVA solves
Suppose you enter a ten-year interest rate swap with a corporate counterparty. On day one, the swap is at-the-money and worth zero to both sides. Over the next few years, rates move and the swap becomes valuable to you: your counterparty owes you net present value. Now suppose they default. They stop paying. You close out the trade and recover some fraction of what they owed you, but not all of it.
This is counterparty credit risk, and it creates a loss that has nothing to do with rates moving against you. It is a credit loss caused by the coincidence of two things: your trade being in-the-money and your counterparty being insolvent. CVA is the expected present value of that loss, computed at trade inception and charged as an upfront adjustment to the risk-free price.
Formally, if $V^{\text{rf}}$ is the risk-free mark-to-market of the derivative, then the price you should quote to a counterparty with non-trivial default risk is:
The sign convention is from your perspective: you lose money if your counterparty defaults when the trade is in-the-money for you ($V > 0$). So CVA is always non-negative, and it reduces the value you ascribe to a trade.
Deriving the CVA formula
Consider a derivative with maturity $T$ between you and a counterparty. Assume that on default, you recover a fraction $R$ (the recovery rate) of the amount owed. If your counterparty defaults at time $\tau \leq T$ and at that moment the trade has value $V(\tau) > 0$ to you, your loss is $(1 - R) \cdot V(\tau)$. If $V(\tau) \leq 0$ at default, you owe them money, and counterparty default actually benefits you; we ignore that asymmetry for now (it gives rise to DVA, discussed at the end).
Throughout this XVA series, $\tau$ denotes the counterparty's default time (a random variable, distinct from the day-count fraction $\tau_j$ used in the IR series). The loss at default time $\tau$ is $(1-R) \cdot V^+(\tau)$, where $V^+(\tau) = \max(V(\tau), 0)$ is the positive part. Discounting back to today and taking expectations under the risk-neutral measure $\mathbb{Q}$, the discount factor is the genuinely stochastic accumulator $\beta(0,\tau)^{-1} = \exp(-\int_0^\tau r_s\,ds)$, evaluated at the random time $\tau$:
Note the difference between $e^{-\int_0^\tau r_s\,ds}$ (random, depends on the path of $r$ up to the random time $\tau$) and the deterministic curve $P(0,t) = \mathbb{E}^{\mathbb{Q}}\!\bigl[e^{-\int_0^t r_s\,ds}\bigr]$ (a function of a fixed maturity $t$). The substitution of the deterministic $P(0,t)$ for the stochastic accumulator is only legal after we condition on $\tau$ and invoke an independence assumption two steps below.
To evaluate this, condition on the default time $\tau$. Since $\tau$ has density $f_\tau(t) = \frac{d}{dt}\text{PD}(t)$ under $\mathbb{Q}$, the law of total expectation converts the outer expectation into an integral over all possible default times:
To pull the bond price out of the conditional expectation we need two assumptions, jointly known as the independence assumption for unilateral CVA: the default time $\tau$ is independent of both the short-rate process $r$ and the exposure process $V$, and (for stochastic-rate models) the rate and exposure processes are themselves independent under $\mathbb{Q}$ (or, equivalently, $V^+(t)$ is interpreted in the $T_t$-forward measure with the $T_t$-forward EE; see Brigo, Morini & Pallavicini 2013, Ch. 13, and Crépey 2015, Ch. 4). Under these assumptions:
This gives the working CVA formula:
R: recovery rate on the counterparty's debt; typically 40% for investment-grade, lower for sub-investment-grade
P(0,t): the risk-free discount factor (zero-coupon bond price from the yield curve)
EE(t) $= \mathbb{E}^{\mathbb{Q}}[\max(V(t), 0)]$: Expected Exposure at time $t$, as defined in XVA Chapter 01
dPD(t): the marginal probability that the counterparty defaults in $[t, t+\mathrm{d}t]$, derived from the CDS market
The integral runs over the life of the trade. At each instant, you weight the exposure you are running by the probability of losing it. The $(1-R)$ factor accounts for the partial recovery you receive from the bankruptcy estate.
This is an expectation over two sources of randomness: the evolution of rates (which drives $V(t)$ and hence $\text{EE}(t)$) and the timing of default (which drives dPD). The standard simplifying assumption, sometimes called the independence assumption, is that these two are uncorrelated. When they are correlated (a high-rate environment that causes the counterparty's distress at the same time it makes the swap valuable to you), the effect is called wrong-way risk and materially increases CVA.
The EE profile used in this formula is built in IR Chapter 08 (Draft) (which reprices the swap on every Monte Carlo path) and analysed in XVA Chapter 01 (which defines EE, EPE, EEE, EEPE, and PFE). We assume the profile is available and focus here on the CVA integral itself.
Default probability from the CDS market
The other ingredient is the term structure of default probabilities for your counterparty. Rather than using historical default frequencies, CVA uses risk-neutral default probabilities implied by the credit default swap (CDS) market. The CDS spread $s(T)$ for tenor $T$ is the annual premium the market charges to insure against default over $[0, T]$. From this spread we can extract a hazard rate $\lambda(t)$, the instantaneous conditional probability of defaulting in the next instant given survival to $t$.
Under a flat hazard rate assumption (constant $\lambda$), the survival probability to time $t$ is:
The marginal default probability in $[t, t+\mathrm{d}t]$ is then $\mathrm{d}\text{PD}(t) = \lambda e^{-\lambda t}\,\mathrm{d}t$. For a counterparty with a 5-year CDS spread of $s$ basis points and a recovery rate $R$, the hazard rate is approximately:
s: annual CDS spread in decimal form (e.g., 80 bp = 0.0080; always convert from basis points before applying this formula)
R: recovery rate (e.g., 0.40)
A CDS contract has two legs. The protection leg pays $(1-R)$ at default. The premium leg pays the spread $s$ continuously until default or maturity $T$. At inception, the two legs are equal:
$$\underbrace{(1-R)\int_0^T e^{-(\lambda+r)t}\lambda\,dt}_{\text{protection leg}} = \underbrace{s\int_0^T e^{-(\lambda+r)t}\,dt}_{\text{premium leg}}$$
Under a flat hazard rate $\lambda$ and flat risk-free rate $r$, both integrals share the same kernel $e^{-(\lambda+r)t}$, which cancels. What remains is $(1-R)\lambda = s$, giving $\lambda = s/(1-R)$.
This identity is exact for continuous premium payments and constant $\lambda$. With discrete quarterly payments or a term structure of spreads, it becomes a first-order approximation. For precise calibration, bootstrap piecewise-constant hazard rates from the full CDS curve.
For example, a counterparty with a 5Y CDS spread of 80 bp and recovery rate 40% implies $\lambda \approx 0.0080\,/\,0.60 = 0.0133$, or 133 bp per year. The probability of surviving ten years is $e^{-0.0133 \times 10} \approx 87.5\%$, consistent with an investment-grade issuer.
In practice, CDS curves are not flat: the market quotes spreads at 1Y, 2Y, 3Y, 5Y, 7Y, and 10Y. You bootstrap a piecewise-constant hazard rate curve from these quotes, analogous to bootstrapping the yield curve from swap rates, as in IR Chapter 01. The survival probability at any date then becomes a product of survival probabilities over each interval.
Discretised CVA: a numerical example
For practical computation, the integral is discretised over monitoring dates $t_1 < t_2 < \cdots < t_M = T$. The marginal default probability in each interval is $\text{PD}(t_{j-1}, t_j) = Q(\tau > t_{j-1}) - Q(\tau > t_j)$:
To make this concrete, consider the following inputs for a 5-year payer swap with a notional of €10 million, against a counterparty with a flat CDS spread of 120 bp and recovery rate 40%:
Each contribution is $P(0,t_j) \cdot \text{EE}(t_j) \cdot \text{PD}(t_{j-1}, t_j)$, computed with $\lambda = s/(1-R) = 120/(10{,}000 \times 0.60) = 0.020$ and a flat 2% discount rate. The sum is €6,815. Multiplied by $(1 - R) = 0.60$, the CVA is approximately €4,089 (rounding from 4,088.7). This is the amount deducted from the risk-free value of the swap to reflect the possibility that the counterparty defaults while the swap is in-the-money.
The sum above evaluates $\text{EE}$ and $P(0,\cdot)$ at the right endpoint $t_j$ of each interval $[t_{j-1}, t_j]$, which matches the library implementation in xvafoundations.xva.cva. This right-point quadrature is first-order accurate: halving the step size halves the error. The trapezoidal rule, which averages the contributions at both endpoints of each interval, is second-order accurate and significantly better for smooth EE profiles. In practice, quarterly monitoring dates ($M = 20$ for a 5-year trade) combined with trapezoidal quadrature is standard and sufficient for most portfolios.
The EE profile in the table is hump-shaped: small at year 1 (the swap just started and residual uncertainty is low relative to remaining cashflows), largest at year 3 (uncertainty has had time to build, there is still significant time left), and falling by year 5 (most cashflows have been paid, little exposure remains). This shape is characteristic of swaps and differs markedly from, say, a cross-currency swap where principal re-exchange at maturity creates a spike in EE at the end.
How CVA scales
Before moving to implementation, it is worth building intuition for how CVA responds to changes in its key inputs. The CVA formula is a product of loss-given-default, discounted expected exposure, and default probability, so each factor drives a distinct scaling behaviour.
Notional. CVA scales linearly with notional. The expected exposure $\text{EE}(t)$ is proportional to the notional of the underlying trade, so doubling the notional doubles CVA.
Maturity. CVA scales super-linearly with maturity for swaps. A longer trade has more monitoring dates where default can occur while exposure is outstanding. Additionally, EE profiles tend to grow before they decay, so extending maturity adds high-exposure intervals rather than low-exposure ones. A 10-year swap typically has more than twice the CVA of a 5-year swap on the same notional.
Volatility. Higher volatility typically increases CVA for at-the-money trades. The expected exposure $\text{EE}(t) = \mathbb{E}^{\mathbb{Q}}[\max(V(t), 0)]$ is option-like, so when $\mathbb{E}^{\mathbb{Q}}[V(t)]$ is held fixed, Jensen's inequality on the convex function $x \mapsto x^+$ gives a one-sided benefit from dispersion. The argument is cleanest at-the-money; for a deep in-the-money trade the positive part is approximately linear over the bulk of the distribution, and additional volatility can shift mass into the negative tail (where the max is zero) without proportionally raising the positive tail, so the relationship can weaken or even reverse. The unconditional rule of thumb "more vol, more CVA" should be read as an ATM statement.
Hazard rate. For small CDS spreads, CVA is approximately linear in the hazard rate $\lambda$ (and hence in the spread $s$). As spreads widen, survival probabilities $e^{-\lambda t}$ decay faster, compressing the contributions from later monitoring dates. The relationship becomes sub-linear: doubling the spread of a distressed counterparty does not double CVA because the survival-weighted exposure at longer tenors is already heavily discounted.
Computing CVA in code
The library provides compute_cva in xvafoundations.xva.cva. It takes an EE profile (produced in XVA Chapter 01), discount factors, a survival curve, and the recovery rate:
import torch
from xvafoundations.xva.exposure import compute_ee, compute_ene
from xvafoundations.xva.cva import compute_cva, compute_dva
# ── Assume EE profile already computed (see XVA Ch.01) ──────────────
# mtm_paths: (2000, 40) from HW simulation + swap repricing (IR Ch.08)
# times: quarterly grid 0.25..10.0
ee = compute_ee(mtm_paths) # shape (40,)
ene = compute_ene(mtm_paths) # shape (40,)
# ── Credit data: flat CDS spread 120 bp, recovery 40% ──────────────
hazard_rate = 0.0120 / (1.0 - 0.40) # lambda = s / (1-R)
survival = torch.exp(-hazard_rate * times)
discount = torch.exp(-0.02 * times) # flat 2% risk-free rate
# ── CVA and DVA ─────────────────────────────────────────────────────
cva = compute_cva(ee, times, discount, survival, recovery=0.40)
dva = compute_dva(ene, times, discount, survival, own_recovery=0.40)
print(f"CVA = EUR {cva.item():,.0f}")
print(f"DVA = EUR {dva.item():,.0f}")
print(f"Bilateral adjustment = EUR {(dva - cva).item():,.0f}")
The exposure simulation and repricing happen upstream. In production, the pricer is fully analytical (Hull-White has a closed-form formula for swap MTM as a function of the simulated state variables), making the inner loop fast enough to run thousands of paths across hundreds of monitoring dates in seconds. The CVA computation itself is pure tensor arithmetic and adds negligible cost.
CVA Greeks: sensitivities that matter
CVA is not just a number charged upfront and forgotten. The desk that manages CVA hedges it dynamically, which requires sensitivities. The two most important are:
CS01 (credit spread delta): the change in CVA for a 1 bp parallel shift in the counterparty's CDS curve. This hedges the credit component of CVA and is typically executed by buying CDS protection. CS01 is approximately $(1-R)\int_0^T P(0,t)\cdot\text{EE}(t)\cdot\frac{\partial}{\partial\lambda}(\lambda e^{-\lambda t})\,\mathrm{d}t$, which simplifies to a weighted average maturity exposure.
IR Delta: the change in CVA for a shift in the risk-free yield curve. Because EE is computed from simulated rate paths, a shift in the curve changes the swap mark-to-market on every path, which changes the EE profile, which changes CVA. This hedging overlay interacts with the interest rate hedge on the underlying swap and must be managed jointly.
In addition, there is a cross-gamma between credit spreads and rates: when rates rise, a payer swap gains value (EE rises), and if a credit-stressed counterparty's CDS spread also widens when rates rise (common in a rising-rate, recession-risk environment), CVA increases non-linearly. This is wrong-way risk materialising in the Greeks.
Wrong-way risk
The CVA formula derived above relies on the independence assumption: the exposure process $V^+(t)$ and the default time $\tau$ are uncorrelated. In practice, this assumption is often violated. Wrong-way risk (WWR) arises when there is positive dependence between exposure and the probability of default. A counterparty is more likely to default precisely when your exposure to them is large, amplifying expected losses beyond what the independence-based formula predicts.
Formally, WWR is a statement about the conditional expectation along the default-time slice rather than a static correlation: it arises whenever $\mathbb{E}^{\mathbb{Q}}[V^+(t)\,|\,\tau = t] > \mathbb{E}^{\mathbb{Q}}[V^+(t)]$, i.e. exposure is on average larger on default-time scenarios than across all scenarios (Hull and White 2012, "CVA and Wrong-Way Risk"; Brigo, Morini & Pallavicini 2013, Ch. 13). Under WWR the conditional expectation $\mathbb{E}^{\mathbb{Q}}[e^{-\int_0^t r_s\,ds}\,V^+(t)\,|\,\tau = t]$ can no longer be replaced by $P(0,t)\,\text{EE}(t)$, and the CVA integral does not factor into a product of exposure and default probability.
Copula-based approach. One standard technique models the joint distribution of the market risk driver (e.g., the short rate in a Hull-White model) and the default time using a Gaussian copula. The copula parameter $\rho$ controls the strength of dependence: $\rho = 0$ recovers the independence case, while $\rho > 0$ introduces WWR. With non-zero $\rho$, the CVA must be computed by jointly simulating the rate paths and default times, evaluating $V^+(t)$ on each path conditional on default occurring at $t$, and averaging. The factorisation into $\text{EE}(t) \times dPD(t)$ no longer holds, and the computational cost increases accordingly. See Brigo, Morini & Pallavicini (2013) for a detailed treatment of copula-based WWR models.
BSDE framework. An alternative approach, developed by Crépey (2015), formulates the CVA as the solution of a backward stochastic differential equation (BSDE). In this framework, the CVA process is solved jointly with the exposure and default intensity as a coupled system. The key advantage is that the independence assumption is never imposed: the dependence structure between market risk factors and default emerges naturally from the dynamics of the BSDE. This makes the framework particularly well-suited to wrong-way risk, though it requires numerical methods (typically regression-based Monte Carlo) that are more involved than the standard factored approach.
A note on DVA
The formula above is unilateral CVA: it only captures the risk that your counterparty defaults. In reality, you might also default, and from your counterparty's perspective that is a risk for them. The symmetric adjustment (the value of your own default risk to them) is DVA, Debt Valuation Adjustment. Under full bilateral netting:
DVA has a sign that feels counterintuitive: your own credit deteriorating makes you a worse counterparty, which makes your DVA larger, which increases the value of your liabilities. Banks that include DVA in P&L can report gains when their own credit spreads widen. This is economically correct but creates accounting anomalies and is the subject of ongoing regulatory scrutiny. FVA (Funding Valuation Adjustment) is a related quantity that captures the cost of funding the collateral on uncollateralised exposures, and it has partially displaced DVA in practitioner thinking.
We have completed the Interest Rate Modeling Series and are now in the XVA Series. IR Chapter 01 bootstrapped discount factors from market swap rates. IR Chapter 02 separated discounting from rate projection. IR Chapter 03 introduced the swaption volatility surface and pricing. IR Chapter 04 showed stochastic short-rate dynamics via the Vasicek model. IR Chapter 05 (Draft) derived Hull-White and extended it to three correlated factors. IR Chapter 06 (Draft) calibrated those parameters to the swaption market. IR Chapter 08 (Draft) computed mark-to-market on every path. This chapter (XVA Chapter 03) assembles the final piece: the $\text{EE}(t)$ profile, the hazard rate, and the CVA integral. The mechanics of a complete, production-grade XVA engine are now on the table.
References
- Gregory, J. (2020). The xVA Challenge (4th ed.). Wiley. The standard practitioner reference on CVA, DVA, FVA, and all valuation adjustments.
- Crépey, S. (2015). Counterparty Risk and Funding: A Tale of Two Puzzles. Chapman & Hall/CRC. Rigorous mathematical treatment of counterparty risk and funding costs.
- Green, A. (2015). XVA: Credit, Funding and Capital Valuation Adjustments. Wiley. Practical guide to implementing XVA in a trading environment.
- Brigo, D., Morini, M. & Pallavicini, A. (2013). Counterparty Credit Risk, Collateral and Funding. Wiley. Covers bilateral CVA, wrong-way risk, and collateral modelling.
- Hull, J. & White, A. (2012). "CVA and Wrong-Way Risk." Financial Analysts Journal, 68(5), 58-69. The conditional-expectation definition of WWR adopted in this chapter.
- Cesari, G., Aquilina, J., Charpillon, N., Filipović, Z., Lee, G. & Manda, I. (2009). Modelling, Pricing, and Hedging Counterparty Credit Exposure. Springer. Detailed treatment of EPE/ENE profiles and exposure simulation.
- Brigo, D. & Mercurio, F. (2006). Interest Rate Models: Theory and Practice (2nd ed.). Springer. Foundation for the rate models underlying XVA computations.
This completes the core XVA pipeline: from interest rate model (IR series) to exposure (XVA-01) to aggregation (XVA-02) to CVA pricing (XVA-03).
The framework presented here assumes independence between exposure and default probability (no wrong-way risk), constant recovery, and a single-currency interest rate portfolio. Extensions (FVA, KVA, SA-CVA, wrong-way risk, multi-asset models) build on this foundation.