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:
ONE WAY MODE (positionSide = BOTH):
Create Long position:
To close position, you do:
Note:
- In this example I’ve created a Long direction position, but could’ve started with Short direction too.
HEDGE WAY MODE (positionSide = LONG or SHORT):
Create Long position:
To close the Long position, you do:
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.
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:
Note: Same logic applies for HEDGE WAY MODE.
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.
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