Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Confusion about how to get minute data

Hi,

I tried to get the list of all minute close data for today. here is my code:

def initialize(context):
schedule_function(mycode, date_rules.every_day(), time_rules.market_close())

def mycode:
today_minute_closes = data.history(stock, 'close',390, '1m')
print(today_minute_closes[0:5])

output:
2016-05-05 20:00:00+00:00 204.980
2016-05-06 13:31:00+00:00 204.100
2016-05-06 13:32:00+00:00 204.170
2016-05-06 13:33:00+00:00 204.339
2016-05-06 13:34:00+00:00 204.270

So I thought it included extended hour data, and I tried to increase the window. but no matter what window size I use, I can't get the begin of day minute data. Actual, if I increase the window just to 391, I got this:
today_minute_closes = data.history(stock, 'close',391, '1m')
print(today_minute_closes[0:5])

output:
2016-05-05 19:59:00+00:00 204.830
2016-05-05 20:00:00+00:00 204.980
2016-05-06 13:31:00+00:00 204.100
2016-05-06 13:32:00+00:00 204.170
2016-05-06 13:33:00+00:00 204.339

now it goes into yesterday's data.

Did I miss something here?

2 responses

For a full trading day, you'll see 390 minutes. There are no data for before market open or after market close.

That is what I did in the first code snippets, using 390. But it didn't give me the right prices.