Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
history function question

If I want to do some computation for stocks for one quarter, and use following line in code:

price_hist = data.history('AAPL', 'price', 90, '1d')  

I will get day's closing values for last 90 trading days. However, these 90 days will actually go beyond actual 90 days because many of the intervening days (like weekends, holidays) will not be trading days.

If I want to limit my history by calendar days, how can I do so?

If I want to do some computations on per minute data for each day for 5 days, how can I get that?
Because if I use data.history('AAPL', 'price', 5, '1m') #This will give me last 5 minutes data
if I use data.history('AAPL','price', 5 * 7 * 60, '1m')
assuming 7 hours of trade, on 5 days, each of 60 minutes, this may not be true because on some day, for some reason, trading hours may get reduced (like heavy snowfall).

 So, what is a reliable way to get this?