Code Monkey home page Code Monkey logo

mortgage-calculators's Introduction

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:

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

Response:

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:

mortgageCalculators.monthlyMortgagePaymentsWithExtraPayments({
	loanAmount : 200000,
	interestRate : 6.75,
	termInYears : 5,
	extraPaymentAmount : 300
});

Response:

{
	withExtraPayment : {
		totalMonthlyPayment : 4236.69,
		interestRate : 6.75,
		term : 5,
		totalCost : 233018.07,
		payments : [{ // Array of Annual Break Down
			annualInterestPayment: 12322.85,
			annualPrincipalPayment: 38517.47,
			balance: 161482.53,
			monthlyBreakdown: [{ // Array of monthly breakdowns
				monthlyPayment : 4236.69,
				principalPayment :  3111.69,
				interestPayment :  1125,
				balance :  196888.31
			}...]
		}...]
	},
	withoutExtraPayment : {
		totalMonthlyPayment : 3936.69,
		interestRate : 6.75,
		term : 5,
		totalCost : 236201.53
	}
}

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:

mortgageCalculators.compareFifteenVsThirtyYearMortgages({
	loanAmount : 100000,
	interestRate1 : 3.25,
	interestRate2 : 3.75
});

Response:

{
	fifteenYearMortgage : {
		monthlyMortgagePayment : 702.67,
		totalPayments : 126480.38,
		totalInterest : 26480.38
	},
	thirtyYearMortgage : {
		monthlyMortgagePayment : 463.12,
		totalPayments : 166721.61,
		totalInterest : 66721.61
	}
}

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:

mortgageCalculators.howMuchCanIBorrow({
	interestRate : 3.75,
	grossMonthlyIncome : 4000,
	monthlyDebtPayment :  400,
	termInYears : 30,
	downPayment : 5,
	yearlyPropertyTax : 1200,
	yearlyPropertyInsurance : 1200		
});

Response:

{
  aggressive: {
    downPayment: 12092.01,
    loanAmount: 241840.27,
    priceOfHome: 253932.28
  },
  conservative: {
    downPayment: 9069.01,
    loanAmount: 181380.2,
    priceOfHome: 190449.21
  },
  futureMonthlyPayment: {
    aggressive: {
      principalAndInterest: 1320,
      taxesAndInsurance: 200,
      totalMonthlyPayment: 1520
    },
    conservative: {
      principalAndInterest: 1040,
      taxesAndInsurance: 200,
      totalMonthlyPayment: 1240
    }
  }
}

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:

mortgageCalculators.comparefixedRateVsARM({
	loanAmount : 100000,
	termInYears : 30,
	interestRate : 6.5,
	monthsBeforeFirstAdjustment : 36,
	monthsBetweenAdjustments : 12,
	expectedAdjustmentRate : 0.25,
	initialInterestRate : 6.5,
	maximumInterestRate : 12
});

Response:

 {
	fixedRate : {
		monthlyMortgagePayment : 632.07
	},
	ARM : {
		initialMonthlyMortgagePayment : 632.07,
		maxMonthlyMortgagePayment : 889.32
	}
}

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:

mortgageCalculators.refinanceMortgage({
	interestRate : 3.75,
	loanAmount : 100000,
	termInYears : 30,
	paymentsMade : 12,
	newInterestRate : 2.75,
	newTermInYears : 30	
});

Response:

{
	interestSaved : 16899.79,
	oldMonthlyMortgage : {
		monthlyMortgagePayment : 463.12,
		remainingInterest : 63003
	},
	newMonthlyMortgage : {
		newMortgageTotal : 98161.22,
		monthlyMortgagePayment : 400.73,
		remainingInterest : 46103.21
	}
}

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:

mortgageCalculators.compareBuyVsRent({
	monthlyRent : 800,
	expectedAnnualRentIncrease : 5,
	purchasePrice : 200000,
	downPayment : 5,
	interestRate : 6,
	termInYears : 30,
	closingCosts : 1.5,
	annualAppreciation : 3,
	howLongBeforeSelling : 10,
	currentAnnualInterestOnDownPayment : 3,
	incomeTaxRate : 28
});

Response:

{
	currentValueOfHome: 268783.28,
	totalOwedToBank: 167371.45,
	equityOnHome: 101411.83,
	netCostOfBuying: 11326.5,
	netCostOfRenting: 120747.77,
	benefitOfBuying: 109421.27
}

mortgage-calculators's People

Contributors

amitrathik avatar ritterb82 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mortgage-calculators's Issues

Difference 0.15 in maxMonthlyMortgagePayment of arm calculator

i am getting 0.15 difference in max monthly income of arm calculator for following input value
loan_amount: "100,000",
rate_of_interest: "4",
term: "30",
month_before_first_adjustment: "12",
month_between_adjustment: "12",
expected_adjustment_rate: "0.25",
initial_rate_interest: "3.25",
max_interest_rate: "12",

expected output
maximum_monthly_payment: $686.50
getting output
maximum_monthly_payment: $686.35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.