resample_rolling#

API documentation for tradingstrategy.utils.groupeduniverse.resample_rolling Python function.

resample_rolling(df, window=24)[source]#

Resample OHLCV feed using a rolling window technique.

  • OHLCV data is looked back from the current hour, not from the day boundary

  • Needed to avoid lookahead bias workarounds

  • Somewhat slow to compute, cache results on the disk

  • Note that the result might not be directly applicable to techical analysis functions: these might still expect you to downsaple the rolling window 1h data to daily, this function will make the data just available in a convinient way to downsample without lookahead bias

See https://stackoverflow.com/q/78036231/315168

Parameters:
  • df (DataFrame) – DataFrame with columns “open”, “high”, “low”, “close”, “volume”

  • window (int) –

    How many samples per one OHLCV window.

    E.g. set to 24 to sample hourly to rolling daily.

Returns:

DataFrame with a rolling OHCLV values as the candles form, without peeking to the future.

There are no NA values. On the first row open = high = low = close because we sample over one value.

Return type:

DataFrame