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

irr and xirr could benefit from initial guess and number of iterations #25

Open
Janther opened this issue Oct 3, 2013 · 2 comments
Open

Comments

@Janther
Copy link

Janther commented Oct 3, 2013

In other implementations of the IRR function, one can set the initial guess and the number of iterations.

Here the irr function doesn't receive any parameter and the xirr receives the number of iterations but i don't see the function make use of this value.

is there a reason for this?

PS: I'm looking at the https://github.com/wkranec/finance/blob/master/lib/finance/cashflows.rb file
PS2: also the tolerance could be nice. For example tolerance = 0.00000001

@arbrown
Copy link

arbrown commented Oct 26, 2013

Hi Janther. It looks like nlsolve (in the BigDecimal Module, newton.rb) doesn't have any code to handle a specific number of iterations: http://svn.codehaus.org/mojo/trunk/mojo/jruby-stdlib/src/main/resources/bigdecimal/newton.rb

On the other hand, you could manually set the tolerance. It would require changing the canned value that every Function object returns. I'll be digging around the code this weekend anyway, so I could submit a pull request to add this functionality if it would be useful to you. Although, the current tolerance is 1.0e-16, which is pretty small, so unless you know you want it to be less accurate than that for speed reasons, there's probably no reason to change it.

@tubedude
Copy link

tubedude commented May 9, 2014

Ok. I have been "spamming" about this, but I was able to add a Guess on IRR and XIRR in #30
But, Janther, you are right, I didn't notice XIIR iterations didn't had any use in the formulas. I'll update the pull request to remove it.

arbrown, Indeed the tolerance seems quite low. I've added a Config method to Finance that allows you to set a default Tolerance in the same PR #30.

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