Coder Social home page Coder Social logo

mrcesar107 / xirr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tubedude/xirr

0.0 0.0 0.0 92 KB

Calculates IRR of a Cashflow, simillar to Excels, XIRR formula.

Home Page: https://rubygems.org/gems/xirr

License: MIT License

Ruby 100.00%

xirr's Introduction

Xirr

Build StatusCoverage StatusCode ClimateEbert

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

Installation

Add this line to your application's Gemfile:

gem 'xirr'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install xirr

Usage

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

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

cf = Xirr::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. Run specs (rake default)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

xirr's People

Contributors

tubedude avatar arifb avatar frankyston avatar ryakh avatar wkirschbaum avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.