{"id":13449017,"url":"https://github.com/quantopian/empyrical","last_synced_at":"2025-05-14T12:11:19.144Z","repository":{"id":37664495,"uuid":"54192943","full_name":"quantopian/empyrical","owner":"quantopian","description":"Common financial risk and performance metrics. Used by zipline and pyfolio.","archived":false,"fork":false,"pushed_at":"2024-07-26T06:19:42.000Z","size":1185,"stargazers_count":1360,"open_issues_count":37,"forks_count":433,"subscribers_count":72,"default_branch":"master","last_synced_at":"2025-04-19T14:41:36.007Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://quantopian.github.io/empyrical","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantopian.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":"2016-03-18T10:22:52.000Z","updated_at":"2025-04-11T07:10:56.000Z","dependencies_parsed_at":"2024-04-10T23:44:00.770Z","dependency_job_id":"ebf49cf5-2961-45a6-86c1-53088373306e","html_url":"https://github.com/quantopian/empyrical","commit_stats":{"total_commits":138,"total_committers":24,"mean_commits":5.75,"dds":0.8405797101449275,"last_synced_commit":"40f61b4f229df10898d46d08f7b1bdc543c0f99c"},"previous_names":["quantopian/qrisk"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fempyrical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fempyrical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fempyrical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Fempyrical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantopian","download_url":"https://codeload.github.com/quantopian/empyrical/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140760,"owners_count":22021219,"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-07-31T06:00:28.664Z","updated_at":"2025-05-14T12:11:19.120Z","avatar_url":"https://github.com/quantopian.png","language":"Python","funding_links":[],"categories":["Research Tools","金融数据处理","Python","Portfolio Management \u0026 Risk","指标\u0026风险分析"],"sub_categories":["Arbitrage","Risk Analysis","风险分析"],"readme":"[![Build Status](https://travis-ci.org/quantopian/empyrical.svg?branch=master)](https://travis-ci.org/quantopian/empyrical)\n\n[![PyPI](https://img.shields.io/pypi/v/empyrical?color=%234ec726\u0026style=flat-square)](https://pypi.org/project/empyrical/)\n\n# empyrical\n\nCommon financial risk metrics.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Support](#support)\n- [Contributing](#contributing)\n- [Testing](#testing)\n\n## Installation\n```\npip install empyrical\n```\n\n## Usage\n\nSimple Statistics\n```python\nimport numpy as np\nfrom empyrical import max_drawdown, alpha_beta\n\nreturns = np.array([.01, .02, .03, -.4, -.06, -.02])\nbenchmark_returns = np.array([.02, .02, .03, -.35, -.05, -.01])\n\n# calculate the max drawdown\nmax_drawdown(returns)\n\n# calculate alpha and beta\nalpha, beta = alpha_beta(returns, benchmark_returns)\n\n```\n\nRolling Measures\n```python\nimport numpy as np\nfrom empyrical import roll_max_drawdown\n\nreturns = np.array([.01, .02, .03, -.4, -.06, -.02])\n\n# calculate the rolling max drawdown\nroll_max_drawdown(returns, window=3)\n\n```\n\nPandas Support\n```python\nimport pandas as pd\nfrom empyrical import roll_up_capture, capture\n\nreturns = pd.Series([.01, .02, .03, -.4, -.06, -.02])\n\n# calculate a capture ratio\ncapture(returns)\n\n# calculate capture for up markets on a rolling 60 day basis\nroll_up_capture(returns, window=60)\n```\n\n## Support\n\nPlease [open an issue](https://github.com/quantopian/empyrical/issues/new) for support.\n\n### Deprecated: Data Reading via `pandas-datareader`\n\nAs of early 2018, Yahoo Finance has suffered major API breaks with no stable\nreplacement, and the Google Finance API has not been stable since late 2017\n[(source)](https://github.com/pydata/pandas-datareader/blob/da18fbd7621d473828d7fa81dfa5e0f9516b6793/README.rst).\nIn recent months it has become a greater and greater strain on the `empyrical`\ndevelopment team to maintain support for fetching data through\n`pandas-datareader` and other third-party libraries, as these APIs are known to\nbe unstable.\n\nAs a result, all `empyrical` support for data reading functionality has been\ndeprecated and will be removed in a future version.\n\nUsers should beware that the following functions are now deprecated:\n\n- `empyrical.utils.cache_dir`\n- `empyrical.utils.data_path`\n- `empyrical.utils.ensure_directory`\n- `empyrical.utils.get_fama_french`\n- `empyrical.utils.load_portfolio_risk_factors`\n- `empyrical.utils.default_returns_func`\n- `empyrical.utils.get_symbol_returns_from_yahoo`\n\nUsers should expect regular failures from the following functions, pending\npatches to the Yahoo or Google Finance API:\n\n- `empyrical.utils.default_returns_func`\n- `empyrical.utils.get_symbol_returns_from_yahoo`\n\n## Contributing\n\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/quantopian/empyrical/compare/).\n\n## Testing\n- install requirements\n  - \"nose\u003e=1.3.7\",\n  - \"parameterized\u003e=0.6.1\"\n\n```\n./runtests.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Fempyrical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantopian%2Fempyrical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Fempyrical/lists"}