Skip to main content

repaykit

Pure Python repayment schedule, financing, loan ledger, and settlement calculation toolkit.

repaykit helps software teams calculate loan and financing schedules, payment ledgers, late charges, statement balances, and settlement quotes. It is framework-agnostic, uses Decimal for money and rates, and keeps business rules policy-driven.

What It Is Not

repaykit is not a loan origination system, accounting system, regulatory compliance engine, or legal opinion. It does not provide legal, accounting, tax, Shariah, regulatory, lending, or financial advice. Users are responsible for validating calculations, policies, disclosures, and compliance requirements for their jurisdiction and product.

Installation

pip install repaykit

Supported Methods

  • Flat rate
  • Sum-of-digits / Rule of 78
  • Reducing balance amortization
  • Constant principal repayment

Supported Schedules

  • Daily, with optional weekend skipping
  • Weekly
  • Biweekly
  • Monthly, with month-end safety
  • Quarterly
  • Yearly
  • Custom explicit due dates

Quickstart

from datetime import date
from decimal import Decimal

from repaykit import Loan

loan = Loan.create(
    amount=Decimal("10000.00"),
    annual_rate=Decimal("0.08"),
    term="24 months",
    payment_frequency="monthly",
    method="flat_rate",
    start_date=date(2026, 6, 1),
)

payment = loan.payment_amount()
rows = loan.schedule()

Use iter_schedule() for lazy row generation, especially for daily schedules.

Expert Mode

from datetime import date
from decimal import Decimal

from repaykit import Loan
from repaykit.accruals import FlatAccrual
from repaykit.methods import FlatRateAllocation
from repaykit.policies import RoundingPolicy
from repaykit.schedules import MonthlySchedule
from repaykit.terms import Term

loan = Loan(
    principal=Decimal("10000.00"),
    term=Term(months=24),
    payment_schedule=MonthlySchedule(day=1),
    accrual_policy=FlatAccrual(annual_rate=Decimal("0.08")),
    repayment_method=FlatRateAllocation(),
    rounding=RoundingPolicy(currency="MYR"),
    start_date=date(2026, 6, 1),
)

Flat Rate Example

loan = Loan.create(
    amount=Decimal("10000.00"),
    annual_rate=Decimal("0.08"),
    term="24 months",
    payment_frequency="monthly",
    method="flat_rate",
    start_date=date(2026, 6, 1),
)

Flat-rate total profit is principal * annual_rate * term_in_years. Future scheduled profit is treated as unearned profit rebate in the default settlement policy.

Sum-of-Digits / Rule of 78 Example

loan = Loan.create(
    amount=Decimal("10000.00"),
    annual_rate=Decimal("0.08"),
    term="12 months",
    payment_frequency="monthly",
    method="sum_of_digits",
    start_date=date(2026, 1, 1),
)

The denominator is generalized as n * (n + 1) / 2, so the method works with non-monthly period counts such as 52 weekly periods.

Reducing Balance Example

loan = Loan.create(
    amount=Decimal("10000.00"),
    annual_rate=Decimal("0.08"),
    term="24 months",
    payment_frequency="monthly",
    method="reducing_balance",
    start_date=date(2026, 6, 1),
)

Reducing balance uses fixed-payment amortization. Profit is calculated on the outstanding balance for each period.

Constant Principal Example

loan = Loan.create(
    amount=Decimal("10000.00"),
    annual_rate=Decimal("0.08"),
    term="24 months",
    payment_frequency="monthly",
    method="constant_principal",
    start_date=date(2026, 6, 1),
)

The principal component is constant except for the final rounding adjustment; installments decline as profit declines.

Weekly Payment Example

loan = Loan.create(
    amount=Decimal("5000.00"),
    annual_rate=Decimal("0.10"),
    term="52 weeks",
    payment_frequency="weekly",
    method="constant_principal",
    start_date=date(2026, 1, 1),
)

Daily Payment Example

loan = Loan.create(
    amount=Decimal("1000.00"),
    annual_rate=Decimal("0.12"),
    term="30 days",
    payment_frequency="daily",
    method="reducing_balance",
    start_date=date(2026, 1, 1),
)

Payment Ledger Example

from repaykit import LoanAccount

account = LoanAccount(loan)
account.add_payment(
    amount=Decimal("500.00"),
    paid_at=date(2026, 7, 5),
    reference="ANGKASA-JULY-2026",
)

statement = account.statement(as_of=date(2026, 8, 1))
print(statement.total_due)
print(statement.total_paid)
print(statement.arrears)
print(statement.outstanding_balance)

Statements use aggregate oldest-due-first allocation for due installments and late-charge exposure. They do not maintain a double-entry accounting ledger or split each payment into principal/profit transactions.

Late Charge Example

from repaykit.policies import LateChargePolicy

loan.late_charge_policy = LateChargePolicy(
    rate=Decimal("0.01"),
    grace_days=5,
    basis="flat",
    minimum_charge=Decimal("0.00"),
)

Supported bases are flat and daily. Negative overdue amounts are treated as zero.

Settlement Example

settlement = account.full_settlement(as_of=date(2026, 12, 15))

print(settlement.outstanding_principal)
print(settlement.unearned_profit_rebate)
print(settlement.late_charges)
print(settlement.amount_payable)
print(settlement.explanation)

Settlement is policy-based. Flat-rate and sum-of-digits methods rebate future scheduled profit by default. Reducing-balance and constant-principal methods have no unearned profit rebate by default. Validate settlement behavior against your contract and regulatory requirements.

Export Example

from repaykit.exporters import schedule_to_csv, schedule_to_dicts

rows = loan.schedule()
data = schedule_to_dicts(rows)
schedule_to_csv(rows, "schedule.csv")

Exporters serialize Decimal values as strings and dates as ISO strings. They never convert money to floats.

Rounding Warning

The default RoundingPolicy uses half-up money rounding with two decimal places. Different institutions and jurisdictions may require different rounding points, decimal places, or settlement rebate rules. Configure and test policies against the governing contract and regulation.

Release Status

Version 1.0.0 declares the public API documented in docs/api.md. Breaking public API changes after 1.0.0 require a major version bump.

Metadata

Release files for repaykit 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for repaykit 1.0.0
File Size Uploaded Provenance Actions
repaykit-1.0.0.tar.gz 27.2 kB With provenance Details for repaykit-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for repaykit 1.0.0
File Interpreter ABI Platform Actions
repaykit-1.0.0-py3-none-any.whl Python 3 none any Details for repaykit-1.0.0-py3-none-any.whl

Total release size: 57.7 kB

Release files / repaykit-1.0.0.tar.gz

Download URL repaykit-1.0.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d5f9654753e1ecc28efbbc29eeae23b1e628312c989b0ae384902c96165e1456
BLAKE2b-256 checksum
How to use checksums
af6a44288ea7a1936954f3f252b32107baf271f49436c582378725907301ae28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Release files / repaykit-1.0.0-py3-none-any.whl

Download URL repaykit-1.0.0-py3-none-any.whl
Size 30.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a186ed93c2af294d4c381870a0e9e427c55ca1806e9bfb16af867b6babf80be4
BLAKE2b-256 checksum
How to use checksums
5cfdcf706d115c04b498f8f542d4cc475e59af2fad7fddc72619ad312f5cc89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

Security for repaykit 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for repaykit-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page