financial_maths 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/financial_maths/version.rb +1 -1
- data/lib/financial_maths.rb +15 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13c87971dac11e54b8ea062a728043248cc9dd7c
|
4
|
+
data.tar.gz: 00f5e26cb70ecd67eeb78d6622958788f9e98385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eea9ef44b4d44ef4119e7f50be408914b252ad23f75db5401da959c7db0558ee2b8495df92b36c8ce15a3f968150940fa4ec5ceea3fb36dc7b6a4e5ce3e0f2de
|
7
|
+
data.tar.gz: b449f2d0c6659624799fb57b49c2da4653f9f95333e2dbfe6161a5628c807403b00dfba119a491e8bc319cfbcb7eb69387bdec6cd20a326924038550cd39a206
|
data/lib/financial_maths.rb
CHANGED
@@ -59,11 +59,13 @@ module FinancialMaths
|
|
59
59
|
|
60
60
|
def anticipated_fixed_payment_amortization(periods, amount, rate, payment)
|
61
61
|
result = []
|
62
|
-
|
62
|
+
result << {:period=> 0, :monthly_payment => nil,
|
63
|
+
:interest => amount * rate, :payment => nil,
|
64
|
+
:balance => amount}
|
63
65
|
|
64
|
-
for i in
|
65
|
-
|
66
|
-
|
66
|
+
for i in 1..periods
|
67
|
+
month_payment = payment * ((1-rate) ** (periods - i))
|
68
|
+
interest = payment - month_payment
|
67
69
|
amount -= month_payment
|
68
70
|
#date += 1
|
69
71
|
result << {:period=> i,
|
@@ -107,33 +109,33 @@ module FinancialMaths
|
|
107
109
|
end
|
108
110
|
|
109
111
|
# == Conversion rates
|
110
|
-
|
111
|
-
##
|
112
|
+
|
113
|
+
##
|
112
114
|
# Description: Find effective rate given nominal rate expired - NVEF
|
113
115
|
# Formula: ((1 + (NOMINAL RATE / PERIODS)) ^ PERIODS) - 1
|
114
116
|
def efective_given_nominal_due(nominal_rate, term)
|
115
117
|
((((1+((nominal_rate.to_f/100)/term))**term)-1).round(6))*100
|
116
118
|
end
|
117
|
-
|
119
|
+
|
118
120
|
##
|
119
121
|
# Description: Find effective rate given anticipated nominal rate - NAEF
|
120
122
|
# Formula: ((1 / ((1- (NOMINAL RATE / PERIODS)) ^ PERIODS)) -1
|
121
123
|
def efective_given_nominal_anticipated(nominal_rate, term)
|
122
124
|
(((1/((1-((nominal_rate.to_f/100)/term))**term))-1)*100).round(4)
|
123
125
|
end
|
124
|
-
|
126
|
+
|
125
127
|
##
|
126
128
|
# Description: Find nominal rate anticipated given effective rate - EFNV
|
127
|
-
# Formulas:
|
129
|
+
# Formulas:
|
128
130
|
# nominalRate = (1 + EFFECTIVE RATE)^(1 / PERIODS) - 1
|
129
131
|
# toAnticipated = nominalRate / 1 + nominalRate
|
130
132
|
# Returned -> toAnticipated * PERIODS
|
131
133
|
def nominal_anticipated_given_efective(effective_rate, periods)
|
132
134
|
nominalRate = (1+(effective_rate.to_f/100))**(1/periods.to_f)-1
|
133
135
|
toAnticipated = nominalRate / (1+nominalRate)
|
134
|
-
(toAnticipated * periods.to_f * 100).round(4)
|
136
|
+
(toAnticipated * periods.to_f * 100).round(4)
|
135
137
|
end
|
136
|
-
|
138
|
+
|
137
139
|
##
|
138
140
|
# Description: Find nominal rate expired given effective rate - HCUA
|
139
141
|
# Formula: ((1 + EFFECTIVE RATE) ^ (1 / PERIODS) - 1)* PERIODS
|
@@ -149,11 +151,10 @@ module FinancialMaths
|
|
149
151
|
end
|
150
152
|
|
151
153
|
# == End conversion rates
|
152
|
-
|
154
|
+
|
153
155
|
# Hallar la cuota fija anticipada HCFA
|
154
156
|
def anticipated_fixed_payment(present_value, rate, term)
|
155
|
-
|
156
|
-
((present_value.to_f * a_rate.to_f) / ((a_rate.to_f + 1) - (1 / (1 + a_rate) ** (term - 1)))).round(4)
|
157
|
+
((present_value.to_f) / ((1 - (1 - rate.to_f ) ** term ) / rate.to_f )).round(4)
|
157
158
|
end
|
158
159
|
|
159
160
|
def variable_payment(amount, periods)
|
@@ -161,5 +162,3 @@ module FinancialMaths
|
|
161
162
|
end
|
162
163
|
|
163
164
|
end
|
164
|
-
|
165
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: financial_maths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruben Espinosa
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|