Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Best practices for comparing annual data

Hello,

I've been playing around with the pipeline, and I'm running into the following error:

"TimeoutException: Too much time spent in handle_data and/or scheduled functions. 50 second limit exceeded"

I wanted to try something very simple, and thought I would look for stocks that had an annual growth of more than 20% for five years straight; however, there seems to be a few challenges with working with that much history. Are there any tips & tricks for using the pipeline in this way. I've seen a few posts on quarterly earnings algorithms, so I shortened my window down to 70 days to see if I could get it to run... but still no luck.

The following backtest is where I'm currently at. Thanks for any insights.

4 responses

Try decreasing the stock universe size

universe_size = 100 # start with small universe and then increase it until Q platform limits let you  
base_universe = AverageDollarVolume(window_length=20, mask=tradeable_stocks).top(universe_size)  

Thanks for the tip. I managed to get it to work intermittently with the smaller universe, but it would still randomly fail. Instead of trying to pull a long window, I ended up pulling the latest values and then doing the filtering outside the pipeline. This seems to run now, although it takes quite a long time to run.

Any thoughts on spots where the code could be a optimized or a done a little smarter?

Thanks again for any thoughts.

Trying to get fundamental data for extended time periods doesn't work very well. The Quantopian pipeline API is not geared towards getting values for points of time in the past. And fundamental data access is very slow. So you end up with either timeout exceptions, or out of memory exceptions.

Also, I'm not sure if Quantopian provides fundamental data updated annually or quarterly or on some other schedule. Consider looking at the one year history for some stock for the factors you're using, and/or comparing with some other data source where this detail is clearly spelled out.

Sunil

+1 bump to this.