QuantStats: Powerful Python Library for Portfolio Analytics
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
QuantStats is a comprehensive Python library designed for portfolio profiling, offering in-depth analytics and risk metrics for quants and portfolio managers. It helps users better understand their investment performance through robust statistical analysis and powerful visualization tools. This library simplifies the process of generating detailed performance reports and conducting advanced quantitative analysis.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
QuantStats is a powerful Python library designed for comprehensive portfolio profiling and analytics. It empowers quants and portfolio managers to gain deeper insights into their investment performance by providing a rich set of in-depth analytics and risk metrics. Built with ease of use in mind, QuantStats streamlines the process of understanding and visualizing complex financial data.
The library is structured around three core modules:
quantstats.stats: For calculating various performance metrics like Sharpe ratio, Win rate, Volatility, and more.quantstats.plots: For visualizing performance, drawdowns, rolling statistics, monthly returns, and other key aspects.quantstats.reports: For generating detailed metrics reports, batch plotting, and creating complete tear sheets that can be saved as HTML files.
QuantStats also includes advanced features such as Monte Carlo simulations for probabilistic risk analysis, helping users forecast potential outcomes and assess risk more effectively.
Installation
Getting started with QuantStats is straightforward. You can install it using either pip or conda.
Using pip:
pip install quantstats --upgrade --no-cache-dir
Using conda:
conda install -c ranaroussi quantstats
Examples
QuantStats offers a quick and intuitive way to analyze stock performance and generate comprehensive reports. Here are a few examples to get you started:
First, import the library and extend pandas functionality:
import quantstats as qs
# extend pandas functionality with metrics, etc.
qs.extend_pandas()
Next, fetch daily returns for a stock (e.g., 'META') and calculate its Sharpe ratio:
# fetch the daily returns for a stock
stock = qs.utils.download_returns('META')
# show sharpe ratio
qs.stats.sharpe(stock)
# or using extend_pandas() :)
stock.sharpe()
Output:
0.7604779884378278
Visualize the stock's performance with a snapshot plot:
qs.plots.snapshot(stock, title='Facebook Performance', show=True)
# can also be called via:
# stock.plot_snapshot(title='Facebook Performance', show=True)

Finally, generate a complete HTML tearsheet report, comparing the stock against a benchmark like 'SPY':
# benchmark can be a pandas Series or ticker
qs.reports.html(stock, "SPY")
This will generate a detailed HTML report similar to this:

You can also explore Monte Carlo simulations for probabilistic risk analysis:
mc = qs.stats.montecarlo(stock, sims=1000, bust=-0.20, goal=0.50)
print(f"Bust probability: {mc.bust_probability:.1%}")
print(f"Goal probability: {mc.goal_probability:.1%}")
mc.plot()
For a full list of available methods, you can inspect qs.stats and qs.plots. It's important to note that QuantStats analyzes return series (daily, weekly, monthly returns), not discrete trade data. This means metrics like "Win Rate" refer to the percentage of periods with positive returns.
Why Use QuantStats?
QuantStats stands out as an essential tool for anyone involved in quantitative finance or portfolio management due to several key advantages:
- Comprehensive Analytics: Access a vast array of performance metrics and risk indicators, from basic returns to advanced conditional value-at-risk.
- Powerful Visualizations: Generate insightful plots and charts that make complex data easy to understand, including drawdowns, rolling statistics, and monthly heatmaps.
- Automated Reporting: Quickly create detailed HTML tearsheets that consolidate all relevant metrics and plots into a single, shareable report.
- Ease of Integration: Seamlessly extends pandas DataFrames, allowing for intuitive method chaining and a more fluid analytical workflow.
- Advanced Features: Incorporates sophisticated tools like Monte Carlo simulations for robust risk assessment and future performance forecasting.
- Open Source: Being open-source, it benefits from community contributions and transparency, ensuring continuous improvement and reliability.
Whether you're backtesting strategies, monitoring live portfolios, or conducting academic research, QuantStats provides the robust framework needed for in-depth financial analysis.
Links
- GitHub Repository: https://github.com/ranaroussi/quantstats
- Full Monte Carlo documentation: https://github.com/ranaroussi/quantstats/blob/main/docs/montecarlo.md
- View original HTML report example: https://rawcdn.githack.com/ranaroussi/quantstats/main/docs/tearsheet.html
Related repositories
Similar repositories that may be relevant next.

Uni-Agent: A Scalable Framework for Training Long-Horizon AI Agents
October 1, 2026
Uni-Agent is a powerful Python framework designed for training long-horizon agents at scale. It allows users to integrate existing agent harnesses, unify diverse agent tasks through an extensible interface, and run thousands of sessions concurrently for efficient data collection and training.

Benchmark Radar: A Living Database for AI Benchmarks and Evaluation
September 29, 2026
Benchmark Radar is an extensive open-source project that tracks over 20,710 AI benchmark, evaluation, dataset, and data-quality records from 37 public sources. It provides daily updates, linked evidence, and tools for researchers and developers to discover and analyze AI benchmarks. This project is essential for anyone needing to stay current with AI evaluation trends and model performance.

Pydantic AI Harness: Enhancing Your AI Agents with Robust Capabilities
September 28, 2026
Pydantic AI Harness is the official capability and harness library for Pydantic AI, designed to extend agents for complex, long-running tasks. It provides a modular system of "capabilities" for functionalities like file system interaction, web research, memory, and sub-agent delegation. This library enables developers to build sophisticated and durable AI agents with ease.

Bernstein: Open-Source Governance and Orchestration for AI Agents
September 28, 2026
Bernstein is an open-source framework designed for the governance and orchestration of AI agents, allowing users to define rules declaratively. It enforces these policies and generates verifiable, replayable records of all agent activities. This Python-based solution provides a robust layer for managing complex AI agent workflows with transparency and accountability.
Source repository
Open the original repository on GitHub.
16 counted GitHub visits