financial_math 0.5.0 → 0.6.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 +11 -0
- data/lib/financial_math/simple_interest.rb +12 -18
- data/lib/financial_math/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b602a59e8cb6248be2b0620edcbbc24d37d7367acb3eb5b5342ccf49ebce3e92
|
|
4
|
+
data.tar.gz: fe86b90b686a54f8f462b8a604e0b7f53de9f066c2f7c20d4f2110d49b23ea88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09bf54f268a2fea8911f933767392f03ba6caf27a30ea85a22dce431df0ae44362c1c9c1d41d49555eba049d99b2ffb486f9e34bf4cb4131a763125258bdf8ce'
|
|
7
|
+
data.tar.gz: ac11588d785b2b00f7bfc67f878f49dc958458449fc50800692f47b21f365f8f49fe724f8a7e9c6c4bacc4198fbce99c5a89beff3e18ab6a484c4beb5d1ce958
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -57,6 +57,13 @@ args = { present_value: 100_000.0, interest_rate: 0.05, periods: 3 }
|
|
|
57
57
|
simple_interest = FinancialMath::SimpleInterest.new(args)
|
|
58
58
|
simple_interest.future_value
|
|
59
59
|
```
|
|
60
|
+
The interest rate must be in terms of years, if your problem is expressed in terms of days or months, provide the frequency of conversion and the periods in terms of days.
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
args = { present_value: 1500.0, interest_rate: 0.45, periods: 73, frequency: 360 }
|
|
64
|
+
simple_interest = FinancialMath::SimpleInterest.new(args)
|
|
65
|
+
simple_interest.future_value
|
|
66
|
+
```
|
|
60
67
|
|
|
61
68
|
## Development
|
|
62
69
|
|
|
@@ -69,6 +76,10 @@ $ gem install financial_math --dev
|
|
|
69
76
|
This command will get the development dependencies installed too.
|
|
70
77
|
|
|
71
78
|
## Release History
|
|
79
|
+
|
|
80
|
+
* 0.6.0
|
|
81
|
+
* ADD: Add `@frequency` to `SimpleInterest` class
|
|
82
|
+
* CHANGE: Change the `periods_in_days` mehtod to `factor` in `SimpleInterest`
|
|
72
83
|
* 0.5.0
|
|
73
84
|
* ADD: Add `average_growth_rate` and `continous_future_value` public methods to `CompoundInterest` class
|
|
74
85
|
* 0.4.1
|
|
@@ -5,6 +5,8 @@ module FinancialMath
|
|
|
5
5
|
def initialize(args)
|
|
6
6
|
@present_value = args.fetch(:present_value, 0)
|
|
7
7
|
@periods = args.fetch(:periods, 0)
|
|
8
|
+
# frequency of conversions
|
|
9
|
+
@frequency = args.fetch(:frequency, 1.0)
|
|
8
10
|
@interest_rate = args.fetch(:interest_rate, 0)
|
|
9
11
|
@future_value = args.fetch(:future_value, 0)
|
|
10
12
|
@bank_discount_rate = args.fetch(:bank_discount_rate, 0)
|
|
@@ -19,45 +21,37 @@ module FinancialMath
|
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def future_value
|
|
22
|
-
@future_value =
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def future_value_in_days
|
|
26
|
-
@future_value = @present_value * (1 + @interest_rate * periods_in_days)
|
|
24
|
+
@future_value = @present_value * (1 + @interest_rate * factor)
|
|
27
25
|
@future_value.round(2)
|
|
28
26
|
end
|
|
29
27
|
|
|
30
28
|
def present_value
|
|
31
|
-
@present_value =
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def present_value_in_days
|
|
35
|
-
@present_value = @future_value / (1 + @interest_rate * periods_in_days)
|
|
29
|
+
@present_value = @future_value / (1 + @interest_rate * factor)
|
|
36
30
|
@present_value.round(2)
|
|
37
31
|
end
|
|
38
32
|
|
|
39
|
-
def
|
|
40
|
-
(@present_value * @interest_rate *
|
|
33
|
+
def rational_discount
|
|
34
|
+
(@present_value * @interest_rate * factor).round(2)
|
|
41
35
|
end
|
|
42
36
|
|
|
43
|
-
def
|
|
44
|
-
(@future_value * @bank_discount_rate *
|
|
37
|
+
def bank_discount
|
|
38
|
+
(@future_value * @bank_discount_rate * factor).round(2)
|
|
45
39
|
end
|
|
46
40
|
|
|
47
41
|
def interest_rate_given_discount_rate
|
|
48
|
-
divisor = 1 - @bank_discount_rate *
|
|
42
|
+
divisor = 1 - @bank_discount_rate * factor
|
|
49
43
|
@interest_rate = (@bank_discount_rate / divisor).round(2)
|
|
50
44
|
end
|
|
51
45
|
|
|
52
46
|
def discount_rate_given_interest_rate
|
|
53
|
-
divisor = 1 + @interest_rate *
|
|
47
|
+
divisor = 1 + @interest_rate * factor
|
|
54
48
|
@bank_discount_rate = (@interest_rate / divisor).round(2)
|
|
55
49
|
end
|
|
56
50
|
|
|
57
51
|
private
|
|
58
52
|
|
|
59
|
-
def
|
|
60
|
-
periods /
|
|
53
|
+
def factor
|
|
54
|
+
periods / @frequency.to_f
|
|
61
55
|
end
|
|
62
56
|
end
|
|
63
57
|
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.
|
|
4
|
+
version: 0.6.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-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|