closePosition parameter with semi-filled limit order

If I execute a limit order, that only gets partially filled, along with a stop_market order and Take_profit_market order, will the remaining unfilled limit order be cancelled if the closePosition parameter is set to True, or will that just close the partially filled limit order that is open?

For example, if my orders looked like this:

request_client.post_order(symbol=market,
ordertype=“LIMIT”,
price=entryPrice,
timeInForce=“GTC”,
side=position_side,
positionSide=“BOTH”,
quantity = qty)

request_client.post_order(symbol=market,
ordertype=“TAKE_PROFIT_MARKET”,
stopPrice= takeProfit,
side=stop_side,
callbackRate=_callbackRate,
quantity = qty,
closePosition=‘true’,
workingType=“CONTRACT_PRICE”)

request_client.post_order(symbol=market,
ordertype=“STOP_MARKET”,
stopPrice= stopLoss,
side=stop_side,
callbackRate=_callbackRate,
quantity = qty,
closePosition=‘true’,
workingType=“MARK_PRICE”)

Lets suppose that the first order, the limit order, only gets filled 20%. If the price then hits the Take Profit market order, will only that 20% position be closed, or is there some way to cancel the remaining limit order that has not been filled if the Take Profit is hit.

I’m aware that this probably won’t cancel any open orders, merely close any open positions. If there’s a better way to achieve this, please lmk. Otherwise, I’ll just have to get my bot to keep checking if the TP has been hit via a websocket etc and then cancel the remaining order.

Thanks :slightly_smiling_face:

Notice what’s in the notes on Binance API Documentation

  • STOP_MARKET, TAKE_PROFIT_MARKET with closePosition=true:
    • Follow the same rules for condition orders.
    • If triggered, close all current long position( if SELL) or current short position( if BUY).
    • Cannot be used with quantity parameter
    • Cannot be used with reduceOnly parameter
    • In Hedge Mode,cannot be used with BUY orders in LONG position side. and cannot be used with SELL orders in SHORT position side

→ Cannot be used with quantity parameter

When it’s closePosition=“true”, it’ll close with open position’s quantity, in your example, the said 20%.
You can refer to websocket to track your order updates and cancel the LIMIT order if not completely filled or check other timeInForce types (Binance API DocumentationTime in force (timeInForce):).

1 Like

Yeah, that’s what I thought. Just wanted to check I wasn’t being a total idiot and there was a much easier way to do it. So yes, I’ll just use a websocket and cancel the Limit order like you said.

Thanks so much, really appreciate it! :slight_smile:

1 Like