Statistics for mortgages
Project description
Mortgage Tools
Mortgage cost/payoff calculators online are a dime a dozen, but they tend to assume you are making consistent extra payments each month, or a single one-time payment. I could not find a single one that was flexible and detailed enough to answer the questions I had about my mortgage.
This package includes some sensible default plots for visualizing generated data, but exposes all of the underlying primitives for manipulation as needed.
Questions you can answer using Mortgage Tools
- What will my total costs be over the lifetime of the loan?
- What will my monthly costs be?
- How do two loan options compare?
- When will the loan be paid off if I pay C extra every month/3 months/year?
- When will the loan be paid off, given the current remaining principal and current loan period?
- What is the impact of a marginal X dollars in reducing the loan payoff period?
- How will changes in interest rates affect my total costs?
- How will different initial principal amounts affect my total costs?
- If I want to pay off a loan by month X how much extra do I need to pay per month?
What will my total costs be over the lifetime of the loan?
from mortgage_tools.calculation import Loan
from mortgage_tools.plot import plot_amortization_components
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
loan.summarize()
>> Interest rate: 6.50%
>> Payoff period: 360 months [30 year(s), 0 month(s)]
>> Cumulative interest paid: $1275444.88
>> Cumulative P&I paid: $2275444.88
>> Percent of total payments to principal: 43.95%
plot_amortization_components(loan.amortization_table())
What will my monthly costs be?
from mortgage_tools.calculation import Loan
from mortgage_tools.plot import plot_monthly_payments, plot_monthly_payments_relative
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
loan.standard_monthly_payment()
>> 6320.68
amortization_table = loan.amortization_table()
plot_monthly_payments(amortization_table)
plot_monthly_payments_relative(amortization_table)
How do two loan options compare?
from mortgage_tools.calculation import Loan
from mortgage_tools.plot import plot_relative_amortization_tables
loan1 = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
loan2 = Loan(initial_principal=1_200_000, term_in_months=360, annual_interest_rate=.065)
loan2.summarize() - loan1.summarize()
>> Payoff period: 0 months less [0 year(s), 0 month(s)]
>> Cumulative interest paid: $255086.03 more
>> Cumulative P&I paid: $455086.03 more
plot_relative_amortization_tables(loan1.amortization_table(),loan2.amortization_table())
When will the loan be paid off if I pay C extra every month/3 months/year?
from mortgage_tools.calculation import Loan
from mortgage_tools.plot import plot_relative_amortization_tables
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
default_amortization_table = loan.amortization_table()
default_loan_summary = loan.summarize()
# model any combination of early payments to principal
loan.apply_monthly_recurring_payment(additional_payment=200)
loan.apply_monthly_recurring_payment(additional_payment=100, start_month=45, end_month=48)
loan.apply_annual_recurring_payment(additional_payment=5_000)
loan.apply_ad_hoc_payment(additional_payment=100_000, month=200)
loan.summarize() - default_loan_summary
>> Payoff period: 101 months less [9 year(s), 7 month(s)]
>> Cumulative interest paid: $380652.76 less
>> Cumulative P&I paid: $380652.76 less
plot_relative_amortization_tables(default_amortization_table, loan.amortization_table())
When will the loan be paid off, given the current remaining principal and current loan period?
from mortgage_tools.calculation import Loan
from mortgage_tools.plot import plot_relative_amortization_tables
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
default_amortization_table = loan.amortization_table()
default_loan_summary = loan.summarize()
# no need to specify when each additional principal payment was made
loan.set_current_status(current_month=55, remaining_principal=784_892, interest_paid=200_368)
loan.payoff_period_months()
>> 261
loan.summarize()
>> Interest rate: 6.50%
>> Payoff period: 261 months [21 year(s), 9 month(s)]
>> Cumulative interest paid: $722045.96
>> Cumulative P&I paid: $1722045.96
>> Percent of total payments to principal: 58.07%
loan.summarize() - default_loan_summary
>> Payoff period: 99 months less [9 year(s), 9 month(s)]
>> Cumulative interest paid: $553399.10 less
>> Cumulative P&I paid: $553399.10 less
plot_relative_amortization_tables(default_amortization_table, loan.amortization_table(), "../../images/fig5.png")
- Precise amortization info for loans with a current status applied cannot be determined, so are omitted from any plots.
What is the impact of a marginal X dollars in reducing the loan payoff period?
from mortgage_tools.calculation import Loan
from mortgage_tools.optimization import payoff_curve
from mortgage_tools.plot import plot_payoff_curve
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
curve = payoff_curve(loan)
curve.head(3)
>> payoff_period
>> monthly_extra
>> 0 360
>> 100 344
>> 200 329
plot_payoff_curve(curve)
How will changes in interest rates affect my total costs?
from mortgage_tools.plot import plot_interest_rate_curve
plot_interest_rate_curve(initial_principal=1_000_000, term_in_months=360, min_interest_rate=0.05, max_interest_rate=0.06)
How will different initial principal amounts affect my total costs?
from mortgage_tools.plot import plot_principal_curve
plot_principal_curve(min_principal=1_000_000, max_principal=1_200_000, interest_rate=0.034, term_in_months=360)
If I want to pay off a loan by month X how much extra do I need to pay per month?
from mortgage_tools.calculation import Loan
from mortgage_tools.optimization import payoff_by_date
loan = Loan(initial_principal=1_000_000, term_in_months=360, annual_interest_rate=.065)
# payoff by year 22 month 6 (starting from the beginning)
payoff_by_date(loan, desired_payoff_month=270)
>> 744.63
# already made some additional payments
loan.set_current_status(current_month=8, remaining_principal=955_000, interest_paid=45_000)
payoff_by_date(loan, desired_payoff_month=270)
>> 500.49
Disclaimer
You should verify any facts and figures with a financial professional before making any financial decisions based on these results.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mortgage_tools-0.0.1.tar.gz.
File metadata
- Download URL: mortgage_tools-0.0.1.tar.gz
- Upload date:
- Size: 590.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1927889ccd04be5cc5f5403272592f60d8f8d6482877cf39f47583e97ebde6
|
|
| MD5 |
6bfafec095670bd5b633746df0098fb6
|
|
| BLAKE2b-256 |
92e9ebab830b84d764b2c98f4a933977748008b96ca0f54911adb989f33b05d5
|
Provenance
The following attestation bundles were made for mortgage_tools-0.0.1.tar.gz:
Publisher:
publish-to-pypi.yml on lmnoel/mortgage-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortgage_tools-0.0.1.tar.gz -
Subject digest:
fe1927889ccd04be5cc5f5403272592f60d8f8d6482877cf39f47583e97ebde6 - Sigstore transparency entry: 154089341
- Sigstore integration time:
-
Permalink:
lmnoel/mortgage-tools@058a8e7ecea72b451b6d8cbbd568f46c27e8a2e1 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/lmnoel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@058a8e7ecea72b451b6d8cbbd568f46c27e8a2e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortgage_tools-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mortgage_tools-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b721608f778a6f2d2ccde1d7210da43028ac9399ba4068f89d83e15ff3fa759
|
|
| MD5 |
bc9899b5f64a51949557a265a805e45a
|
|
| BLAKE2b-256 |
480fcc88198dadd5cc074e6120338bf467238037b3eaec4c92afc25f5314087b
|
Provenance
The following attestation bundles were made for mortgage_tools-0.0.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on lmnoel/mortgage-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortgage_tools-0.0.1-py3-none-any.whl -
Subject digest:
6b721608f778a6f2d2ccde1d7210da43028ac9399ba4068f89d83e15ff3fa759 - Sigstore transparency entry: 154089342
- Sigstore integration time:
-
Permalink:
lmnoel/mortgage-tools@058a8e7ecea72b451b6d8cbbd568f46c27e8a2e1 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/lmnoel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@058a8e7ecea72b451b6d8cbbd568f46c27e8a2e1 -
Trigger Event:
push
-
Statement type: