QuantStats — Portfolio Analytics for Quants
Python library for portfolio performance analytics: Sharpe/Sortino/Calmar ratios, drawdown reports, tearsheets.
QuantStats — Portfolio Analytics for Quants
QuantStats is the de-facto Python toolkit for quantitative portfolio performance analysis. With a single function call you get Sharpe, Sortino, Calmar, Omega ratios, rolling drawdowns, monthly P&L heatmaps, and full HTML tearsheets — all from a simple returns Series.
Key features
- 60+ performance and risk metrics (CAGR, VaR, CVaR, Ulcer Index, Kurtosis)
- One-line HTML tearsheets with interactive Plotly charts
- Benchmark comparison (e.g., SPY) via
yfinanceauto-pull - Compatible with Pandas, Zipline, Backtrader, and VectorBT
- Works for daily, hourly, and minute-level returns
Quick start
pip install quantstats
import quantstats as qs
import yfinance as yf
returns = qs.utils.download_returns("AAPL")
qs.reports.html(returns, output="tearsheet.html", benchmark="SPY")
# Opens a full tearsheet in your browser
qs.stats.sharpe(returns) # → float
npx ai-supply add quantstats-portfolio-analytics
Curated mirror of the open-source QuantStats (Apache-2.0). Get it from the source.
Compromise signals — malicious or tampered code (leaked secrets, backdoors, a dropped executable) — reduce the score, and known dependency CVEs carry a bounded penalty (they warrant review but never QUARANTINE — update the dependency to clear). Other dangerous-by-capability traits are risk surface, expected for some capabilities. Every finding is mapped to its OWASP control below.
Findings mapped to the OWASP Top 10 for LLM Applications (2025) and the OWASP Machine Learning Security Top 10. Expand any flagged control for the exact findings — compromise reduces the score; expected/risk-surface do not, except a known CVE, which carries a small bounded penalty (high/critical → Review).
The same gate an agent runs before installing (POST /api/v1/trust/quantstats-portfolio-analytics/check). Click a policy:
Consume QuantStats — Portfolio Analytics for Quants programmatically. Authenticate with an API key or session — see Authorize an agent.
# Agents: CHECK BEFORE YOU INSTALL (no auth) — score, grade, level, capability manifest
curl https://ai-supply.store/api/v1/trust/quantstats-portfolio-analytics
# Gate against your org policy (returns { pass, violations })
curl -X POST https://ai-supply.store/api/v1/trust/quantstats-portfolio-analytics/check \
-H "Content-Type: application/json" \
-d '{"minGrade":"B","denyPermissions":["shell"],"denyUnknownEgress":true}'
# CLI
npx ai-supply add quantstats-portfolio-analytics
# REST (install → download)
curl -X POST https://ai-supply.store/api/v1/listings/quantstats-portfolio-analytics/install \
-H "Authorization: Bearer $AIM_KEY"
# MCP tool
install_listing({ "slug": "quantstats-portfolio-analytics" })OpenAPI spec →Curated mirror — latest upstream source. See the repository for tagged releases.