Subscribe to the order_responses channel to receive order responses.
Messages are pushed every 1 second.
1) Authenticate
Send this immediately after connecting to wss://trade.qfex.com?api_key=YOUR_API_KEY:
{ "type": "auth", "params": { "api_key": "YOUR_API_KEY" } }
2) Subscribe
{ "type": "subscribe", "params": { "channels": ["order_responses"] } }
Sample Code
# Python (websocket-client)
# pip install websocket-client
import json, websocket
API_KEY = "YOUR_API_KEY"
def send(ws, obj): ws.send(json.dumps(obj))
def on_open(ws):
# 1) Authenticate
send(ws, {"type": "auth", "params": {"api_key": API_KEY}})
# 2) Subscribe to order responses
send(ws, {"type": "subscribe", "params": {"channels": ["order_responses"]}})
ws = websocket.WebSocketApp(
"wss://trade.qfex.com?api_key=YOUR_API_KEY",
on_open=on_open,
on_message=lambda _, m: print("Message:", m),
on_error=lambda _, e: print("Error:", e),
on_close=lambda *_: print("Closed"),
)
ws.run_forever()
Example Responses
{ "subscribed": "order_responses" }
{
"order_response": {
"order_id": "5b309929-206f-40ec-804d-cbe46e81afc1",
"symbol": "AAPL-USD",
"status": "ACK",
"quantity": 1.0,
"price": 200.0,
"take_profit": 0.0,
"stop_loss": 0.0,
"side": "BUY",
"type": "LIMIT",
"time_in_force": "GTC",
"user_id": "0020ce8e-eaee-480e-8d7f-b9241d756ee5",
"client_order_id": "",
"quantity_remaining": 1.0,
"trade_id": null
}
}
Order responses are live.