Skip to content

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.

  1. Log in to OKX
  2. Account & SecurityAPICreate V5 API Key
  3. Permissions: Trade (and Read)
  4. Set a passphrase — store it; you'll enter it alongside the key/secret
  5. IP whitelist the host running the bot
  6. 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.

tradectl — Automate Crypto Trading