{"id":13739639,"url":"https://github.com/ymyke/pypme","last_synced_at":"2026-01-17T07:04:08.284Z","repository":{"id":56900108,"uuid":"464439789","full_name":"ymyke/pypme","owner":"ymyke","description":"A Python package for PME (Public Market Equivalent) calculation","archived":false,"fork":false,"pushed_at":"2025-03-31T16:17:23.000Z","size":111,"stargazers_count":13,"open_issues_count":3,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-12T14:46:35.960Z","etag":null,"topics":["finance","financial-analysis","investing","investment-analysis","pme","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ymyke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2022-02-28T10:38:32.000Z","updated_at":"2025-08-25T19:37:15.000Z","dependencies_parsed_at":"2025-05-08T19:37:25.776Z","dependency_job_id":null,"html_url":"https://github.com/ymyke/pypme","commit_stats":{"total_commits":100,"total_committers":2,"mean_commits":50.0,"dds":0.13,"last_synced_commit":"60d11f498bc50134da250e67dab9239de194392b"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ymyke/pypme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymyke%2Fpypme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymyke%2Fpypme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymyke%2Fpypme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymyke%2Fpypme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymyke","download_url":"https://codeload.github.com/ymyke/pypme/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymyke%2Fpypme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28503021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"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":["finance","financial-analysis","investing","investment-analysis","pme","python"],"created_at":"2024-08-03T04:00:36.039Z","updated_at":"2026-01-17T07:04:08.259Z","avatar_url":"https://github.com/ymyke.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":["Financial Instruments and Pricing","金融工具与定价"],"readme":"# pypme – Python package for PME (Public Market Equivalent) calculation\n\nBased on the [Modified PME\nmethod](https://en.wikipedia.org/wiki/Public_Market_Equivalent#Modified_PME).\n\n## Example\n\n```python\nfrom pypme import verbose_xpme\nfrom datetime import date\n\npmeirr, assetirr, df = verbose_xpme(\n    dates=[date(2015, 1, 1), date(2015, 6, 12), date(2016, 2, 15)],\n    cashflows=[-10000, 7500],\n    prices=[100, 120, 100],\n    pme_prices=[100, 150, 100],\n)\n```\n\nWill return `0.5525698793027238` and  `0.19495150355969598` for the IRRs and produce this\ndataframe:\n\n![Example dataframe](https://raw.githubusercontent.com/ymyke/pypme/main/images/example_df.png)\n\nNotes:\n- The `cashflows` are interpreted from a transaction account that is used to buy from an\n  asset at price `prices`.\n- The corresponding prices for the PME are `pme_prices`.\n- The `cashflows` is extended with one element representing the remaining value, that's\n  why all the other lists (`dates`, `prices`, `pme_prices`) need to be exactly 1 element\n  longer than `cashflows`.\n\n## Variants\n\n- `xpme`: Calculate PME for unevenly spaced / scheduled cashflows and return the PME IRR\n  only. In this case, the IRR is always annual.\n- `verbose_xpme`: Calculate PME for unevenly spaced / scheduled cashflows and return\n  vebose information.\n- `pme`: Calculate PME for evenly spaced cashflows and return the PME IRR only. In this\n  case, the IRR is for the underlying period.\n- `verbose_pme`: Calculate PME for evenly spaced cashflows and return vebose\n  information.\n- `tessa_xpme` and `tessa_verbose_xpme`: Use live price information via the tessa\n  library. See below.\n\n## tessa examples – using tessa to retrieve PME prices online\n\nUse `tessa_xpme` and `tessa_verbose_xpme` to get live prices via the [tessa\nlibrary](https://github.com/ymyke/tessa) and use those prices as the PME. Like so:\n\n```python\nfrom datetime import datetime, timezone\nfrom pypme import tessa_xpme\n\ncommon_args = {\n    \"dates\": [\n        datetime(2012, 1, 1, tzinfo=timezone.utc), \n        datetime(2013, 1, 1, tzinfo=timezone.utc)\n    ],\n    \"cashflows\": [-100],\n    \"prices\": [1, 1],\n}\nprint(tessa_xpme(pme_ticker=\"LIT\", **common_args))  # source will default to \"yahoo\"\nprint(tessa_xpme(pme_ticker=\"bitcoin\", pme_source=\"coingecko\", **common_args))\nprint(tessa_xpme(pme_ticker=\"SREN.SW\", pme_source=\"yahoo\", **common_args))\n```\n\nNote that the dates need to be timezone-aware for these functions.\n\n\n## Garbage in, garbage out\n\nNote that the package will only perform essential sanity checks and otherwise just works\nwith what it gets, also with nonsensical data. E.g.:\n\n```python\nfrom pypme import verbose_pme\n\npmeirr, assetirr, df = verbose_pme(\n    cashflows=[-10, 500], prices=[1, 1, 1], pme_prices=[1, 1, 1]\n)\n```\n\nResults in this df and IRRs of 0:\n\n![Garbage example df](https://raw.githubusercontent.com/ymyke/pypme/main/images/garbage_example_df.png)\n\n\n## Other noteworthy libraries\n\n- [tessa](https://github.com/ymyke/tessa): Find financial assets and get their price history without worrying about different APIs or rate limiting.\n- [strela](https://github.com/ymyke/strela): A python package for financial alerts.\n\n\n## References\n\n- [Google Sheet w/ reference calculation](https://docs.google.com/spreadsheets/d/1LMSBU19oWx8jw1nGoChfimY5asUA4q6Vzh7jRZ_7_HE/edit#gid=0)\n- [Modified PME on Wikipedia](https://en.wikipedia.org/wiki/Public_Market_Equivalent#Modified_PME)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymyke%2Fpypme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymyke%2Fpypme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymyke%2Fpypme/lists"}