Skip to main content

Provides various tools for loan analysis, including generating loan amortization schedule and total interest paid using daily calculation.

Project description

Loan Analysis Toolkit

This packages generates all transactions and an interest schedule for loan accounts such as home loans. It runs daily interest accrual which makes it more accurate than simple formula based calculations. Most banks calculates interests daily and charge them monthly. This package mimics that process. In runs through a daily loop and performs calculation until the loan is paid off.

Technical Documentation

https://salaken-ds.github.io/loan_analysis_toolkit/

Features:

  • calculates daily interest which makes the schedule very accurate
  • adjusts account balance on repayment dates
  • charges interest on monthly loan anniversary e.g. if loan is settled on the 3rd of the month then interest is always charged on the 3rd of the month
  • supports offset account with zero or non-zero initial balance
  • regular contribution of offset account
  • returns (1) all transactions, (2) monthly summary containing interest charged, repayment, loan balance and offset account balance and (3) total interest charged to the customer

Assumption:

  • Daily interest charge is based on 365 days in a year, even in a leap year. This is because most Australian bank does it that way.

Usage examples:

  • Generate all transactions to the loan account to cross-check against bank. Helps to make sure bank is not making any mistakes. (It may sound surprising, but banks DO make a lot of mistakes!)
  • Calculate interest savings by adding an offset account, and making regular contributions. This helps creating strategies to pay out the loan faster and helps with financial wellbeing.
from loan_analysis_toolkit.schedule import prepare_loan_summary


if __name__ == "__main__":
    # loan parameters
    loan_amount = 650_000  # Loan amount in dollars
    annual_rate = 5.34     # Annual interest rate in percentage
    loan_duration_years = 30          # Loan term in years
    loan_duration_months = 0          # Additional months in loan term
    start_date = '2025-10-05'  # Loan settlement date
    repayment_frequency = 'fortnightly'  # Repayment frequency
    initial_offset_amount = 20_000  # Initial offset account balance in dollars
    offset_contribution_frequency = 'monthly'  # Offset contribution frequency
    offset_contribution_regular_amount = 500  # Offset contribution amount in dollars

    loan_parameters = {'loan_amount' : loan_amount,
                   'annual_rate' : annual_rate,
                   'loan_duration_years' : loan_duration_years,
                   'loan_duration_months' : loan_duration_months,
                   'start_date' : start_date,
                   'repayment_frequency' : repayment_frequency,
                   'initial_offset_amount' : initial_offset_amount,
                   'offset_contribution_frequency' : offset_contribution_frequency,
                   'offset_contribution_regular_amount' : offset_contribution_regular_amount
                   }

    res = prepare_loan_summary(loan_parameters, store_results = True)

    total_interest_paid_by_customer = res['total_interest_charged']
    print("total interested paid by the customer: {}".format(total_interest_paid_by_customer))
    print(res['monthly_summary'].head())

Contributions

Please raise a pull request outlining changes.

Others

  • Pre-requisite: uv (either pip install uv or see https://docs.astral.sh/uv/getting-started/installation/#standalone-installer)
  • Clone and then build using: uv build
  • Local install into another virtual environment using the built package (assuming you're currently in directory xyz which is at the same level as loan_analysis_toolkit): uv pip install ../loan_analysis_toolkit/dist/loan_analysis_toolkit-0.1.0.tar.gz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loan_analysis_toolkit-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loan_analysis_toolkit-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file loan_analysis_toolkit-0.2.0.tar.gz.

File metadata

File hashes

Hashes for loan_analysis_toolkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 280d5f6efd4dcc997ea806f90a1de01f8cca989db9534b4773cdf7adb61ee92d
MD5 f1b74c9d1f419995a2a2a6ab97cb1f3b
BLAKE2b-256 d404a423a5da0a3d9b9c0c2d47424a8893a2b765f6ad995f81e7d13a500492c0

See more details on using hashes here.

File details

Details for the file loan_analysis_toolkit-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for loan_analysis_toolkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04fe79eba86554593508293068b4a428b62c8f420b5630a750f26264184fe161
MD5 e03cb42533a9f0bc9cf226093f33ea28
BLAKE2b-256 4c3ea811247d573ede78967d0f4eab76fd89cf7d5486b8a34faf6c495577743d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page