JPhrases/Finance

From J Wiki
Jump to navigation Jump to search

12A. Finance

d0=: %@>:@(] % 100"_) #. |.@[ Present value flows x at y%
d1=: >:@(] % 100"_) #. [ Future value of flows x at interest rate y
d2=: ([: >: [ % 100"_) ^/ ] Amount of 1 at x% for y periods
d3=: 13 : '|: y%-.(>:y) ^/ -x' Annuity coefficient: periods x at rate y
d4=: [ d3 [: m5 ] Annuity coefficient: periods x at y %
m5=: 0.01&* Rate from percent
m6=: 100&* Percent from rate
d7=: <: @ ((^%)~ >:) Modal rate from annual rate
d8=: stretch=: [ $ ] , ($ ,: @ {:) Stretch y to length x
d9=: */\ @ (1&,) @ (stretch >:) Accumulate at y for period x
m10=: (% {.) @ (|.@(+/\)@i.@>:) Outstanding balances on rule of 78
m11=: }.%}: Rate of change from amounts
m12=: 2&((%~)/\) Rate of change from amounts
d13=:4 :'r*+/\y%r=:*/\1,x$~<:#y' Accumulate deposits y at x
d14=: [+2: -/\ [: >./\ 0:,[: +/\ - Work done; x=capacity, y=demand

Convert an annual interest rate of 7% to a monthly rate.

   ]m=: 12 d7 0.07
0.00565415
   (1 + m)^12
1.07

Calculate the amount of 1 for 5 periods at rates of 7% for the first two years and 6% thereafter. The function d9 uses d8 to fill out the term with the last given rate.

   5 d9 0.07 0.07 0.06
1 1.07 1.1449 1.21359 1.28641 1.36359

Calculate the declining balances for a year for 1 using the rule of 78.

   ,.m10 12
        1
 0.846154
 0.705128
 0.576923
 0.461538
 0.358974
 0.269231
 0.192308
 0.128205
0.0769231
0.0384615
0.0128205
        0
   x: m10 12
1 11r13 55r78 15r26 6r13 14r39 7r26 5r26 5r39 1r13 1r26 1r78 0
   78 * m10 12
78 66 55 45 36 28 21 15 10 6 3 1 0

Calculate the balances after periodic payments of 100, 100, 200, and 200 are made at rates of 10%, 10%, and 5%.

   1.10 1.10 1.05 m13 100 100 200 200
100 210 431 652.55