sigmaquant.performance.rolling.rolling_metric#

sigmaquant.performance.rolling.rolling_metric(
returns,
metric,
*,
window,
min_periods=None,
**kwargs,
)#

Compute a rolling metric on a sequence of returns.

The input is internally converted to a pandas Series. If the input does not provide a datetime index, a default integer index is used.

Parameters:
  • returns – Sequence of periodic returns. If a pandas Series is provided, its index is preserved. Otherwise, a default integer index is assigned.

  • metric

    Metric function to apply. The function must have the signature:

    metric(returns: Iterable[float], **kwargs) -> float

  • window – Size of the rolling window, expressed in number of observations.

  • min_periods – Minimum number of observations required to compute the metric. If None, defaults to window.

  • **kwargs – Additional keyword arguments passed directly to metric.

Returns:

Time series of rolling metric values.

Return type:

pandas.Series

Notes

  • The rolling operation is index-based, not time-based.

  • If the input does not carry a datetime index, temporal semantics (e.g. resampling, calendar alignment) are not available.

  • NaN handling is delegated to the metric function.