Definition
A rolling metric is a statistic computed over a moving window of the most recent N observations, recomputed at each time step as the window slides forward. As the window advances by one period, the oldest observation drops out and the newest enters, producing a fresh value of the statistic. The family includes rolling mean, rolling standard deviation, rolling correlation, rolling Sharpe ratio, rolling drawdown, and rolling rank correlation — any statistic, in principle, can be wrapped in a rolling window.
The point of the construction is to turn a static statistic into a time series of its own. A single full-history Sharpe ratio for a strategy averages over good and bad regimes alike and may hide a recent collapse in performance. A rolling Sharpe shows whether the strategy is currently working, currently fading, or currently in trouble — information that a single-number summary can erase.
Why it matters
How it works
The naive implementation computes the statistic from scratch at each step over the N-element window, which is O(N) per step. For mean and variance, an incremental update — subtract the leaving observation, add the arriving one — drops the cost to O(1) per step and makes rolling computation practical on long histories and high-frequency data. Pandas, NumPy, and most time-series libraries provide vectorised rolling implementations that handle the bookkeeping efficiently.
Window-length selection is half the engineering problem. Too short and the metric is dominated by noise — a five-day rolling Sharpe oscillates wildly even on a stable strategy. Too long and the metric lags real changes: a six-month rolling Sharpe will keep reporting strength for months after the strategy has stopped working. Common practice is to inspect the rolling metric at several window lengths simultaneously, or to use exponentially weighted alternatives that down-weight old observations smoothly rather than dropping them sharply.