{"id":25806035,"url":"https://github.com/alipsa/financials","last_synced_at":"2026-04-14T02:31:34.709Z","repository":{"id":128760237,"uuid":"256553969","full_name":"Alipsa/financials","owner":"Alipsa","description":"R package for fincancial functions ","archived":false,"fork":false,"pushed_at":"2022-03-06T16:51:33.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T02:45:45.897Z","etag":null,"topics":["jvm","r-package","renjin"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alipsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Alipsa"]}},"created_at":"2020-04-17T16:25:16.000Z","updated_at":"2022-02-27T19:17:27.000Z","dependencies_parsed_at":"2023-04-27T20:01:58.509Z","dependency_job_id":null,"html_url":"https://github.com/Alipsa/financials","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Alipsa/financials","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Ffinancials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Ffinancials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Ffinancials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Ffinancials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alipsa","download_url":"https://codeload.github.com/Alipsa/financials/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alipsa%2Ffinancials/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31779943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["jvm","r-package","renjin"],"created_at":"2025-02-27T19:52:48.170Z","updated_at":"2026-04-14T02:31:34.702Z","avatar_url":"https://github.com/Alipsa.png","language":"R","funding_links":["https://github.com/sponsors/Alipsa"],"categories":[],"sub_categories":[],"readme":"# financials\nR package for financial functions for the Renjin implementation of R for the JVM.\n\nTo use it add the following dependency to your pom\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ese.alipsa\u003c/groupId\u003e\n    \u003cartifactId\u003efinancials\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Functions\n\n### Payment\n`pmt \u003c- function(interestRate, nper, pv, fv = 0, type = 0)`\n\nEquivalent to Excel/Calc's PMT(interest_rate, number_payments, PV, FV, Type)\nfunction, which calculates the payments for a loan or the future value of an investment\n#### Parameters\n- _interestRate_ periodic interest rate represented as a decimal.\n- _nper_ number of total payments / periods.\n- _pv_   present value -- borrowed or invested principal.\n- _fv_   future value of loan or annuity, default to 0 (which is what you want for loans)\n- _type_ when payment is made: beginning of period is 1; end is 0. Default is 0\n\n#### Value\n_returns_ A double representing the periodic payment amount.\n\n#### Example\n__Calulate payment for a loan__\n\nThe following data:\n\n| Item            | amount |\n| -----           | -----  |\n| Loan Amount\t  |  50000 |\n| Interest rate\t  |  3.50% |\n| Periods\t      |     60 |\n| Monthly payment |\t909.59 |\n\nThen the Monthly payment can be calculated as\n`pmt(3.5/100/12, 60, -50000)`\n\n### Monthly Annuity Amount\n`monthlyAnnuityAmount \u003c- function(loanAmount, interestRate, tenureMonths, amortizationFreemonths = 0, type = 0)`\n\nCalculate the monthly annuity amount i.e. the amortization and interest amount each payment period (month)\n\n#### Parameters\n- _loanAmount_ the total loan amount including capitalized fees (e.g. startup fee)\n- _interestRate_ the annual nominal interest\n- _tenureMonths_ the tenure of the loan in number of months\n- _amortizationFreeMonths_ the number of initial amortization free months, default to 0\n- _type_ - when payment is made: beginning of period is 1; end is 0. Default is 0\n\n#### Value\n_returns_ the monthly annuity amount\n\n#### Example\nAssuming the following:\n\n| Item            | amount |\n| -----           | -----  |\n| Loan Amount\t  |  50000 |\n| Interest rate\t  |  3.50% |\n| Tenure\t      |     60 |\n| Amortization Free months |\t6 |\n\nThe monthly annuity amount would be\n`monthlyAnnuityAmount(50000, 3.5/100, 60, 6)` = 1002.10\n\n### Cash Flow\n`cashFlow \u003c- function(loanAmount, interestRate, tenureMonths, amortizationFreeMonths, invoiceFee)`\n\n#### Parameters\n- _loanAmount_ the total loan amount including capitalized fees (e.g. startup fee)\n- _interestRate_ the annual nominal interest\n- _tenureMonths_ the tenure of the loan in number of months\n- _amortizationFreeMonths_ the number of initial amortization free months, default to 0\n- _invoiceFee_ a fee for each statement invoiced, default to 0\n\n#### Value\n_returns_ a vector of cachFlow entries for each period\n\n#### Example\n```r\ncf \u003c- cashFlow(\n  loanAmount=50000,\n  interestRate=0.035,\n  tenureMonths=60,\n  amortizationFreeMonths=6,\n  invoiceFee=30\n)\n```\n\n### Payment Plan\n`paymentPlan \u003c- function(loanAmount, interestRate, tenureMonths, amortizationFreeMonths = 0, invoiceFee = 0)`\n\n#### Parameters\n- _loanAmount_ the total loan amount including capitalized fees (e.g. startup fee)\n- _interestRate_ the annual nominal interest\n- _tenureMonths_ the total tenure of the loan in number of months\n- _amortizationFreeMonths_ the number of initial amortization free months, default to 0\n- _invoiceFee_ a fee for each statement invoiced, default to 0\n\n#### Value\n_returns_ a dataframe with the initial payment plan based on the input, based on monthly payment periods\n\n#### Example\n\n```r\nloanAmt \u003c- 10000\ntenureMonths \u003c- 1.5 * 12\namortizationFreeMonths \u003c- 6\ninterest \u003c- 3.5 / 100\ninvoiceFee \u003c- 30\n\nppdf \u003c- paymentPlan(loanAmt, interest, tenureMonths, amortizationFreeMonths, invoiceFee)\n```\n\nwhich will yield a data.frame (ppdf) as follows:\n\n| month\t| costOfCredit | interestAmt | amortization | invoiceFee | outgoingBalance | cashFlow |\n| ----  | --------     | ------      | ------       | ------     | ------          | ----     |\n| 0\t|      0\t|      0    |     0\t    |  0    | 10000\t    | -10000  |\n| 1\t| 29.167\t| 29.167\t|     0\t    | 30    | 10000\t    | 59.167  |\n| 2\t| 29.167\t| 29.167    |     0\t    | 30    | 10000\t    | 59.167  |\n| 3\t| 29.167    | 29.167\t|     0\t    | 30    | 10000\t    | 59.167  |\n| 4\t| 29.167    | 29.167    |\t  0\t    | 30    | 10000\t    | 59.167  |\n| 5\t| 29.167\t| 29.167\t|     0\t    | 30    | 10000\t    | 59.167  |\n| 6\t| 849.216\t| 29.167\t| 820.05    | 30    | 9179.95   | 879.216 |\n| 7\t|  849.216\t| 26.775    | 822.441\t| 30    | 8357.509  | 879.216 |\n| 8\t| 849.216\t| 24.376\t| 824.84\t| 30\t| 7532.669\t| 879.216 |\n| 9\t| 849.216\t|  21.97\t| 827.246\t| 30\t| 6705.423\t| 879.216 |\n|10\t| 849.216\t| 19.557\t| 829.659\t| 30\t| 5875.764\t| 879.216 |\n|11\t| 849.216\t| 17.138\t| 832.079\t| 30\t| 5043.685\t| 879.216 | \n|12\t| 849.216\t| 14.711\t| 834.506\t| 30\t|  4209.18\t| 879.216 |\n|13\t| 849.216\t| 12.277\t|  836.94\t| 30\t|  3372.24\t| 879.216 |\n|14\t| 849.216\t|  9.836\t| 839.381\t| 30\t|  2532.86\t| 879.216 |\n|15\t| 849.216\t|  7.388\t| 841.829\t| 30\t| 1691.031\t| 879.216 |\n|16\t| 849.216\t|  4.932\t| 844.284\t| 30\t|  846.747\t| 879.216 |\n|17\t| 849.216\t|   2.47\t| 846.747\t| 30\t|        0\t| 879.216 |\n|18\t| 849.216\t|      0\t| 849.216\t| 30\t| -849.216\t| 879.216 |\n\n### Total Payment amount\n`totalPaymentAmount \u003c- function(loanAmount, interestRate, tenureMonths, amortizationFreeMonths = 0, invoiceFee = 0)`\n\nTotal Payment amount is the sum of all payments.\n#### Parameters\n- _loanAmount_ the total loan amount including capitalized fees (e.g. startup fee)\n- _interestRate_ the annual nominal interest\n- _tenureMonths_ the total tenure of the loan in number of months\n- _amortizationFreeMonths_ the number of initial amortization free months, default to 0\n- _invoiceFee_ a fee for each statement invoiced, default to 0\n\n#### Value\n_returns_ a double containing the sum of all payments \n\n#### Example\n\n```r\nloanAmt \u003c- 10000\ntenureMonths \u003c- 1.5 * 12\namortizationFreeMonths \u003c- 6\ninterest \u003c- 3.5 / 100\ninvoiceFee \u003c- 30\n\ntotalAmt \u003c- totalPaymentAmount(loanAmt, interest, tenureMonths, amortizationFreeMonths, invoiceFee)\nprint(totalAmt)\n```\n```\n[1] 11725.645213062116\n```\n\n### Internal Rate of Return\n`irr \u003c- function(cf, precision = 1e-6)`\n\n#### Parameters\n- _cf_ a vector of the cash flow (see the cashFlow or paymentPlan functions)\n- _precision_ The desired accuracy to calculate the irr with (optional, default 1e-6) precision is used in the \n`uniroot` function and is assigned to the `tol` parameter of uniroot.\n#### Value\n_returns_ a double containing the internal return rate\n\n#### Example\nGiven the cache flow above\n\n```r\ninternalReturn \u003c- irr(ppdf$cashFlow)\nprint(internalReturn)\n```\n\n```\n[1] 0.00291665871251\n```\n\n### Annual Percentage Rate (a.k.a. effective interest)\n\n`apr \u003c- function(monthlyIrr)`\n\n#### Parameters\n- _monthlyIrr_ the MONTHLY internal rate of return (monthly irr)\n\n#### Value\n_Returns_ a double with the annual percentage rate\n\n#### Example\n```r\nannualPercentage \u003c- apr(internalReturn)\nprint(annualPercentage)\n```\n```\n[1] 0.03556685438873\n```\n\n### Net present value\n\n`npv \u003c- function(i, cf, t=seq(along=cf))`\n\nNet present value (NPV) is the difference between the present value\nof cash inflows and the present value of cash outflows over a period of time.\nThis function produces the same results as Excel does which differs from packages such as FinCal.\n\n#### Parameters\n- _i_ interest rate\n- _cf_ cache flow e.g. the cashFlow vector of the payment plan\n- _t_ time series (optional)\n\n#### Value\n_Returns_ a double with the net present value\n\n#### Examples\n```r\nprint(npv(cf = c(-123400, 36200, 54800, 48100), i = 0.035))\n```\n```\n[1] 5908.865636076123\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Ffinancials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falipsa%2Ffinancials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falipsa%2Ffinancials/lists"}