QFEX provides a 50ms pulsed stream of the order book up to 20 levels deep via websocket.

How it works

Connect to the public websocket:
  • URL: wss://mds.qfex.com
Then send a subscribe message:
{"type": "subscribe", "channels": ["level2"], "symbols": ["AAPL-USD","SP500-USD"]}
You can also use a wildcard to subscribe to all symbols:
{"type": "subscribe", "channels": ["level2"], "symbols": ["*"]}

Sample Code

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

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

def on_message(ws, message):
    data = json.loads(message)
    print("OrderBook 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": "level2",
  "symbol": "AAPL-USD",
  "bid": [
    ["10101.10", "0.45054140"],
    ["10101.00", "0.55054140"]
  ],
  "ask": [
    ["10102.55", "0.57753524"],
    ["10102.65", "0.57753524"]
  ],
  "sequence": 30272539,
  "time": "2025-09-04T09:26:39.545268322Z"
}

Unsubscribe (optional)

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

Notes
  • Pulsed at 50ms intervals.
  • Depth: up to 20 levels.
  • symbols accepts a wildcard * to stream all symbols.