The tearsheet library whose cagr(rf=...) accepts your risk-free rate and silently discards it - "cagr" sits on an exclusion list inside _prepare_returns, which dispatches on the caller's function name. TRIGGER - quantstats, "import quantstats as qs", qs.reports.html, qs.stats.sharpe, qs.stats.cagr, qs.stats.value_at_risk, expected_shortfall, gain_to_pain_ratio, rolling_volatility, qs.extend_pandas, tearsheet, quantstats-lumi; or a wildly negative Sharpe. Memory is stale on status and correctness - 0.0.81 shipped in a single-day hotfix burst on 2026-01-13 with no default-branch commits since, and the cagr bug survived it. SKIP for optimizing against these measures (lib-riskfolio, lib-skfolio) and for PSR/DSR, which it does not have (backtest-validation). SKIP when the question is WHICH library to choose, or names no library at all - both belong to the domain skill.
Ships in fin-libraries. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
One-call HTML tearsheets and performance analytics — enormously popular, and the source of more quietly wrong published numbers than anything else in this domain.
| pip / import | QuantStats / quantstats (conventionally import quantstats as qs) |
| Version | 0.0.81 (2026-01-13) · Python >=3.10 |
| Licence | Apache-2.0 |
| Status | ⚠️ burst-maintained — 7,612★ / 32 issues; no default-branch commits since 2026-01-13 |
The maintenance pattern matters because of the bugs below: 0.0.78 ("2026 Modernization Update") shipped with
circular-import errors hot-fixed through 0.0.79, 0.0.80 and 0.0.81 the same day, and the metric bugs survived it.
Forks: quantstats-lumi 1.1.5, quantstats-reloaded 0.1.0.
🚨 CONFIRMED BUG: quantstats.stats.cagr() discards rf. The signature is cagr(returns, rf=0.0, compounded=True, periods=252) and the docstring says it computes the CAGR
"of excess returns". The parameter has no effect. Root cause in
quantstats/utils.py::_prepare_returns, which dispatches on the caller's function name:
function = inspect.stack()[1][3]
unnecessary_function_calls = ["_prepare_benchmark", "cagr", "gain_to_pain_ratio", "rolling_volatility"]
if function not in unnecessary_function_calls:
if rf > 0:
return to_excess_returns(data, rf, nperiods)
"cagr" is on the exclusion list, so rf is accepted and silently dropped. The same list disables rf for
gain_to_pain_ratio and rolling_volatility. Compute excess-return CAGR yourself.
🚨 quantstats.stats.value_at_risk is parametric Gaussian — verified from source, it computes `norm.ppf(1
. The docstring says "variance-covariance method"; the function name does not, and the tear sheet labels it simply "Daily Value-at-Risk". expected_shortfallis an alias ofconditional_value_at_risk. Measured, one seeded 1,260-day series, rf=0`, all defaults:| Metric | quantstats | empyrical | ffn | Hand-computed |
|---|---|---|---|---|
| VaR 95% | −0.018574 | −0.018111 | — | −0.018111 historical / −0.018574 Gaussian |
| CVaR 95% | −0.023346 | −0.022786 | — | −0.022786 (historical tail mean) |
| CAGR | 0.250378 | 0.250378 | 0.258761 | 0.250378 (len/252) / 0.260442 (calendar) |
Systematic disagreements, not rounding. On fat-tailed strategies quantstats understates tail risk. Say "historical 95% 1-day VaR" or "Gaussian VaR" — never just "VaR".
rf= is ANNUAL — a wildly negative Sharpe is the diagnostic signaturequantstats' rf= is ANNUAL (converted geometrically), as are ffn's rf= and PyPortfolioOpt's risk_free_rate=.
🔴 empyrical / pyfolio-reloaded's risk_free= is PER-PERIOD (daily), subtracted raw — and it sits beside
period='daily', so almost everyone passes an annual rate.
qs.stats.sharpe(r, rf=0.05) # -0.285948 correct: 5% annual
ep.sharpe_ratio(r, risk_free=0.05) # -81.323237 <- 5% PER DAY, the signature
ep.sharpe_ratio(r, risk_free=0.05 / 252) # -0.293729 <- de-annualised by division
✅ Reproduce with scripts/rf_convention.py (seed 0, 4 years of daily returns). The residual
between −0.293729 and −0.285948 is quantstats de-annualising geometrically, not by dividing
by 252 — so /252 gets you close to its answer but never equals it. The script's own reference
implementations match both installed libraries to every printed digit, so it demonstrates the
trap on a machine where neither package is installed.
⚠️ Geometric vs simple: (1.05)**(1/252)-1 → 1.021119, 0.05/252 → 1.014726 — never identical.
🚨 It guesses whether your input is prices: if data.min() >= 0 and data.max() > 1: data = data.pct_change(). An
all-non-negative return series containing one +100% period is silently differenced into nonsense — realistic for
crypto, small caps and options. 🚨 _prepare_returns does fillna(0), turning missing days into zero-return days:
inflated n, deflated volatility, distorted drawdown duration. dropna() first. 🚨 Annualization is hard-coded
(periods=252), not inferred. Measured: the same data resampled to monthly gives Sharpe 2.2731 at the default
vs 0.4960 with periods=12 — a 4.58× (√21) overstatement from one unchanged default. ffn is the exception;
it infers from the DatetimeIndex. ⚠️ No PSR, no DSR, no MinTRL — sharpe and sortino, and it stops there.
Drawdown is the one family everybody agrees on: quantstats, empyrical, ffn and (P/P.cummax()-1).min() agree to 6 dp.
import quantstats as qs
r = returns.dropna() # 🚨 first: fillna(0) inflates n and deflates vol
assert not ((r.min() >= 0) and (r.max() > 1)), "quantstats would silently pct_change() this"
sharpe = qs.stats.sharpe(r, rf=0.05, periods=252) # rf ANNUAL; state periods explicitly
excess = (1 + r) / (1 + 0.05) ** (1 / 252) - 1 # 🚨 cagr(rf=) is ignored — do it yourself
cagr_excess = (1 + excess).prod() ** (252 / len(excess)) - 1
var_gaussian = qs.stats.value_at_risk(r) # 🚨 GAUSSIAN — label it as such
var_hist = r.quantile(0.05) # historical, if that is what you meant
qs.reports.html(r, benchmark="SPY", output="tearsheet.html", rf=0.05)
For a number you will publish or trade on, use ffn plus a hand-rolled cross-check, and state
the risk-free convention and annualization factor with the metric. A 3-year Sharpe of 1.0 has a standard error near
0.58 — report the interval.
../../../fin-core/skills/portfolio-and-risk/SKILL.md — the domain skill for performance analytics../../../fin-core/skills/portfolio-and-risk/references/analytics-libraries.md — the source card and measured audit../../../fin-core/skills/portfolio-and-risk/references/risk-measures.md — VaR/CVaR estimator families../../../fin-core/skills/backtest-validation/SKILL.md — PSR, DSR and PBO, which quantstats does not haveThis file is the deep dive on one library and assumes the choice is already made.
For which library to pick, how it compares with the alternatives, and the traps that span
several of them, the entry point is the domain skill portfolio-and-risk (../../../fin-core/skills/portfolio-and-risk/SKILL.md).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
24 skills in this plugin
/lib-akshareakshare is the widest free Chinese-market scraper (1,103 public interfaces) and it purges its own PyPI history, so you cannot pin it. TRIGGER - akshare, "import akshare as ak", pip install akshare, stock_zh_a_hist, stock_zh_a_daily, index_stock_cons_csindex, stock_zt_pool_em, stock_zh_a_stop_em, adjust="qfq"/"hfq", 复权, 前复权, 后复权, 涨跌停, 东方财富, 新浪财经, A股数据, 沪深300成分股, "No matching distribution found for akshare==", akshare 报错, akshare 封 IP. akshare ships roughly 2.3 releases a week and deletes the old ones, so any signature, column name or version pin you remember is probably already gone. SKIP for lib-tushare, which is the skill for point-in-time fundamentals and dated index membership. SKIP when the question is WHICH library to choose, or names no library at all - both belong to the domain skill./lib-alpaca-pyAlpaca's current Python SDK, which defaults to the paper host but lets url_override silently send live orders from a client that believes it is in the sandbox. TRIGGER - import alpaca, pip install alpaca-py, TradingClient, StockHistoricalDataClient, CryptoHistoricalDataClient, submit_order, LimitOrderRequest, MarketOrderRequest, OrderSide, TimeInForce, client_order_id, url_override, paper=True, BaseURL.TRADING_PAPER, paper-api.alpaca.markets, bracket OCO OTO orders, trail_percent, IEX vs SIP feed, Algo Trader Plus, alpaca-trade-api, APCA_API_BASE_URL; an order rejected asynchronously for time-in-force or price precision. Memory is stale here: alpaca-trade-api was deprecated in 2024 and defaulted to LIVE, whereas alpaca-py 0.44.0 (2026-08-11) declares paper=True - the widely repeated warning is inverted. SKIP for Interactive Brokers and for the general order-safety patterns (broker-execution-apis). SKIP for choosing between libraries, or when no library is named - the domain skill's job./fin-libraries:lib-quantstatsfrom fin-libraries
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin fin-libraries