> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qfex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 价格上下限

订阅交易品种的实时最低和最高允许价格更新。

## 使用方式

连接公开 WebSocket：

* URL：`wss://mds.qfex.com`。

然后发送订阅消息：

```json theme={null}
{
  "type": "subscribe",
  "channels": ["minmax_price"],
  "symbols": ["AAPL-USD"]
}
```

## 示例代码

```python python theme={null}
# Python (websocket-client)
import json
import websocket

def on_open(ws):
    sub = {
        "type": "subscribe",
        "channels": ["minmax_price"],
        "symbols": ["AAPL-USD"]
    }
    ws.send(json.dumps(sub))

def on_message(ws, message):
    print("Update:", message)

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

```javascript node theme={null}
// Node.js (ws)
import WebSocket from "ws";

const ws = new WebSocket("wss://mds.qfex.com");

ws.on("open", () => {
  const sub = {
    type: "subscribe",
    channels: ["minmax_price"],
    symbols: ["AAPL-USD"]
  };
  ws.send(JSON.stringify(sub));
});

ws.on("message", (msg) => {
  console.log("Update:", msg.toString());
});
```

## 响应示例

```json theme={null}
{
  "type": "minmax_price",
  "symbol": "AAPL-USD",
  "min_price": "400.00",
  "max_price": "450.00",
  "time": "2025-05-08T20:52:48.000Z"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.