Skip to content

已弃用 (2026-05-25) —— 该算子是 Layer-1 变换、非 Layer-0 原子输入,已并入 compute_sma_v1。保留作历史。

做什么(One-liner) ​

pandas rolling mean 的 thin wrapper,技术指标基础 primitive。

怎么用 ​

python
from services.algo.technical import compute_sma
compute_sma(prices, period=20)

核心公式 ​

sma_t = prices.rolling(window=period).mean()[t]

假设与适用场景 ​

假设:等距时间戳 + pd.Series/list 输入 + window≥2。

适用:价格 smoothing、MACD 组件、GC/DC 策略。

不适用:weighted MA(EMA)、adaptive window。

已知局限 ​

  1. 左对齐(NaN prefix)
  2. period default 20
  3. 不处理 calendar gap

参考文献 ​

Murphy (1999) Technical Analysis。

Golden Test ​

tests/golden/fixtures/tier1/compute_sma/,1e-12,2026-04-20 passing。

Changelog ​

  • 1.0.0 (2026-04-20) — 首次 Active

Verifiable intelligence for the decisions that demand scrutiny.