Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby implementation of various financial analysis functions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 1.7
~> 0
~> 10.0
~> 3.2
 Project Readme

CashFlowAnalysis

Build Status

Ruby implementation of various financial analysis functions.

Installation

Add this line to your application's Gemfile:

gem "cash_flow_analysis"

And then execute:

$ bundle

Or install it yourself as:

$ gem install cash_flow_analysis

Usage

The gem provides four calculators, CAGR, Payment, XIRR, and XNPV.

CAGR

Calculates the CAGR based on a start value, end value, and a term.

CashFlowAnalysis::Calculator::Cagr.calculate(25.5, 35.5, 5)
# 0.06840923807777366

Payment

Calculates the payment for a loan, assuming fixed payments and rates.

CashFlowAnalysis::Calculator::Payment.calculate(10000, 60, 0.025)
# 323.5339590005929

XNPV

Calculates the XNPV, assuming irregularly timed cash flows.

items = []
items << OpenStruct.new(date: Date.new(2008, 1, 1), amount: -10000)
items << OpenStruct.new(date: Date.new(2008, 3, 1), amount: 2750)
items << OpenStruct.new(date: Date.new(2008, 10, 30), amount: 4250)
items << OpenStruct.new(date: Date.new(2009, 2, 15), amount: 3250)
items << OpenStruct.new(date: Date.new(2009, 4, 1), amount: 2750)
CashFlowAnalysis::Calculator::Xnpv.calculate(0.09, items)
# 2086.647602031535

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/cash_flow_analysis/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