QuantStats vs Pyfolio: Choosing the Right Library for Portfolio Performance Analysis

QuantStats is a stand-alone visualization toolkit that generates complete performance dashboards with a single function call, while Pyfolio is a modular risk-analytics library designed to integrate with the Zipline back-testing framework.

When evaluating portfolio performance in Python, developers often compare QuantStats and Pyfolio for their analytical capabilities. Both libraries provide statistical metrics and visualizations, yet they serve fundamentally different architectural purposes according to the awesome-systematic-trading repository source code. Understanding their distinct design philosophies ensures you select the appropriate tool for your systematic trading workflow.

Core Architectural Differences

QuantStats Stand-Alone Design

QuantStats operates as a self-contained library built on top of pandas, NumPy, and Matplotlib. In quantstats/__init__.py, the library exposes high-level functions like reports.full that operate directly on simple pandas Series or DataFrame objects. This architecture requires no external back-testing framework, allowing analysts to analyze return streams from CSV files, databases, or alternative back-testers without coupling to specific data structures.

Pyfolio Zipline Integration

Pyfolio functions primarily as a plug-in for Zipline, the Quantopian back-testing engine. According to the source code in pyfolio/tears.py, many core functions expect objects like returns and positions generated by Zipline simulations. While Pyfolio can process standalone return data, its design leverages scipy, seaborn, and statsmodels within an ecosystem optimized for the Quantopian/Zipline workflow, making it most powerful when integrated with that specific back-testing infrastructure.

Metric Coverage and Visualization Depth

QuantStats delivers approximately 50 distinct performance metrics, including specialized ratios like Calmar, Omega, and tail-risk analytics, alongside customizable report sections. The library automatically generates tear-sheet style visualizations—arranging drawdown plots, turnover charts, and monthly return heatmaps into polished, presentation-ready dashboards.

Pyfolio provides a core set of standard risk metrics (Sharpe, Sortino, maximum drawdown) and pre-built plotting utilities for rolling returns and risk decomposition. However, extending Pyfolio with additional custom metrics typically requires manual coding, whereas QuantStats offers these advanced statistical measures out of the box.

Implementation and Workflow Comparison

The practical distinction emerges when generating comprehensive reports. QuantStats enables one-line report generation that automatically arranges all visualizations:

import pandas as pd
import quantstats as qs

# `returns` is a pandas Series of portfolio daily returns

returns = pd.read_csv("my_returns.csv", index_col=0, parse_dates=True)["return"]
qs.reports.full(returns)  # One-line full report with charts

Pyfolio requires manual assembly of individual components to achieve similar coverage:

import pandas as pd
import pyfolio as pf

# `returns` is a pandas Series of portfolio daily returns

returns = pd.read_csv("my_returns.csv", index_col=0, parse_dates=True)["return"]
pf.create_returns_tear_sheet(returns)  # Builds specific tear-sheet panel

While Pyfolio's modular approach permits granular control over individual risk visualizations, QuantStats automates layout and formatting for immediate consumption without additional configuration.

Dependencies and Maintenance Status

QuantStats maintains a minimal dependency footprint, requiring only pandas, numpy, matplotlib, and scipy. This lightweight architecture reduces installation friction and version conflicts across different Python environments.

Pyfolio carries additional dependencies on seaborn, statsmodels, and ideally the Zipline library for full functionality. Furthermore, development activity slowed significantly after Quantopian's closure in 2020, though the repository remains available with approximately 8,000 GitHub stars. QuantStats continues active maintenance with roughly 4,000 stars and receives more frequent updates for modern Python compatibility.

Summary

  • QuantStats functions as a stand-alone, visualization-heavy toolkit emphasizing ready-made performance dashboards without back-testing engine coupling.
  • Pyfolio operates as a modular risk-analytics library tightly integrated with the Quantopian/Zipline workflow.
  • QuantStats offers broader metric coverage (~50 metrics) compared to Pyfolio's standard risk analytics set.
  • QuantStats requires only core scientific Python libraries, while Pyfolio depends on Zipline-specific objects and additional statistical packages.
  • For quick visual performance reviews, QuantStats provides one-line report generation; Pyfolio requires manual assembly for comprehensive coverage.

Frequently Asked Questions

Can Pyfolio be used without the Zipline back-testing framework?

Yes, Pyfolio can analyze standalone return Series, but its architecture optimizes for Zipline-generated objects like positions and transactions. Without Zipline, users must manually format data structures and combine multiple tear-sheet functions to replicate the comprehensive reporting that QuantStats achieves automatically.

Which library offers more performance metrics out of the box?

QuantStats provides approximately 50 metrics including specialized ratios like Calmar and Omega, plus tail-risk analytics. Pyfolio focuses on standard risk-adjusted metrics (Sharpe, Sortino, max drawdown) and requires custom code for extended statistical analysis beyond its core tear-sheet offerings.

Is Pyfolio still maintained for production use?

Development activity slowed after Quantopian ceased operations in 2020, though the repository remains available and functional for existing implementations. QuantStats receives more frequent updates and modern maintenance, making it potentially more suitable for new projects requiring long-term support and active community engagement.

Which quantstats vs pyfolio approach suits quantitative researchers best?

Researchers embedded in the Zipline ecosystem who need granular control over risk decomposition and transaction-level analysis should choose Pyfolio. Analysts requiring immediate, publication-quality performance reports from any data source should select QuantStats for its stand-alone dashboard capabilities and minimal dependency requirements.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →