Skip to content

Apr.fs: add UnitedKingdom.representativeApr for UK CCA advertising#54

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/add-representative-apr-function
Draft

Apr.fs: add UnitedKingdom.representativeApr for UK CCA advertising#54
Copilot wants to merge 3 commits into
mainfrom
copilot/add-representative-apr-function

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

UK lenders advertising credit products must quote a representative APR (the rate at or below which ≥51% of accepted applicants are offered) derived via FCA CONC App 1.2.6 / CCA 1974 actuarial methodology. No function existed to derive this from a nominal rate + fee + term.

Changes

src/Apr.fs

  • Adds UnitedKingdom.representativeApr to the existing UnitedKingdom module:
    • Computes equal monthly payments via the annuity formula on principal + fee at nominalAnnualRate / 12
    • Rounds to the nearest cent via Cent.fromDecimal
    • Solves the representative APR on the net advance (principal) using the existing calculateAprEuUk (actual-days UK actuarial method)
    • Returns Solution.Impossible for zero/negative term or zero principal
// £1,000 loan, 20% nominal p.a., 12 months, £50 arrangement fee
// Gross financed: £1,050 → monthly repayment: £97.27
// Representative APR solved on £1,000 net advance → ≈ 34.1%
let apr =
    Apr.UnitedKingdom.representativeApr
        (Date(2025, 1, 1))
        (Percent 20m)
        100_000L<Cent>   // £1,000 principal
        12
        5_000L<Cent>     // £50 fee

tests/AprUnitedKingdomTests.fs

New RepresentativeApr module with five tests:

Scenario Principal Nominal Term Fee Expected APR
No-fee baseline £1,000 20% 12 mo £0 ≈ 22.03%
Fee raises APR (invariant) £1,000 20% 12 mo £50 > no-fee APR
FCA CCA worked example £1,000 20% 12 mo £50 ≈ 34.08%
Zero term 0 Impossible
Zero principal Impossible

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 28, 2026 22:53
Agent-Logs-Url: https://github.com/simontreanor/FSharp.Finance.Personal/sessions/b4734a90-5f13-4070-822e-96d91a7e8c19

Co-authored-by: simontreanor <4550815+simontreanor@users.noreply.github.com>
Copilot AI changed the title [WIP] Add function to calculate representative APR in Apr.fs Apr.fs: add UnitedKingdom.representativeApr for UK CCA advertising Apr 28, 2026
Copilot AI requested a review from simontreanor April 28, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apr.fs: representative APR calculation (UK CCA)

2 participants