Functional Weave
Code in Rust

insurance.rating-factors@1.0.1

README.md

3,132 bytes · view raw

# insurance.rating-factors

A premium from a base rate multiplied by rating factors (relativities) looked
up for the risk, then by loadings and discounts, held within a minimum and a
maximum premium. This is the multiplicative model most personal-lines and
many commercial rating engines use.

## Inputs

- **tables**: one per rating factor (area, driver age band, vehicle group,
  occupation...), each a list of `key -> multiplier` rows. Multipliers are
  basis points: 10000 is 1.0, 13500 is 1.35, 9000 is 0.9. The tables are the
  insurer's own and change by the insurer's release, so they are arguments
  rather than data in this package.
- **risk**: the risk's value for each table, by table name. Every table
  needs a value, every value needs a row, and a value for a factor no table
  rates is an error rather than being ignored (a misspelt factor name would
  otherwise silently rate at 1.0). Numeric factors are banded first, e.g.
  with `insurance.age-banding`.
- **adjustments**: loadings and discounts after the tables, as changes: 2500
  is a 25% loading, multiplying by 1.25; -1000 a 10% discount, multiplying by
  0.9. They multiply, one after another, like the table factors: a 25%
  loading and a 10% discount come to 1.125, not 1.15. -10000 (free) is the
  lowest allowed.

## One rounding

The base is multiplied by every multiplier in exact integer arithmetic
(math.big-integer in Rust, native big integers in TypeScript and Python),
and rounded to a minor unit once, in the caller's mode. Rounding after each
factor drifts: 1.01 at 1.005 three times is 1.0252, so 1.03, but 1.04 when
rounded at every step. Order therefore does not change the answer.

## Minimum and maximum premium

Applied last, to the rounded result. `calculated` is the premium before
them, `premium` after, and `cap` says which one, if either, set it. A result
exactly equal to a cap is not reported as capped.

Not covered: additive loadings in money (a flat 25.00 policy fee), which are
added after rating, and IPT, which is `insurance.ipt` on the final premium.

## Before you rely on this

**Not professional advice.** This capability calculates insurance 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 an actuary 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 actuary 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.