Lending

From JoelLewis/finance_skills · View interactive version

Lending is an AI agent skill from the GitHub repository JoelLewis/finance_skills. Analyze lending products including mortgages, HELOCs, and personal loans with amortization and comparison tools. Use when the user asks about mortgage comparison, fixed vs ARM rates, loan qualification, amortization schedules, extra payments, or buying points. Also trigger when users mention 'monthl

How to use this skill

Skill file

Lending Analysis

Core Concepts

Fixed-Rate Mortgage

The interest rate and monthly payment remain constant for the life of the loan:

Adjustable-Rate Mortgage (ARM)

Rate is fixed for an initial period, then adjusts periodically based on an index plus a margin:

Monthly Payment Calculation

The standard amortization formula for a fixed-rate loan:

Total Interest Paid

Extra Payments

Additional principal payments reduce the outstanding balance, shorten the loan term, and reduce total interest:

Mortgage Points

Prepaid interest that reduces the loan's interest rate:

APR vs Interest Rate

HELOC (Home Equity Line of Credit)

A revolving credit line secured by home equity:

Loan Qualification Criteria

PMI (Private Mortgage Insurance)

Required when conventional loan LTV exceeds 80%:

15-Year vs 30-Year Comparison

Key Formulas

| Formula | Expression | Use Case |

|---------|-----------|----------|

| Monthly payment | PMT = P × [r(1+r)^n] / [(1+r)^n - 1] | Fixed-rate loan payment |

| Total interest | n × PMT - P | Total cost of borrowing |

| Remaining balance after k payments | B_k = P × [(1+r)^n - (1+r)^k] / [(1+r)^n - 1] | Balance at any point |

| Points breakeven | Cost of points / monthly savings | Months to recoup points |

| LTV | Loan amount / property value | Risk and PMI assessment |

| CLTV | (First mortgage + HELOC) / home value | Combined leverage |

| ARM fully indexed rate | Index + margin | Rate after fixed period |

Worked Examples

Example 1: 30-year vs 15-year mortgage comparison

Given: Home price $500K, down payment $100K, loan amount $400K. 30-year rate: 6.5%. 15-year rate: 5.9%.

Calculate: Monthly payments, total interest, and interest savings.

Solution:

  1. 30-year monthly payment: PMT = $400,000 × [0.005417 × (1.005417)^360] / [(1.005417)^360 - 1]
  1. 30-year total interest: 360 × $2,528 - $400,000 = $510,178
  2. 15-year monthly payment: PMT = $400,000 × [0.004917 × (1.004917)^180] / [(1.004917)^180 - 1]
  1. 15-year total interest: 180 × $3,354 - $400,000 = $203,694
  2. Payment difference: $3,354 - $2,528 = $826/month more for 15-year.
  3. Interest savings: $510,178 - $203,694 = $306,484 saved by choosing 15-year.
  4. The 15-year costs 33% more per month but saves 60% in total interest.

Example 2: Extra payment impact

Given: $300K 30-year mortgage at 6.5% (payment = $1,896.20/month). Borrower adds $200/month extra to principal, making the total payment $2,096.20/month.

Calculate: Time saved and interest saved.

Solution:

  1. Without extra payments: 360 months, total interest = 360 × $1,896.20 - $300,000 = $382,633.
  2. New term (closed-form estimate): n = -ln(1 - P × r / PMT_total) / ln(1+r) with r = 0.065/12 = 0.005417:
  1. Exact amortization (month-by-month simulation, final payment partial): payoff in 277 months = 23 years 1 month (~23.1 years), total interest = $279,185. The closed form and the exact schedule agree closely.
  2. Interest saved: $382,633 - $279,185 = $103,449.
  3. Time saved: 360 - 277 = 83 months ≈ 6.9 years.
  4. Total extra principal paid ≈ 276 × $200 = $55,200. Interest saved per dollar of extra payment: $103,449 / $55,200 ≈ $1.87.

Common Pitfalls

Cross-References

Running the script

Run the reference implementation directly:

uv run scripts/lending.py          # PEP 723 header resolves dependencies automatically
python3 scripts/lending.py         # after: pip install numpy scipy

A bare run prints a demo covering payment calculation, extra-payment impact, LTV/PMI, DSCR, balloon payments, refinance analysis, points breakeven, and ARM resets. Use --verify to recompute the demo figures and assert they match this skill's worked examples (prints PASS/FAIL, exits nonzero on mismatch), and --help to list the available classes and functions. The file is primarily meant to be imported as a module (from lending import LendingAnalysis) rather than run standalone.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.