I already read this post How to implement OTOCO(TP/SL) orders using API
After a market order is done (then I make a getPositionRisk and see the position), I send a stop loss market order, with the newClientOrderId from the market order. But it returns error 2013 Order does not exist.
I don’t know how to make it work.
Thanks for any help.
Your market order has already been filled and converted to position, so when you send the stop loss market order with previous newClientOrderId, it’s normal to receive that error message, since it’s no longer open.
Oh thank you for explaining.
So, in my case, how can I set TP/SL, and then they will disappear (cleared) after I close the position like on the Binance website??
I already try with TP SL order without newClientOrderId, but get the same error (that’s why then I try with newClientOrderId)
sell_stop_market = client.futures_create_order(
symbol=coin,
side='SELL',
positionSide='LONG',
type='STOP_MARKET',
stopPrice=sl,
closePosition=True,
timeInForce='GTE_GTC',
workingType='MARK_PRICE',
priceProtect=True
)