How does compression work when resampling feed data (...and I have read the docs)
-
Reading the documentation/examples and studying community posts on resampling I still have a few questions. Mainly related to how compression in the feed relates to compression in resampledata and the specific role of sessionstart/sessionend.
Question 1: Im loading 1 hour bar data. Can I resample from 1 hour bars to 90 minute bars, like this?:
data = bt.feeds.GenericCSVData( dataname='./data/VXX-1h-2016-08-09us.csv', #1 hour bars timeframe=bt.TimeFrame.Minutes, compression=60, sessionstart=datetime.time(9, 30), sessionend=datetime.time(15, 0)) #souce resolution is a higher timeframe than destination resolution - does that work? cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=90)
Question 2: Im loading 15min bar data. Can i resample from 15min bars to 120min bars like this?:
data = bt.feeds.GenericCSVData( dataname='./data/VXX-15m-2016-08-09us.csv', #15 minute bars timeframe=bt.TimeFrame.Minutes, compression=15, sessionstart=datetime.time(9, 30), sessionend=datetime.time(16, 0)) #souce resolution is divisible with destination resolution - is that a requirement? cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=120)
Question 3: Im loading 15min bar data. Can i resample from 15min bars to 50min bars like this?:
data = bt.feeds.GenericCSVData( dataname='./data/VXX-15m-2016-08-09us.csv', #15 minute bars timeframe=bt.TimeFrame.Minutes, compression=15, sessionstart=datetime.time(9, 30), sessionend=datetime.time(16, 0)) #souce resolution is indivisible with destination resolution - does that work? cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes, compression=50)
Question 4: Using NASDAQ as an example trading session starts 9.30 and ends 16.00 and my feed data consists of 1 hour bars with first daily bar at 10.00 last daily bar at 15.00. Should sessionstart and sessionend be set:
#the data's trading hours sessionstart=datetime.time(10, 0), sessionend=datetime.time(15, 0)
Or:
#the exchange's actual trading hours sessionstart=datetime.time(9, 30), sessionend=datetime.time(16, 0)
Also if possible please explain the role og sessionstart and sessionend, like what does it do? And should always set them when loading data?
Thx in advance :-)
-
@søren-pallesen said in How does compression work when resampling feed data (...and I have read the docs):
Question 1: Im loading 1 hour bar data. Can I resample from 1 hour bars to 90 minute bars, like this?:
Sorry but it would be a miracle to get a meaningful compression from
1-hour
(i.e.:60-minutes
) to90-minutes
. Common sense and math dictate that you need a divisor of90
to resample up to90-minutes
@søren-pallesen said in How does compression work when resampling feed data (...and I have read the docs):
#souce resolution is a higher timeframe than destination resolution - does that work?
And no:
1-hour
is not higher than90-minutes
@søren-pallesen said in How does compression work when resampling feed data (...and I have read the docs):
Question 2: Im loading 15min bar data. Can i resample from 15min bars to 120min bars like this?:
120 / 15 = 8
. Yes.@søren-pallesen said in How does compression work when resampling feed data (...and I have read the docs):
Question 3: Im loading 15min bar data. Can i resample from 15min bars to 50min bars like this?:
Go back to the answer for question 1.
@søren-pallesen said in How does compression work when resampling feed data (...and I have read the docs):
Also if possible please explain the role og sessionstart and sessionend, like what does it do? And should always set them when loading data?
They let the resampling code know when a new session has started or ended to avoid working directly with day boundaries.
You should use
09:30
if it does start at09:30