--- id: quantstats version: "0.0.81" license: Apache-2.0 license_treatment: permissive maintenance: active --- # quantstats — Portfolio analytics for quants License: permissive · Maintenance: active · Downloads: 315.9K/mo ## What it is and what it does QuantStats is a Python library for analyzing and visualizing portfolio returns. It calculates standard performance metrics like Sharpe ratio, Sortino ratio, maximum drawdown, volatility, and win rate from a time series of returns, then visualizes them via matplotlib and seaborn plots or generates interactive HTML tearsheets for comparison against benchmarks. The library operates on return periods (daily, weekly, monthly) rather than discrete trades, making it well-suited for systematic strategies with regular rebalancing. The package wraps eight core dependencies—numpy, pandas, scipy, matplotlib, seaborn, tabulate, yfinance, and python-dateutil—to provide three main modules: `stats` for metric calculation, `plots` for visualization, and `reports` for batch analysis and tearsheet generation. It includes Monte Carlo simulation for probabilistic risk analysis and can extend pandas DataFrames with convenience methods like `.sharpe()` and `.plot_snapshot()`. Use it for: - Calculate and compare Sharpe ratio, Sortino ratio, and other risk-adjusted returns for a strategy against a benchmark. - Generate an HTML tearsheet showing monthly returns, drawdowns, rolling volatility, and performance metrics for stakeholder reporting. - Run Monte Carlo simulations to estimate bust probability and goal probability for a portfolio under different market scenarios. - Visualize daily returns, drawdown periods, and rolling statistics to identify performance patterns and risk periods. - Analyze win rate, consecutive wins/losses, and profit factor for systematic trading strategies on a period-by-period basis. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. QuantStats computes portfolio performance metrics (Sharpe ratio, volatility, drawdown, win rate) and generates visualizations and HTML tearsheets for analyzing investment returns. Yes. QuantStats is actively maintained, has no known vulnerabilities, uses permissive licensing, and installs with low friction. It is well-suited if you need to compute standard portfolio metrics and generate tearsheets. Be aware that it operates on return periods, not discrete trades—if you trade multi-day positions, period-based metrics like win rate will differ from trade-level statistics. Verify that its metric definitions align with your risk model before relying on it for critical decisions. ## Install pip install quantstats uv add quantstats poetry add quantstats ## Installing quantstats Before you install: Low friction installation with a pure-Python wheel. Actively maintained with recent commits and a large community (7547 stars). Requires Python >= 3.10 and eight runtime dependencies including numpy, pandas, scipy, matplotlib, and yfinance—all stable, widely-used libraries. License in practice: Distributed under Apache-2.0 (permissive). You can use, modify, and distribute QuantStats freely in commercial and private projects with minimal restrictions. Quickstart: pip install quantstats import quantstats as qs stock = qs.utils.download_returns('META') sharpe = qs.stats.sharpe(stock) qs.plots.snapshot(stock, title='Performance', show=True) qs.reports.html(stock, 'SPY') Requires Python >= 3.10. yfinance dependency needs internet access to download market data. Verify before relying: - Whether Monte Carlo simulations (bust_probability, goal_probability) are suitable for your risk model assumptions. - How period-based metrics (win rate, consecutive wins) map to your specific trading workflow if you use multi-day trades. - Performance characteristics with very large return series or high-frequency data. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 315.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags portfolio performance analytics, sharpe ratio calculator, investment returns analysis, portfolio tearsheet generator, drawdown visualization, quantitative trading metrics, risk metrics for portfolios, portfolio-analysis, quantitative-finance, risk-metrics [View on SkillFed](https://skillfed.io/packages/quantstats) · [View on PyPI](https://pypi.org/project/quantstats/)