Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Stopping handle_data

For my algorithm, I want handle_data to stop calling itself after a certain condition is met. Is there any code I can put in that will stop handle_data?

3 responses

Set a Boolean value in the context then at the top of the function return if it's true

Sorry, I don't really understand what you mean. Like basically I have an if statement that, if true, does what I want and then I want handle_data to stop. So you're saying in that if statement I need to make it do what I want and return a boolean value instance variable?

handle_data wil be called every minute. However, if there is code within handle_data that you don't want executed, then do this prior to the code:

if context.skip_handle_data:  
    return  

Initialize context.skip_handle_data as boolean False, and flip it to True when you want to stop executing the code.