financial_maths 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWU2OWEwODIyOTFkZmVmMTg1NWViOGJhZDRmYWRlZjQ4OTM3YzQ4YQ==
4
+ MDgyOTgxM2ZiMDRkMzJlZTBkMmQwMWIwZDk1OGQyZGM4YzdkOWM3NQ==
5
5
  data.tar.gz: !binary |-
6
- MzQxOWFlZTE5M2MyYWFjNjE1MTg4MTViNDhmOTk5NmNjYTZkMjU3NQ==
6
+ YjcwNWJlYzRhOGRlMWVlM2I4Y2E1ODBjMWRjODUyOTZhNTM5MzAzMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2Q0MjQzZTA3M2Q5OTBkNTdlZTQ4NmFiMTFmOThlYWY2NTk3ODgzNzBlNDY2
10
- MzZhOGZjNTMyN2JkNmRlNGRlZWJmZjAzMjQ1MjU3OGJjNjc1OGIwZTI1NDA3
11
- OWU5ZmUyM2M1MGJjZjBiMWZkNTMzNzE1MDQwZmEyNDJjODFmNGM=
9
+ ZDQ1MDE4YjNiZTFkZWQ2YTgxMWQwYTE4ZmUyZTdlY2NkOGRjY2FhY2FlYWEz
10
+ ZmQ4OGJiOTljNWQ3ZGExNzI3YTE3ZWQ0OGJlNDAwMzk5NjQ3YTE1YzBhMTYy
11
+ ZWQ1MzIyMWIyOTk5ZGM1MDBmNjNiZTM0NmFmMmFhOGY5YTI5OTM=
12
12
  data.tar.gz: !binary |-
13
- YTRkMDkzZmY4Y2Y1YTEwNzY4MjM2ZTQ0YjRhOTk2ZjAyMjg1NmI3ZTA1ZTAy
14
- YzA2NTVjOTEwMjk1OWFiOGYwODk3YmNhZGEzYWU3NmYwMzVmMWJmYjY0Mjlj
15
- YTRhY2Q3MTM5NDQwNDQ3MmE1OWIwNzc5MjNkZjJhYjY4YTdkM2Y=
13
+ YjkzYmM1NTliMmViZGRlNWU0ZWU0MjRiYTNiNWI4ODNiMjdjODhiMTc5Mjgy
14
+ NjcxZmEzMDlkNWIxOWU5ODhkNzM0MjFiMzUwODkxMzM5ZjgwZTkxNjRkZWRl
15
+ MjRiZWI3NmRiOGFkNjNiZjc2NmRiOTNiOTJiODZhMTBiNDQwOWQ=
data/README.md CHANGED
@@ -2,13 +2,22 @@
2
2
 
3
3
  more functions will be added soon
4
4
 
5
+ #### New in version 0.0.4
6
+
7
+ 1. Amortization tables
8
+ 2. efective_given_nominal_due(nominal_rate, term)
9
+ 3. efective_given_nominal_antipipated
10
+ 4. nominal_antipiated_given_efective
11
+ 5. nominal_due_given_efective
12
+ 6. anticipated_fixed_payment
13
+
5
14
  #### New in version 0.0.3
6
15
 
7
16
  1. future_given_present
8
17
  2. present_given_future
9
18
  3. annuity_given_present
10
19
  4. annuity_given_future
11
- 5. present_given_annuity(
20
+ 5. present_given_annuity
12
21
  6. future_given_annuity
13
22
 
14
23
  #### Pending
@@ -42,7 +51,7 @@ A credit in a period of 15 years, the amount is $100.000.000 and the interest is
42
51
  call the method following the next instruction.
43
52
 
44
53
  ```ruby
45
- fixed_payment_equity(15,100000000,0.0144594763)
54
+ variable_payment_amortization(15,100000000,0.0144594763)
46
55
  ```
47
56
  The result is a hash with the plan of payments, it looks like that
48
57
 
@@ -54,7 +63,7 @@ The result is a hash with the plan of payments, it looks like that
54
63
  .
55
64
  ]
56
65
 
57
- The lists of the methods and they params
66
+ The lists of the methods and their params
58
67
 
59
68
  future_given_present(present_value, interest, term)
60
69
  present_given_future(future_value, interest, term)
@@ -62,6 +71,14 @@ The lists of the methods and they params
62
71
  annuity_given_future(future_value, interest, term)
63
72
  present_given_annuity(annuity, interest, term)
64
73
  future_given_annuity(annuity, interest, term)
74
+ efective_given_nominal_due(nominal_rate, term)
75
+ efective_given_nominal_antipipated(nominal_rate, term)
76
+ nominal_antipiated_given_efective(nominal_rate, term)
77
+ nominal_due_given_efective(nominal_rate, term)
78
+ anticipated_fixed_payment(present_value, rate, term)
79
+
80
+ variable_payment_amortization(periods, amount, rate)
81
+ fixed_payment_amortization(periods, amount, rate, payment)
65
82
 
66
83
  ## Contributing
67
84
 
@@ -1,3 +1,3 @@
1
1
  module FinancialMaths
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -2,14 +2,14 @@ require "financial_maths/version"
2
2
 
3
3
  module FinancialMaths
4
4
 
5
- def fixed_payment_equity(year, amount, year_interest)
6
- years = year*12
7
- monthly_payments = amount/years
5
+ def variable_payment_amortization(periods, amount, rate)
6
+
7
+ monthly_payments = amount/periods
8
8
  result = []
9
9
  result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
10
10
 
11
- for i in 1..years
12
- interest = amount * year_interest
11
+ for i in 1..periods
12
+ interest = amount * rate
13
13
  month_payment = monthly_payments + interest
14
14
  amount -= monthly_payments
15
15
  #date += 1
@@ -22,40 +22,80 @@ module FinancialMaths
22
22
  result
23
23
  end
24
24
 
25
- def fixed_payment_amortization(year, amount, year_interest)
25
+ def fixed_payment_amortization(periods, amount, rate, payment)
26
+ result = []
27
+ result << {:period=> 0, :monthly_payment => nil, :interest => nil, :payment => nil, :balance => amount}
26
28
 
29
+ for i in 1..periods
30
+ interest = amount * rate
31
+ month_payment = payment - interest
32
+ amount -= month_payment
33
+ #date += 1
34
+ result << {:period=> i,
35
+ :payment => payment,
36
+ :interest => interest,
37
+ :monthly_payment => month_payment,
38
+ :balance => amount}
39
+ end
40
+ result
27
41
  end
28
42
 
29
- # hallar futuro dado el valor presente
43
+ # hallar futuro dado el valor presente HFDP
30
44
  def future_given_present(present_value, interest, term)
31
45
  (present_value.to_f * (1 + interest.to_f) ** term).round(4)
32
46
  end
33
47
 
34
- # hallar presente dado el futuro
48
+ # hallar presente dado el futuro HPDF
35
49
  def present_given_future(future_value, interest, term)
36
50
  (future_value.to_f / (1 +interest.to_f) ** term).round(4)
37
51
  end
38
52
 
39
- # hallar Anualidad dado el valor presente
53
+ # hallar Anualidad dado el valor presente HADP
40
54
  def annuity_given_present(present_value, interest, term)
41
- (present_value.to_f * ((interest *(1+interest.to_f) ** term) / ((1 + interest.to_f) ** term) -1)).round(4)
55
+ interest = interest.to_f
56
+ (present_value.to_f * ((interest * (1+interest) ** term) / (((1 + interest) ** term) -1))).round(4)
42
57
  end
43
58
 
44
- # hallar anualidad dado el valor futuro
59
+ # hallar anualidad dado el valor futuro HADF
45
60
  def annuity_given_future(future_value, interest, term)
46
61
  (future_value.to_f * (interest.to_f / ((1 + interest) ** term)-1)).round(4)
47
62
  end
48
63
 
49
- # hallar presente dado la anualidad
64
+ # hallar presente dado la anualidad HPDA
50
65
  def present_given_annuity(annuity, interest, term)
51
66
  (annuity.to_f * (((1 + interest.to_f) ** term) -1) / (interest.to_f * (1 + interest.to_f) ** term )).round(4)
52
67
  end
53
68
 
54
- # hallar futuro dado la anualidad
69
+ # hallar futuro dado la anualidad HFDA
55
70
  def future_given_annuity(annuity, interest, term)
56
71
  (annuity * (((1 + interest.to_f) ** term) -1) / interest.to_f ).round(4)
57
72
  end
58
73
 
74
+ # hallar tasa efectiva dado la tasa nominal vencida NVEF
75
+ def efective_given_nominal_due(nominal_rate, term)
76
+ (((1 + nominal_rate.to_f) ** term)-1).round(4)
77
+ end
78
+
79
+ # hallar tasa efectiva dado la tasa nominal anticipada NAEF
80
+ def efective_given_nominal_antipipated(nominal_rate, term)
81
+ (1 / ((1 - nominal_rate.to_f) ** term)).round(4) - 1
82
+ end
83
+
84
+ # hallar tasa nominal anticipada dado efectiva EFNV
85
+ def nominal_antipiated_given_efective(nominal_rate, term)
86
+ (1 - (1 / (1 + nominal_rate.to_f) ** (1 / term))).round(4)
87
+ end
88
+
89
+ # hallar tasa nominal anticipada dado efectiva EFNV
90
+ def nominal_due_given_efective(nominal_rate, term)
91
+ ((nominal_rate.to_f + 1) ** (1 / term)).round(4)
92
+ end
93
+ # Hallar la cuota fija anticipada HCFA
94
+ def anticipated_fixed_payment(present_value, rate, term)
95
+ ((present_value.to_f * rate.to_f) / ((rate.to_f + 1) - (1 / (1 + rate) ** (term - 1)))).round(4)
96
+ end
97
+
98
+
59
99
  end
60
100
 
61
101
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: financial_maths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Espinosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-05 00:00:00.000000000 Z
11
+ date: 2013-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler