项目作者: AMBRDetroit

项目描述 :
Mortgage Calculators done in JavaScript
高级语言: HTML
项目地址: git://github.com/AMBRDetroit/mortgage-calculators.git
创建时间: 2016-02-04T04:11:29Z
项目社区:https://github.com/AMBRDetroit/mortgage-calculators

开源协议:

下载


Mortgage Calculators

This JS Library contains functions commonly used with mortgage calculations.

Background

While trying to build a set of mortgage calculators for a client, we were hoping to find a Javascript library that contained the functions.
After hours of research, we were unable to find any Javascript library. However, we found a bunch of spreadsheets and after thorough investigation, developed our own functions.

Getting Started

To get started you can download the minified code src/mortgage-calculators.js or clone the entire repo and import it into your next project.

Modules

This library contains 7 different modules used for different

  1. Monthly Mortgage Payment
  2. Monthly Mortgage Payment With Extra Monthly Payments
  3. 15 Year VS 30 Year Mortgage
  4. How Much Can I Borrow ?
  5. Fixed Rate VS ARM
  6. Refinance Mortgage
  7. Should I Buy or Rent a home?

Monthly Mortgage Payment

Description:

This module calculates the monthly mortgage payment based on the loan amount, annual interest rate, and the term in years.

Usage:

  1. mortgageCalculators.monthlyMortgagePayments({
  2. loanAmount : 100000,
  3. interestRate : 3.75, (Annual Rate, will be converted to a monthly percentage in calculations)
  4. termInYears : 30
  5. });

Response:

  1. Returns 463.12;

Monthly Mortgage Payment With Extra Monthly Payments

Description:

This module calculates the monthly monthly payment from above with an extra monthly payment amount. It returns an object with annual and monthly breakdowns.

Usage:

  1. mortgageCalculators.monthlyMortgagePaymentsWithExtraPayments({
  2. loanAmount : 200000,
  3. interestRate : 6.75,
  4. termInYears : 5,
  5. extraPaymentAmount : 300
  6. });

Response:

  1. {
  2. withExtraPayment : {
  3. totalMonthlyPayment : 4236.69,
  4. interestRate : 6.75,
  5. term : 5,
  6. totalCost : 233018.07,
  7. payments : [{ // Array of Annual Break Down
  8. annualInterestPayment: 12322.85,
  9. annualPrincipalPayment: 38517.47,
  10. balance: 161482.53,
  11. monthlyBreakdown: [{ // Array of monthly breakdowns
  12. monthlyPayment : 4236.69,
  13. principalPayment : 3111.69,
  14. interestPayment : 1125,
  15. balance : 196888.31
  16. }...]
  17. }...]
  18. },
  19. withoutExtraPayment : {
  20. totalMonthlyPayment : 3936.69,
  21. interestRate : 6.75,
  22. term : 5,
  23. totalCost : 236201.53
  24. }
  25. }

15 Year VS 30 Year Mortgage

Description:

This module calculates the comparison of a 15-year mortgage with a 30-year mortgage based on the loan amount, and the interest rate of the respective year.

Usage:

  1. mortgageCalculators.compareFifteenVsThirtyYearMortgages({
  2. loanAmount : 100000,
  3. interestRate1 : 3.25,
  4. interestRate2 : 3.75
  5. });

Response:

  1. {
  2. fifteenYearMortgage : {
  3. monthlyMortgagePayment : 702.67,
  4. totalPayments : 126480.38,
  5. totalInterest : 26480.38
  6. },
  7. thirtyYearMortgage : {
  8. monthlyMortgagePayment : 463.12,
  9. totalPayments : 166721.61,
  10. totalInterest : 66721.61
  11. }
  12. }

How Much Can I Borrow?

Description:

This module calculates how much you could be expected to borrow from a lender based on various parameters. It returns an aggressive and conservative break down using commonly used debt-to-payment ratios.

Usage:

  1. mortgageCalculators.howMuchCanIBorrow({
  2. interestRate : 3.75,
  3. grossMonthlyIncome : 4000,
  4. monthlyDebtPayment : 400,
  5. termInYears : 30,
  6. downPayment : 5,
  7. yearlyPropertyTax : 1200,
  8. yearlyPropertyInsurance : 1200
  9. });

Response:

  1. {
  2. aggressive: {
  3. downPayment: 12092.01,
  4. loanAmount: 241840.27,
  5. priceOfHome: 253932.28
  6. },
  7. conservative: {
  8. downPayment: 9069.01,
  9. loanAmount: 181380.2,
  10. priceOfHome: 190449.21
  11. },
  12. futureMonthlyPayment: {
  13. aggressive: {
  14. principalAndInterest: 1320,
  15. taxesAndInsurance: 200,
  16. totalMonthlyPayment: 1520
  17. },
  18. conservative: {
  19. principalAndInterest: 1040,
  20. taxesAndInsurance: 200,
  21. totalMonthlyPayment: 1240
  22. }
  23. }
  24. }

Fixed Rate VS ARM

Description:

This module calculates the comparison between a fixed rate mortgage and an adjustable rate mortgage based on various parameters.

Usage:

  1. mortgageCalculators.comparefixedRateVsARM({
  2. loanAmount : 100000,
  3. termInYears : 30,
  4. interestRate : 6.5,
  5. monthsBeforeFirstAdjustment : 36,
  6. monthsBetweenAdjustments : 12,
  7. expectedAdjustmentRate : 0.25,
  8. initialInterestRate : 6.5,
  9. maximumInterestRate : 12
  10. });

Response:

  1. {
  2. fixedRate : {
  3. monthlyMortgagePayment : 632.07
  4. },
  5. ARM : {
  6. initialMonthlyMortgagePayment : 632.07,
  7. maxMonthlyMortgagePayment : 889.32
  8. }
  9. }

Refinance Mortgage

Description:

This module calculates new values for a new monthly mortgage after an n number of payments are already made. Returns an object with old and new mortgage values and the interest potentially saved by refinancing.

Usage:

  1. mortgageCalculators.refinanceMortgage({
  2. interestRate : 3.75,
  3. loanAmount : 100000,
  4. termInYears : 30,
  5. paymentsMade : 12,
  6. newInterestRate : 2.75,
  7. newTermInYears : 30
  8. });

Response:

  1. {
  2. interestSaved : 16899.79,
  3. oldMonthlyMortgage : {
  4. monthlyMortgagePayment : 463.12,
  5. remainingInterest : 63003
  6. },
  7. newMonthlyMortgage : {
  8. newMortgageTotal : 98161.22,
  9. monthlyMortgagePayment : 400.73,
  10. remainingInterest : 46103.21
  11. }
  12. }

Should I Buy or Rent a Home?

Description:

This module calculates the potential benefits of buying a home as opposed to renting a home based on various given parameters. Returns a break down of the various costs of both buying vs renting, and a final value of money saved by buying. This final value may be negative to indicate a benefit of renting rather than buying.

Usage:

  1. mortgageCalculators.compareBuyVsRent({
  2. monthlyRent : 800,
  3. expectedAnnualRentIncrease : 5,
  4. purchasePrice : 200000,
  5. downPayment : 5,
  6. interestRate : 6,
  7. termInYears : 30,
  8. closingCosts : 1.5,
  9. annualAppreciation : 3,
  10. howLongBeforeSelling : 10,
  11. currentAnnualInterestOnDownPayment : 3,
  12. incomeTaxRate : 28
  13. });

Response:

  1. {
  2. currentValueOfHome: 268783.28,
  3. totalOwedToBank: 167371.45,
  4. equityOnHome: 101411.83,
  5. netCostOfBuying: 11326.5,
  6. netCostOfRenting: 120747.77,
  7. benefitOfBuying: 109421.27
  8. }