Functional Weave
Code in Python

banking.savings-aer@1.0.0

README.md

2,173 bytes · view raw

# banking.savings-aer

The AER (Annual Equivalent Rate) of a savings account from its gross rate and
how often it pays interest: the rate that, paid and compounded once a year,
gives the same return. UK savings advertising must quote it, so accounts that
pay monthly and yearly can be compared.

## The rule

The UK Finance / Building Societies Association "Annual Equivalent Rate (AER)
Practice Note" (January 2025, which replaced the 1985-2024 "Code of Conduct
for the Advertising of Interest Bearing Accounts" and its AER appendix) gives,
where interest is paid more often than annually, formula (d):

    AER = ((1 + i / (n × 100))^n − 1) × 100

with i the gross annual rate in percent and n the number of times a year it is
paid. Guideline A5: "AERs are to be rounded and displayed up to two decimal
places." Its worked example 5: 5.8% paid monthly is 5.956...%, an AER of
5.96%; worked example 1: interest paid once a year has an AER equal to the
gross rate. Both are vectors here.

Source: https://www.ukfinance.org.uk/policy-and-guidance/guidance/annual-equivalent-rate-aer-practice-note
(PDF: https://www.ukfinance.org.uk/system/files/2025-02/Annual%20Equivalent%20Rate%20AER%20practice%20note_0.pdf),
read 2026-09-23.

## Exact, then rounded once

The rate is b basis points, so with D = 10000 × n the AER in basis points is
exactly 10000 × ((D + b)^n − D^n) / D^n. That is computed in integers
(`bigint`, Python `int`, `math.big-integer` in Rust; for daily interest D^n
has about 2,400 digits) and rounded half-up to a whole basis point, which is
two decimal places of a percent. "Rounded" in A5 is read as the usual half-up;
there is no floating-point step where 4.595% could become 4.5949999%.

## What it does not do

The Practice Note's general formula (a) also covers bonuses, rates that step
up, deposits during the term and terms other than a year; those need the cash
flows and an iterative solve, and are not this function. This is the
fixed-rate, whole-year, single-deposit case of formula (d), which is what a
headline AER almost always is. The rate is gross (before tax), 0 to 100000
basis points, and interest is paid 1 to 365 times a year.