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

def initialize(context):
context.stocks = symbols(sid(25776))
def handle_data(context, data):
if curr_bar > 5.74
return order(sid(25776), 100, style=StopOrder (5.74))
else curr_bar < 5.74
return order(sid(25776), -100)

3 responses

you need a ':' after your if and else logic statements. Be sure the resulting orders are indented.

Also the returns aren't necessary, and you need to assign 'curr_bar' some value if you haven't done that elsewhere in the code

I did all that you said to and it still says invalid syntax

def initialize(context):
context.stocks = symbols(sid(25776))
def handle_data(context, data):
curr_bar = price_history[s][-1]
if: curr_bar > 5.74
order(sid(25776), 100, style=StopOrder (5.74))
else: curr_bar < 5.74
order(sid(25776), -100)

something like this?

def initialize(context):  
    context.stock = sid(25776)  
def handle_data(context, data):  
    price_history = history(10, '1d', 'price')  
    curr_bar = price_history[context.stock][-1]  
    if curr_bar > 5.74:  
        order(context.stock, 100, style=StopOrder(5.74))  
    else:  
        order(context.stock, -100)