financial_math 0.3.1 → 0.4.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/financial_math/compound_interest.rb +41 -0
- data/lib/financial_math/version.rb +1 -1
- data/lib/financial_math.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85d7bef08ae4b2d40293f618f5f05423202353b11374c5dea7c374dd6c0d94e7
|
|
4
|
+
data.tar.gz: cd732a3b96217bc0e484ca63b131b7a75052cf79af83448c42e6339c31d48f15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3389a31479535fe268bcc87a98a6a370e6f8b03337e2e861702909b7dc26aee6cd1bc174262ef537ba616575dd6094ddaa956239d88b4969d1fee2003e7fc0dc
|
|
7
|
+
data.tar.gz: acb5b463279313390aec97a2548850d69ff7ea016ff624a638f29bc94a58fce741c0f020923bc971ecf338adb865416901a0d37a666fa727e6516dd6c63d0653
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module FinancialMath
|
|
2
|
+
class CompoundInterest
|
|
3
|
+
def initialize(args)
|
|
4
|
+
@present_value = args.fetch(:present_value, 0.0)
|
|
5
|
+
@periods = args.fetch(:periods, 1.0)
|
|
6
|
+
# frequency of conversions
|
|
7
|
+
@frequency = args.fetch(:frequency, 1.0)
|
|
8
|
+
@interest_rate = args.fetch(:interest_rate, 0.0)
|
|
9
|
+
@nominal_rate = args.fetch(:nominal_rate, 0.0)
|
|
10
|
+
@effective_rate = args.fetch(:effective_rate, 0.0)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def effective_rate
|
|
14
|
+
@effective_rate = (1 + @nominal_rate / @frequency)**@frequency - 1
|
|
15
|
+
@effective_rate.round(4)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def future_value
|
|
19
|
+
(@present_value * factor).round(2)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def interest
|
|
23
|
+
@present_value * (factor - 1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def nominal_rate
|
|
27
|
+
@nominal_rate = ((1 + @effective_rate)**nth_rooth - 1) * @frequency
|
|
28
|
+
@nominal_rate.round(4)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def factor
|
|
34
|
+
(1.0 + @interest_rate / @frequency)**(@frequency * @periods)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def nth_rooth
|
|
38
|
+
1.0 / @frequency
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/financial_math.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'financial_math/basics'
|
|
|
3
3
|
require 'financial_math/geometric_progression'
|
|
4
4
|
require 'financial_math/arithmetic_progression'
|
|
5
5
|
require 'financial_math/simple_interest'
|
|
6
|
+
require 'financial_math/compound_interest'
|
|
6
7
|
|
|
7
8
|
module FinancialMath
|
|
8
9
|
# Your code goes here...
|
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.
|
|
4
|
+
version: 0.4.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-
|
|
11
|
+
date: 2018-10-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -74,6 +74,7 @@ files:
|
|
|
74
74
|
- lib/financial_math.rb
|
|
75
75
|
- lib/financial_math/arithmetic_progression.rb
|
|
76
76
|
- lib/financial_math/basics.rb
|
|
77
|
+
- lib/financial_math/compound_interest.rb
|
|
77
78
|
- lib/financial_math/geometric_progression.rb
|
|
78
79
|
- lib/financial_math/simple_interest.rb
|
|
79
80
|
- lib/financial_math/version.rb
|