financial_math 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b602a59e8cb6248be2b0620edcbbc24d37d7367acb3eb5b5342ccf49ebce3e92
4
- data.tar.gz: fe86b90b686a54f8f462b8a604e0b7f53de9f066c2f7c20d4f2110d49b23ea88
3
+ metadata.gz: c75b430ae023c7b389a1cb1303567f002e83390d7f5d866a9271dafe9eb5a3e0
4
+ data.tar.gz: 062ffa4757770a5228e6f31be3f862d7ff1a7cb1e1647ce9c1dbd39df9d84d99
5
5
  SHA512:
6
- metadata.gz: '09bf54f268a2fea8911f933767392f03ba6caf27a30ea85a22dce431df0ae44362c1c9c1d41d49555eba049d99b2ffb486f9e34bf4cb4131a763125258bdf8ce'
7
- data.tar.gz: ac11588d785b2b00f7bfc67f878f49dc958458449fc50800692f47b21f365f8f49fe724f8a7e9c6c4bacc4198fbce99c5a89beff3e18ab6a484c4beb5d1ce958
6
+ metadata.gz: 6610e4d4d5449e99f6f83b628f7985fa2c8acfa1ca8ec919654f73877eec72fe12033ca9fed3b03108d597e9dcc47f4ce411d05e617a1de47bd8c02a4525296e
7
+ data.tar.gz: f222e973425114c3dabc54bc88c4a4a810fabe0253cdf7a5df2773f60f1481b46c3355fd7e6f5b7160fdee555ea32188d7d1610ee59c0c82c50d192b40f1d66f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- financial_math (0.6.0)
4
+ financial_math (0.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -77,6 +77,10 @@ This command will get the development dependencies installed too.
77
77
 
78
78
  ## Release History
79
79
 
80
+
81
+ * 0.7.0
82
+ * ADD: Add `present_value`, `continous_present_value` to `CompoundInterest` as public methods
83
+ * ADD: Add `internal_rate_of_return`, `real_rate_of_return` and `a_good_investment?` to `CompoundInterest` as public methods
80
84
  * 0.6.0
81
85
  * ADD: Add `@frequency` to `SimpleInterest` class
82
86
  * CHANGE: Change the `periods_in_days` mehtod to `factor` in `SimpleInterest`
@@ -9,6 +9,11 @@ module FinancialMath
9
9
  @nominal_rate = args.fetch(:nominal_rate, 0.0)
10
10
  @effective_rate = args.fetch(:effective_rate, 0.0)
11
11
  @future_value = args.fetch(:future_value, 0.0)
12
+ @inflation_rate = args.fetch(:inflation_rate, 0.0)
13
+ end
14
+
15
+ def a_good_investment?
16
+ real_rate_of_return > 0
12
17
  end
13
18
 
14
19
  def average_growth_rate
@@ -20,6 +25,11 @@ module FinancialMath
20
25
  @future_value.round(2)
21
26
  end
22
27
 
28
+ def continous_present_value
29
+ @present_value = @future_value / Math.exp(@interest_rate * @periods)
30
+ @present_value.round(2)
31
+ end
32
+
23
33
  def effective_rate
24
34
  @effective_rate = (1 + @nominal_rate / @frequency)**@frequency - 1
25
35
  @effective_rate.round(4)
@@ -33,11 +43,23 @@ module FinancialMath
33
43
  @present_value * (factor - 1)
34
44
  end
35
45
 
46
+ def internal_rate_of_return
47
+ ((@future_value / @present_value)**(1.0 / @periods) - 1).round(4)
48
+ end
49
+
50
+ def present_value
51
+ (@future_value / factor).round(2)
52
+ end
53
+
36
54
  def nominal_rate
37
55
  @nominal_rate = ((1 + @effective_rate)**nth_rooth - 1) * @frequency
38
56
  @nominal_rate.round(4)
39
57
  end
40
58
 
59
+ def real_rate_of_return
60
+ ((@interest_rate - @inflation_rate) / (1 + @inflation_rate)).round 4
61
+ end
62
+
41
63
  private
42
64
 
43
65
  def factor
@@ -1,3 +1,3 @@
1
1
  module FinancialMath
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: financial_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Omar Vergara Pérez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-21 00:00:00.000000000 Z
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler