qis.compute_ewm_trend_slope

qis.compute_ewm_trend_slope(data, span=12, min_periods=2)[source]

Fit an exponentially weighted linear trend with an intercept, through each row.

Ages are row counts, not timestamp differences. Supply an ordered grid with explicit missing rows for elapsed periods. Past nonfinite levels are ignored, but their periods still elapse; the current level must be finite. No log, risk scaling or annualisation is implicit. A log level gives log growth per row. Runs in one pass per column.

Parameters:
  • data (Series | DataFrame | ndarray) – Numeric levels as a labelled series/frame or one- or two-dimensional array.

  • span (float) – Finite scalar greater than one; decay equals (span - 1) / (span + 1).

  • min_periods (int) – Minimum number of finite levels per column, including the current row. Defaults to two (the first identifiable slope); use 13 for a 12-span warm-up requiring 13 observed levels.

Returns:

Slope per row, with the input shape and labels. Unavailable slopes are NaN.

Raises:

ValueError – Invalid span, count, input dimensions or non-unique/unordered index.

Return type:

Series | DataFrame | ndarray