I ran a backtest yesterday and it was stuck on “requesting backtest” for a long time, later I came back and it had completed. Today I tried another one and it's the same problem. Previously never had this trouble, the backtests always seemed to start right up. Only difference I can think is this project has a large (64k) python file with some side data I'm trying to test against, but not sure why this would matter. Runs instantly on local debug testing.
Jesse Pangburn
My other projects run fine, just seems to be this one that gets stuck on “Requesting Backtest”. It was stuck for at least 8 hours today and never moved to the “Analyzing Strategy” step. The main.py is relatively small (7107 bytes) but it loads a variable from a separate python file, and that file is 63744 bytes.
Varad Kabade
Hi Jesse Pangburn,
Can you share a backtest for which the issue is occurring to try to reproduce the issue?
Best,
Varad Kabade
Jesse Pangburn
Hi Varad,
Sure, thanks for trying to help! Mostly they don't seem to ever finish and I have to just delete them to kill the backtest and try another, but the one I attached eventually completed successfully.
I tried reducing the data file size to ~38k today, and started a backtest ~10 minutes ago and it's still running. So not entirely sure that's the problem. I think I'll try putting the data file on the web and loading it via URL (not sure if that works on QuantConnect, we'll see). As it is, building takes a little while in the web IDE.
Jesse Pangburn
For anyone who runs into this same problem, I fixed this by putting the data file I needed at a publicly available URL (used Dropbox but any public URL will do) and using the QCAlgorithm.Download method which is documented at https://www.quantconnect.com/docs/algorithm-reference/importing-custom-data#Importing-Custom-Data-Loading-Reference-Data
In case it helps, that method just downloads strings so you could use a CSV file but I was already using pickle. If you need pickle instead of CSV, then do this with your exported data wherever you're creating it:
Put that file at a place with a public URL. In your backtest code, you want to download that file and unpickle it. You can do that like this where “qcAlgorithm” is a variable of type QCAlgorithm (self in your backtest code usually):
If you use Dropbox, make sure you change the URL from dl=0 to dl=1 at the end.
After I did this, the project backtests rapidly as usual. Seems like having a large code file is bad news for backtesting, so don't encode reference data in a python file like I did. Do it this way instead (or with a CSV).
Jesse Pangburn
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!