FinanceMath is a Ruby library for mapping Loan based Exel functions. It deals with problem of calculating the PMT and APR functions. It implements advanced usage, taking into account bank fees, fee for for each payment and currency protection (if currency other than $ USD). Highly precise with high speed of execution.
FinanceMath is available as a gem, to install it just install the gem:
gem install finance_math
If you're using Bundler, add the gem to Gemfile.
gem 'finance_math'
Run bundle install
.
Create an instance, and pass parameters for nominal annual rate, duration (in months), and amount of loan.
Loan.new(10.5, 12, 15000)
Create an instance, and pass parameters for nominal annual rate, duration (in months), and amount of loan, and additional values such as bank fee, currency protection, and fee for each monthly payment.
Defaults are bank fee = 5, currency protection = 3, so please update if you need other values.
Loan.new(10.5, 12, 15000, 5.1, 2.75, 25)
This is the list of available functions.
Calculates the periodic payment for an annuity investment based on constant-amount periodic payments and a constant interest rate.
loan = Loan.new(10, 12, 1000)
loan.pmt
# 87.9158872300099
Calculates the Annual Percentage Rate.
loan = Loan.new(13, 12, 10000)
loan.apr
#29.179538647635006
loan = Loan.new(15, 36, 10000, 5, 3, 10)
loan.apr
#23.964418264624054
- Fork it ( https://github.com/kolosek/finance_math/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Please cover with tests your pull requests
Copyright (c) 2014-2015 Nebojsa Zoric, and Kolosek, Inc. (http://kolosek.com)
###Follow up @nebojsaz and @kolosek
MIT License. See LICENSE for details.