Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
TimeoutException in live trading

My algo produced "TimeoutException: Too much time spent in handle_data and/or scheduled functions. 50 second limit exceeded.
There was a runtime error on line 174." in live paper trading.

Line 174:
hist = data.history(context.security_list, "close", hist_window, "1d")

The error is not generated in backtesting.

4 responses

do you mean live trading through zipline-live or paper trading through Quantopian?

Paper trading through Quantopian.

The first thing I'd try is to move the 'pipeline_output' code from your scheduled routine to 'before_trading_start' (you will need to add this method). Delete it from your scheduled method. The 'handle_data' and scheduled routines get allotted only 50 seconds while the before_trading method get's allotted 300 seconds (see https://www.quantopian.com/posts/time-limit-for-schedule-function ). I have an idea why you don't see the timeout in backtests, but just try it and see. Pretty sure this will fix the problem.

    def before_trading_start(context, data):  
        # Move the following code from the scheduled function to here  
        context.output = pipeline_output('investment_universe')  
        context.security_list = context.output.index

Dan,
It works!
Thank you!