Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zha0yangchen opened this issue May 17, 2024 · 1 comment
Open

Comments

@zha0yangchen
Copy link

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:
@BL0987
Copy link

BL0987 commented Jun 8, 2024

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

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

No branches or pull requests

2 participants