QFEX provides a realtime stream of executed trades across all symbols via websocket.

How it works

Connect to the public websocket:
  • URL: wss://mds.qfex.com
Then send a subscribe message:
{"type": "subscribe", "channels": ["trade"], "symbols": ["AAPL-USD","SP500-USD"]}

Sample Code

# Python (websocket-client)
# pip install websocket-client
import json
import websocket

def on_open(ws):
    sub = {
        "type": "subscribe",
        "channels": ["trade"],
        "symbols": ["SP500-USD"]  # or ["*"]
    }
    ws.send(json.dumps(sub))

def on_message(ws, message):
    data = json.loads(message)
    print("Trade update:", json.dumps(data, indent=2))

def on_error(ws, error):
    print("Error:", error)

def on_close(ws, close_status_code, close_msg):
    print("Closed:", close_status_code, close_msg)

if __name__ == "__main__":
    ws = websocket.WebSocketApp(
        "wss://mds.qfex.com",
        on_open=on_open,
        on_message=on_message,
        on_error=on_error,
        on_close=on_close,
    )
    ws.run_forever()

Example Response

{
  "type": "trade",
  "trade_id": "ac928c66-ca53-498f-9c13-a110027a60e8",
  "sequence": 50,
  "time": "2014-11-07T08:19:27.028459Z",
  "symbol": "AAPL-USD",
  "size": "5.23512",
  "price": "400.23",
  "side": "sell"
}

Unsubscribe (optional)

{"type":"unsubscribe","channels":["trade"],"symbols":["SP500-USD"]}

Notes
  • Messages are pushed in realtime as trades occur.
  • Supports multiple symbols or a wildcard *.
  • Fields mirror REST and gRPC trade objects.