marksweston / finance

A library for financial calculations in Ruby
https://rubygems.org/gems/finance
Other
217 stars 93 forks source link

irr freezes with incorrect inputs #12

Closed dnagir closed 12 years ago

dnagir commented 12 years ago

[10, 20, 30].irr will freeze :-(

It should raise a specific exception instead.

wkranec commented 12 years ago

Thanks for letting me know about this. I've added some basic input checking: there now needs to be at least one positive and negative value in the array for an irr / xirr calculation to run. You'll find this in the 1.1.2 release.

If you know of any other specific instances when an irr calculation will fail (I know they exist but haven't done the necessary research), let me know and I can build it in.

dnagir commented 12 years ago

It also fails on this input:

       [-55520.45,
       -37844.51169999999,
       -37398.54089999999,
       -36922.17929999999,
       -36417.90629999999,
       -35901.15277199999,
       -35371.54308215999,
       -34916.927563624784,
       -34448.67357953353,
       -33966.37197591954,
       -33469.60132419712,
       748521.188503498]