Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xirr bug? #31

Open
josh-m-sharpe opened this issue Jun 3, 2014 · 4 comments
Open

xirr bug? #31

josh-m-sharpe opened this issue Jun 3, 2014 · 4 comments

Comments

@josh-m-sharpe
Copy link

Good Doc's xirr() thinks the result should be: 0.1877607042

The result should certainly be positive.

DATA:
5/3/2010   --   -3984.732
8/12/2010  --   -1877.98
6/2/2014   --    11684.915242
2.0.0-p353 :044 > trans = []
 => []
2.0.0-p353 :045 > trans << Finance::Transaction.new(-3984.732, date: Date.civil(2010, 5, 3).to_time)
 => [Transaction(-3984.732)]
2.0.0-p353 :046 > trans << Finance::Transaction.new(-1877.98, date: Date.civil(2010, 8, 12).to_time)
 => [Transaction(-3984.732), Transaction(-1877.98)]
2.0.0-p353 :047 > trans << Finance::Transaction.new(11684.915242, date: Date.civil(2014, 6, 2).to_time)
 => [Transaction(-3984.732), Transaction(-1877.98), Transaction(11684.915242)]
2.0.0-p353 :048 > trans.xirr.apr.to_f
 => -2.212298586260735

untitled_spreadsheet_-_google_sheets_and_1__tmux

@tubedude
Copy link

tubedude commented Jun 3, 2014

@crankharder why don't you give a try on my branch: https://github.com/tubedude/finance
The error appears when you use 1.0 as guess (which is the standard in this release). But you should get to the correct answer by using a guess of 0.1:

trans.xirr(1).apr.to_f # => -2.212298586260735
trans.xirr(0.1).apr.to_f  # => 0.1882953622624719

@josh-m-sharpe
Copy link
Author

@tubedude confirmed that your branch fixes the issue.

My other test cases didn't change either.

I thought it was odd that the 'transactions' param wasn't being used.

@weshatheleopard
Copy link

See Issue #38. It's a bug in the search value function. I provided the fix (#39).

@tubedude
Copy link

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants