Hi,
I think many people on Q are struggling with the issue of timeframes. There is no easy/clear explanation on how to make different size bars, like 1 hour, 2 hours, etc. But, the community is always great to help out, so that is really great.
I'm trying to make 2 hour bars. Assuming NYSE, I want close prices for 11:30, 1:30, 3:30, and 4:00.
I have read that data in Q is in UTC and therefor is not affected by daylight savings time, but I'm not sure I understand that completely, because I have this line of code:
prices = data.history(context.stock, "price", 1550, "1m").resample('120T', closed='right', label='right', base=90) .last().dropna()
That gives me what I want when DST is active (march to november), but does not give me the proper data when during november to march when there is not DST in effect. This code can be used to determine if DST is in effect:
import pytz
from datetime import datetime, timedelta
tz = pytz.timezone('America/New_York')
now = pytz.utc.localize(datetime.utcnow())
is_dst = now.astimezone(tz).dst() != timedelta(0)
But how should I alter my code above to get the same data (close of 11:30, 1:30, 3:30, and 4:00) when there is no DST? Or, is there an easier way to do all this that I am not seeing?
Thank you.