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

I am trying to test a simple code with Schedule function but it keeps showing error. Please tell me what is wrong

def initialize(context):
context.security = symbol('AAPL')

# Run handle_entry at 10:00 every day  
schedule_function(handle_entry, date_rules.every_day(), time_rules.market_open(minutes=30))  

 def handle_entry(context, data):  
#Go long if open price is higher than prior day close  
close_price = history(2, '1d', field='price')  
open_price = history(2, '1d', field='open_price')  
if close_price < open_price:  
    order(sid(24), 50)  

 def handle_data(context, data):  
pass  
1 response

What exactly does the error message say? Which line does it refer to? I don't suppose all you tell a doctor is that "It hurts".

Make sure all the lines are properly indented - in Python, indentation reflects the nesting structure of statements. All the lines beginning with def should have the same indentation level, preferably no indentation. Other lines should have more indentation, customarily four spaces. The order line should have more indentation than the if line.