Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
displaying the first minute after NY open

I'm trying to isolate and use only the first minute of the trading day for the last year but can't figure it out. I have tried to select just the 9:31 timestamp in get_pricing() with no success, and tried a few other manipulations of the returned data table but just can't get that first minute row by itself. I need someone to point me in the right direction, thanks.

2 responses

Since you are using the 'get_pricing' method I assume you are looking for a solution that works in the notebooks. 'get_pricing' returns a dataframe or series indexed by a UTC timezone aware datetime. Use the .tz_convert method to convert it to Eastern Time or 'market time'. Then compare the 'time' property of the index to the time you are looking for. Something like this.

import datetime  
prices = get_pricing(['SPY', 'AAPL'], start_date="2016-03-10", end_date="2016-03-15", fields='low', frequency='minute')  
prices_et = prices.tz_convert('US/Eastern')  
prices_et.loc[prices_et.index.time == datetime.time(9, 31)]  

See attached notebook. This method also works in a similar fashion in the IDE when using the 'get_history' method.

Awesome, That worked - thank you very much!