{"id":13449020,"url":"https://github.com/ranaroussi/quantstats","last_synced_at":"2026-01-16T20:23:47.956Z","repository":{"id":37550147,"uuid":"184420323","full_name":"ranaroussi/quantstats","owner":"ranaroussi","description":"Portfolio analytics for quants, written in Python","archived":false,"fork":false,"pushed_at":"2025-03-31T12:53:08.000Z","size":2789,"stargazers_count":5655,"open_issues_count":146,"forks_count":985,"subscribers_count":118,"default_branch":"main","last_synced_at":"2025-05-07T06:38:34.363Z","etag":null,"topics":["algo-trading","algorithmic-trading","algotrading","finance","plotting","python","quant","quantitative-analysis","quantitative-finance","quantitative-trading","visualization"],"latest_commit_sha":null,"homepage":"","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/ranaroussi.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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":null,"patreon":"ranaroussi","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-05-01T13:29:29.000Z","updated_at":"2025-05-07T03:52:03.000Z","dependencies_parsed_at":"2023-02-17T08:31:23.393Z","dependency_job_id":"3bf10276-c033-4c51-baae-958bec261c6a","html_url":"https://github.com/ranaroussi/quantstats","commit_stats":{"total_commits":419,"total_committers":33,"mean_commits":"12.696969696969697","dds":"0.21718377088305485","last_synced_commit":"fa0a91a42400978bcc95f5f2fb2cf20e6f7af56c"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranaroussi%2Fquantstats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranaroussi%2Fquantstats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranaroussi%2Fquantstats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranaroussi%2Fquantstats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ranaroussi","download_url":"https://codeload.github.com/ranaroussi/quantstats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092648,"owners_count":22013290,"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":["algo-trading","algorithmic-trading","algotrading","finance","plotting","python","quant","quantitative-analysis","quantitative-finance","quantitative-trading","visualization"],"created_at":"2024-07-31T06:00:28.716Z","updated_at":"2026-01-16T20:23:42.896Z","avatar_url":"https://github.com/ranaroussi.png","language":"Python","readme":".. image:: https://img.shields.io/badge/python-3.6+-blue.svg?style=flat\n    :target: https://pypi.python.org/pypi/quantstats\n    :alt: Python version\n\n.. image:: https://img.shields.io/pypi/v/quantstats.svg?maxAge=60\n    :target: https://pypi.python.org/pypi/quantstats\n    :alt: PyPi version\n\n.. image:: https://img.shields.io/pypi/status/quantstats.svg?maxAge=60\n    :target: https://pypi.python.org/pypi/quantstats\n    :alt: PyPi status\n\n.. image:: https://img.shields.io/pypi/dm/quantstats.svg?maxAge=2592000\u0026label=installs\u0026color=%2327B1FF\n    :target: https://pypi.python.org/pypi/quantstats\n    :alt: PyPi downloads\n\n.. image:: https://www.codefactor.io/repository/github/ranaroussi/quantstats/badge\n    :target: https://www.codefactor.io/repository/github/ranaroussi/quantstats\n    :alt: CodeFactor\n\n.. image:: https://img.shields.io/github/stars/ranaroussi/quantstats.svg?style=social\u0026label=Star\u0026maxAge=60\n    :target: https://github.com/ranaroussi/quantstats\n    :alt: Star this repo\n\n.. image:: https://img.shields.io/twitter/follow/aroussi.svg?style=social\u0026label=Follow\u0026maxAge=60\n    :target: https://twitter.com/aroussi\n    :alt: Follow me on twitter\n\n\\\n\nQuantStats: Portfolio analytics for quants\n==========================================\n\n**QuantStats** Python library that performs portfolio profiling, allowing quants and portfolio managers to understand their performance better by providing them with in-depth analytics and risk metrics.\n\n`Changelog » \u003c./CHANGELOG.rst\u003e`__\n\nQuantStats is comprised of 3 main modules:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n1. ``quantstats.stats`` - for calculating various performance metrics, like Sharpe ratio, Win rate, Volatility, etc.\n2. ``quantstats.plots`` - for visualizing performance, drawdowns, rolling statistics, monthly returns, etc.\n3. ``quantstats.reports`` - for generating metrics reports, batch plotting, and creating tear sheets that can be saved as an HTML file.\n\nHere's an example of a simple tear sheet analyzing a strategy:\n\nQuick Start\n===========\n\n.. code:: python\n\n    %matplotlib inline\n    import quantstats as qs\n\n    # extend pandas functionality with metrics, etc.\n    qs.extend_pandas()\n\n    # fetch the daily returns for a stock\n    stock = qs.utils.download_returns('META')\n\n    # show sharpe ratio\n    qs.stats.sharpe(stock)\n\n    # or using extend_pandas() :)\n    stock.sharpe()\n\nOutput:\n\n.. code:: text\n\n    0.8135304438803402\n\n\nVisualize stock performance\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    qs.plots.snapshot(stock, title='Facebook Performance', show=True)\n\n    # can also be called via:\n    # stock.plot_snapshot(title='Facebook Performance', show=True)\n\nOutput:\n\n.. image:: https://github.com/ranaroussi/quantstats/blob/main/docs/snapshot.jpg?raw=true\n    :alt: Snapshot plot\n\n\nCreating a report\n~~~~~~~~~~~~~~~~~\n\nYou can create 7 different report tearsheets:\n\n1. ``qs.reports.metrics(mode='basic|full\", ...)`` - shows basic/full metrics\n2. ``qs.reports.plots(mode='basic|full\", ...)`` - shows basic/full plots\n3. ``qs.reports.basic(...)`` - shows basic metrics and plots\n4. ``qs.reports.full(...)`` - shows full metrics and plots\n5. ``qs.reports.html(...)`` - generates a complete report as html\n\nLet' create an html tearsheet\n\n.. code:: python\n\n    (benchmark can be a pandas Series or ticker)\n    qs.reports.html(stock, \"SPY\")\n\nOutput will generate something like this:\n\n.. image:: https://github.com/ranaroussi/quantstats/blob/main/docs/report.jpg?raw=true\n    :alt: HTML tearsheet\n\n(`view original html file \u003chttps://rawcdn.githack.com/ranaroussi/quantstats/main/docs/tearsheet.html\u003e`_)\n\n\nTo view a complete list of available methods, run\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    [f for f in dir(qs.stats) if f[0] != '_']\n\n\n.. code:: text\n\n\t['avg_loss',\n\t 'avg_return',\n\t 'avg_win',\n\t 'best',\n\t 'cagr',\n\t 'calmar',\n\t 'common_sense_ratio',\n\t 'comp',\n\t 'compare',\n\t 'compsum',\n\t 'conditional_value_at_risk',\n\t 'consecutive_losses',\n\t 'consecutive_wins',\n\t 'cpc_index',\n\t 'cvar',\n\t 'drawdown_details',\n\t 'expected_return',\n\t 'expected_shortfall',\n\t 'exposure',\n\t 'gain_to_pain_ratio',\n\t 'geometric_mean',\n\t 'ghpr',\n\t 'greeks',\n\t 'implied_volatility',\n\t 'information_ratio',\n\t 'kelly_criterion',\n\t 'kurtosis',\n\t 'max_drawdown',\n\t 'monthly_returns',\n\t 'outlier_loss_ratio',\n\t 'outlier_win_ratio',\n\t 'outliers',\n\t 'payoff_ratio',\n\t 'profit_factor',\n\t 'profit_ratio',\n\t 'r2',\n\t 'r_squared',\n\t 'rar',\n\t 'recovery_factor',\n\t 'remove_outliers',\n\t 'risk_of_ruin',\n\t 'risk_return_ratio',\n\t 'rolling_greeks',\n\t 'ror',\n\t 'sharpe',\n\t 'skew',\n\t 'sortino',\n\t 'adjusted_sortino',\n\t 'tail_ratio',\n\t 'to_drawdown_series',\n\t 'ulcer_index',\n\t 'ulcer_performance_index',\n\t 'upi',\n\t 'utils',\n\t 'value_at_risk',\n\t 'var',\n\t 'volatility',\n\t 'win_loss_ratio',\n\t 'win_rate',\n\t 'worst']\n\n.. code:: python\n\n    [f for f in dir(qs.plots) if f[0] != '_']\n\n.. code:: text\n\n\t['daily_returns',\n\t 'distribution',\n\t 'drawdown',\n\t 'drawdowns_periods',\n\t 'earnings',\n\t 'histogram',\n\t 'log_returns',\n\t 'monthly_heatmap',\n\t 'returns',\n\t 'rolling_beta',\n\t 'rolling_sharpe',\n\t 'rolling_sortino',\n\t 'rolling_volatility',\n\t 'snapshot',\n\t 'yearly_returns']\n\n\n**\\*\\*\\* Full documenttion coming soon \\*\\*\\***\n\nIn the meantime, you can get insights as to optional parameters for each method, by using Python's ``help`` method:\n\n.. code:: python\n\n    help(qs.stats.conditional_value_at_risk)\n\n.. code:: text\n\n\tHelp on function conditional_value_at_risk in module quantstats.stats:\n\n\tconditional_value_at_risk(returns, sigma=1, confidence=0.99)\n\t    calculats the conditional daily value-at-risk (aka expected shortfall)\n\t    quantifies the amount of tail risk an investment\n\n\nInstallation\n------------\n\nInstall using ``pip``:\n\n.. code:: bash\n\n    $ pip install quantstats --upgrade --no-cache-dir\n\n\nInstall using ``conda``:\n\n.. code:: bash\n\n    $ conda install -c ranaroussi quantstats\n\n\nRequirements\n------------\n\n* `Python \u003chttps://www.python.org\u003e`_ \u003e= 3.5+\n* `pandas \u003chttps://github.com/pydata/pandas\u003e`_ (tested to work with \u003e=0.24.0)\n* `numpy \u003chttp://www.numpy.org\u003e`_ \u003e= 1.15.0\n* `scipy \u003chttps://www.scipy.org\u003e`_ \u003e= 1.2.0\n* `matplotlib \u003chttps://matplotlib.org\u003e`_ \u003e= 3.0.0\n* `seaborn \u003chttps://seaborn.pydata.org\u003e`_ \u003e= 0.9.0\n* `tabulate \u003chttps://bitbucket.org/astanin/python-tabulate\u003e`_ \u003e= 0.8.0\n* `yfinance \u003chttps://github.com/ranaroussi/yfinance\u003e`_ \u003e= 0.1.38\n* `plotly \u003chttps://plot.ly/\u003e`_ \u003e= 3.4.1 (optional, for using ``plots.to_plotly()``)\n\nQuestions?\n----------\n\nThis is a new library... If you find a bug, please\n`open an issue \u003chttps://github.com/ranaroussi/quantstats/issues\u003e`_\nin this repository.\n\nIf you'd like to contribute, a great place to look is the\n`issues marked with help-wanted \u003chttps://github.com/ranaroussi/quantstats/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22\u003e`_.\n\n\nKnown Issues\n------------\n\nFor some reason, I couldn't find a way to tell seaborn not to return the\nmonthly returns heatmap when instructed to save - so even if you save the plot (by passing ``savefig={...}``) it will still show the plot.\n\n\nLegal Stuff\n------------\n\n**QuantStats** is distributed under the **Apache Software License**. See the `LICENSE.txt \u003c./LICENSE.txt\u003e`_ file in the release for details.\n\n\nP.S.\n------------\n\nPlease drop me a note with any feedback you have.\n\n**Ran Aroussi**\n","funding_links":["https://patreon.com/ranaroussi"],"categories":["Analytics","Python","Analytic tools","By Industry","algorithmic-trading","TextBook","Curated List","指标\u0026风险分析"],"sub_categories":["Metrics computation","Finance","Trading \u0026 Backtesting","交易与回测","금융경제학c","Analytics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franaroussi%2Fquantstats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Franaroussi%2Fquantstats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franaroussi%2Fquantstats/lists"}