{"id":13540842,"url":"https://github.com/marksweston/finance","last_synced_at":"2025-04-02T08:30:51.468Z","repository":{"id":1544260,"uuid":"1873329","full_name":"marksweston/finance","owner":"marksweston","description":"A library for financial calculations in Ruby","archived":false,"fork":false,"pushed_at":"2022-11-04T10:53:51.000Z","size":247,"stargazers_count":220,"open_issues_count":21,"forks_count":91,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-23T15:40:05.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/finance","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marksweston.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-06-09T22:19:21.000Z","updated_at":"2024-12-18T15:39:57.000Z","dependencies_parsed_at":"2022-08-16T13:40:45.636Z","dependency_job_id":null,"html_url":"https://github.com/marksweston/finance","commit_stats":null,"previous_names":["wkranec/finance"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksweston%2Ffinance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksweston%2Ffinance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksweston%2Ffinance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marksweston%2Ffinance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marksweston","download_url":"https://codeload.github.com/marksweston/finance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246781859,"owners_count":20832921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T10:00:33.744Z","updated_at":"2025-04-02T08:30:51.022Z","avatar_url":"https://github.com/marksweston.png","language":"Ruby","funding_links":[],"categories":["Libraries","Calculators \u0026 Tax"],"sub_categories":["Ruby"],"readme":"# FINANCE\n\na library for financial modelling in Ruby.\n\n## INSTALL\n\n    $ sudo gem install finance\n\n## IMPORTANT CHANGES\n\nContributions by [@thadd](https://github.com/thadd) and\n[@bramswenson](https://github.com/bramswenson) have made the `finance`\nlibrary fully compatible with rails, at the cost of the `#years` and\n`#months` convenience methods on `Integer`, as well as the `#to_d` method for\nconverting `Numerics` into `DecNums`.  These methods have been removed, due to\nconflicts with existing rails methods.\n\nCorrespondingly, `finance` has been bumped up to version 2.0.\n\n## OVERVIEW\n\n### GETTING STARTED\n\n    \u003e\u003e require 'finance'\n\n*Note:* As of version 1.0.0, the entire library is contained under the\nFinance namespace.  Existing code will not work unless you add:\n\n    \u003e\u003e include Finance\n\nfor all of the examples below, we'll assume that you have done this.\n\n### AMORTIZATION\n\nYou are interested in borrowing $250,000 under a 30 year, fixed-rate\nloan with a 4.25% APR.\n\n    \u003e\u003e rate = Rate.new(0.0425, :apr, :duration =\u003e (30 * 12))\n    \u003e\u003e amortization = Amortization.new(250000, rate)\n\nFind the standard monthly payment:\n\n    \u003e\u003e amortization.payment\n    =\u003e DecNum('-1229.91')\n\nFind the total cost of the loan:\n\n    \u003e\u003e amortization.payments.sum\n    =\u003e DecNum('-442766.55')\n\nHow much will you pay in interest?\n\n    \u003e\u003e amortization.interest.sum\n    =\u003e DecNum('192766.55')\n\nHow much interest in the first six months?\n\n    \u003e\u003e amortization.interest[0,6].sum\n    =\u003e DecNum('5294.62')\n\nIf your loan has an adjustable rate, no problem.  You can pass an\narbitrary number of rates, and they will be used in the amortization.\nFor example, we can look at an amortization of $250000, where the APR\nstarts at 4.25%, and increases by 1% every five years.\n\n    \u003e\u003e values = %w{ 0.0425 0.0525 0.0625 0.0725 0.0825 0.0925 }\n    \u003e\u003e rates = values.collect { |value| Rate.new( value, :apr, :duration =\u003e (5  * 12) }\n    \u003e\u003e arm = Amortization.new(250000, *rates)\n\nSince we are looking at an ARM, there is no longer a single \"payment\" value.\n\n    \u003e\u003e arm.payment\n    =\u003e nil\n\nBut we can look at the different payments over time.\n\n    \u003e\u003e arm.payments.uniq\n    =\u003e [DecNum('-1229.85'), DecNum('-1360.41'), DecNum('-1475.65'), DecNum('-1571.07'), ... snipped ... ]\n\nThe other methods previously discussed can be accessed in the same way:\n\n    \u003e\u003e arm.interest.sum\n    =\u003e DecNum('287515.45')\n    \u003e\u003e arm.payments.sum\n    =\u003e DecNum('-537515.45')\n\nLast, but not least, you may pass a block when creating an Amortization\nwhich returns a modified monthly payment.  For example, to increase your\npayment by $150, do:\n\n    \u003e\u003e rate = Rate.new(0.0425, :apr, :duration =\u003e (30 * 12))\n    \u003e\u003e extra_payments = 250000.amortize(rate){ |period| period.payment - 150 }\n\nDisregarding the block, we have used the same parameters as the first\nexample.  Notice the difference in the results:\n\n    \u003e\u003e amortization.payments.sum\n    =\u003e DecNum('-442745.98')\n    \u003e\u003e extra_payments.payments.sum\n    =\u003e DecNum('-400566.24')\n    \u003e\u003e amortization.interest.sum\n    =\u003e DecNum('192745.98')\n    \u003e\u003e extra_payments.interest.sum\n    =\u003e DecNum('150566.24')\n\nYou can also increase your payment to a specific amount:\n\n    \u003e\u003e extra_payments_2 = 250000.amortize(rate){ -1500 }\n\n## ABOUT\n\nI started developing `finance` while analyzing mortgages as a personal\nproject.  Spreadsheets have convenient formulas for doing this type of\nwork, until you want to do something semi-complex (like ARMs or extra\npayments), at which point you need to create your own amortization\ntable.  I thought I could create a better interface for this type of\nwork in Ruby, and since I couldn't find an existing resource for these\ntools, I am hoping to save other folks some time by releasing what I\nhave as a gem.\n\nMore broadly, I believe there are many calculations that are necessary\nfor the effective management of personal finances, but are difficult\n(or impossible) to do with spreadsheets or other existing open source\ntools.  My hope is that the `finance` library will grow to provide a set\nof open, tested tools to fill this gap.\n\nIf you have used `finance` and find it useful, I would enjoy hearing\nabout it!\n\n## FEATURES\n\nCurrently implemented features include:\n\n* Uses the [flt](http://flt.rubyforge.org/) library to ensure precision decimal arithmetic in all calculations.\n* Fixed-rate mortgage amortization (30/360).\n* Interest rates\n* Various cash flow computations, such as NPV and IRR.\n* Adjustable rate mortgage amortization.\n* Payment modifications (i.e., how does paying an additional $75 per month affect the amortization?)\n\n## RESOURCES\n\n* [RubyGems Page](https://rubygems.org/gems/finance)\n* [Source Code](http://github.com/wkranec/finance)\n* [Bug Tracker](https://github.com/wkranec/finance/issues)\n* [Google Group](http://groups.google.com/group/finance-gem/topics?pli=1)\n\n## COPYRIGHT\n\nThis library is released under the terms of the LGPL license.\n\nCopyright (c) 2011, William Kranec.\nAll rights reserved.\n\nThis program is free software: you can redistribute it and/or modify it\nunder the terms of the GNU Lesser General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your\noption) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along\nwith this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarksweston%2Ffinance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarksweston%2Ffinance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarksweston%2Ffinance/lists"}