Skip to content

What (One-liner)

YoY / QoQ growth rate calculation. Library-level primitive, fault-tolerant for None / 0 baselines.

How to use

python
from services.algo.time_series import growth_rate_series
growth_rate_series([100, 110, None, 132])
# → [None, 0.10, None, None]   (index 2 None, index 3 denominator None)

Core formulas

g_t = (v_t - v_{t-1}) / v_{t-1}   if v_{t-1} not in (None, 0) else None

Assumptions & applicability

Assumptions: simple pct change + None fault tolerance + output length equals input.

Applicability: YoY / QoQ / MoM growth rates for revenue / profit / macro indicators.

Not applicable: log growth, continuous 0 sequences.

Known limitations

  1. Negative baseline returns negative division (distortion when "turning from loss to profit")
  2. No smoothing
  3. 0 baseline directly None (no error raised)

References

pandas.pct_change definition + Diebold (2020) time series forecasting basics.

Golden Test

tests/golden/fixtures/tier1/growth_rate_series/, 1e-12, 2026-04-20 passing.

Changelog

  • 1.0.0 (2026-04-20) — First Active

Verifiable intelligence for the decisions that demand scrutiny.