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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c921d52e51e5f58cc4f57b35fb3be689be412fe951b7c47c827841cfae32c69e
4
- data.tar.gz: 36d24ce900c09e7c004e944928bb02b94d0bc02ecbaaee195ff1a0255dac2231
3
+ metadata.gz: 85d7bef08ae4b2d40293f618f5f05423202353b11374c5dea7c374dd6c0d94e7
4
+ data.tar.gz: cd732a3b96217bc0e484ca63b131b7a75052cf79af83448c42e6339c31d48f15
5
5
  SHA512:
6
- metadata.gz: 1034b3bad2c684ffb511babb43a232bf76e74bc6f8805c6f6d54e4b392ca2d7668673c40fff3e7c37f0d43bd28d986f85ae966e709d2b49e43e9fa7e71196d98
7
- data.tar.gz: 94660004e27d53b1bf246d4f3e42e75ea16069f65abd8362f53eeb3a3456e2113be17cf60856f0d819728685b6c0fc515eea1318eb1380ad54f3bce0eb1bca8a
6
+ metadata.gz: 3389a31479535fe268bcc87a98a6a370e6f8b03337e2e861702909b7dc26aee6cd1bc174262ef537ba616575dd6094ddaa956239d88b4969d1fee2003e7fc0dc
7
+ data.tar.gz: acb5b463279313390aec97a2548850d69ff7ea016ff624a638f29bc94a58fce741c0f020923bc971ecf338adb865416901a0d37a666fa727e6516dd6c63d0653
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- financial_math (0.3.1)
4
+ financial_math (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -53,6 +53,8 @@ This command will get the development dependencies installed too.
53
53
 
54
54
  ## Release History
55
55
 
56
+ * 0.4.0
57
+ * ADD: Add `CompoundInterest` class
56
58
  * 0.3.1
57
59
  * CHANGE: Update docs (module code remains unchanged)
58
60
  * 0.3.0
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FinancialMath
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -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.3.1
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-05 00:00:00.000000000 Z
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