Hello, I’m using alpaca-trader-api with python to develop an Algo… Currently using paper_url.
I am submitting the following OCO order to close an already open position.
# buy order previously filled at $404.11
take_profit_limit = 405.35
stop_loss = 402.04
api.submit_order(
symbol='SPY',
qty=qty,
side=close_p,
type='limit',
time_in_force='day',
order_class='oco',
stop_loss={'stop_price': stop_loss},
take_profit={'limit_price': take_profit_limit}
)
All the orders are getting submitted just fine but the stop sell is jumping the gun and exiting my positions early.
I expected the stop sell to do nothing until SPY fell below $402.04, days low at this point is $403.35. It closed my position at $403.98 at 9:44… 6 minutes later? Am I misunderstanding OCO orders? Incidentally, my take-gain would have been successful. So I got that going for me, which is nice.
What’s happening here?