Black's Formula for a Caplet
Before its rate is fixed, a caplet is worth the discounted forward rate times a normal probability minus the strike times another, Black's formula; the program computes it by hand, sets the engine's price beside it and draws the value against volatility.
The question
The last lesson gave the payoff of a caplet at its end. What is the caplet worth today, before the rate is fixed? The payoff is a call on the rate, and the forward rate for the period is the rate that the market's discount factors imply for it. Fischer Black's formula for a call on a forward prices it, and it looks like the Black-Scholes formula with the forward rate in place of the stock price.
The price depends on a volatility, a number that says how much the forward rate is assumed to move. Nobody observes it: it is an input of the model, and the page draws what the price does as it changes.
Work it by hand
The inputs are a forward rate of 4.5%, a strike of 4%, a volatility of 20% a year, a fixing in 2 years and a discount factor of 0.9 from today to the payment date. The caplet's notional is 1,000,000 and its accrual is 0.5 year.
- The total volatility over the life is 0.2 times the square root of 2, which is 0.2828.
- d1 is the natural log of forward over strike, divided by 0.2828, plus half of 0.2828. The log of 1.125 is 0.1178, so d1 is 0.4164 plus 0.1414, which is 0.5578. d2 is d1 minus 0.2828, which is 0.2750.
- N(d1) and N(d2) are the standard normal probabilities of d1 and d2: 0.7115 and 0.6083.
- Per unit: the discount factor 0.9 times (0.045 times N(d1) minus 0.04 times N(d2)), which is 0.00691642 with the probabilities not rounded. Times notional and accrual, 500,000, that is the caplet's value, 3,458.21. The four-digit probabilities above give 3,458.48: keep more digits when you check by hand.
The formula is exact for its model: a forward rate that stays positive, with one constant volatility until the fixing, and no change in the discount factor.
Run it
The program takes forward, strike, vol, expiry, discount, notional and accrual. Line 1 asks the engine for the price per unit of notional and accrual with pricing.black76. Lines 2 to 6 do the same by hand with lmf.log and lmf.norm_cdf, and the two results agree. Line 7 multiplies by notional and accrual, and line 8 keeps the discounted intrinsic value.
The loop on lines 10 to 14 prices the caplet at 30 volatilities from 2% to 60% and puts the discounted intrinsic value, what the caplet would be worth if the rate were fixed at the forward, beside each as the flat line. With these inputs the vertical axis starts at 2,000, not at 0. The program returns the caplet's value in whole cents.

Watch the steps (recorded video)
let engine = pricing.black76("call", forward, strike, vol, expiry, discount);
let sd = vol * math_sqrt(expiry);
let d1 = lmf.log(forward / strike) / sd + sd / 2.0;
let d2 = d1 - sd;
let n1 = lmf.norm_cdf(d1); let n2 = lmf.norm_cdf(d2);
let by_hand = discount * (forward * n1 - strike * n2);
let scale = notional * accrual;
let kept = lmf.round(scale * discount * math_max(forward - strike, 0.0), 2);
let vols = float_list(); let values = float_list(); let flat = float_list();
for (i in range(1, 31)) {
let v = 0.02 * float(i);
let unit = pricing.black76("call", forward, strike, v, expiry, discount);
vols.add(v); values.add(lmf.round(scale * unit, 2)); flat.add(kept);
}
lmcode_return_put("vols", vols);
lmcode_return_put("values", values);
lmcode_return_put("flat", flat);
lmcode_return_put("d1", lmf.round(d1, 4));
lmcode_return_put("d2", lmf.round(d2, 4));
lmcode_return_put("n_d1", lmf.round(n1, 4));
lmcode_return_put("n_d2", lmf.round(n2, 4));
lmcode_return_put("by_hand", lmf.money(scale * by_hand));
lmcode_return_put("intrinsic", lmf.money(kept));
let answer = int(math_round(lmf.round(scale * engine, 2) * 100.0));
{
"answer": 345821,
"vols": [
0.02,
0.04,
0.06,
0.08,
0.1,
0.12,
0.14,
0.16,
0.18,
0.2,
0.22,
0.24,
0.26,
0.28,
0.3,
0.32,
0.34,
0.36,
0.38,
0.4,
0.42,
0.44,
0.46,
0.48,
0.5,
0.52,
0.54,
0.56,
0.58,
0.6
],
"values": [
2250,
2257.34,
2310.94,
2416.15,
2555.73,
2716.67,
2891.2,
3074.71,
3264.32,
3458.21,
3655.13,
3854.21,
4054.83,
4256.52,
4458.94,
4661.79,
4864.85,
5067.94,
5270.91,
5473.62,
5675.96,
5877.83,
6079.15,
6279.82,
6479.79,
6678.98,
6877.33,
7074.79,
7271.3,
7466.82
],
"flat": [
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250,
2250
],
"d1": 0.5578,
"d2": 0.275,
"n_d1": 0.7115,
"n_d2": 0.6083,
"by_hand": "3,458.21",
"intrinsic": "2,250.00"
}You can change all seven inputs, with limits. The forward, the strike, the volatility, the expiry and the discount factor must be positive, or line 1 stops with "pricing.black76: forward must be positive, got -0.002 (use pricing.bachelier for a negative forward)", "pricing.black76: vol must be positive, got 0" or the same wording for strike, expiry and discount. The notional and the accrual are plain multipliers.
Your turn
The program below is meant to return the time value of the caplet in whole cents: its Black value for the notional and accrual minus its intrinsic value, which is the notional times the accrual times the discount factor times the larger of forward minus strike and zero. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on five others.

let scale = notional * accrual;
let unit = pricing.black76("call", forward, strike, vol, expiry, discount);
let intrinsic = scale * math_max(forward - strike, 0.0);
let answer = int(math_round(lmf.round(scale * unit - intrinsic, 2) * 100.0));
{
"answer": 45118
}A caplet has the given notional and accrual, a forward rate, a strike, a volatility, a time to the fixing (expiry, in years) and a discount factor from today to the payment date. Return its time value in whole cents: its value by Black's formula, with notional and accrual, minus its intrinsic value, which is notional times accrual times discount times the larger of forward minus strike and zero. Round the result to cents.
Read the result carefully
The formula assumes that the forward rate is lognormal with one constant volatility until the fixing. In that model the rate can never be negative; the last lesson of this book uses another model for that case. The volatility is an input nobody observes, and 20% here is made up. The discount factor is a given number, not computed from a curve.
The caplet's value is greater than its intrinsic value because the rate may still move before the fixing. How much greater depends on the volatility input, which is why the picture is a curve. The numbers are in whole cents because the engine's binary numbers carry tiny errors. It is a description of an arithmetic model and not investment advice.
Recap
- A caplet before its fixing is worth notional times accrual times Black's formula on the forward rate.
- d1 is the log of forward over strike over the total volatility, plus half the total volatility; d2 is d1 minus it.
- The value grows with the volatility and never falls below the discounted intrinsic value.
pricing.black76gives the value per unit of notional and accrual, discounted by the factor you pass.