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 position’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.

1 Like

How can I close the position if I created it with type=LIMIT when I try to close it by creating an order of opposite direction?

So can I close an open order by sending closePosition=true?

The closePosition is only used with STOP_MARKET or `TAKE_PROFIT_MARKET, if the instructions are unclear, you can use the Futures Testnet to test around position closing options.

1 Like

How do I know the quantity ? is there any code to know the quantity to open opposite order to close position

if you already open position you call “GET /fapi/v2/positionRisk” and get positionAmt

https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data