Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Latest commit

 

History

History
81 lines (51 loc) · 2.31 KB

README.md

File metadata and controls

81 lines (51 loc) · 2.31 KB

Credit

This gem was forked from https://github.com/tubedude/xirr and uses the code from the open pull request here tubedude#5 to remove the dependency on Ruby inline which needs to access the file system in order to work and won't play nicely with cloud 66 deployment.

Xirr

Build StatusCoverage StatusCode ClimateDependency Status

This is a gem to calculate XIRR on Bisection Method or Newton Method.

Installation

Add this line to your application's Gemfile:

gem 'xirr', git: '[email protected]:InfuseGroup/xirr.git', branch: 'master'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install xirr

Usage

include Xirr

cf = Cashflow.new
cf << Transaction.new(-1000,  date: '2014-01-01'.to_date)
cf << Transaction.new(-2000,  date: '2014-03-01'.to_date)
cf << Transaction.new( 4500, date: '2015-12-01'.to_date)
cf.xirr
# 0.25159694345042327 # [BigDecimal]

flow = []
flow << Transaction.new(-1000,  date: '2014-01-01'.to_date)
flow << Transaction.new(-2000,  date: '2014-03-01'.to_date)
flow << Transaction.new( 4500, date: '2015-12-01'.to_date)

cf = Cashflow.new flow: flow
cf.xirr

Configuration

# intializer/xirr.rb

Xirr.configure do |config|
  config.eps = '1.0e-12'
  config.days_in_year = 365.25
end

Documentation

http://rubydoc.info/github/tubedude/xirr/master/frames

Supported versions

Ruby:
 - 2.2.1
 - 2.3
 - 2.4

ActiveSupport:
 - 4.2
 - 5

Thanks

http://puneinvestor.wordpress.com/2013/10/01/calculate-xirr-in-ruby-bisection-method/ https://github.com/wkranec/finance

Contributing

  1. Fork it ( https://github.com/tubedude/xirr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request