{"id":20923398,"url":"https://github.com/dmotte/investats","last_synced_at":"2025-04-22T11:11:06.454Z","repository":{"id":263135487,"uuid":"889445236","full_name":"dmotte/investats","owner":"dmotte","description":"🐍 Investment statistics calculator","archived":false,"fork":false,"pushed_at":"2025-02-01T16:15:03.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T14:34:48.687Z","etag":null,"topics":["analysis","analyzer","calculator","command","compute","csv","gain","invest","investats","investment","package","pip","py","pypi","python","return","statistic","statistics","value","yield"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/investats/","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/dmotte.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}},"created_at":"2024-11-16T12:04:42.000Z","updated_at":"2025-02-01T16:15:06.000Z","dependencies_parsed_at":"2024-12-22T15:01:06.861Z","dependency_job_id":"2a5311d4-e284-4dad-9d52-3241ea84365f","html_url":"https://github.com/dmotte/investats","commit_stats":null,"previous_names":["dmotte/investats"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmotte%2Finvestats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmotte%2Finvestats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmotte%2Finvestats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmotte%2Finvestats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmotte","download_url":"https://codeload.github.com/dmotte/investats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250228637,"owners_count":21395958,"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":["analysis","analyzer","calculator","command","compute","csv","gain","invest","investats","investment","package","pip","py","pypi","python","return","statistic","statistics","value","yield"],"created_at":"2024-11-18T20:15:27.933Z","updated_at":"2025-04-22T11:11:06.421Z","avatar_url":"https://github.com/dmotte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# investats\n\n[![GitHub main workflow](https://img.shields.io/github/actions/workflow/status/dmotte/investats/main.yml?branch=main\u0026logo=github\u0026label=main\u0026style=flat-square)](https://github.com/dmotte/investats/actions)\n[![PyPI](https://img.shields.io/pypi/v/investats?logo=python\u0026style=flat-square)](https://pypi.org/project/investats/)\n\n:snake: **Inve**stment **stat**istic**s** calculator.\n\n## Installation\n\nThis utility is available as a Python package on **PyPI**:\n\n```bash\npython3 -mpip install investats\n```\n\n## Usage\n\nThere are some files in the [`example`](example) directory of this repo that can be useful to demonstrate how this tool works, so let's change directory first:\n\n```bash\ncd example/\n```\n\nWe need a Python **virtual environment** (\"venv\") with some packages to do the demonstration:\n\n```bash\npython3 -mvenv venv\nvenv/bin/python3 -mpip install -r requirements.txt\n```\n\n\u003e **Note**: we refer to the **source asset** of the investment with the **generic ticker symbol** `SRC`, and to the **destination asset** with `DST`.\n\nNow we need some **input data** about some investments. You can **generate** dummy data using the `investats_gen` CLI entrypoint. Example commands:\n\n```bash\npython3 -minvestats_gen -d2021-01-01 -a.20 -c24 --fmt-rate='{:.4f}' data-AAA.yml\npython3 -minvestats_gen -d2021-01-01 -a.30 -c24 --fmt-rate='{:.4f}' data-BBB.yml\n```\n\nOr you can **scrape** data from raw text files using the `investats_scrape` CLI entrypoint:\n\n```bash\npython3 -minvestats_scrape AAA transactions.txt --pfix-{inv-src=Amount,inv-dst=Shares,rate=Price}: -t0.15\n```\n\nNow that we have the data, we can **compute the statistics** about the investments:\n\n```bash\nfor i in AAA BBB; do\n    python3 -minvestats --fmt-{days,src}='{:.2f}' --fmt-{dst,yield}='{:.4f}' \\\n        --fmt-rate='{:.6f}' \"data-$i.yml\" \"stats-$i.csv\"\ndone\n```\n\n\u003e **Note**: each supported **input and output entry field** is described with a comment in the `compute_stats` function's code. You can search for the string `# - entry_` in the [`investats/cli.py`](investats/cli.py) file to get an overview.\n\nThen, we can **aggregate** the resulting data (related to multiple investments) into a single CSV file:\n\n```bash\npython3 -minvestats_aggr AAA stats-AAA.csv BBB stats-BBB.csv \\\n    --fmt-{days,src}='{:.2f}' --fmt-{dst,yield}='{:.4f}' --fmt-rate='{:.6f}' \\\n    \u003e stats.csv\n```\n\nAnd finally display some nice **plots** using the [`plots.py`](example/plots.py) script (which uses the [_Plotly_](https://github.com/plotly/plotly.py) Python library):\n\n```bash\nvenv/bin/python3 plots.py -srga stats.csv\n```\n\nFor more details on how to use these commands, you can also refer to their help message (`--help`).\n\n## Development\n\nIf you want to contribute to this project, you can install the package in **editable** mode:\n\n```bash\npython3 -mpip install -e . --user\n```\n\nThis will just link the package to the original location, basically meaning any changes to the original package would reflect directly in your environment ([source](https://stackoverflow.com/a/35064498)).\n\nIf you want to run the tests, you'll have to install the `pytest` package and then run:\n\n```bash\npython3 -mpytest test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmotte%2Finvestats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmotte%2Finvestats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmotte%2Finvestats/lists"}