Affordable Loan
Calculates the loan a fixed monthly payment carries at every weekly US mortgage rate: the 30-year fixed-rate mortgage the payment repays, and how that loan compares with the one it carried at the start date. By default the payment is the one a 400,000 US dollar loan had at the first rate of the range, so the answer is how much house the same monthly budget buys as rates move (the 1,611.86 a month of a 400,000 loan at 2.65% carries 237,935 at 7.18%).
The loan is an annuity, repaid in equal payments. The formula is as follows:
\[\text{Affordable Loan} = P \cdot (1 - (1 + r) ^{-n}) / r,\;\; \text{or}\; P \cdot n \;\text{when}\; r \;\text{is zero}\] \[\text{Change} = \text{Affordable Loan} / \text{Affordable Loan} (\text{first date}) - 1\]Where:
\[P = \text{Payment per period}\] \[r = \text{Rate} / \text{payments per year},\;\; \text{the rate per payment}\] \[n = \text{years} \cdot \text{payments per year},\;\; \text{the number of payments}\]US mortgage rates are quoted as a nominal annual rate compounded monthly, so the rate per payment is the annual rate divided by twelve. The rate is the weekly average 30-year fixed rate of Freddie Mac’s Primary Mortgage Market Survey, from FRED when a FRED API key is set and from Freddie Mac otherwise. For a rate of your own, use loan_model.get_affordable_loan.
Also known as: affordability, how much can I borrow, mortgage affordability, borrowing capacity, loan amount from payment.
Affordable Loan in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_affordable_loan as shown below.
from financetoolkit import FixedIncome
fixedincome = FixedIncome(start_date='2021-01-01', end_date='2026-11-06')
fixedincome.get_affordable_loan().iloc[[0, -1]]
Or, after setting up the Finance Toolkit MCP, ask:
With the monthly payment of a 400,000 dollar 30-year US mortgage in January 2021, how much could a buyer borrow on 5 November 2026?
Which returns:
| Date | Rate | Payment | Affordable Loan | Change |
|---|---|---|---|---|
| 2021-01-07 | 0.0265 | 1611.8552 | 400000.0000 | 0.0000 |
| 2026-11-05 | 0.0718 | 1611.8552 | 237935.0883 | -0.4052 |
Parameters
get_affordable_loan accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
payment | float | None | The payment per period. Defaults to None, the payment of a loan of principal at the first rate between the start and end date. | None, the payment of a loan of principal at the first rate between the start and end date |
principal | float | The loan whose payment at the first rate is used when no payment is given. Defaults to 400,000. | 400,000 |
years | float | The term of the loan in years. The rate stays the 30-year fixed mortgage rate for another term. Defaults to 30. | 30 |
payments_per_year | int | The number of payments per year. Defaults to 12. | 12 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the class. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |