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.

Agent Sandbox: Secure Local Development for AI Coding Agents
August 17, 2026
Agent Sandbox provides a robust and secure local development environment specifically designed for collaborating with AI coding agents. It ensures minimal filesystem access, configurable network egress policies, and secure secret injection, protecting your local machine from potentially risky agent operations. This project supports various AI agents and integrates seamlessly with both CLI and popular IDE devcontainer setups.

AMD Skills: Empowering AI Agents with AMD's Optimized Software Stack
August 16, 2026
AMD Skills is the official catalog of AI agent skills from AMD, designed to empower AI agents with optimized software for AMD hardware. This repository provides knowledge, scripts, and conventions for working with AMD's stack, enabling seamless integration with major coding agents like Cursor, Claude Code, OpenAI Codex, and Gemini CLI.

agent-tackle-box: A Terminal Debugger for LangGraph & LangChain Agents
August 15, 2026
agent-tackle-box is a comprehensive toolkit for developing AI agents, featuring the powerful `agent-debugger`. This terminal debugger provides deep insights into LangGraph and LangChain agents. It allows developers to inspect state, monitor tool calls, and step through Python code, all within a unified Textual UI.

ADR: Uber's Enterprise Security System for AI Agents
August 14, 2026
ADR (Agentic AI Detection and Response) is an enterprise security system developed by Uber to secure AI agents. It offers critical capabilities like observability, security benchmarking, and threat detection, ensuring the safe operation of both employee and customer-facing AI applications. This open-source project is deployed in production at Uber and was accepted to MLSys 2026.
Source repository
Open the original repository on GitHub.
13 counted GitHub visits