Skip to content

how to get correct 15min value by using resample_apply with 1min data #1143

Closed

Description

@zha0yangchen

Expected Behavior

Expected data should same as this high = pd.DataFrame({'high': self.data.High}, index=self.data.index).resample('15min').agg('max').dropna().values[:, 0][-500:]

Actual Behavior

but when i use self.High = resample_apply('15min', None, self.data.High)
and print( self.High[-1], high[-1]), the value of self.high is incorrect, but high[-1] is corrct.

Steps to Reproduce

python code goes here

Additional info

  • Backtesting version: 0.?.?
  • bokeh.__version__:
  • OS:

Activity

  1. BL0987 commented on Jun 8, 2024

    @BL0987

    I get better results by resampling the dataframe prior to using it in the backtest:

    e.g

    import pandas as pd
    import yfinance as yf

    df = yf.download('AAPL', period='5y', interval='1d') # rounding=True

    df1 = df.resample('2d').agg({'Open': 'first',
    'High': 'max',
    'Low': 'min',
    'Close': 'last',
    'Volume': 'sum'})

    Hope it helps

  2. kernc commented on Feb 18, 2025

    @kernc
    Owner

    high = pd.DataFrame({'high': self.data.High}, index=self.data.index).resample('15min').agg('max').dropna().values[:, 0][-500:]

    You should have compared with label="right":

    high = self.data.High.s.resample('15min', label='right').agg('max') ...

    or at least that's what resample_apply() does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis is not a (valid) bug report

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions