loan.ijs

Script: ~addons/finance/finexec/basicfinance/loan.ijs
Contributor: William Szuch
Updated: 2022 6 25
Depend: ~addons/graphics/plot/plot.ijs
        ~addons/finance/finexec/ipm/mwrr.ijs
        ~addons/finance/finexec/toolbox/plot.ijs
Definitions: loaded to locale base
Status: dev
Script source: loan.ijs

Definitions for loan calculation problems with
a constant effective interest rate over the loan period.
Defintions for loan schedules and plots.
No rounding in calculations unles specified in the definition.

Definitions

L loanBal, loanLevelPmt, loanLevelPmtEffRate, loanMonthlyPmt, loanMonthlyPmtShd, loanTerm, loanTermMonths, loanVarPmtsEffRate
P plotLoanMonthlyPmtShd

loanBal (monad)

Form: explicit
Depend: nil
Loan balance over one time unit after interest and loan repayment.
Result is a 5 item list:
(1) loan balance at start of the time unit
(2) effective interest rate for the time unit
(3) interest payable at the end of the time unit
(4) payment made at the end of the time unit
(5) loan balance at the end of the time unit
    a negative balance is an overpayment

Syntax

loanBal(L;E;P)
L = loan balance at start of time unit
E = effective rate of interest for the time unit
P = payment at the end of the time unit

Example

   loanBal(100000;0.06;7110)
100000 0.06 6000 7110 98890
  loanBal(1000;0.06;1200)
1000 0.06 60 1200 _140
  loanBal(1000;0.06;55)

loanLevelPmt (dyad)

Form: tacit
Depend: nil
Calculate the level loan repayments for time units.
Loan repayments commence at the end of the first time unit.

Syntax

(E)loanLevelPmt(L;N)
E = effective rate of interest for the time unit
L = amount of the loan
N = number of loan repayments (integer)

Example

   (0.06)loanLevelPmt(100000;12)
11927.7
   (0.06 0.05)loanLevelPmt(100000;10 15 20)
13586.8 12950.5
10296.3 9634.23
8718.46 8024.26

loanLevelPmtEffRate (verb)

Form: explicit
Depend: mwrPeriodic
Calculate the effective rate of interest for a time unit
for a loan with level repayments at each time unit.
Depend: mwrPeriodic

loanMonthlyPmt (dyad)

Form: tacit
Depend: nil
Calculate the level monthly loan repayments.
Loan repayments commence at the end of the first month.

Syntax

(R)loanMonthlyPmt(L;M)
R = yearly nominal rates of interest payable monthly
L = amount of the loan
M = period of the loan in months (integer)

Example

   (0.06)loanMonthlyPmt(100000;120)
1110.21
   (0.06 0.05)loanMonthlyPmt(100000;120 132 144)
1110.21 1060.66
 1036.7 986.449
 975.85  924.89

loanMonthlyPmtShd (verb)

Form: explicit
Depend: loanBal
Calculate the monthly loan repayment schedule.
Interest and monthly payment paid at end of the month.

Syntax

([Opt])loanMonthlyPmtShd(R;L;M)
[Opt] = optional result display:
        default numeric table with columns:
 Opt =  1 boxed  table with header
       'Month';'Bal Start';'Eff Rate';'Int';'Pmt';'Bal End'
R = annual nominal rate of interest payable monthly
L = amount of the loan
M = period of the loan in months (integer)

Example

   loanMonthlyPmtShd(0.12;100000;120)
  (1)loanMonthlyPmtShd(0.12;100000;120)

loanTerm (monad)

Form: explicit
Depend: loanBal
Calculate the number of time units to fully repay
a loan. The result is a two item list:
(1) number of time units payments
(2) amount of over payment in the final payment
No rounding in the calculations.

Syntax

loanTermMonths(L;R;P)
L = amount of loan
E = effective interest rate for the time unit
P = loan repayment at end of time unit

Example

  loanTerm(100000;0.01;12000)
 9 _3053.8
 loanTerm(100000;0.005;1110.21)
120 _0.816215
 loanTerm(100000;0.005;975.85)
145 _975.805
 loanTerm(1000;0.01;1200)
1 _190
 loanTerm(1000;0.01;1)
┌───────────────────────────────┐
│Loan Payments not repaying loan│
└───────────────────────────────┘

loanTermMonths (monad)

Form: explicit
Depend: loanBal
Calculate the number of months to fully repay
a loan. The result is a two item list:
(1) number of monthly payments
(2) amount of over payment in the final monthly payment
No rounding in the calculations.

Syntax

loanTermMonths(L;R;P)
L = amount of loan
R = yearly nominal interest rate payable monthly
P = monthly loan repayment

Example

  loanTermMonths(100000;0.12;12000)
 9 _3053.8
 loanTermMonths(100000;0.06;1110.21)
120 _0.816215
 loanTermMonths(100000;0.06;975.85)
145 _975.805
 loanTermMonths(1000;0.06;1200)
1 _195

 loanTermMonths(1000;0.06;5)
┌───────────────────────────────┐
│Loan Payments not repaying loan│
└───────────────────────────────┘

loanVarPmtsEffRate (verb)

Form: explicit
Depend: mwr
Calculate the effective rate of interest for a time unit
for a loan with variable repayments at each time unit.
Depend: mwr

plotLoanMonthlyPmtShd (monad)

Form: explicit
Depend: loanMonthlyPmtShd
               plotm
Plot the loan monthly payment schedule details.

Syntax

plotLoanMonthlyPmtShd(R;L;M)
R = yearly nominal rate of interest payable monthly
L = amount of the loan
M = period of the loan in months (integer)

Example

   plotLoanMonthlyPmtShd(0.05;100000;120)
   plotLoanMonthlyPmtShd(0.06;100000;360)
   plotLoanMonthlyPmtShd(0.05;100000;12)