ranaroussi

quantstats: Analyze Portfolio Performance and Risk

QuantStats is a Python library for analyzing investment return series with performance metrics, risk statistics, visualizations, and reports. It suits quants and portfolio managers who want to profile and compare strategies from periodic returns.

PythonApache-2.0LibraryFinanceAnalytics
View on GitHub Compare
Stars
7.7k
Forks
1.2k
Stars, last 30 days
+164

Our take

Health score

41/100

How it is scored
Activity
53
Community
42
Issues
48
Pull requests
20

+164 stars in the last 30 days

  • Slower to close issues than 82% of the projects we track

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

7,886

Forks

1,301

Change since Nov 17, 2026: +8 stars·+1 forks

Overview

QuantStats analyzes portfolio return series to help quants and portfolio managers assess performance and risk. Its metrics cover measures such as Sharpe ratio, volatility, and drawdown, while plots and reports make results easier to inspect and share.

It works with daily, weekly, or monthly returns rather than discrete trade records. This distinction matters when interpreting metrics such as win rate: they describe positive and negative return periods, not individual trades.

Key Features

  • Calculate performance and risk metrics, including Sharpe ratio, volatility, maximum drawdown, and value at risk.
  • Visualize returns, drawdowns, rolling statistics, and monthly returns.
  • Generate metrics and plot reports, including HTML tear sheets.
  • Extend pandas objects with QuantStats metrics and plotting methods.
  • Run Monte Carlo simulations for probabilistic risk analysis.
  • Compare return series with a benchmark.

Use Cases

  • A quant can profile a systematic strategy's periodic returns and review its risk metrics.
  • A portfolio manager can compare a portfolio with a benchmark and produce an HTML report for review.
  • An analyst can visualize drawdowns, rolling volatility, and monthly return patterns when investigating performance.
  • A strategy researcher can use Monte Carlo simulations to examine bust and goal probabilities based on return data.

Getting Started

Install with pip:

pip install quantstats

Import it with import quantstats as qs. See the README for usage details and requirements.

Considerations

  • The library analyzes return periods, not individual trade entries and exits. Period-based win and loss metrics may therefore differ from trade-level statistics.
  • The README lists Python 3.10 or newer and minimum versions for pandas, NumPy, SciPy, Matplotlib, Seaborn, tabulate, and yfinance. Plotly is optional for plots.to_plotly().
  • The README notes a plotting caveat: saving the monthly returns heatmap may still display it.

Found this useful?

Share it with someone who would like quantstats.

Comparisons