xirr 0.2.7 → 0.2.8

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
  SHA1:
3
- metadata.gz: 2944764274ca9f0acb15890cfd6540f62f074ff9
4
- data.tar.gz: dc62255a7a04825f670208c439ce0adb9437f3a9
3
+ metadata.gz: dcb7b25e26618e39ecb5c1e8b38ad211be4edc73
4
+ data.tar.gz: 0c845e053436159125d5b8bedf2dd08e8243cdbc
5
5
  SHA512:
6
- metadata.gz: 0d8cbf1bcb0d9b47148e748b5db9748061fb4c7ddcae2b2c52b7a046a1d036e80cc0789085e988ef02d8709f0093c7fd158f05283db49855abad729cf31281cf
7
- data.tar.gz: d4ee0b6b68097528fd5a28b4d5095fcf73524c8919b4b4cae614c12725fee20f5c0182c88533fce6cdb0421703cb7a74aeef13df7203b86256cd2e4ccea4b611
6
+ metadata.gz: ec7a9821be4721669be0d656864b1d7db88f5d0fc1ec4306b0f190d5b2d2143f0b98ebe338589f3de60af6f07f9077a9a19b9022ee3d64f0aeec81f94b1885b7
7
+ data.tar.gz: dcf0c3570dbc34e6595cfd3f0e1976ec4f2bd876e1a9ad11dfebdc52b75494199a55f3b4dabb12185b07d36abe79c1a987453a2ebe3889fd4bc756bc00bc2253
data/CHANGE_LOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Version 0.2.8
2
+
3
+ * Added missing tests
4
+ * Fixed Fallback method
5
+
1
6
  ## Version 0.2.7
2
7
 
3
8
  * Bisection will now retry XIRR in Newton Method if right limit is reached
@@ -13,6 +13,7 @@ module Xirr
13
13
  # Initial values
14
14
  left = [BigDecimal.new(-0.99, Xirr::PRECISION), cf.irr_guess].min
15
15
  right = [BigDecimal.new(9.99, Xirr::PRECISION), cf.irr_guess + 1].max
16
+ @original_right = right
16
17
  midpoint ||= cf.irr_guess
17
18
  runs = 0
18
19
 
@@ -29,7 +30,7 @@ module Xirr
29
30
  end
30
31
 
31
32
  # If enabled, will retry XIRR with NewtonMethod
32
- if Xirr::FALLBACK && right_limit_reached?(right, midpoint)
33
+ if Xirr::FALLBACK && right_limit_reached?(midpoint)
33
34
  return NewtonMethod.new(cf).xirr
34
35
  end
35
36
 
@@ -43,8 +44,8 @@ module Xirr
43
44
  # @param midpoint [BigDecimal]
44
45
  # @return [Boolean]
45
46
  # Checks if result is the right limit.
46
- def right_limit_reached?(right, midpoint)
47
- (right - midpoint).abs < Xirr::EPS
47
+ def right_limit_reached?(midpoint)
48
+ (@original_right - midpoint).abs < Xirr::EPS
48
49
  end
49
50
 
50
51
  # @param left [BigDecimal]
data/lib/xirr/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Xirr
2
2
  # Version of the Gem
3
- VERSION = "0.2.7"
3
+ VERSION = "0.2.8"
4
4
  end
@@ -23,7 +23,7 @@ describe 'Cashflows' do
23
23
  end
24
24
 
25
25
  it 'has an Internal Rate of Return on Bisection Method using a Guess' do
26
- assert_equal '0.225683'.to_f, @cf.xirr(0.15)
26
+ assert_in_delta 0.225683, @cf.xirr(0.15).to_f, 0.000002
27
27
  end
28
28
 
29
29
  it 'has an Internal Rate of Return on Newton Method' do
@@ -44,12 +44,16 @@ describe 'Cashflows' do
44
44
  @cf << Transaction.new(6000, date: '1995-01-01'.to_date)
45
45
  end
46
46
 
47
+ it 'has a sum of its transactions' do
48
+ assert_equal '5600'.to_f, @cf.sum
49
+ end
50
+
47
51
  it 'has an Internal Rate of Return on Bisection Method' do
48
52
  assert_equal '0.225683'.to_f, @cf.xirr
49
53
  end
50
54
 
51
55
  it 'has an Internal Rate of Return on Bisection Method using a Guess' do
52
- assert_equal '0.225683'.to_f, @cf.xirr(0.15)
56
+ assert_in_delta 0.225683, @cf.xirr(0.15).to_f, 0.000002
53
57
  end
54
58
 
55
59
  it 'has an Internal Rate of Return on Newton Method' do
@@ -73,6 +77,10 @@ describe 'Cashflows' do
73
77
  assert_equal '22.352206 '.to_f, @cf.xirr
74
78
  end
75
79
 
80
+ it 'has a sum of its transactions' do
81
+ assert_equal '-2000000'.to_f, @cf.sum
82
+ end
83
+
76
84
  it 'has an Internal Rate of Return on Newton Method' do
77
85
  assert_equal '22.352206 '.to_f, @cf.xirr(nil, :newton_method)
78
86
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xirr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - tubedude
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-10 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler