Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
algo time out?

This algo times out, but I thought that handle_data could take as long as ~ 58 seconds. Why does it time out?

import time

def initialize(context):  
    pass  
def handle_data(context, data):  
    order(sid(24), 50)  
    time.sleep(10)    # pause 10 seconds  
3 responses

Is there any way to detect a handle_data time-out condition within the algorithm, to avoid an error?

Here's some code that runs, but will time-out if context.iterations is increased to 90000000. I've inferred a time-out restriction of ~ 4 seconds, but in live trading, it is ~ 50 seconds, correct?

Anyone know how to catch the time-out error so the algorithm doesn't crash?

import time

def initialize(context):  
    context.stocks = sid(24)  
    context.iterations = 85000000  
def handle_data(context, data):  
    start = time.clock()  
    for k in range(context.iterations):  
        pass  
    elapsed = time.clock() - start  
    print elapsed  

Has any one figured this out? How can you record the time it takes for a custom factor or pipeline to run?