A five-year forward on SPY that is worth nothing today carries, on 21 August 2026, an expected positive exposure of 109.8 dollars per share at its end, and a 95% potential exposure of 518.8. If the counterparty defaults, we lose part of that. Pricing this risk against a counterparty that defaults 3% of the time each year gives a credit value adjustment of 5.47 dollars per share, about 0.7% of the price. This topic builds the exposure, the CVA and its relatives from scenarios.
Exposure
Where we are. The last topic priced the default of one company from the point of view of the seller of protection. Now the *other side of a derivative* might default. Take a forward contract: it is worth nothing when signed, but its value moves. If it is positive for us, the counterparty owes us money, and a default would lose us some of it. If it is negative, we owe money, and a default of the counterparty does not hurt us. So only the *positive part* of the value is at risk.
The amount we would lose if the counterparty defaulted at a given future time: the positive part of the value of the contract, max(V, 0). It is not known today, so we simulate many scenarios of the market and average. The average is the expected positive exposure (EPE), and the average of max(−V, 0), what we owe, is the expected negative exposure (ENE).
The EPE is an average, and risk managers also look at a bad but possible outcome: the potential future exposure (PFE), a high quantile (usually 95%) of the values, floored at zero. For a forward the value is the asset price minus the strike brought back from the maturity, and in each scenario it can be of either sign.
Worked example 1. *Problem:* a forward to buy at 100 in two years, with a rate of 5%. Four scenarios for the asset price at years 1 and 2 are [80, 70], [95, 100], [110, 120] and [125, 140]. What are the values, the EPE, the ENE and the 75% PFE? *Plan:* compute the values, then the three summaries. *Steps:* below.
paths = np.array([[80, 70], [95, 100], [110, 120], [125, 140.0]])1values = forward_values(paths, np.array([1.0, 2.0]), 100.0, 0.05, 2.0)print(values.round(4).tolist())print(epe(values).round(4).tolist(), ene(values).round(4).tolist(), pfe(values, 0.75).round(4).tolist())2
[[-15.1229, -30.0], [-0.1229, 0.0], [14.8771, 20.0], [29.8771, 40.0]] [11.1885, 15.0] [3.8115, 7.5] [18.6271, 25.0]
- 1One row per scenario, one column per time.
- 2The three summaries of the exposure.
*Check:* at year 1 the values are −15.1229, −0.1229, 14.8771 and 29.8771, because the strike is brought back one year at 5%. The EPE is (0 + 0 + 14.8771 + 29.8771) / 4 = 11.1885 and the ENE is 3.8115. At year 2 the values are −30, 0, 20 and 40, with an EPE of 15 and an ENE of 7.5. The 75% PFE is 18.6271 and 25. *What to notice:* the EPE minus the ENE is the average value (7.3771 at year 1), and the PFE is well above the EPE: the typical loss is much smaller than the loss in a bad scenario.
The credit value adjustment
If the counterparty defaults in a year, we lose the exposure at that time, except for the part we recover. The expected loss is the credit value adjustment (CVA): add up, over the years, the discounted exposure times the probability of default inside that year times the loss given default. The probability is the one of the credit topic, Q_(i−1) − Q_i. Exposure and default are treated as independent here, which is a simplification.
Worked example 2. *Problem:* the EPE at years 1 to 5 is 23.7, 34.2, 42.4, 49.9, 56.7, the par curve is 2%, 3%, 4%, 4.5%, 5%, the recovery is 40% and the counterparty has a hazard rate of 3% a year. What is the CVA? What if the hazard is 6%? *Plan:* bootstrap the discount factors, compute the survival probabilities, then the formula. *Steps:* below.
discount = bootstrap_discount(np.array([0.02, 0.03, 0.04, 0.045, 0.05]))exposure = np.array([23.7, 34.2, 42.4, 49.9, 56.7])print(round(cva(discount, exposure, survival_from_hazard([0.03] * 5), 0.4), 4))1print(round(cva(discount, exposure, survival_from_hazard([0.06] * 5), 0.4), 4))2
2.9656 5.4697
- 1The CVA with a hazard of 3%.
- 2The same exposure, a riskier counterparty.
*Check:* the CVA is 2.9656 with a hazard of 3% and 5.4697 with 6%: the price of the contract falls by that amount, per unit of the asset. The credit risk almost doubles but does not exactly double, because the survival probabilities are exponentials, not straight lines. *What to notice:* a counterparty that cannot default (survival all ones) gives a CVA of 0, and so does a recovery of 100%. The CVA is the credit topic and the exposure of this topic multiplied together.
DVA, funding and the other adjustments
The contract can also go the other way: we owe money, and *we* might default. Then the counterparty loses and we gain, because we do not pay all we owe. This gain is the debit value adjustment (DVA). It is the CVA formula with the expected negative exposure, our own survival and our own recovery. The bilateral adjustment is CVA minus DVA.
Two things reduce exposure in practice. Collateral is cash or securities that the counterparty posts as the value rises. With a threshold, collateral is asked only for the value above it, so the exposure left is max(V − threshold, 0). Netting means that all trades with one counterparty are added up before a default is settled: a gain on one trade is used to cover a loss on another. Netted exposure is max(V_A + V_B, 0), never larger than max(V_A, 0) + max(V_B, 0).
Worked example 3. *Problem:* use the scenarios of example 1. What are the DVA and the bilateral adjustment for the exposure of example 2 if our own hazard is 1.5%? What is the exposure left with a threshold of 10? What does a second trade, a short forward struck at 110, give in netting? *Plan:* apply the three functions. *Steps:* below.
print(round(dva(discount, exposure, survival_from_hazard([0.015] * 5), 0.4), 4), round(cva(discount, exposure, survival_from_hazard([0.03] * 5), 0.4) - dva(discount, exposure, survival_from_hazard([0.015] * 5), 0.4), 4))1print(collateralised_exposure(values, 10.0).round(4).tolist())2other = -forward_values(paths, np.array([1.0, 2.0]), 110.0, 0.05, 2.0)print(netting_benefit(values, other).round(4).tolist(), epe(values + other).round(4).tolist())3
1.5451 1.4205 [6.1885, 10.0] [10.2439, 17.5] [9.5123, 10.0]
- 1DVA and the bilateral adjustment (the exposure of example 2 is used on both sides to keep the numbers simple).
- 2Only the part above the threshold is at risk.
- 3The two trades together.
*Check:* the DVA is 1.5451, so the bilateral adjustment is 2.9656 − 1.5451 = 1.4205. With a threshold of 10 the EPE falls from [11.1885, 15] to [6.1885, 10]. The two trades together are worth 10 × exp(−0.05 × (2 − t)) in every scenario: 9.5123 at year 1 and 10 at year 2, so the netted EPE is [9.5123, 10] instead of the sum [19.7561, 27.5] of the two separate exposures, and the netting benefit is [10.2439, 17.5]. *What to notice:* the benefit is larger when the trades are opposite, and zero if one of them is empty.
CVA and DVA are not the only adjustments. The funding value adjustment (FVA) is the cost of financing positions that are not covered by collateral: if we have to borrow at a spread over the risk-free rate to pay a hedge, that spread times the discounted exposure is a cost. The capital value adjustment (KVA) is the cost of the capital that regulators require us to hold, and the margin value adjustment (MVA) is the cost of the initial margin posted to clearing houses. Together they are called XVA. We compute CVA and DVA only; the others follow the same pattern of discounted exposure times a cost.
The formula multiplies the exposure and the default probability as if they were unrelated. In reality, the two can move together: a bank that sold protection against a market fall is most likely to fail exactly when its exposure is greatest. This is called wrong-way risk, and it makes the true CVA larger than the formula says.
The XVA of a forward on three real days
Worked example 4. *Problem:* price the XVA of a five-year forward on SPY, struck at the forward price so that it is worth nothing today, on three real days, with a counterparty hazard of 3%, our hazard of 1.5% and a recovery of 40%. *Plan:* study takes the SPY price, the Treasury curve and the volatility of the last year of returns, simulates 20,000 scenarios, and computes all the quantities of this topic. *Steps:* below.
data = load_data()out = study(data)1for date, row in out.items(): print(date, round(row["vol"], 4), round(row["epe"][-1], 1), round(row["pfe"][-1], 1), round(row["cva"], 3), round(row["dva"], 3), round(row["cva_collateral"], 3))
2022-01-03 0.1298 56.7 267.9 3.288 1.725 1.936 2023-07-03 0.1938 91.8 458.3 4.583 2.404 3.377 2026-08-21 0.1291 109.8 518.8 5.467 2.869 3.365
- 1One result per date.
*Check:* the volatility of SPY was 12.98%, 19.38% and 12.91% on the three days, the EPE at five years 56.7, 91.8 and 109.8 and the 95% PFE 267.9, 458.3 and 518.8. The CVA is 3.288, 4.583 and 5.467, the DVA 1.725, 2.404 and 2.869. Collateral with a threshold of 10% of the price lowers the CVA to 1.936, 3.377 and 3.365. *What to notice:* the exposure of a forward grows with time, so most of the CVA comes from the last years. As a share of the SPY price (455.80, 433.56 and 765.72) the CVA is 0.72%, 1.06% and 0.71%: it follows the volatility, which was high in 2023, and not the price level.
A check that the simulation is correct: the EPE of a forward at a future time is the average payoff of a call option on the asset at that time, with the strike brought back from the maturity. The average payoff of a call under lognormal prices has a closed form. The test of this lab compares the simulated EPE with it, and the difference is below 3%, which is what 20,000 scenarios give.
- FunctionQuestion it answers
- forward_values(paths, times, strike, rate, maturity)What is the contract worth in each scenario?price minus the discounted strike
- epe(values)How much is owed to us on average?average of the positive parts
- ene(values)How much do we owe on average?average of the negative parts
- pfe(values, level)What is a bad but possible exposure?the linear quantile, at least zero
- cva(discount, exposure, survival, recovery)What is the expected loss from the counterparty's default?loss given default times discounted exposure times default probability
- dva(discount, negative_exposure, own_survival, own_recovery)What do we gain from our own default?the CVA formula from the other side
- collateralised_exposure(values, threshold)What is left at risk after collateral?the EPE above the threshold
- netting_benefit(values_a, values_b)How much does netting reduce the exposure?separate exposures minus netted exposure
What you will build
The lab follows the lecture. Task 1 turns scenarios of the asset into values of the forward. Tasks 2, 3 and 4 summarise them as the EPE, the ENE and the PFE. Task 5 is the heart of the topic: the CVA. Task 6 is the DVA, task 7 the exposure with collateral and task 8 the benefit of netting. Task 9 runs everything on a five-year forward on SPY on three real days.
Next topic: this topic took the volatility of the asset as given. The next one, Building a volatility surface and checking it for arbitrage, goes back to the option prices of the market and asks what volatility they imply for each strike and maturity, and when a set of prices cannot be right.
Lab · what's graded
9 tasks · 100 pts- Forward values10 pts
- Expected positive exposure5 pts
- Expected negative exposure5 pts
- Potential future exposure10 pts
- The credit value adjustment15 pts
- The debit value adjustment10 pts
- Collateral10 pts
- Netting10 pts
- The XVA on three days25 pts