Back to Community
Where to run code that takes > 5 minutes?

Hi all,

I have some heavy computation I'd like to perform prior to doing any trades for each day, but the code takes > 5 minutes to run. Is there a way/place to run the code without running into a timeout error?

2 responses

Hi Chris,

Have you tried doing your calculations in before_trading_start? This method has the longest execution time limit, and is the recommended method for time intensive calculations. Another approach could be to break down your calculation, if possible, into multiple minute-bars.

Out of curiosity, what type of calculations are you running? If they involve fundamentals data, we are currently working on a project that will speed up query time for our fundamentals dataset. This could help speed up your calculations once it's released.

I hope this 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.

Unfortunately the calculations are on price history, but I may be able to perform them using your suggestion. How long is the time limit in before_trading_start? Also, would it be possible to break down the calculation into multiple minute bars inside of before_trading_start?