Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Stop Loss and Buy Stop Questions

Since I am trying to optimize the "stop-loss" system on my algorithm, I have two quick questions that I find it necessary to ask:

  1. How do you check if stop-loss orders are actually selling stock at or below the set target (like logging something once stop-loss executes)?

  2. Is there an equivalent of placing a stop-loss order for a short position? I think this is technically termed a "buy-stop" order, but I was wondering how I would place such an order for a stock when this is not a direct option on Quantopian?

1 response

Stop orders do not guarantee getting filled at an exact price. The difference between the price you are filled and your stop price is known as slippage. Buy stops are always above the market price and sell stops are below market price....or the current "print".
Some exchanges and brokers support stop orders with limits. In that manner you know your fill will not go outside of that limit. However, in fast moving markets, you may not get filled at all with a limit stop order.
If the trading platform does not support a stop order, you must create a simulated stop order via code and track the stop levels yourself.
When the market price reaches the stop level, you then issue a market order. Essentially this known as workstation-level stop handling. There is also server-level stop handling that is performed by some trading platforms. However, these are both inferior compared to exchange-level stop handling because there is much less latency for stop orders placed on the servers of the exchanges.