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

Is it possible to make a market entry using a stop order? After my signal is generated i would like to place a buy order above todays market price, and keep it there.
My understanding is that that could be done in the following way: order(security, 0.16, style=StopOrder(context.output.get_value(security, 'High')))

I understand that Quantopian delete unfilled orders at the end of the day, so to keep the stop order, it must be saved, and redeployed each day until triggered.

When i use the following code to verify my stop order, nothing is printed, so they do not seem to be placed within the market :

order(security, 0.16, style=StopOrder(context.output.get_value(security, 'High')))  
for equity, orders in get_open_orders().items():  
                                print(equity)  
                                print(orders)  
                                for open_order in orders:  
                                    debug_str = "order created on {0} for {1} shares of {2}"  
                                    print  debug_str.format(open_order.created,  open_order. amount,  open_order.sid)  

additional information about the stop order:
I have printed out all parameters of the order, so it gets a security name, amount and a stop price, so why does it not come up as an active order when i do the check right after the order should have been initiated ??

Hope anyone could help me clarify this.

2 responses

Seems like that should work. Consider sharing a basic algo example.
The other route, capture the order id returned from order() and then do get_order()

Hi,

Ok here is a backtest, that does not generate any orders. If i change the order type to market, it trades.

As you can see there is stop and limit orders, this specific test have limit marked out, but I have ran both alternatives, and none of them gives any print outs to indicate that an order is placed.

If any one could help me clarify this, I would be weary grateful