// Go (gorilla/websocket)
// go get github.com/gorilla/websocket
package main
import (
"log"
"github.com/gorilla/websocket"
)
func mustWriteJSON(c *websocket.Conn, v any) {
if err := c.WriteJSON(v); err != nil {
log.Fatal("write:", err)
}
}
func main() {
c, _, err := websocket.DefaultDialer.Dial("wss://trade.qfex.com?api_key=YOUR_API_KEY", nil)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()
// 1) Authenticate
mustWriteJSON(c, map[string]any{
"type": "auth",
"params": map[string]any{"hmac": map[string]any{"public_key": "qfex_pub_xxxxx", "nonce": "c0ffee...", "unix_ts": 1760545414, "signature": "5f2e..."}}
})
// 2a) Cancel by order_id (exactly one order)
mustWriteJSON(c, map[string]any{
"type": "cancel_order",
"params": map[string]any{
"order_id": "REPLACE_WITH_ORDER_UUID_V4",
"symbol": "AAPL-USD",
"cancel_order_id_type": "order_id",
},
})
// 2b) Cancel by client_order_id (may cancel multiple)
// mustWriteJSON(c, map[string]any{
// "type": "cancel_order",
// "params": map[string]any{
// "client_order_id": "my-client-oid-123",
// "symbol": "AAPL-USD",
// "cancel_order_id_type": "client_order_id",
// },
// })
}