QuantStats: Powerful Python Library for Portfolio Analytics

This repository profile is provided by osrepos.com, an open source repository discovery platform.

QuantStats: Powerful Python Library for Portfolio Analytics

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

Analyzed by OSRepos on February 4, 2026

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)

Snapshot plot

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:

HTML tearsheet

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

Related repositories

Similar repositories that may be relevant next.

AgentEvals: Robust Evaluation Tools for LLM Agent Trajectories

AgentEvals: Robust Evaluation Tools for LLM Agent Trajectories

June 30, 2026

AgentEvals is a powerful open-source package from LangChain designed to simplify the evaluation of agentic applications. It provides a collection of ready-made evaluators and utilities, with a particular focus on analyzing agent trajectories, the intermediate steps an agent takes to solve problems. This helps developers understand and improve the reliability and performance of their LLM agents.

PythonLLMAgents
Phoenix: AI Observability and Evaluation Platform for LLMs

Phoenix: AI Observability and Evaluation Platform for LLMs

June 28, 2026

Phoenix is an open-source AI observability platform from Arize AI, designed for comprehensive experimentation, evaluation, and troubleshooting of LLM applications. It provides robust features including OpenTelemetry-based tracing, LLM evaluation, and systematic prompt management. This platform helps developers optimize and debug their AI models effectively across various environments.

AI ObservabilityLLM EvaluationPrompt Engineering
Observers: A Lightweight Library for AI Observability in Python

Observers: A Lightweight Library for AI Observability in Python

June 28, 2026

Observers is a Python library designed for AI observability, enabling developers to track and store interactions with generative AI APIs. It provides a flexible framework with various observers for popular LLM providers and multiple storage backends. This tool helps in monitoring, debugging, and analyzing AI model behavior effectively.

PythonAI ObservabilityLLM
Jsonformer: Bulletproof Structured JSON Generation from Language Models

Jsonformer: Bulletproof Structured JSON Generation from Language Models

June 27, 2026

Jsonformer is a powerful library designed to generate syntactically correct and schema-conforming JSON from language models. It addresses the common challenge of unreliable JSON output by focusing on generating only content tokens, making the process more efficient and robust. This approach ensures bulletproof structured data generation for various applications.

JSONLanguage ModelsAI

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️