quantstats
Portfolio analytics for quants
What it is and what it does
QuantStats is a Python library for analyzing and visualizing portfolio returns. It calculates standard performance metrics like Sharpe ratio, Sortino ratio, maximum drawdown, volatility, and win rate from a time series of returns, then visualizes them via matplotlib and seaborn plots or generates interactive HTML tearsheets for comparison against benchmarks. The library operates on return periods (daily, weekly, monthly) rather than discrete trades, making it well-suited for systematic strategies with regular rebalancing.
The package wraps eight core dependencies—numpy, pandas, scipy, matplotlib, seaborn, tabulate, yfinance, and python-dateutil—to provide three main modules: `stats` for metric calculation, `plots` for visualization, and `reports` for batch analysis and tearsheet generation. It includes Monte Carlo simulation for probabilistic risk analysis and can extend pandas DataFrames with convenience methods like `.sharpe()` and `.plot_snapshot()`.
Use it for:
- Calculate and compare Sharpe ratio, Sortino ratio, and other risk-adjusted returns for a strategy against a benchmark.
- Generate an HTML tearsheet showing monthly returns, drawdowns, rolling volatility, and performance metrics for stakeholder reporting.
- Run Monte Carlo simulations to estimate bust probability and goal probability for a portfolio under different market scenarios.
- Visualize daily returns, drawdown periods, and rolling statistics to identify performance patterns and risk periods.
- Analyze win rate, consecutive wins/losses, and profit factor for systematic trading strategies on a period-by-period basis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
QuantStats computes portfolio performance metrics (Sharpe ratio, volatility, drawdown, win rate) and generates visualizations and HTML tearsheets for analyzing investment returns.
Yes. QuantStats is actively maintained, has no known vulnerabilities, uses permissive licensing, and installs with low friction. It is well-suited if you need to compute standard portfolio metrics and generate tearsheets. Be aware that it operates on return periods, not discrete trades—if you trade multi-day positions, period-based metrics like win rate will differ from trade-level statistics. Verify that its metric definitions align with your risk model before relying on it for critical decisions.
Install
quantstats on PyPI
pip
pip install quantstatsuv
uv add quantstatspoetry
poetry add quantstatsInstalling quantstats
Before you install
Low friction installation with a pure-Python wheel. Actively maintained with recent commits and a large community (7547 stars). Requires Python >= 3.10 and eight runtime dependencies including numpy, pandas, scipy, matplotlib, and yfinance—all stable, widely-used libraries.
License in practice
Distributed under Apache-2.0 (permissive). You can use, modify, and distribute QuantStats freely in commercial and private projects with minimal restrictions.
Quickstart
pip install quantstats
import quantstats as qs
stock = qs.utils.download_returns('META')
sharpe = qs.stats.sharpe(stock)
qs.plots.snapshot(stock, title='Performance', show=True)
qs.reports.html(stock, 'SPY')
Requires Python >= 3.10. yfinance dependency needs internet access to download market data.
Verify before relying
- Whether Monte Carlo simulations (bust_probability, goal_probability) are suitable for your risk model assumptions.
- How period-based metrics (win rate, consecutive wins) map to your specific trading workflow if you use multi-day trades.
- Performance characteristics with very large return series or high-frequency data.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — matplotlib, numpy, pandas, python-dateutil, scipy, seaborn, tabulate, yfinance |
| Maintenance | actively maintained — 213 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 315,897/month — #7,682 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: quantstats-0.0.81-py3-none-any.whl
Keywords: algo-trading, algorithmic-trading, algotrading, finance, plotting, portfolio, quant, quantitative-analysis, quantitative-trading, visualization
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
empyrical-reloadedComputes financial return and risk…
permissive · top 15,000 on PyPI
gs-quantGS Quant is a Python toolkit for quantitative…
permissive · top 15,000 on PyPI
backtestingBacktesting.py lets you define and test trading…
agpl · top 15,000 on PyPI
skfolioskfolio is a Python library for portfolio…
permissive · top 15,000 on PyPI
pyportfoliooptPyPortfolioOpt implements portfolio…
permissive · top 15,000 on PyPI
QuantLibQuantLib provides Python bindings to a C++…
permissive · top 5,000 on PyPI
riskfolio-libRiskfolio-Lib builds optimized investment…
permissive · top 15,000 on PyPI
pvanalyticsPVAnalytics provides quality control,…
permissive · top 15,000 on PyPI
vnstock-ezchartGenerates publication-quality static financial…
permissive · top 15,000 on PyPI
vollibvollib calculates option prices, implied…
permissive · top 15,000 on PyPI