How to close an open position in futures?

Q: I’m using futures and I would like to close my open position(s) for symbol BTCUSDT perpetual. How to do it?

Generally speaking, you close a position by creating a new order with the opposite direction and with the same quantity as your open position. To be more specific, if you’re in:

:point_right: ONE WAY MODE (positionSide = BOTH):

Create Long position:

POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=BUY&positionSide=BOTH&type=MARKET&quantity=0.5&timestamp=xxx&signature=xxx

To close position, you do:

POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=SELL&positionSide=BOTH&type=MARKET&quantity=0.5&timestamp=xxx&signature=xxx

Note:

  • In this example I’ve created a Long direction position, but could’ve started with Short direction too.

:point_right: HEDGE WAY MODE (positionSide = LONG or SHORT):

Create Long position:

POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=BUY&positionSide=LONG&type=MARKET&quantity=0.5&timestamp=xxx&signature=xxx

To close the Long position, you do:

POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=SELL&positionSide=LONG&type=MARKET&quantity=0.5&timestamp=xxx&signature=xxx

Note:

  • In this example I’ve created a Long direction position, but could’ve started with Short direction too.
  • You might have both Long and Short position open, which you’ll need to send 2 new orders to cancel one at a time, can’t be done with one request.

:point_right: ONE WAY MODE and Order type = STOP_MARKET or TAKE_PROFIT_MARKET.

Close position by sending closePosition=true, which will automatically create a MARKET order with open order’s quantity for when the stopPrice is triggered:

POST https://testnet.binancefuture.com/fapi/v1/order?symbol=BTCUSDT&side=SELL&positionSide=BOTH&type=TAKE_PROFIT_MARKET&stopPrice=39793&closePosition=true&timestamp=xxx&signature=xxx

Note: Same logic applies for HEDGE WAY MODE.