Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How does the If function work

I am very new to Quantopian and python in general and i would appreciate some help on why line number 12 of my code will not work because of what the log describes as "in handle_data.

 if sma_20 > sma_50:  
        if context.aapl not in open_orders:  
            order_target_percent(context.aapl, 1.0,)  

the first line being the offender