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.
You can set the leverage level for each symbol for your account.
You cannot change the leverage level if you have any open orders or a non zero
position.
Leverage management is performed over WebSocket.
- Endpoint:
wss://trade.qfex.com?api_key=YOUR_API_KEY
- Authenticate within 1 minute of connecting.
Example Request
{
"type": "set_user_leverage",
"params": {
"symbol": "AAPL-USD",
"leverage": 20.0
}
}
symbol — the symbol to set the leverage for
leverage — the leverage level to set
Sample Code
# Python (websocket-client)
import json, websocket
API_KEY = "YOUR_API_KEY"
def send(ws, obj): ws.send(json.dumps(obj))
def on_open(ws):
# Authenticate
# https://docs.qfex.com/websocket/channels/trade/authenticate#how-it-works
send(ws, {"type": "auth", "params": { "hmac": { "public_key": "qfex_pub_xxxxx", "nonce": "c0ffee...", "unix_ts": 1760545414, "signature": "5f2e..." }}})
# Set leverage
send(ws, {"type": "set_user_leverage", "params": {"symbol": "AAPL-USD", "leverage": 20.0}})
ws = websocket.WebSocketApp(
"wss://trade.qfex.com?api_key=YOUR_API_KEY",
on_open=on_open,
on_message=lambda _, m: print("Message:", m)
)
ws.run_forever()
Example Response