mortgage
The mortgage file contains classes and functions that can be used to calculate various attributes of a fully amoratarized mortgage period.
Mortgage
- class mortgage_calc.mortgage.Mortgage(value: float, payment: float, interest: float = 7.145, months: float = 360, tax: float = 1.16, ins_rate: float = 0.42, pmi_rate: float = 1.0)[source]
- Parameters:
value – The total value of the property to be purchased
payment – The total down-payment for the property
interest – The annual interest rate for the loan, defaulted to the 2023 value of 7.145%
months – The duration of the loan in units of months. Defaulted to 360
tax – The annual tax rate for the property, defaulted to 1.16%
ins_rate – The annual insurance rate for the property, defaulted to 0.42%.
pmi_rate – The annual rate for private mortgage insurance, defaulted to 1.0%
This class will determine the monthly payments to be made on a purchased property over an entire Amoratized mortgage time line. This class does not account for HOA fees. This class has the following public attributes.
- Variables:
value – The value of the property.
payment – The down payment on the property.
interest – The interests rate for the loan.
months – The number of months over which the loan is distributed.
tax – The rate the property is taxed at.
ins_rate – The insurance rate for the property.
pmi_rate – The Private Mortgage Inusrance. Only applicable when the down payment is less than 20% of the home value.
loan_amount – The value of the loan, value - payment.
monthly_taxes – The tax value paid per month.
monthly_insurance – The insurance paid monthly.
monthly_total – The total amount paid on the property per month.
Examples
Example showing how to instantiate a class and how to access and print attributes.
from mortgage_calc.mortgage import Mortgage # Instantiate class with custom mortage period and interest rate value = 500000.0 # Propertry value payment = 300000.0 # down payment on property rate = 4.5 months = 150.0 property = Mortgage(value, payments, interest=rate, months=months) # Print all attributes print(property) # Print specifc attribute print(property.monthly_total)
Down Payment: $400000.00 Loan Amount: $200000.00 Primary Mortgage: $63986.77 Taxes: $580.00 Insurance: $210.00 Total Monthly Payment: $64776.77 64776.77
- total_interest() float[source]
Calculate the total amount of interest paid over the amortized period.
Example
from mortgage_calc.mortgage import Mortgage home = Mortgage(600000.0, 400000.0, interest=3.15, tax=0.45) interest = home.total_interest() print(f"Total Interest: {interest:.2f}")
>> Total Interest: 109410.55
- total_pmi() float[source]
Calculate the total amount paid in Private Mortgage Insurance (PMI). Assumes PMI is paid until 20% equity is achieved.
Example
from mortgage_calc.mortgage import Mortgage home = Mortgage(600000.0, 100000.0, interest=3.15, tax=0.45) pmi = home.total_pmi() print("Total PMI paid: {pmi:.2f}")
>> Total PMI paid: 10203.35
Affordable Home Value
- mortgage_calc.mortgage.affordable_home_value(monthly_total: float, down_payment: float, interest: float = 7.145, months: float = 360, tax: float = 1.16, ins_rate: float = 0.42) float[source]
Calculate the total value of a home that can be afforded based on a given monthly payment and down payment.
- Parameters:
monthly_total – The total monthly payment, including tax and insurance but excluding PMI.
down_payment – The down payment for the home.
interest – The annual interest rate for the loan (defaulted to 7.145%).
months – The duration of the loan in months (defaulted to 360).
tax – The annual tax rate for the property (defaulted to 1.16%).
ins_rate – The annual insurance rate for the property (defaulted to 0.42%).
- Returns:
The total value of the home that can be afforded.
Example
from mortgage_calc.Mortgage import affordable_home_value) val = affordable_home_value(2815.21, 300000.0, months=360, interest=7.145, tax=1.16) print(f"Home Value: {val:.2f}")
>> 600000.00