xirr 0.2.4 → 0.2.5
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/CHANGE_LOG.md +5 -0
- data/lib/xirr/cashflow.rb +4 -4
- data/lib/xirr/version.rb +1 -1
- data/test/test_cashflow.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 893aa205c2c9ff4d6608cb61a9360638bb335974
|
4
|
+
data.tar.gz: ea5fc078f408285564152271f95faf34326cf6b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b0d7975ce89e61ad8df222ab66564f3b005f73cd6da3c1c7d0db9a3012376e9af7fe12b882f465558c52716748616bec135b52473e55e7abe3fb67acb1e9b62
|
7
|
+
data.tar.gz: a01d888ce35bef52506235ed2b1734d52e46c55615a58a59e260519d5f894f8fe3c55f228654b66efb65e08df11937bf34941dc54fc020a7c571c1ee13e7b182
|
data/CHANGE_LOG.md
CHANGED
data/lib/xirr/cashflow.rb
CHANGED
@@ -16,7 +16,7 @@ module Xirr
|
|
16
16
|
self.flatten!
|
17
17
|
end
|
18
18
|
|
19
|
-
# Check if Cashflow is invalid
|
19
|
+
# Check if Cashflow is invalid
|
20
20
|
# @return [Boolean]
|
21
21
|
def invalid?
|
22
22
|
positives.empty? || negatives.empty?
|
@@ -50,7 +50,7 @@ module Xirr
|
|
50
50
|
# @param method [Symbol]
|
51
51
|
# @return [Float]
|
52
52
|
# Finds the XIRR according to the method provided. Default to Bisection
|
53
|
-
def
|
53
|
+
def xirr_with_exception(guess = nil, method = Xirr.config.default_method)
|
54
54
|
if valid?
|
55
55
|
choose_(method).send :xirr, guess
|
56
56
|
else
|
@@ -62,11 +62,11 @@ module Xirr
|
|
62
62
|
# @param guess [Float]
|
63
63
|
# @param method [Symbol]
|
64
64
|
# @return [Float]
|
65
|
-
def
|
65
|
+
def xirr(guess = nil, method = Xirr.config.default_method)
|
66
66
|
if invalid?
|
67
67
|
BigDecimal.new(0, Xirr::PRECISION)
|
68
68
|
else
|
69
|
-
|
69
|
+
xirr_with_exception(guess, method)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
data/lib/xirr/version.rb
CHANGED
data/test/test_cashflow.rb
CHANGED
@@ -14,10 +14,14 @@ describe 'Cashflows' do
|
|
14
14
|
assert_raises(ArgumentError) { @cf.xirr(nil, :no_method) }
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'has an Internal Rate of Return on
|
17
|
+
it 'has an Internal Rate of Return on default Method' do
|
18
18
|
assert_equal '0.225683'.to_f, @cf.xirr
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'has an Internal Rate of Return on default Method' do
|
22
|
+
assert_equal '0.225683'.to_f, @cf.xirr(nil, :bisection)
|
23
|
+
end
|
24
|
+
|
21
25
|
it 'has an Internal Rate of Return on Bisection Method using a Guess' do
|
22
26
|
assert_equal '0.225683'.to_f, @cf.xirr(0.15)
|
23
27
|
end
|