{"id":18053833,"url":"https://github.com/danielstern/calculon","last_synced_at":"2025-04-05T08:21:41.903Z","repository":{"id":17030501,"uuid":"19794638","full_name":"danielstern/calculon","owner":"danielstern","description":"A Friendly Library for a Time When Conventional Calculators are No Longer Needed... 2011.","archived":false,"fork":false,"pushed_at":"2014-05-30T00:47:50.000Z","size":196,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T16:18:09.138Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielstern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-14T20:15:22.000Z","updated_at":"2014-05-30T00:47:50.000Z","dependencies_parsed_at":"2022-07-12T18:23:10.478Z","dependency_job_id":null,"html_url":"https://github.com/danielstern/calculon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstern%2Fcalculon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstern%2Fcalculon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstern%2Fcalculon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstern%2Fcalculon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielstern","download_url":"https://codeload.github.com/danielstern/calculon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247307328,"owners_count":20917448,"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-10-31T00:08:15.443Z","updated_at":"2025-04-05T08:21:41.859Z","avatar_url":"https://github.com/danielstern.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Calculon\n========\n\n\"If I buy a stamp five years ago for $5, and sell it today for $50, what was my compound annual rate of return?\"\n\nWhat is Calculon?\n------\nCalculon is a calculator for investments. It can find compound rate of return, and return statistics useful for making graphs.\n\nWhy do I care?\n------\nCompound rate of return is a very important formula used frequently in real estate investing and the stock market. \n\nWhy not just use `math.pow()?`\n-------\n`math.pow()` can't account for recurring payments and it doesn't output statistics.\n\nHow to use?\n-----------\n\n```html\n\u003cscript src='Calculon.js'\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var q = Calculon.rateOfReturn({\n      interestRate:8,\n      startingValue: 3,\n      finalValue: null,\n      numMonths: 32,\n      recurringPayment: 5,\n  })\n  alert(q);\n  // Object {value: 182.59, valueType: \"finalValue\", params: Object, stats: Array[32]}\n\u003c/script\u003e\n```\n\n###Description:\n\nYou must pass a parameters object to `Calculon.rateOfReturn()` with all *but one* entry filled out (in the example above, finalValue is `null`). Recurring payment is optional and cannot be calculated.\n\n```\n  returnObject = Calculon.rateOfReturn(parameters)\n```\n\n```\n@parameters: object { \n    interestRate:number - the annual rate of return \n    startingValue:number - the starting value of the investment \n    finalValue:number - the final value of the investment at the end of the time period\n    numMonths:number -  the number of months in the time period\n    [recurringPayment:number - an addition or subtraction of value every month]\n} \n```\n\n```\n@returnObject: object { \n    value:number - the value of the query\n    valueType:string - the nature of the response \n    params:object - the original parameters passed to the function\n    stats:array - the value each month\n} \n```\n\n###Shortcuts\n\n```\nCalculon.ror = Calculon.rateOfReturn\n```\n\n#### Examples\n\n```javascript\n  Calculon.instructions();\n  // outputs colorful instructions\n```\n\n```javascript\n  Calculon.rateOfReturn({\n    startingValue: 100,\n    numMonths: 150,\n    interestRate: 7.58,\n    recurringPayment: 6,\n    finalValue: undefined,\n  })\n  //Object {value: 1759.38, valueType: \"finalValue\", params: Object, stats: Array[150]}\n```\n\n```javascript\n  Calculon.rateOfReturn({\n    startingValue: 3,\n    finalValue: 50,\n    numMonths: 120\n  })\n  //Object {value: 28.451, valueType: \"interestRate\", params: Object, stats: Array[120]}\n```\n\n\n#### Example Using the Stock Market\n\n```javascript\n  // IBM's stock price where the first value is 10 years ago today and the last is today\n  var IBM = [85.53,86.06,87.05,87.42,87.13,87.1,88.7,88.35,88.59,88.59,88.12,87.98,87.35,87.56,88.64,90.04,90.09,90.46,90.07,90.54,90.38,90.44,90.06,89.49,90.02,90.79,89.99,89.55,88.71,88.29,88.15,87.5,87.04,85.7,85.35,83.65,83.89,84.95,85.25,84.13,84.02,84.28,85.3,86.36,85.3,86.06,84.85,85.09,85.88,85.85,86.77,87.07,86 ... ];\n  \n  Calculon.rateOfReturn({\n    startingValue: IBM[0],\n    numMonths: IBM.length / 20,\n    interestRate: undefined,\n    finalValue: IBM[IBM.length - 1]\n  });\n  \n  // 7.58\n  // Returns my copmound annual rate of return on IBM if I bought it at the beginning and sold at the end. (It's 20 because there are 20 business days in a month)\n  \n  Calculon.rateOfReturn({\n    startingValue: IBM[240],\n    numMonths: 60,\n    interestRate: undefined,\n    finalValue: IBM[1440]\n  });\n\n  // 9.56\n  // Returns my compound rate of return if I had bought it 1 year into the data set, and sold 6 years into it. A significantly better deal!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielstern%2Fcalculon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielstern%2Fcalculon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielstern%2Fcalculon/lists"}