From 73b757419058483c8421c75be8535267df3d03eb Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Wed, 28 Oct 2020 15:54:16 -0400 Subject: [PATCH] init commit --- README.md | 26 ++++++++++++++++++++++++++ mortgage-calculator-test.asd | 1 + mortgage-calculator.asd | 24 ++++++++++++++++++++++++ mortgage-calculator.lisp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 README.md create mode 100644 mortgage-calculator-test.asd create mode 100644 mortgage-calculator.asd create mode 100644 mortgage-calculator.lisp diff --git a/README.md b/README.md new file mode 100644 index 0000000..9e6cf42 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# mortgage-calculator + +Calculate mortgages in multiple ways + +# Overview + +The purpose of this program stems from my inability to find loan calculators +that will let me put in what I want to pay per month to see how much loan +I can afford. + +Thus, this program will be able to calculate mortages in whichever way +you feel fit. + +fixme: Be more specific once program is created + +# Useage + +fixme: Useage examples + +# Documentation + +fixme: Write documentation + +# License + +fixme: Grab ICS diff --git a/mortgage-calculator-test.asd b/mortgage-calculator-test.asd new file mode 100644 index 0000000..76d5ef8 --- /dev/null +++ b/mortgage-calculator-test.asd @@ -0,0 +1 @@ +Unit tests diff --git a/mortgage-calculator.asd b/mortgage-calculator.asd new file mode 100644 index 0000000..0d9b38f --- /dev/null +++ b/mortgage-calculator.asd @@ -0,0 +1,24 @@ +(defsystem mortgage-calculator + :author "Joseph J. Green " + :maintainer "Joseph J. Green " + :license "ISC" + :homepage "https://" + :version "0.1" + :components ((:module "src" + :serial t + :components + ((:file "mortgage-calculator")))) + :description "Mortgage calculators" + :long-description + #.(uiop:read-file-string + (uiop:subpathname *load-pathname* "README.md")) + :in-order-to ((test-op (test-op my-project-test)))) + +#|(defsystem mortgage-calculator-test + :author "Joseph J. Green " + :license "ISC" + :depends-on (:mortgage-calculator) + :components ((:module "t" + :serial t + :components + ((:file "mortgage-calculator"))))) |# diff --git a/mortgage-calculator.lisp b/mortgage-calculator.lisp new file mode 100644 index 0000000..0c400b4 --- /dev/null +++ b/mortgage-calculator.lisp @@ -0,0 +1,34 @@ +;;;; Mortgage Calculators + +#| +loan amount (p) +interest rate (r) +years (t) +payments per year (n) +loan type: fixed-rate + +Payment = P x (r/n) * [1+(r/n)^n * t]/(1+r/n)^n *t - 1 + +or + +P = payment +PV = Present Value +r = rate per period +n = number of periods + +P = (r(PV)) / (1-(1+r)^-n) + +|# + +(defun payments (loan-total rate number-of-payments) + (/ (* rate loan-total) + (- 1 (expt (+ 1 rate) (* number-of-payments -1))))) +(defun monthly-payments(loan-total rate number-of-payments) + "Number of payments in years" + (payments loan-total (/ rate 12) (* number-of-payments 12))) +(defun payment-total-per-year (loan-total rate number-of-payments) + (* (payments loan-total (/ rate 12) (* number-of-payments 12)) 12)) + + + +