Superseded (2026-05-25) — this operator is a Layer-1 transform, not a Layer-0 atomic input. Merged into
sharpe_ratio_v1. Kept for history.
What (One-liner)
Annualized Sharpe Ratio — a classic measure of risk-adjusted returns. Library-level primitive, consumed by Canvas operators like portfolio_risk_metrics, currently not directly exposed in Canvas (one of the candidate Canvas nodes, pending decision).
How to use
Internal Python call:
from services.algo.time_series import sharpe_ratio
sharpe = sharpe_ratio(returns, risk_free_rate=0.02) # Annualized 2% rfCore formulas
daily_rf = rf / 252
excess_t = r_t - daily_rf
sharpe = mean(excess) / std(excess, ddof=0) × √252Special case: ptp(excess) == 0 (constant returns, no volatility) → returns 0.0 (not NaN / inf).
Assumptions & applicability
Assumptions: Daily frequency returns + 252 trading days annualization + population std + linear daily rf conversion.
Applicable: Portfolio / strategy performance measurement, n ≥ 30 days.
Not applicable: Intraday, fat-tailed assets, leveraged option portfolios.
Known limitations
- Normality assumption (large deviation for BTC/crypto)
- Zero volatility clamped to 0 (experience from BUG-GOLDEN-001)
- Annualization factor 252 hardcoded (caller must convert for monthly / weekly)
References
Sharpe (1966) + Sharpe (1994) revisions. See frontmatter for details.
Golden Test
tests/golden/fixtures/tier1/sharpe_ratio/, 1e-12 tolerance, covering 3 scenarios: normal series / zero volatility / small sample. 2026-04-20 passing.
Changelog
- 1.0.0 (2026-04-20) — First Active after BUG-GOLDEN-001 fix (zero volatility zero-division replaced with ptp-based guard)

