Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is it possible to get 3m, 5m, 10m, 15m data using Quantopian?

I see that get_pricing function gives 'daily' and 'minute' data; but is it possible to get 3m, 5m, 10m, 15m data WITHOUT writing elaborate conversion auxiliary functions? Do they have something like get_pricing('AAPL', '5m')?

2 responses

Data can be easily 'resampled' into any length bars one wishes. There isn't a 'built in' Quantopian parameter for this, but it's as easy as applying the pandas resample method (see the pandas docs for info). Something like this to get 5 minute bars

prices_1m = get_pricing('AAPL', '1-1-2020', '1-3-2020', fields=['price'], frequency='minute')  
prices_5m = prices_1m.resample('5T', closed='right', label='right').last()

The 'T' abbreviation is used to designate minutes (because 'M' was already used for months). The parameter "closed='right'" will ensure the last minute is included in the resampled bar. The parameter "label='right'" will label the bars with the ending time and not the beginning time (which is the default). There is a bit more on resampling in this post.

Hope that helps.

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.

Here is a notebook with the above method for resampling AAPL minute data.