more functions will be added soon
- New functions for loan amortizations
- New payments calculations
- New unit tests
- include more functions
- add some unit tests
Add this line to your application's Gemfile:
gem 'financial_maths'
And then execute:
$ bundle
Or install it yourself as:
$ gem install financial_maths
require "financial_maths"
include FinancialMaths
due_variable_payment_amortization (periods, amount, rate, payment)
$ due_variable_payment_amortization(5,10000,1.8,2000)
$ [{:period=>0, :monthly_payment=>nil, :interest=>nil, :payment=>nil, :balance=>10000},
{:period=>1, :payment=>20000.0, :interest=>18000.0, :monthly_payment=>2000, :balance=>8000},
{:period=>2, :payment=>16400.0, :interest=>14400.0, :monthly_payment=>2000, :balance=>6000},
{:period=>3, :payment=>12800.0, :interest=>10800.0, :monthly_payment=>2000, :balance=>4000},
{:period=>4, :payment=>9200.0, :interest=>7200.0, :monthly_payment=>2000, :balance=>2000},
{:period=>5, :payment=>5600.0, :interest=>3600.0, :monthly_payment=>2000, :balance=>0}]
anticipated_variable_payment_amortization (periods, amount, rate, payment)
$ anticipated_variable_payment_amortization(5,10000,1.8,2000)
$ [{:period=>0, :payment=>20000.0, :interest=>18000.0, :monthly_payment=>2000, :balance=>8000},
{:period=>1, :payment=>16400.0, :interest=>14400.0, :monthly_payment=>2000, :balance=>6000},
{:period=>2, :payment=>12800.0, :interest=>10800.0, :monthly_payment=>2000, :balance=>4000},
{:period=>3, :payment=>9200.0, :interest=>7200.0, :monthly_payment=>2000, :balance=>2000},
{:period=>4, :payment=>5600.0, :interest=>3600.0, :monthly_payment=>2000, :balance=>0}]
due_fixed_payment_amortization (periods, amount, rate, payment)
$ due_fixed_payment_amortization(5,10000,1.8,2109)
$ [{:period=>0, :monthly_payment=>nil, :interest=>nil, :payment=>nil, :balance=>10000},
{:period=>1, :payment=>2109, :interest=>18000.0, :monthly_payment=>-15891.0, :balance=>25891.0},
{:period=>2, :payment=>2109, :interest=>46603.8, :monthly_payment=>-44494.8, :balance=>70385.8},
{:period=>3, :payment=>2109, :interest=>126694.44, :monthly_payment=>-124585.44, :balance=>194971.24},
{:period=>4, :payment=>2109, :interest=>350948.232, :monthly_payment=>-348839.232, :balance=>543810.4720000001},
{:period=>5, :payment=>2109, :interest=>978858.8496000002, :monthly_payment=>-976749.8496000002, :balance=>1520560.3216000004}]
anticipated_fixed_payment_amortization (periods, amount, rate, payment)
future_given_present (present_value, interest, term)
$ future_given_present(10000,1.8,5)
$ 1721036.8
present_given_future (future_value, interest, term)
$ present_given_future(10000,1.8,5)
$ 58.1045
annuity_given_present (present_value, interest, term)
$ annuity_given_present(10000,1.8,5)
$ 18105.1994
annuity_given_future (future_value, interest, term)
present_given_annuity (annuity, interest, term)
future_given_annuity (annuity, interest, term)
efective_given_nominal_due (nominal_rate, term)
efective_given_nominal_antipipated (nominal_rate, term)
nominal_antipiated_given_efective (nominal_rate, term)
nominal_due_given_efective (nominal_rate, term)
anticipated_fixed_payment (present_value, rate, term)
variable_payment (amount, periods)
$ variable_payment(10000,5)
$ 2000.0
- Fork it
- 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 new Pull Request