Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Intraday data bins based on 1 minute bar - How to work with 30 min bars?

Hi, I'd like to have data in 30 minute bars, not 1 minute and to work with historical data say a year or two. In simple terms I'd like to compare 30 minutes intervals for the last 3 years with corresponding 30 min Open, High, Low, Close and check if there are some trends in the first 30 min of trading and its influence on the close of the. day. How could I go about getting data in this format? I can only see a way of getting 1 minute bar with some big window back, but it's not what I'm after.
any help would be appreciated, thanks

3 responses

You have a couple options.

If you're in the IDE, you could use data.history() at a 1 minute frequency and do a pandas resample down to a 30 minute frequency.

Chances are you'll run out of memory limits if you try to increase the lookback period too long (Doing rolling computations over years of 30 minute price data is really intensive!)

You might want to check out this strategy in research first, and identify exactly which 30 minute intervals are relevant to your strategy on a smaller subset.

Then, when implementing the algorithm you could use the bar_count parameter in data.history to specify how far you want to look back/look at relevant price information.

Let me know if you have any questions!

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks for the idea Matthew. Can you tell me the title of the research as when I click on the link, I only see a list of my cloned notebooks.
I also have thought that maybe I can use multiple schedule_functions each with different time shift and construct a list or something with these values.

When I linked Research, I was referencing the Research environment. The research environment is for testing trends like this - it's hard to narrow down a strategy only using the IDE.