qis.compute_rolling_drawdowns

qis.compute_rolling_drawdowns(prices, min_periods=1)[source]

Compute the running drawdown series from peak.

Drawdown at time t is defined as price_t / max(price_0..t) - 1, always ≤ 0.

Parameters:
  • prices (DataFrame | Series) – Price level Series or DataFrame.

  • min_periods (int) – Minimum observations required by the expanding peak. The default of 1 means the peak starts from the first valid price; for daily series with leading NaNs after reindexing, this means the first valid value becomes the initial peak immediately. Increase this if you want the drawdown to remain NaN until a longer warm-up window has elapsed.

Returns:

Drawdown Series or DataFrame matching the input shape, with values in (-1, 0].

Raises:

ValueError – If prices is neither Series nor DataFrame.

Return type:

DataFrame | Series