I have a backtest that runs no problem in the cloud IDE, but when I initiate it through LEAN CLI half of the time it works but other times it fails with error after 5 minutes:
Algorithm.Initialize() Error: Execution Security Error: Operation timed out - 5 minutes max. Check for recursive loops. Stack Trace: Execution Security Error: Operation timed out - 5 minutes max. Check for recursive loops.
When I check the IDE, the backtest status is in “running” but it is not initiated at all. If I add “--verbose” to the CLI command, I can see in the API response the request status is “in-queue”.
Mia Alissi
Here are some insights and steps you can take to address the issue you're facing with the "Execution Security Error" and the "in-queue" status when running your backtest via the LEAN CLI:
Understanding the Error
Execution Security Error: Operation Timed Out:
Initialize
method or any other part of your algorithm takes too long to execute, exceeding the allowed time limit. This can be due to recursive loops or complex operations that are not optimized.In-Queue Status:
Steps to Resolve
Optimize the
Initialize
Method:Initialize
method is not performing any heavy computations or recursive operations. It should primarily set up securities, cash, and other configurations.Check for Recursive Loops:
Use Verbose Logging:
--verbose
flag to gather detailed logs. This can help identify specific operations or lines of code that are causing delays.Resource Allocation:
Test in Segments:
Consult Support:
By following these steps, you should be able to identify and resolve the issues causing the execution timeout and in-queue status.
Sources: Algorithm Engine - QuantConnect.com, Debugging - QuantConnect.com, Debugging Tools - QuantConnect.com, Order Errors - QuantConnect.com
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Roosevelt Lai
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!