ThirdMomentQuantX

Chapter 21

Loans

Contents
  1. 21.1 Terms, conventions and the lender's side
  2. 21.2 Principal and repayment
  3. 21.3 Interest
  4. 21.4 The floor on the benchmark
  5. 21.5 Value and volatility
  6. 21.6 Reports
  7. 21.7 Z-spread
  8. 21.8 Fees
  9. 21.9 Worked example
  10. 21.10 Edge cases and limits

This chapter defines how the library describes a term loan, lent or borrowed, on a fixed rate, a term rate such as SAIBOR, or an overnight rate such as SOFR compounded daily in arrears; how it repays the principal; how it values the floor that loans usually put on the benchmark rate; and what it reports: the value, the cash flows, the outstanding principal, the current rate, the accrued interest and the Z-spread.

A loan reuses the legs of the swaps (Chapter 6, Section 10.3), the notional exchanges of Section 12.4 for its principal, and the cap and floor pricer of Section 13.5 for its floor. Nothing in this chapter is taken from an existing implementation; the conventions are the public market practice of bilateral and syndicated term loans.

21.1 Terms, conventions and the lender's side

Symbol Meaning
\(P\) The signed principal: positive when lent, negative when borrowed
\(\epsilon\) The sign of \(P\): \(+1\) when lent, \(-1\) when borrowed
\(S_i, E_i\) The adjusted start and end of interest period \(i\), \(i = 1, \dots, n\)
\(D_i\) The payment date of the interest of period \(i\)
\(\delta_i\) The accrual fraction of period \(i\) under the loan's day count
\(N_i\) The balance outstanding over period \(i\), positive
\(a_i\) The principal repaid at the end of period \(i\); \(a_i = N_i - N_{i+1}\), \(N_{n+1} = 0\)
\(r\) The fixed rate of a fixed-rate loan
\(B_i\) The benchmark rate of period \(i\): the term fixing, or the compounded overnight rate
\(m\) The margin over the benchmark
\(F\) The floor on the benchmark, before the margin (0% by default)
\(Z(d)\) The discount factor to date \(d\) on the curve the loan is discounted on
\(v\) The valuation date
\(z\) A Z-spread

Terms. A loan has an identifier, a convention, a signed principal \(P\), a start (drawdown) date, a maturity date, a rate (the fixed rate \(r\) of a fixed-rate loan, or the margin \(m\) of a floating-rate loan), a repayment (Section 21.2) and, for a floating-rate loan, a floor \(F\) or none, where the floor applies (Section 21.4), and the lookback and observation shift of a compounded rate (Section 6.8). The whole principal is drawn on the start date, and the loan is assumed not to be prepaid.

The lender's side. The principal carries the direction:

\[\text{cash flow to the holder} = \epsilon \times \text{flow of a loan lent of size } |P|.\]
(21.1)

In words: a loan lent (\(P > 0\)) is an asset; its interest, repayments and floor are received (positive) and its drawdown is paid (negative). A loan borrowed (\(P < 0\)) is a liability with every sign reversed. This is the library's sign rule (received positive, paid negative). A loan is a bilateral contract, not a traded security, so unlike a bond (Section 19.1) it has no separate security and position.

Conventions. A loan convention holds what a family of loans shares: the currency, the index (none for a fixed rate), the interest frequency, day count, business day convention, calendar, payment lag, end-of-month rule and how the periods are generated, and the defaults of each loan's floor, floor basis, lookback and observation shift. It also names the collateral currency of the curve that discounts the loans (Section 21.5). A loan on an overnight index accrues on the index's day count. The shipped conventions:

Convention Rate Frequency, day count Calendar Floor Discounting
SAR-SAIBOR-3M-LOAN 3M SAIBOR + margin 3M, Act/360 Riyadh 0%, period rate SAR curve under USD collateral
SAR-SAIBOR-6M-LOAN 6M SAIBOR + margin 6M, Act/360 Riyadh 0%, period rate SAR curve under USD collateral
SAR-FIXED-LOAN Fixed 3M, Act/360 Riyadh none SAR curve under USD collateral
USD-SOFR-LOAN SOFR compounded + margin, lookback 5 days, no shift 3M, Act/360 New York 0%, period rate SOFR curve
USD-FIXED-LOAN Fixed 3M, Act/360 New York none SOFR curve

All use Modified Following, no payment lag, periods generated backward from the maturity.

21.2 Principal and repayment

The interest periods are the schedule of Chapter 4 from the start to the maturity. The balance outstanding over each period is

\[N_1 = |P|, \qquad N_{i+1} = N_i - a_i, \quad i = 1, \dots, n - 1,\]
(21.2)

and the last period repays what is left, \(a_n = N_n\). The repayment decides the amounts \(a_i\):

  • Bullet: \(a_i = 0\) before the last period; \(N_i = |P|\) throughout.
  • Linear: the same amount every period, \(N_i = |P| (n - i + 1) / n\).
  • Custom: one amount per period, given with the loan; they add up to \(|P|\) and leave a positive balance in every period.
  • Annuity (fixed-rate loans only): a constant instalment \(A\) of interest and principal, \(A = N_i r \delta_i + a_i\) for every \(i\). Rolling the balance forward, \(N_{i+1} = N_i (1 + r \delta_i) - A\), and asking for \(N_{n+1} = 0\) gives
\[A = \frac{|P|}{\sum_{i=1}^{n} \prod_{j=1}^{i} (1 + r \delta_j)^{-1}}.\]
(21.3)

In words: the instalment is the principal divided by the value, at the loan's own rate, of one unit paid at the end of each period. The accrual fractions are the loan's own, so short and long periods are honoured exactly; with \(r = 0\) the annuity is the linear repayment. A floating-rate annuity is refused: its instalment is not known in advance.

Dates. The drawdown is paid on the start date, each repayment \(a_i\) on the start of period \(i + 1\) (the end of period \(i\)), and the last on the end of the last period; the notional exchanges of Equation (12.6) on the balances \(N_i\). With no payment lag, as in every shipped convention, the end of a period is the payment date of its interest. With a payment lag, interest is paid on \(D_i\) and principal on the period end.

21.3 Interest

The interest of period \(i\), paid on \(D_i\), is \(N_i \delta_i\) times

  • \(r\) for a fixed-rate loan (Section 6.6, fixed leg);
  • \(\max(B_i, F) + m\) for a floating-rate loan, with \(B_i\) the term fixing of Section 10.3, fixed two Riyadh business days before the period start for SAIBOR, or the overnight rate compounded over the period of Section 6.6, read with the loan's lookback and observation shift (Section 6.8). Loans default to a lookback of 5 business days of the index's fixing calendar without observation shift; both can be changed per loan.

The leg that carries the interest is the swap leg of the same kind, received when lent and paid when borrowed, with the balances \(N_i\) as its notionals and the margin as its spread, so every rule of chapters 6 and 10 applies: a published fixing is used, a missing past fixing throws, a future one is projected on the index's curve.

21.4 The floor on the benchmark

Loans usually floor the benchmark at 0% before adding the margin. Since \(\max(B, F) = B + \max(F - B, 0)\), the floored rate splits into the plain floating rate and an option:

\[\max(B_i, F) + m = (B_i + m) + \max(F - B_i, 0).\]
(21.4)

In words: a floored loan is the same loan without a floor, plus a floorlet on the benchmark at strike \(F\) in every period, on the balance \(N_i\) and the accrual \(\delta_i\), without margin. The lender owns the floorlets; the borrower has sold them. The library builds them as a floor (Section 13.5) on a copy of the loan's leg without margin and values them with the index's caplet volatilities: the Bachelier or shifted Black price of Equation (13.5), with the variance to the fixing for a term rate (Equation (13.6)) and the variance of Equation (13.7) for a compounded rate. A floorlet whose fixing is published is worth its payoff. Floor values are reported separately, because with SAIBOR and SOFR well above 0% they are close to zero.

Where the floor applies on a compounded rate is an input of each loan (its floor basis):

  • Period rate (the default): the floor applies to the compounded rate of the period. Equation (21.4) is then exact.
  • Daily rate: the floor applies to each daily fixing before it compounds, \(\prod (1 + \max(o_k, F) w_k)\). The library floors every published fixing in the compounded rate itself, in both the interest leg and the floorlets' leg, and values the future days with the period floor on the remaining compounded rate. Since compounding floored rates gives at least the floor of the compounded rate, this is a lower bound of the true value; the gap is material only when the rate sits near the floor. A term rate has one fixing per period, so its basis does not matter.

21.5 Value and volatility

The value of a loan on the valuation date \(v\) is the sum of its unsettled flows, each discounted:

\[V = \epsilon \Big[ \sum_{D_i > v} N_i \delta_i\, (\hat B_i + m)\, Z(D_i) + \sum_{i \,:\, E_i > v} a_i\, Z(E_i) - \mathbf{1}_{S_1 > v}\, |P|\, Z(S_1) \Big] + \epsilon \sum_{D_i > v} \text{Floorlet}_i,\]
(21.5)

with \(\hat B_i\) the fixed, compounded or projected benchmark (for a fixed-rate loan \(\hat B_i + m\) is \(r\)), the drawdown counted only while it is in the future, and the floorlets of Section 21.4. Flows paid on or before \(v\) are settled and left out.

Discount curve. A loan is discounted on its currency's curve under the convention's collateral currency, whatever the collateral terms of a valuation: SAR loans on the SAR curve under USD collateral, like SAR bonds and swaps; USD loans on the SOFR curve. No netting set or counterparty CSA overrides it, so its Standard CSA PV and CSA PV are equal (Section 20.3). The value on that curve is the loan's risk-free value; credit comes on top as a Z-spread (Section 21.7).

Volatility proxies. A floored loan reads the caplet volatilities of its index, and a missing grid throws. Where an index has no grid of its own, for example 6M SAIBOR, the market definition may name a proxy: VolatilityProxies = SAR-SAIBOR-6M=SAR-SAIBOR-3M makes the market hold the 3M SAIBOR grid under 6M SAIBOR too. The proxy is explicit, never silent; an index with a grid of its own cannot also have a proxy, and when the source grid is absent the proxied index is absent too. Risk records the source grid once, so the vega of both indices lands on the source grid's nodes. The shipped markets name no proxy, and they hold no 6M SAIBOR curve yet, so a 6M SAIBOR loan needs both before it can be valued.

21.6 Reports

Cash flows. The rows of Section 10.9, signed by Equation (21.1): leg 0 the interest (the rate shown is the benchmark plus margin, before the floor), leg 1 the drawdown and the repayments, leg 2 the floorlets, each with the floor as its rate, its value as its present value and the value over the discount factor as its amount. A floorlet row takes the status (fixed or projected, Section 20.2) of its period's interest. The rows sum to Equation (21.5). The settled list over a window (Section 20.2.1) has the same legs, with the amounts paid: the interest from the fixings, and each floorlet's payoff \(N_i \delta_i \max(F - B_i, 0)\) on its period's benchmark.

Outstanding principal on a date: \(\epsilon N_i\) for the period with \(S_i \le d < E_i\); zero before the drawdown and from the end of the last period.

Current rate, for the period \(i\) with \(S_i \le v < E_i\):

\[R(v) = \begin{cases} r & \text{fixed rate,}\\ \max(B_i, F) + m & \text{term rate,}\\ \max(B_i[S_i, v), F) + m & \text{compounded rate, period basis,}\\ B^{F}_i[S_i, v) + m & \text{compounded rate, daily basis,} \end{cases}\]
(21.6)

where \(B_i[S_i, v)\) is the overnight rate compounded from the period's start to the valuation date over published fixings only (the period cut at \(v\), with the loan's lookback), and \(B^F\) the same with each fixing floored. On the start itself, where nothing has compounded yet, the compounded rate is the projected rate of the whole period; so it is too with observation shift while the shifted observation period has not begun to elapse (a period starting on a holiday, valued the next day). The rate is that of the period accruing on \(v\) even when its interest is already paid, as with a negative payment lag. On the daily basis, a projected rate (nothing realised yet) is floored on the period basis, as the floorlets value it. On a period's start the accrued interest is zero, whatever the day count.

Accrued interest, signed:

\[AI(v) = \epsilon\, N_i\, R(v)\, \alpha(S_i, v),\]
(21.7)

with \(\alpha\) the loan's day count (the index's for an overnight rate). In words: what the borrower would owe if the period ended today at the rate known so far.

21.7 Z-spread

As for bonds (Section 19.11), a loan's Z-spread \(z\) discounts each flow further by \(e^{-z\, t(d)}\) on the curve's time \(t\) of Equation (7.1):

\[V_z = \sum_{\text{rows } k \ne \text{drawdown}} \text{PV}_k\, e^{-z\, t(d_k)} + \text{PV}_{\text{drawdown}},\]
(21.8)

where the rows are those of Section 21.6 with their payment dates \(d_k\). The drawdown stays on the curve: it is the lender's own payment, not the borrower's credit. Forward rates are not changed by \(z\).

Solving from a price. Secondary loan prices are quoted clean, per 100 of the principal outstanding. Given a clean price \(C\), the library solves

\[V_z - \text{PV}_{\text{drawdown}} = \epsilon\, \frac{C}{100}\, N_i + AI(v)\]
(21.9)

for \(z\) with Brent's method (Section 5.5) between \(-5\%\) and \(50\%\), with \(N_i\) the balance of the period holding \(v\) (the first balance before the drawdown). The solved spread is a number: curve risk holds it fixed, as for bonds.

21.8 Fees

A borrower pays fees on its debt: an upfront or arrangement fee at signing, an agency fee each year, renewal fees, a fee when it prepays, and others. This section defines the fees a loan or a bond issue carries; the commitment and utilisation fees of a facility come later.

Symbol Meaning
\(s, e\) The fee's start and end dates (unadjusted).
\(f\) The fee's frequency; none for a fee paid once.
\([a_j, b_j)\) The \(j\)-th period of the fee.
\(A\) A fixed amount each period, signed: negative payable, positive receivable.
\(r\) A rate per year on the base, as a decimal, not negative.
\(N(t)\) The principal outstanding on day \(t\), positive: the loan's balance of the period holding \(t\), or the bond trade's face times the redemptions of the periods ending after \(t\).
\(\alpha(x, y)\) The fee's day count (the host's when the fee has none); Actual/Actual (ICMA) counts as Actual/Actual (ISDA), a fee period not being a coupon period, and Calculation/252 counts the host's business days.
\(\epsilon\) The direction of a rate fee: \(-1\) payable (the default), \(+1\) receivable.
\(d_j\) The payment date of period \(j\).

Periods. A fee without a frequency has one period, \([s, e]\), and pays on \(e\); a fee paid once on a single day has \(s = e\). A fee with a frequency \(f\) has the periods of a schedule from \(s\) to \(e\) rolled forward by \(f\), the last one short when \(f\) does not divide the run. The payment date \(d_j\) is \(b_j\) adjusted on the host's calendar with the host's business-day rule: the loan convention's, or the bond's calendar and payment convention.

Amount. A fixed fee pays \(A\) each period. A rate pays

\[F_j = \epsilon\, r \sum_{k} N_k\, \alpha(t_k, t_{k+1}), \qquad a_j = t_0 < t_1 < \dots < t_K = b_j,\]
(21.10)

where \(t_1, \dots, t_{K-1}\) are the days inside the period on which the outstanding principal changes, and \(N_k\) is the principal outstanding from \(t_k\) to \(t_{k+1}\). In words: the rate is applied to each run of days at its own balance, so a repayment inside the period counts from its day. On a loan with one balance over the period it is \(\epsilon\, r\, N\, \alpha(a_j, b_j)\). The row reports the average base, \(\sum_k N_k \alpha(t_k, t_{k+1}) / \alpha(a_j, b_j)\), the rate and the accrual \(\alpha(a_j, b_j)\).

Sign. As for every cash flow, negative is payable and positive receivable. A fixed amount carries its own sign. A rate is never negative; the fee says whether it is payable (the default, \(\epsilon = -1\)) or receivable (\(\epsilon = +1\)). The sign does not depend on the side of the loan: a borrower paying an agency fee enters a negative amount or a payable rate, a lender receiving an upfront fee a positive amount.

Value. The amounts depend only on the terms and on the principal schedule, so they are known at booking. A fee row paid after the valuation date \(v\) has status Fixed and is worth \(F_j\, P(v, d_j)\) on the trade's own discount curve; a row paid on or before \(v\) is settled (Section 20.2.1). Fee rows are kind Fee, in a leg of their own, "Fees": leg 3 of a loan, after interest, principal and floor, and leg 2 of a bond trade, after the holding and the settlement. The trade's value is the sum of its rows, fees included. The loan's value of Section 21.5, its Z-spread (Section 21.7) and a bond's price and yield leave fees out: they are the instrument's market figures, and fees are the borrower's cost.

Prepayment fee. A prepayment fee stores its amount or rate and the window in which it applies, and pays nothing until a prepayment is booked.

Storage. A loan or bond trade document holds one optional field per kind of fee, UpfrontFee, AgencyFee, RenewalFee, PrepaymentFee and OtherFee, each a group of Amount or Rate, Receivable (a rate's direction, absent when payable), Base, StartDate, EndDate, Frequency and DayCount. A trade holds at most one fee of each kind; a second one goes in OtherFee.

Example. A loan borrowed of 10,000,000, bullet, with a payable agency fee of 0.10% a year on the outstanding, Act/360, paid yearly: over a year of 365 days the fee is \(-10{,}000{,}000 \times 0.001 \times 365/360 = -10{,}138.89\). Had the loan been 12,000,000 repaid linearly by 3,000,000 a quarter, with balances 12, 9, 6 and 3 million over quarters of 92, 89, 92 and 92 days, a fee of 0.20% a year would be

\[-0.002 \times \frac{12 \times 92 + 9 \times 89 + 6 \times 92 + 3 \times 92}{360} \times 10^6 = -0.002 \times 7{,}591{,}666.67 = -15{,}183.33,\]

on an average base of \(2{,}733 / 365 \times 10^6 = 7{,}487{,}671.23\).

21.9 Worked example

On flat curves (continuously compounded zero rates of 5% for discounting and 5.5% for 3M SAIBOR) and a flat normal caplet volatility of 1%, valued on 15 October 2026: a SAR loan lent, 5,000,000 on 3M SAIBOR plus 150 basis points, drawn on 2 November 2026, maturing 2 November 2029, repaid linearly over its 12 quarters. Values are in SAR, to the lender.

Floor Value Floor value
none 155,248.55 0
6% 209,535.76 54,287.20

The floored value is the unfloored value plus the floor, Equation (21.4) (155,248.55 + 54,287.20 = 209,535.76). At the shipped 0% floor the floor value is SAR 0.74: with forwards near 5.5%, a 0% floor is far out of the money.

An annuity of SAR 12,000,000 at 6% for five years, quarterly Act/360 from 2 November 2026, pays an instalment of SAR 700,522.74 every quarter (Equation (21.3)).

21.10 Edge cases and limits

  • Prepayment, delayed drawdowns, revolving facilities, commitment fees, amortised upfront fees in the cost of debt, capitalised interest, daily simple (non-compounded) SOFR and credit adjustment spreads are not modelled; each comes later if needed.
  • The daily floor's future days are a lower bound (Section 21.4).
  • A loan valued at zero Z-spread is a risk-free value; issuer survival curves with recovery come later.
  • A missing past fixing throws, as everywhere in the library.
  • A lookback cannot be combined with a rate cut-off of more than one day (Section 6.8); loans have no rate cut-off.
  • Islamic financing (Murabaha, Ijara, Tawarruq) will be a wrapper around a loan, as Sukuk are around bonds.

Reconnecting Connection paused Could not reconnect Could not resume Session expired

The connection to the server was lost. Trying to restore it. Next attempt in 0s. The connection was paused. It will resume on its own. The server did not answer. Your work is still here. The paused session could not be resumed. The server could not restore this session. Reloading will start a new one.

An unhandled error has occurred. Reload 🗙