OKX
tradectl supports OKX perpetual swaps (USDT-margined) via OKX's V5 API.
Supported features
- Real-time ticker, public trade, and L2 depth WebSocket streams
- Market and limit orders
- TP (limit) and SL (stop-market) exits
- Leverage configuration; isolated and cross margin
- Portfolio margin mode (single-currency or multi-currency)
- User-data WebSocket for fills
API key setup
OKX requires three credentials: API key, secret, and passphrase.
- Log in to OKX
- Account & Security → API → Create V5 API Key
- Permissions: Trade (and Read)
- Set a passphrase — store it; you'll enter it alongside the key/secret
- IP whitelist the host running the bot
- Do not enable withdrawals
Configuration
json
{
"api": {
"provider": "OKX",
"key": "...",
"secret": "...",
"passphrase": "..."
},
"strats": [{
"name": "btc-perp",
"type": "shot",
"marketType": "LINEAR",
"isEmulator": false,
"pairs": ["BTC-USDT-SWAP", "ETH-USDT-SWAP"],
"leverage": 10
}]
}OKX uses dash-delimited symbols with a -SWAP suffix for perpetuals (e.g., BTC-USDT-SWAP).
Testnet (demo trading)
OKX provides a paper-trading "demo" environment with separate API keys. Generate them under Demo Trading → API, then mark the credentials as Testnet in tradectl.
