Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
getting 30 mins bar price for intraday HMM algo

Hi,
I am trying to play with a hidden markov model with 30 mins bars for SPY. Now I am stuck at generating 30 mins bars. I followed Jamie McCorriston's suggestion from
https://www.quantopian.com/posts/multiple-time-frames-algos

for i in range(1, total_minutes):  
# Every 30 minutes run schedule  
  if i % 30 == 0:  
# This will start at 9:31AM and will run every 30 minutes  
      schedule_function(  
      myfunc,  
        date_rules.every_day(),  
        time_rules.market_open(minutes=i),  
        True  
      )

to use schedule_function() every 30 mins. But when I was looking at the log of most recent 10 bars I found some weird results:
In the mid of the day for two consecutive print-outs I have different prices for the two most recent bars. For example
Print A:
2016-12-01 11:00 PRINT 2016-11-30 19:30:00+00:00 220.600
2016-11-30 20:00:00+00:00 221.005
2016-11-30 20:30:00+00:00 220.540
2016-11-30 21:00:00+00:00 220.330
2016-12-01 14:30:00+00:00 220.260
2016-12-01 15:00:00+00:00 220.390
2016-12-01 15:30:00+00:00 220.000
2016-12-01 16:00:00+00:00 220.035
2016-12-01 16:30:00+00:00 220.140
2016-12-01 17:00:00+00:00 220.180
Print B:
2016-12-01 11:30 PRINT 2016-11-30 20:00:00+00:00 221.005
2016-11-30 20:30:00+00:00 220.540
2016-11-30 21:00:00+00:00 220.330
2016-12-01 14:30:00+00:00 220.260
2016-12-01 15:00:00+00:00 220.390
2016-12-01 15:30:00+00:00 220.000
2016-12-01 16:00:00+00:00 220.035
2016-12-01 16:30:00+00:00 220.140
2016-12-01 17:00:00+00:00 219.890
2016-12-01 17:30:00+00:00 219.910

The price at 17:00 GMT (12:00 EST) changed from 220.180 to 219.890.

I am totally lost about how to generate a good 30 mins bar data now. I used to play at quantconnect and they have a very reliable consolidator to deal with this type of problem. I am migrating to quantopian in hope that I could validate some time series idea more easily. Any idea on how to deal with those type of problem? Thanks.