Install & Compatibility
Where this runs
tested against v0.0.81 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 6.274s · 454.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 19.1s · import 5.767s · 435MB
455MB installed
● package 455MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
quantstats
✓ import quantstats as qs
Standard import alias for brevity.
extend_pandas
✓ qs.extend_pandas()
Extends pandas DataFrames/Series with QuantStats metrics and plotting methods, allowing method chaining (e.g., `df.sharpe()`). Should be called after importing quantstats.
This quickstart demonstrates how to import QuantStats, extend pandas DataFrames for easy access to metrics, download historical stock data using `yfinance`, calculate a basic performance metric like the Sharpe Ratio, and generate a comprehensive HTML tearsheet comparing a stock's performance against a benchmark.
import quantstats as qs
import yfinance as yf
import pandas as pd
# Extend pandas functionality with QuantStats methods
qs.extend_pandas()
# Download daily returns for a stock using yfinance
ticker = 'AAPL'
stock_data = yf.download(ticker, start='2020-01-01', end='2023-12-31')
returns = stock_data['Adj Close'].pct_change().dropna()
# Optionally, download benchmark returns
benchmark_ticker = 'SPY'
benchmark_data = yf.download(benchmark_ticker, start='2020-01-01', end='2023-12-31')
benchmark_returns = benchmark_data['Adj Close'].pct_change().dropna()
# Calculate and print Sharpe Ratio
sharpe_ratio = returns.sharpe()
print(f"Sharpe Ratio for {ticker}: {sharpe_ratio:.4f}")
# Generate a full HTML report (opens in browser by default)
# Ensure you have matplotlib and seaborn installed for plots
qs.reports.html(returns, benchmark=benchmark_returns, title=f'{ticker} vs {benchmark_ticker} Performance', output='quantstats_report.html')
Errors
Common errors & fixes
ImportError: cannot import name 'stats' from partially initialized module 'quantstats' (most likely due to a circular import)
This error typically indicates a circular dependency issue during module loading, often triggered when `quantstats` itself tries to import a submodule that, in turn, attempts to import a parent module before it's fully initialized.
fixThis was a known bug in `quantstats` versions 0.0.78 and 0.0.79. Upgrade your `quantstats` package to version 0.0.80 or newer: `pip install quantstats --upgrade`.
NameError: name 'dd_get_stats' is not defined
This error occurs specifically when attempting to generate a full report using `qs.reports.full()` in certain versions of `quantstats` due to a mistyped internal function name.
fixThis bug was fixed in `quantstats` version 0.0.81. Upgrade your package: `pip install quantstats --upgrade`.
FutureWarning: The default fill_method='pad' in Series.pct_change is deprecated and will be removed in a future version.
This `FutureWarning` originates from pandas, indicating that `quantstats` functions using `pct_change()` with the implicit default `fill_method='pad'` are relying on deprecated behavior.
fixThis warning was addressed in `quantstats` version 0.0.78. Upgrade your `quantstats` package to this version or newer: `pip install quantstats --upgrade`.
FutureWarning: The '1M' freq alias is deprecated and will be removed in a future version, use 'M' instead.
This `FutureWarning` is from pandas, indicating that `quantstats` or user code is using outdated frequency aliases (e.g., '1M') that are no longer recommended and will be removed.
fixThis warning was resolved in `quantstats` version 0.0.75 by updating internal usage to modern pandas frequency aliases (e.g., '1ME'). Upgrade your package: `pip install quantstats --upgrade`.
Upgrade
Version history
0.0.81latest on PyPI · released Jan 13, 2026
Audit
Dependencies
pythonrequiredRequired Python version
pandasrequiredCore data structures and manipulation
numpyrequiredNumerical operations
scipyrequiredScientific computing functions
matplotlibrequiredPlotting and visualization
seabornrequiredStatistical data visualization
tabulaterequiredPretty-printing tabular data
yfinancerequiredUsed by qs.utils.download_returns for fetching financial data
plotlyoptionalOptional, for interactive plots using plots.to_plotly()