Skip to main content
Stop Orders can be cancelled over WebSocket.
  • You must specify the stop_order’s stop_order_id (UUID v4).

1) Authenticate

Send this immediately after you connect:
{ "type": "auth", "params": { "api_key": "YOUR_API_KEY" } }

2) Cancel Order

{
  "type": "cancel_stop_order",
  "params": {
    "stop_order_id": "510333ac-3f7b-4d88-934a-4396d48824cc"
  }
}

Parameters

FieldTypeRequiredDescription
stop_order_idstringUUID v4 of the stop order to cancel.

Sample Code

# Python (websocket-client)
import json, websocket

API_KEY = "YOUR_API_KEY"

def send(ws, obj): ws.send(json.dumps(obj))

def on_open(ws):
    # Authenticate
    send(ws, {"type": "auth", "params": {"api_key": API_KEY}})
    # Cancel stop order
    send(ws, {
        "type": "cancel_stop_order",
        "params": {
            "stop_order_id": "510333ac-3f7b-4d88-934a-4396d48824cc"
        }
    })

ws = websocket.WebSocketApp(
    "wss://trade.qfex.com?api_key=YOUR_API_KEY",
    on_open=on_open,
    on_message=lambda _, m: print("Message:", m)
)
ws.run_forever()

Example Response

When a stop order is successfully cancelled, you receive an order_response with status CANCELLED:
{
  "order_response": {
    "order_id": "510333ac-3f7b-4d88-934a-4396d48824cc",
    "symbol": "AAPL-USD",
    "status": "CANCELLED",
    "quantity": 0.0,
    "price": 200.0,
    "side": "BUY",
    "type": "TAKE_PROFIT",
    "time_in_force": "GTC",
    "user_id": "0020ce8e-eaee-480e-8d7f-b9241d756ee5",
    "client_order_id": "",
    "quantity_remaining": 0.0
  }
}