I’m finding that some limit orders don’t get filled because the price has already moved too far away. Is there a way to submit a OCO limit order (e.g. $10) and a stop order at a higher price ($10.03) or market order in case the limit price is missed?
I’ve tried stop loss orders, but in real time they seem to execute at a higher price when compared a simultaneously placed limit order.
Response from Alpaca Support:
Currently OCO orders such as this would currently only be supported for exit orders. As in closing an existing position but not opening a new one.
Please feel free to reach back out if you would like to discuss further. Please also take a look at the orders page for more information. You may consider a stop limit order and see if this suits your needs better.
if you look back in my post ive talked about a price collar, try increasing the price of your buy or sell orders by 3-6% let me know if that helps
A potential solution is to do something like the following:
order = api.submit_order(symbol, quantity, side, ‘limit’, ‘gtc’, limit_price = price)
time.sleep(3)
api.replace_order(order_id = order.id, limit_price = 999)
This should attempt a limit order first, wait 3 seconds, and then if it isn’t filled it’ll guarantee a buy with a high limit price… if the limit order went through, it shouldn’t place a new limit order. I’ll give it a go tomorrow, see if it works out.
Update: works perfectly
if you need anything else let me know !
api.submit_order(
symbol=setStock.upper(),
side=‘buy’,
type=‘stop_limit’,
limit_price=limitPrice,
stop_price=stopPrice,
qty=qtyshare,
time_in_force=‘day’,
order_class=‘bracket’,
take_profit=dict(
limit_price=limitPricetosell*1.05,
),
stop_loss=dict(
stop_price=stopPricetosell
)
)
I put limit price and stop price to get in the trade and then also set up the exiting with profit taker price and stop price.