qis.generate_rebalancing_indicators¶
- qis.generate_rebalancing_indicators(df=None, index=None, freq='ME', include_start_date=False, include_end_date=False, num_warmup_periods=None, return_true_only=False)[source]¶
boolean rebalancing flags aligned to an observation index.
Builds a schedule at
freqover the span of the index, then marks each observation date on or after a scheduled date. The result is theis_rebalancinginput the backtester expects, so rebalancing happens on dates the data actually has rather than on calendar dates that may fall on a holiday.- Parameters:
df (DataFrame | Series) – frame or series whose index defines the observation dates; ignored if
indexis givenindex (DatetimeIndex) – observation dates, as an alternative to
dffreq (str) – rebalancing frequency, passed to
generate_dates_schedule()include_start_date (bool) – mark the first observation as a rebalancing date
include_end_date (bool) – mark the last observation as a rebalancing date
num_warmup_periods (int | None) – number of leading observations forced to False, so an estimator has data before the first rebalancing
return_true_only (bool) – return only the True entries rather than a flag per observation
- Returns:
boolean series indexed as the observations, or only its True entries when
return_true_only- Raises:
ValueError – if neither
dfnorindexis givenNotImplementedError – if
dfis neither pd.Series nor pd.DataFrame
- Return type: