A Caplet Pays When the Rate Is High
A caplet pays the notional times the accrual times the amount by which a floating rate is above its strike, and nothing otherwise; a floorlet pays on the other side. The program draws both payoffs against the rate.
The question
A company borrows 1,000,000 at a floating rate. Every period it pays interest at the rate that was set at the start of the period. If rates rise, the interest rises with them. Is there a contract that limits the damage, so that the company never pays more than some chosen rate? There is, and it is an option on the rate: a caplet.
A caplet is the building block of the caps in the next chapter. This lesson is only about what one caplet pays at the end of one period, and about its mirror image, the floorlet. No price is computed yet.
Work it by hand
A caplet has a notional, a strike rate and a period. At the start of the period the floating rate is fixed. At the end the caplet pays the notional times the accrual, the length of the period in years, times the amount by which the rate is above the strike. If the rate is at or below the strike, it pays nothing. A floorlet pays when the rate is below the strike, by the amount of the shortfall.
Take notional 1,000,000, strike 4%, a period of 181 days counted as 181 over 360 of a year, and a fixed rate of 5.5%.
- Accrual: 181 over 360, which is 0.50278 (rounded for display; keep 181 over 360 in the products).
- The rate is 1.5 points above the strike. Caplet payoff: 1,000,000 times 181 over 360 times 0.015, which is 7,541.67.
- Interest at 5.5% for the period: 1,000,000 times 181 over 360 times 0.055, which is 27,652.78.
- Interest minus the caplet payoff: 20,111.11. At the strike, 4%, the interest would be 1,000,000 times 181 over 360 times 0.04, also 20,111.11.
So the borrower who holds the caplet pays what a 4% loan would cost, however far the rate rises above 4%. If the rate had been 3%, the caplet would pay nothing and the interest would be lower than at the strike.
Run it
The program takes notional, strike, the fixed rate and the number of days. Line 1 turns days into a fraction of a 360-day year. The loop on lines 4 to 9 goes through 33 rates from 0% to 8% in steps of 0.25 points and keeps the two payoffs of each, rounded to cents. Line 10 computes the caplet payoff at the input rate; the interest at that rate is returned beside it.
The picture draws both payoffs against the rate: the caplet is zero up to the strike and then rises in a straight line, the floorlet is the mirror image. The program returns the caplet payoff at the input rate in whole cents.

Watch the steps (recorded video)
let accrual = float(days) / 360.0;
let rates = float_list();
let caplet = float_list(); let floorlet = float_list();
for (i in range(0, 33)) {
let r = 0.0025 * float(i);
rates.add(r);
caplet.add(lmf.round(notional * accrual * math_max(r - strike, 0.0), 2));
floorlet.add(lmf.round(notional * accrual * math_max(strike - r, 0.0), 2));
}
let pay = notional * accrual * math_max(rate - strike, 0.0);
lmcode_return_put("rates", rates);
lmcode_return_put("caplet", caplet);
lmcode_return_put("floorlet", floorlet);
lmcode_return_put("interest", lmf.money(notional * accrual * rate));
lmcode_return_put("payoff", lmf.money(pay));
let answer = int(math_round(lmf.round(pay, 2) * 100.0));
{
"answer": 754167,
"rates": [
0,
0.0025,
0.005,
0.0075,
0.01,
0.0125,
0.015,
0.0175,
0.02,
0.0225,
0.025,
0.0275,
0.03,
0.0325,
0.035,
0.0375,
0.04,
0.0425,
0.045,
0.0475,
0.05,
0.0525,
0.055,
0.0575,
0.06,
0.0625,
0.065,
0.0675,
0.07,
0.0725,
0.075,
0.0775,
0.08
],
"caplet": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1256.94,
2513.89,
3770.83,
5027.78,
6284.72,
7541.67,
8798.61,
10055.56,
11312.5,
12569.44,
13826.39,
15083.33,
16340.28,
17597.22,
18854.17,
20111.11
],
"floorlet": [
20111.11,
18854.17,
17597.22,
16340.28,
15083.33,
13826.39,
12569.44,
11312.5,
10055.56,
8798.61,
7541.67,
6284.72,
5027.78,
3770.83,
2513.89,
1256.94,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"interest": "27,652.78",
"payoff": "7,541.67"
}You can change all four inputs. The program only multiplies and takes a maximum, so no input of ordinary size stops it: a rate below the strike gives a payoff of 0.00, a rate of exactly the strike gives 0.00 on both sides. The picture always covers 0% to 8%; a strike outside that range shows one payoff as a flat line. Negative inputs are accepted but have no meaning for this lesson.
There is one limit. A returned whole number must stay below 2 to the power 53, about 9 followed by 15 zeros. With the other inputs as they are, a notional of 1.2e16 makes the payoff in cents larger than that, and the run stops with "lmcode return: invalid JSON value at /answer: unsafe_integer".
Your turn
A borrower pays the floating rate on a notional for a number of days, counted as days over 360 of a year, and holds a caplet struck at a given rate for that same period. The program below is meant to return the borrower's net interest cost in whole cents: the interest minus what the caplet pays. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on five others.

let accrual = float(days) / 360.0;
let interest = notional * accrual * rate;
let payoff = notional * math_max(rate - strike, 0.0);
let answer = int(math_round(lmf.round(interest - payoff, 2) * 100.0));
{
"answer": -1000000
}A borrower pays the floating rate on notional for days days, counted as days over 360 of a year, and holds a caplet with the given strike for the same period. The rate was fixed at the start of the period. Return the borrower's net interest cost in whole cents: the interest at rate minus the caplet's payoff, both for the period. Round the result to cents.
Read the result carefully
The rate, the day count and the notional are made-up inputs. A real contract names a reference rate, a calendar and a fixing lag, and the caplet is bought for a price paid at the start; this lesson leaves out that price, the credit of the seller and taxes. The result is the net interest cost in this model, not a statement about whether such protection is worth buying.
The payoff takes the larger of the rate difference and zero, so the caplet can only add to what the borrower receives. Amounts are rounded to cents with lmf.round, because the engine's numbers are binary floating point, and the answer is returned in whole cents. It is a description of an arithmetic model and not investment advice.
Recap
- A caplet pays notional times accrual times the larger of rate minus strike and zero, at the end of the period.
- A floorlet pays notional times accrual times the larger of strike minus rate and zero.
- Interest minus the caplet payoff is never more than the interest at the strike.
- The payoff is a rule with a corner at the strike, like the call payoff in the option book.