Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How to get 1 minute data for a specific date?

How to get 1 minute data for a specific date?

E.g. for example how to print the 1 minute low for SPY for May 31 2016 at 9:31, 10:01, 10:31 ?

Thanks a lot!

5 responses

I assume you are asking how to do this in the research (notebook) environment? If so take a look at this post https://www.quantopian.com/posts/confused-about-return-value-of-get-pricing-goog#587d5543d24bf6000d176375. Use the 'get_pricing' method. Set the frequency='minute'

pricing_series = get_pricing('SPY', start_date="2015-05-31", end_date="2015-05-31", fields='low', frequency='minute')

After that it's a matter of manipulating and slicing the resulting dataframe to pull out the specific times you want. I've attached a notebook which uses the 'query' method to do this. Another approach may be to use the 'resample' method?

Note I subtracted 6 from the hours to get the market time. Should have subtracted 4, but you get the idea.

Thank you Dan, this is exactly what I needed, I am going to check it out in detail! Thanks again!

Dan, one more question (you can see I am really new to this), how I can get the actual value for 9:31 for example:

line_0931 = prices.query('hour == 9 and minute == 31')

index   Equity(8554 [SPY])  minute  hour  

0 2017-01-10 14:31:00+00:00 226.39 31 9

low_0931 = ???

Thanks again!

To get a specific row use the query method to narrow it down. Just like you have it prices.query('hour == 9 and minute == 31').

That gets you a dataframe (like a 2D array) with the rows that match the condition. To retrieve the values for the 'low' one could use the 'loc' method.

a_specific_value = prices.query('hour == 9 & minute == 31').loc[0,'low']

That returns the value in column 'low' for the first row (python starts with 0 as the first row). There are a lot of ways to index into a pandas dataframe to get specific values. Search online for 'pandas dataframe indexing' or something similar.

See attached notebook. The same as previous but added a cell at the bottom which shows this. (oh, also did rename the columns to make it a bit more readable)

Thank you Dan, you made my day!