Example usage of loan analysis toolkit#
from loan_analysis_toolkit.schedule import prepare_loan_summary
Generating loan transactons and interest schedules#
This is the primary function of the package. This function will generate all transactions on the loan account along with a monthly summary.
# 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
extra_repayments_frequency = 'annually' # Extra repayments frequency
extra_repayments_regular_amount = 5_000 # Extra repayments amount in dollars
# Whether to capture daily and monthly interest accruals in the transactions
# Default is False
capture_interest_accrual = True
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,
'extra_repayments_frequency' : extra_repayments_frequency,
'extra_repayments_regular_amount' : extra_repayments_regular_amount,
'capture_interest_accrual' : capture_interest_accrual
}
res = prepare_loan_summary(loan_parameters, store_results = False)
total_interest_paid_by_customer = res['total_interest_charged']
print("total interested paid by the customer: {}".format(total_interest_paid_by_customer))
display(res['monthly_summary'].head())
total interested paid by the customer: 353294.29488180205
MONTH | Total Repayment | Total Interest Charged | Loan Balance (First Day of Month) | Offset Balance (Last Day of Month) | |
---|---|---|---|---|---|
0 | 2025-10 | 1672.564346 | 0.000000 | 650000.000000 | 20000 |
1 | 2025-11 | 5017.693037 | 2852.371784 | 648327.435654 | 20500 |
2 | 2025-12 | 3345.128691 | 2754.865877 | 646162.114402 | 21000 |
3 | 2026-01 | 3345.128691 | 2840.477592 | 645571.851588 | 21500 |
4 | 2026-02 | 3345.128691 | 2834.452964 | 645067.200489 | 22000 |
We have seen the monthly summmaries above which includes the total interest paid by the customer. Lets checkout the transactions at the beginning of the time period.
display_df = res['all_transactions'].copy()
display_df = display_df.loc[display_df['Transaction Type'] != 'Monthly Interest Acrrued']
display_df.head(50)
Date | Transaction Type | Transaction Amount | Loan Balance | Offset Balance | |
---|---|---|---|---|---|
0 | 2025-10-05 | Settlement | 650000.000000 | 650000.000000 | 20000 |
1 | 2025-10-06 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
3 | 2025-10-07 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
5 | 2025-10-08 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
7 | 2025-10-09 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
9 | 2025-10-10 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
11 | 2025-10-11 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
13 | 2025-10-12 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
15 | 2025-10-13 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
17 | 2025-10-14 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
19 | 2025-10-15 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
21 | 2025-10-16 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
23 | 2025-10-17 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
25 | 2025-10-18 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
27 | 2025-10-19 | Daily Interest Acrrued | 92.169863 | 650000.000000 | 20000 |
29 | 2025-10-19 | Repayment | 1672.564346 | 648327.435654 | 20000 |
30 | 2025-10-20 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
32 | 2025-10-21 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
34 | 2025-10-22 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
36 | 2025-10-23 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
38 | 2025-10-24 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
40 | 2025-10-25 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
42 | 2025-10-26 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
44 | 2025-10-27 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
46 | 2025-10-28 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
48 | 2025-10-29 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
50 | 2025-10-30 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
52 | 2025-10-31 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
54 | 2025-11-01 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
56 | 2025-11-02 | Daily Interest Acrrued | 91.925165 | 648327.435654 | 20000 |
58 | 2025-11-02 | Repayment | 1672.564346 | 646654.871309 | 20000 |
59 | 2025-11-03 | Daily Interest Acrrued | 91.680466 | 646654.871309 | 20000 |
61 | 2025-11-04 | Daily Interest Acrrued | 91.680466 | 646654.871309 | 20000 |
63 | 2025-11-05 | Daily Interest Acrrued | 91.680466 | 646654.871309 | 20000 |
65 | 2025-11-05 | Interest Charged | 2852.371784 | 649507.243093 | 20000 |
66 | 2025-11-05 | Offset Contribution | 500.000000 | 649507.243093 | 20500 |
67 | 2025-11-06 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
69 | 2025-11-07 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
71 | 2025-11-08 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
73 | 2025-11-09 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
75 | 2025-11-10 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
77 | 2025-11-11 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
79 | 2025-11-12 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
81 | 2025-11-13 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
83 | 2025-11-14 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
85 | 2025-11-15 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
87 | 2025-11-16 | Daily Interest Acrrued | 92.024621 | 649507.243093 | 20500 |
89 | 2025-11-16 | Repayment | 1672.564346 | 647834.678748 | 20500 |
90 | 2025-11-17 | Daily Interest Acrrued | 91.779923 | 647834.678748 | 20500 |
92 | 2025-11-18 | Daily Interest Acrrued | 91.779923 | 647834.678748 | 20500 |
Lets also examine the transactions towards the end of the loan period.
display_df.tail(20)
Date | Transaction Type | Transaction Amount | Loan Balance | Offset Balance | |
---|---|---|---|---|---|
16168 | 2046-06-14 | Daily Interest Acrrued | 0.000000 | 1782.112634 | 144000 |
16170 | 2046-06-15 | Daily Interest Acrrued | 0.000000 | 1782.112634 | 144000 |
16172 | 2046-06-16 | Daily Interest Acrrued | 0.000000 | 1782.112634 | 144000 |
16174 | 2046-06-17 | Daily Interest Acrrued | 0.000000 | 1782.112634 | 144000 |
16176 | 2046-06-17 | Repayment | 1672.564346 | 109.548288 | 144000 |
16177 | 2046-06-18 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16179 | 2046-06-19 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16181 | 2046-06-20 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16183 | 2046-06-21 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16185 | 2046-06-22 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16187 | 2046-06-23 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16189 | 2046-06-24 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16191 | 2046-06-25 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16193 | 2046-06-26 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16195 | 2046-06-27 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16197 | 2046-06-28 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16199 | 2046-06-29 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16201 | 2046-06-30 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16203 | 2046-07-01 | Daily Interest Acrrued | 0.000000 | 109.548288 | 144000 |
16205 | 2046-07-01 | Repayment | 109.548288 | 0.000000 | 144000 |
Quantifying the benefit of offset account#
This example shows how much interest can be saved by having an offset account where the customer will be regularly contributing $500
a month with an initial balance of $20,000
.
# 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
extra_repayments_frequency = 'annually' # Extra repayments frequency
extra_repayments_regular_amount = 5000 # Extra repayments amount in dollars
# Whether to capture daily and monthly interest accruals in the transactions
# Default is False
capture_interest_accrual = False
loan_parameters_with_offset = {
'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,
'extra_repayments_frequency' : extra_repayments_frequency,
'extra_repayments_regular_amount' : extra_repayments_regular_amount,
'capture_interest_accrual' : capture_interest_accrual
}
res_with_offset = prepare_loan_summary(loan_parameters_with_offset, store_results = False)
total_interest_paid_by_customer_with_offset = res_with_offset['total_interest_charged']
print("Total interest paid by the customer:")
print(" - with offset account : ${}".format(round(total_interest_paid_by_customer_with_offset,2)))
loan_parameters_without_offset = {
'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' : 0,
'offset_contribution_frequency' : offset_contribution_frequency,
'offset_contribution_regular_amount' : 0,
'extra_repayments_frequency' : extra_repayments_frequency,
'extra_repayments_regular_amount' : extra_repayments_regular_amount,
'capture_interest_accrual' : capture_interest_accrual
}
res_without_offset = prepare_loan_summary(loan_parameters_without_offset, store_results = False)
total_interest_paid_by_customer_without_offset = round(res_without_offset['total_interest_charged'],2)
print(" - without offset account : ${}".format(round(total_interest_paid_by_customer_without_offset,2)))
print("Interest saving due to offset account (without additional transactions) : ${}".format(round(total_interest_paid_by_customer_without_offset - total_interest_paid_by_customer_with_offset, 2)))
Total interest paid by the customer:
- with offset account : $353294.29
- without offset account : $495545.42
Interest saving due to offset account (without additional transactions) : $142251.13