Skip to main content
Closing a position is performed over WebSocket.
This command instructs the engine to place a LIMIT IOC order on the opposite side of your current position, pegged near the mark price to maximise the chance of a complete close-out.
The engine automatically sizes the order to match your open position, so you always close in full.
  • Endpoint: wss://trade.qfex.com?api_key=YOUR_API_KEY
  • Authenticate within 1 minute of connecting.

1) Authenticate

Send this immediately after you connect:

2) Close a Position

Parameters

⚠️ Notes:
  • The generated order is always LIMIT + IOC, reduce-only, and inherits the appropriate closing side.
  • Subscribe to fills to receive executions.
  • Subscribe to order_responses to receive final status updates.

Sample Code

Example Responses

You will receive an order_response acknowledgement immediately, followed by fill updates (if any).
Any unfilled remainder is cancelled automatically because the engine always uses IOC. If you have no open position for the symbol, the command is rejected.