2 * Introduction to finance::
3 * Functions and Variables for finance::
6 @node Introduction to finance, Functions and Variables for finance, Package finance, Package finance
7 @section Introduction to finance
9 This is the Finance Package (Ver 0.1).
11 In all the functions, @var{rate} is the compound interest
12 rate, @var{num} is the number of periods and must be
13 positive and @var{flow} refers to cash flow so if you
14 have an Output the flow is negative and positive
17 Note that before using the functions defined in this
18 package, you have to load it writing @code{load("finance")$}.
20 Author: Nicolas Guarin Zapata.
22 @node Functions and Variables for finance, , Introduction to finance, Package finance
23 @section Functions and Variables for finance
27 @deffn {Function} days360 (@var{year1},@var{month1},@var{day1},@var{year2},@var{month2},@var{day2})
29 Calculates the distance between 2 dates, assuming 360 days years, 30 days months.
34 (%i1) load("finance")$
35 (%i2) days360(2008,12,16,2007,3,25);
39 @opencatbox{Categories:}
40 @category{Package finance}
47 @deffn {Function} fv (@var{rate},@var{PV},@var{num})
49 We can calculate the future value of a Present one given a certain interest rate.
50 @var{rate} is the interest rate, @var{PV} is the present value and @var{num} is
51 the number of periods.
56 (%i1) load("finance")$
57 (%i2) fv(0.12,1000,3);
61 @opencatbox{Categories:}
62 @category{Package finance}
69 @deffn {Function} pv (@var{rate},@var{FV},@var{num})
71 We can calculate the present value of a Future one given a certain interest rate.
72 @var{rate} is the interest rate, @var{FV} is the future value and @var{num} is
73 the number of periods.
78 (%i1) load("finance")$
79 (%i2) pv(0.12,1000,3);
80 (%o2) 711.7802478134108
83 @opencatbox{Categories:}
84 @category{Package finance}
91 @deffn {Function} graph_flow (@var{val})
93 Plots the money flow in a time line, the positive values are in blue
94 and upside; the negative ones are in red and downside.
95 The direction of the flow is given by the sign of the value.
96 @var{val} is a list of flow values.
101 (%i1) load("finance")$
102 (%i2) graph_flow([-5000,-3000,800,1300,1500,2000])$
105 @opencatbox{Categories:}
106 @category{Package finance}
113 @deffn {Function} annuity_pv (@var{rate},@var{PV},@var{num})
115 We can calculate the annuity knowing the present value (like an amount),
116 it is a constant and periodic payment. @var{rate} is the interest rate,
117 @var{PV} is the present value and @var{num} is the number of periods.
122 (%i1) load("finance")$
123 (%i2) annuity_pv(0.12,5000,10);
124 (%o2) 884.9208207992202
127 @opencatbox{Categories:}
128 @category{Package finance}
135 @deffn {Function} annuity_fv (@var{rate},@var{FV},@var{num})
137 We can calculate the annuity knowing the desired value (future value),
138 it is a constant and periodic payment. @var{rate} is the interest rate,
139 @var{FV} is the future value and @var{num} is the number of periods.
144 (%i1) load("finance")$
145 (%i2) annuity_fv(0.12,65000,10);
146 (%o2) 3703.970670389863
149 @opencatbox{Categories:}
150 @category{Package finance}
156 @anchor{geo_annuity_pv}
157 @deffn {Function} geo_annuity_pv (@var{rate},@var{growing_rate},@var{PV},@var{num})
159 We can calculate the annuity knowing the present value (like an amount),
160 in a growing periodic payment. @var{rate} is the interest rate, @var{growing_rate}
161 is the growing rate, @var{PV} is the present value and @var{num} is the number of periods.
166 (%i1) load("finance")$
167 (%i2) geo_annuity_pv(0.14,0.05,5000,10);
168 (%o2) 802.6888176505123
171 @opencatbox{Categories:}
172 @category{Package finance}
178 @anchor{geo_annuity_fv}
179 @deffn {Function} geo_annuity_fv (@var{rate},@var{growing_rate},@var{FV},@var{num})
181 We can calculate the annuity knowing the desired value (future value),
182 in a growing periodic payment. @var{rate} is the interest rate, @var{growing_rate}
183 is the growing rate, @var{FV} is the future value and @var{num} is the number of periods.
188 (%i1) load("finance")$
189 (%i2) geo_annuity_fv(0.14,0.05,5000,10);
190 (%o2) 216.5203395312695
193 @opencatbox{Categories:}
194 @category{Package finance}
199 @anchor{amortization}
200 @deffn {Function} amortization (@var{rate},@var{amount},@var{num})
202 Amortization table determined by a specific rate.
203 @var{rate} is the interest rate, @var{amount} is the amount value,
204 and @var{num} is the number of periods.
209 (%i1) load("finance")$
210 (%i2) amortization(0.05,56000,12)$
211 "n" "Balance" "Interest" "Amortization" "Payment"
212 0.000 56000.000 0.000 0.000 0.000
213 1.000 52481.777 2800.000 3518.223 6318.223
214 2.000 48787.643 2624.089 3694.134 6318.223
215 3.000 44908.802 2439.382 3878.841 6318.223
216 4.000 40836.019 2245.440 4072.783 6318.223
217 5.000 36559.597 2041.801 4276.422 6318.223
218 6.000 32069.354 1827.980 4490.243 6318.223
219 7.000 27354.599 1603.468 4714.755 6318.223
220 8.000 22404.106 1367.730 4950.493 6318.223
221 9.000 17206.088 1120.205 5198.018 6318.223
222 10.000 11748.170 860.304 5457.919 6318.223
223 11.000 6017.355 587.408 5730.814 6318.223
224 12.000 0.000 300.868 6017.355 6318.223
227 @opencatbox{Categories:}
228 @category{Package finance}
234 @anchor{arit_amortization}
235 @deffn {Function} arit_amortization (@var{rate},@var{increment},@var{amount},@var{num})
237 The amortization table determined by a specific rate and with growing payment
238 can be calculated by @code{arit_amortization}.
239 Notice that the payment is not constant, it presents
240 an arithmetic growing, increment is then the difference between two
241 consecutive rows in the "Payment" column.
242 @var{rate} is the interest rate, @var{increment} is the increment, @var{amount}
243 is the amount value, and @var{num} is the number of periods.
248 (%i1) load("finance")$
249 (%i2) arit_amortization(0.05,1000,56000,12)$
250 "n" "Balance" "Interest" "Amortization" "Payment"
251 0.000 56000.000 0.000 0.000 0.000
252 1.000 57403.679 2800.000 -1403.679 1396.321
253 2.000 57877.541 2870.184 -473.863 2396.321
254 3.000 57375.097 2893.877 502.444 3396.321
255 4.000 55847.530 2868.755 1527.567 4396.321
256 5.000 53243.586 2792.377 2603.945 5396.321
257 6.000 49509.443 2662.179 3734.142 6396.321
258 7.000 44588.594 2475.472 4920.849 7396.321
259 8.000 38421.703 2229.430 6166.892 8396.321
260 9.000 30946.466 1921.085 7475.236 9396.321
261 10.000 22097.468 1547.323 8848.998 10396.321
262 11.000 11806.020 1104.873 10291.448 11396.321
263 12.000 -0.000 590.301 11806.020 12396.321
266 @opencatbox{Categories:}
267 @category{Package finance}
273 @anchor{geo_amortization}
274 @deffn {Function} geo_amortization (@var{rate},@var{growing_rate},@var{amount},@var{num})
276 The amortization table determined by rate, amount,
277 and number of periods can be found by @code{geo_amortization}.
278 Notice that the payment is not constant, it presents
279 a geometric growing, @var{growing_rate} is then the quotient between two
280 consecutive rows in the "Payment" column.
281 @var{rate} is the interest rate, @var{amount}
282 is the amount value, and @var{num} is the number of periods.
287 (%i1) load("finance")$
288 (%i2) geo_amortization(0.05,0.03,56000,12)$
289 "n" "Balance" "Interest" "Amortization" "Payment"
290 0.000 56000.000 0.000 0.000 0.000
291 1.000 53365.296 2800.000 2634.704 5434.704
292 2.000 50435.816 2668.265 2929.480 5597.745
293 3.000 47191.930 2521.791 3243.886 5765.677
294 4.000 43612.879 2359.596 3579.051 5938.648
295 5.000 39676.716 2180.644 3936.163 6116.807
296 6.000 35360.240 1983.836 4316.475 6300.311
297 7.000 30638.932 1768.012 4721.309 6489.321
298 8.000 25486.878 1531.947 5152.054 6684.000
299 9.000 19876.702 1274.344 5610.176 6884.520
300 10.000 13779.481 993.835 6097.221 7091.056
301 11.000 7164.668 688.974 6614.813 7303.787
302 12.000 0.000 358.233 7164.668 7522.901
305 @opencatbox{Categories:}
306 @category{Package finance}
313 @deffn {Function} saving (@var{rate},@var{amount},@var{num})
315 The table that represents the values in a constant and periodic
316 saving can be found by @code{saving}.
317 @var{amount} represents the desired quantity and num the number
323 (%i1) load("finance")$
324 (%i2) saving(0.15,12000,15)$
325 "n" "Balance" "Interest" "Payment"
326 0.000 0.000 0.000 0.000
327 1.000 252.205 0.000 252.205
328 2.000 542.240 37.831 252.205
329 3.000 875.781 81.336 252.205
330 4.000 1259.352 131.367 252.205
331 5.000 1700.460 188.903 252.205
332 6.000 2207.733 255.069 252.205
333 7.000 2791.098 331.160 252.205
334 8.000 3461.967 418.665 252.205
335 9.000 4233.467 519.295 252.205
336 10.000 5120.692 635.020 252.205
337 11.000 6141.000 768.104 252.205
338 12.000 7314.355 921.150 252.205
339 13.000 8663.713 1097.153 252.205
340 14.000 10215.474 1299.557 252.205
341 15.000 12000.000 1532.321 252.205
344 @opencatbox{Categories:}
345 @category{Package finance}
352 @deffn {Function} npv (@var{rate},@var{val})
354 Calculates the present value of a value series to evaluate the viability in a
356 @var{val} is a list of varying cash flows.
361 (%i1) load("finance")$
362 (%i2) npv(0.25,[100,500,323,124,300]);
363 (%o2) 714.4703999999999
366 @opencatbox{Categories:}
367 @category{Package finance}
374 @deffn {Function} irr (@var{val},@var{IO})
376 IRR (Internal Rate of Return) is the value of rate which makes Net Present Value
378 @var{flowValues} is a list of varying cash flows,
379 @var{I0} is the initial investment.
384 (%i1) load("finance")$
385 (%i2) res:irr([-5000,0,800,1300,1500,2000],0)$
386 (%i3) rhs(res[1][1]);
387 (%o3) .03009250374237132
390 @opencatbox{Categories:}
391 @category{Package finance}
397 @anchor{benefit_cost}
398 @deffn {Function} benefit_cost (@var{rate},@var{input},@var{output})
400 Calculates the ratio Benefit/Cost. Benefit is the Net Present Value (NPV)
401 of the inputs, and Cost is the Net Present Value (NPV) of the outputs.
402 Notice that if there is not an input or output value in a specific period,
403 the input/output would be a zero for that period.
404 @var{rate} is the interest rate, @var{input} is a list of input values,
405 and @var{output} is a list of output values.
410 (%i1) load("finance")$
411 (%i2) benefit_cost(0.24,[0,300,500,150],[100,320,0,180]);
412 (%o2) 1.427249324905784
415 @opencatbox{Categories:}
416 @category{Package finance}