Skip to content

BUG: Resample multi-series indicator inputs consistently - #1390

Open
Jaco-Ren wants to merge 1 commit into
kernc:masterfrom
Jaco-Ren:agent/resample-multi-series
Open

BUG: Resample multi-series indicator inputs consistently#1390
Jaco-Ren wants to merge 1 commit into
kernc:masterfrom
Jaco-Ren:agent/resample-multi-series

Conversation

@Jaco-Ren

@Jaco-Ren Jaco-Ren commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • resample additional time-indexed indicator inputs alongside the primary series
  • apply the existing OHLCV aggregation defaults to each input and align their complete periods
  • add an ATR-style regression test that exercises the real Strategy.data array path

Motivation and Context

Fixes #1243.

resample_apply() currently resamples only its primary series. Additional inputs passed through *args remain at the source frequency, so a call such as:

resample_apply('D', atr, self.data.High, self.data.Low, self.data.Close, 14)

passes daily High values together with minute-level Low and Close values. Multi-series indicators therefore receive incompatible lengths and indexes and may fail before producing a result.

The change recognizes pandas Series/DataFrames and Strategy data arrays only when they share the primary series' original index. Those inputs are resampled with their field-specific defaults (High=max, Low=min, Close=last, etc.); scalar parameters and unrelated arguments remain unchanged. The existing label='right' behavior is preserved so a higher-timeframe value becomes available only after that period is complete, avoiding look-ahead bias.

Testing

  • confirmed the new regression test fails before the implementation because Low and Close remain raw _Array values
  • python -m unittest backtesting.test._test.TestLib.test_resample_apply backtesting.test._test.TestLib.test_resample_apply_multiple_series
  • python -m backtesting.test - 82 passed, 1 skipped
  • git diff --check

Types of changes

  • Bug fix
  • Tests
  • Documentation

@Jaco-Ren
Jaco-Ren marked this pull request as ready for review August 12, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atr (and others) indicators not working with resample

1 participant