Skip to content

夏普比率

年化夏普比率:(mean(return) − rf) / std(return) × sqrt(年化因子)。零波动输入经 np.ptp guard 处理(BUG-GOLDEN-001 修复)。Edge-first;连到多个 Price Factor 时按标的 fan out 为 by_symbol

做什么(One-liner)

Layer-1 变换:消费收益率序列,输出年化风险调整收益。恒定(零波动)收益 clamp 到 0.0,不是 NaN/inf。

输入

  • returns(array,必填)—— 收益率序列。
  • annualization_factor(number,可选)—— 默认 252(日频);月频用 12。
  • risk_free_rate(number,可选)—— 年化无风险利率,默认 0。

输出

  • sharpe_ratio —— 年化夏普。
  • by_symbol —— 连多个 Price Factor 时的 per-ticker 映射。

怎么用

  1. 提供 returns 数组。
  2. 设置 annualization_factor(日频 252,月频 12)。
  3. 可选设置 risk_free_rate(年化)。

核心公式

per_period_rf = rf / 年化因子
excess_t = r_t - per_period_rf
sharpe = mean(excess) / std(excess, ddof=0) × √年化因子

特殊情况ptp(excess) == 0(恒定收益,无波动)→ 返回 0.0(不是 NaN / inf)。

假设与适用场景

假设:年化因子与输入频率匹配(日频 252 / 月频 12)+ population std + linear per-period rf 日化 + 收益近似正态。

适用:组合 / 策略绩效度量,n ≥ 30。

不适用:intraday、厚尾资产、带杠杆的 option portfolio、短序列 n<30。

已知局限

  1. 对上行与下行波动对称惩罚(仅下行见 Sortino)。
  2. annualization_factor 敏感 —— 日频 vs 月频须与输入频率匹配。
  3. 正态假设(BTC/crypto 偏差大)。
  4. 零波动 clamp 到 0.0(从 BUG-GOLDEN-001 经验)。

参考文献

Sharpe (1966) + Sharpe (1994) 修订。详见 frontmatter。

Golden Test

tests/golden/fixtures/tier1/sharpe_ratio/,1e-12 tolerance,覆盖正常序列 / 零波动 / 小样本 3 个场景。2026-05-25 passing。参考:numpy 2.2.6 独立重实现 Sharpe 1966 定义。

Changelog

  • 1.1.0 (2026-05-25) —— 提升为 Active 的 Layer-1 变换;并入已弃用 Layer-0 sharpe_ratio 卡片的完整治理字段。
  • 1.0.0 (2026-05-23) —— 初始 edge-first Layer-1 Draft 卡片。

Verifiable intelligence for the decisions that demand scrutiny.