Quick answer
QuantStats is a Python library for portfolio and strategy analytics. Give it a pandas Series of returns and it computes Sharpe, Sortino, Calmar, drawdowns, win rates, monthly return tables and more, draws the standard charts, and writes a complete HTML tear sheet with qs.reports.html(), optionally against a benchmark.
QuantStats at a glance
- Category
- Portfolio optimization & analytics
- Language
- Python
- License
- Apache-2.0
- Does
- Performance analytics
- Markets
- Stocks, ETFs, Crypto, Forex, Futures
- Best for
- Reporting and comparing strategy performance.
- In AlgoGP
- Built-in bridge: add it to any project
Pick it if
Reporting and comparing strategy performance.
Watch out for
Analytics only.
QuantStats strengths and limitations
Strengths
- One-line HTML reports.
- Extensive metric set.
- Benchmark comparison.
Limitations
- Analytics only.
- Benchmark downloads rely on Yahoo Finance.
QuantStats example
pip install quantstatsimport quantstats as qs
returns = qs.utils.download_returns("QQQ")
qs.reports.html(returns, benchmark="SPY", output="report.html")Use QuantStats with AlgoGP
AlgoGP has a built-in QuantStats bridge. Describe the strategy to the copilot and backtest it in AlgoGP, then open the project’s APIs & keys tab and add QuantStats under Frameworks. The project gains these files, saved as a new version and included in every export:
frameworks/algogp_bridge.pyframeworks/tests/test_bridge.pyframeworks/quantstats_report.pyrequirements.txtgains:quantstats,pandas
python backtest.py && python frameworks/quantstats_report.pyQuantStats: frequently asked questions
Can I get a QuantStats report for an AlgoGP backtest?
Yes: add QuantStats to the project, run python backtest.py, then python frameworks/quantstats_report.py.
QuantStats alternatives
- pyfolio-reloadedPythonThe maintained fork of Quantopian’s pyfolio: returns, positions, transaction and round-trip tear sheets for strategy performance analysis.
- Alphalens ReloadedPythonFactor analysis from the Quantopian lineage: information coefficients, quantile returns and turnover to test whether an alpha factor predicts returns.
- PyPortfolioOptPythonPortfolio optimization in Python: mean-variance, Black-Litterman, hierarchical risk parity, efficient frontiers and discrete allocation.
- vectorbtPythonVectorized backtesting on pandas and Numba: test thousands of parameter combinations in seconds, with interactive Plotly analytics.
Independent guide. AlgoGP is not affiliated with QuantStats. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.