Functional Weave
Code in Rust

lending.ltv@1.0.1

README.md

2,607 bytes · view raw

# lending.ltv

Loan-to-value: the loan as a share of the property's value, in basis points
(7500 = 75%), and which band of the lender's table it falls in. Mortgage
pricing is set by LTV band, so the band is what a rate lookup needs.

## Bands are yours, and inclusive

The band table is an argument, because every lender's differs. Each band is a
ceiling, inclusive: a band of 7500 holds everything up to and including 75%.
Bands must be in strictly ascending order, and the loan goes in the first
band whose ceiling it is within. Above the top band, `band` is null: the
loan is outside the table (for example negative equity above 100%), which
the caller must handle rather than silently getting the top band.

## Exact at the boundary

The band is decided on the exact ratio, never on a rounded percentage: £225,000
on £300,000 is exactly 75% and is in the 75% band; one penny more is 75.0000033%
and is not. The reported `basisPoints` is rounded up (math.round-div "up"), so
it never understates the ratio, and it always agrees with the band: a whole
ceiling holds the exact ratio exactly when it holds the rounded-up one.

## What it does not do

It does not decide which value to use (valuation or purchase price, usually
the lower) or add fees to the loan; pass the figures your policy uses. A zero
loan is 0%. The value must be positive, and the loan at most about £9 billion
in pence (900,719,925,474 minor units), where loan × 10000 stays exact in
every language.

## Before you rely on this

**Not professional advice.** This capability calculates lending figures from published rules. It is a software component for developers, not financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have a consumer-credit compliance specialist review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.

**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified consumer-credit compliance specialist has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.

1.0.1 marks it unreviewed. The code and the tests are unchanged.