exonio 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +11 -1
- data/lib/exonio/financial.rb +23 -0
- data/lib/exonio/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7c8540cc0960cf7ecaa4ca890b9fcffa0e83188
|
4
|
+
data.tar.gz: 7242e19ab28e0746c164d6d7144763830ddd86a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5060942e118057edcd050a004ec2f0a84ba4ed8054f6c0d6021bd9ee121dc25006bbd0b8a65f7bdc4dedf7b2e79c901a4446feddb8a7d82044c0804f775639e6
|
7
|
+
data.tar.gz: 220d4df06a167c0966b72f98042e6032a13aef295178f88e1dc8cefa60d4b8055e9e53bfd40ee41d1aa47a6e9c2558bbcff6571605f17267c5dcf871aa031b84
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,17 @@ By convention, the negative sign represents cash flow out (i.e. money not
|
|
43
43
|
available today). Thus, saving $100 a month at 5% annual interest leads
|
44
44
|
to $15,692.93 available to spend in 10 years.
|
45
45
|
|
46
|
+
### IPMT
|
47
|
+
|
48
|
+
What is the interest part of a payment in the 8th period (i.e., 8th month),
|
49
|
+
having a $5,000 loan to be paid in 2 years at an annual interest rate of 7.5%?
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Exonio.ipmt(0.075 / 12, 8, 12 * 2, 5_000.00) # ==> -22.612926783996798
|
53
|
+
```
|
54
|
+
|
55
|
+
So, in the 8th payment, $22.61 are the interest part.
|
56
|
+
|
46
57
|
### NPER
|
47
58
|
|
48
59
|
If you only had $150/month to pay towards the loan, how long would it take
|
@@ -91,7 +102,6 @@ There's a lot of formulas to be implemented, including:
|
|
91
102
|
* AMORLINC
|
92
103
|
* DB
|
93
104
|
* DDB
|
94
|
-
* IPMT
|
95
105
|
* IRR
|
96
106
|
* MIRR
|
97
107
|
* NPV
|
data/lib/exonio/financial.rb
CHANGED
@@ -22,6 +22,29 @@ module Exonio
|
|
22
22
|
-(pv * temp + pmt * fact)
|
23
23
|
end
|
24
24
|
|
25
|
+
# Calculates the payment on interest for an investment based on
|
26
|
+
# constant-amount periodic payments and a constant interest rate.
|
27
|
+
#
|
28
|
+
# @param rate [Float] The interest rate as decimal (not per cent) per period
|
29
|
+
# @param per [Integer] The amortization period, in terms of number of periods
|
30
|
+
# @param nper [Integer] The number of payments to be made
|
31
|
+
# @param pv [Float] The present value
|
32
|
+
# @param fv [Float] The future value remaining after the final payment has been made
|
33
|
+
# @param end_or_begining [Integer] Whether payments are due at the end (0) or
|
34
|
+
# beggining (1) of each period
|
35
|
+
#
|
36
|
+
# @return [Float]
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# Exonio.ipmt(0.075 / 12, 8, 12 * 2, 5000) # ==> -22.612926783996798
|
40
|
+
#
|
41
|
+
def ipmt(rate, per, nper, pv, fv = 0, end_or_beginning = 0)
|
42
|
+
pmt = self.pmt(rate, nper, pv, fv, end_or_beginning)
|
43
|
+
fv = self.fv(rate, (per - 1), pmt, pv, end_or_beginning) * rate
|
44
|
+
temp = end_or_beginning == 1 ? fv / (1 + rate) : fv
|
45
|
+
|
46
|
+
(per == 1 && end_or_beginning == 1) ? 0.0 : temp
|
47
|
+
end
|
25
48
|
|
26
49
|
# Calculates the number of payment periods for an investment based on
|
27
50
|
# constant-amount periodic payments and a constant interest rate.
|
data/lib/exonio/version.rb
CHANGED