marksweston / finance

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

xirr #3

Closed wkranec closed 12 years ago

wkranec commented 12 years ago

Finance should have an implementation of the XIRR function. Some details are available on the OpenOffice.org wiki:

http://wiki.services.openoffice.org/wiki/Documentation/How_Tos/Calc:_XIRR_function

Other implementations I've found on the web:

Some thoughts on the implementation:

Example

> t = []
> t << Transaction.new(-5000, :date => '3/1/2011')
> t << Transaction.new(100, :date => '4/1/2011')
> t << Transaction.new(100, :date => '5/15/2011')
> t << Transaction.new(100, :date => '6/29/2011')
> t << Transaction.new(5000, :date => '7/4/2011')
> t.xirr
#=> 0.19021145803047
wkranec commented 12 years ago

Added basic working support in 1.1.0. Tests and feedback are welcome!