skillfed

quantstats

Portfolio analytics for quants

quantstats v0.0.81 315.9K downloads/30d#7,682 on PyPI7,547
Permissive license Apache-2.0 Active released

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 quantstats

uv

uv add quantstats

poetry

poetry add quantstats

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Office/Business :: FinancialTopic :: Office/Business :: Financial :: InvestmentTopic :: Scientific/EngineeringTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

portfolio performance analyticssharpe ratio calculatorinvestment returns analysisportfolio tearsheet generatordrawdown visualizationquantitative trading metricsrisk metrics for portfolios
portfolio-analysisquantitative-financerisk-metrics

More Libraries packages