init commit

This commit is contained in:
Logen Kain 2020-10-28 15:54:16 -04:00
commit 73b7574190
4 changed files with 85 additions and 0 deletions

26
README.md Normal file
View File

@ -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

View File

@ -0,0 +1 @@
Unit tests

24
mortgage-calculator.asd Normal file
View File

@ -0,0 +1,24 @@
(defsystem mortgage-calculator
:author "Joseph J. Green <logen@sudotask.com>"
:maintainer "Joseph J. Green <logen@sudotask.com>"
: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 <logen@sudotask.com>"
:license "ISC"
:depends-on (:mortgage-calculator)
:components ((:module "t"
:serial t
:components
((:file "mortgage-calculator"))))) |#

34
mortgage-calculator.lisp Normal file
View File

@ -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))