
Okx Cex Trade
Execute and manage OKX CEX spot, swap, futures, options, and event-contract orders from the agent via the official okx CLI with API credentials.
Overview
okx-cex-trade is an agent skill for the Build phase that places, cancels, and amends OKX spot, derivatives, options, and event-contract orders through the okx trade CLI using API credentials.
Install
npx skills add https://github.com/okx/agent-skills --skill okx-cex-tradeWhat is this skill?
- Spot, perpetual swap, delivery futures, options, and event contract order flows
- Conditional algos: TP/SL, trailing stop, pending, chase, iceberg, TWAP, and split large orders
- Options: chains, implied volatility, and Greeks (delta, gamma) in trading context
- Requires `okx` CLI from `@okx_ai/okx-trade-cli@1.3.3` and OKX API credentials
- Explicitly excludes market data (okx-cex-market), balances (okx-cex-portfolio), and bots (okx-cex-bot)
- Skill metadata version 1.3.3
- CLI package @okx_ai/okx-trade-cli@1.3.3
Adoption & trust: 7.1k installs on skills.sh; 134 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You want your coding agent to execute OKX trades from chat without hand-writing REST payloads for every order type and algo variant.
Who is it for?
Indie builders with OKX API keys who script or agent-drive execution for spot, perps, options, or event markets.
Skip if: Price-only research (use okx-cex-market), read-only portfolio checks (use okx-cex-portfolio), unattended bot strategies (use okx-cex-bot), or users without API credentials.
When should I use this skill?
User asks to buy/sell, place or amend orders, manage perp/options/event positions, or set TP/SL/trailing/TWAP-style algos on OKX CEX (not market data, portfolio, or bots).
What do I get? / Deliverables
Orders and conditional algos run through the okx CLI with parameters matching your intent, while data and balance tasks stay on the correct sibling skills.
- Executed, cancelled, or amended OKX orders via CLI
- Algo and position instructions applied per user parameters
Recommended Skills
Journey fit
Trading automation is built as an integration against OKX’s APIs and CLI—canonical on Build → integrations before you rely on it in production routines. Covers order placement, amendments, algos, and position tools—not portfolio read-only views or market-data-only queries.
How it compares
Trade-execution skill package tied to OKX’s CLI—not a backtesting framework or paper-trading simulator.
Common Questions / FAQ
Who is okx-cex-trade for?
Solo developers building trading agents or CLI assistants that must submit real OKX CEX orders with proper credentials.
When should I use okx-cex-trade?
During Build while wiring agent trading flows—e.g. limit buy BTC, short ETH perp, set trailing stop, buy event-contract Yes—when execution must hit OKX rather than fetch quotes.
Is okx-cex-trade safe to install?
It requires trading API secrets and can move funds; use least-privilege keys, test on small size, and review the Security Audits panel on this page before trusting automation.
SKILL.md
READMESKILL.md - Okx Cex Trade
# OKX CEX Trading CLI Spot, perpetual swap, delivery futures, **options**, and **event contract** order management on OKX exchange. Place, cancel, amend, and monitor orders; query option chains and Greeks; trade binary outcome event contracts (Yes/No, Up/Down); set take-profit/stop-loss and trailing stops; manage leverage and positions. **Requires API credentials.** > **CLI vs MCP tool names** — Subcommands use spaces (`okx swap algo place`, `okx bot grid create`), not hyphens. Do NOT convert an MCP tool identifier (`swap_place_algo_order`) into a hyphen-joined CLI command (`okx swap place-algo`) — that will be rejected with "Unknown command". Per-module mapping tables live in `references/<module>-commands.md`. ## Preflight Before running any command, follow [`../_shared/preflight.md`](../_shared/preflight.md). Use `metadata.version` from this file's frontmatter as the reference for Step 2. ## Prerequisites 1. Install `okx` CLI: ```bash npm install -g @okx_ai/okx-trade-cli ``` 2. Configure credentials: ```bash okx config init # select site -> follow browser OAuth flow ``` 3. Test with demo mode (simulated trading, no real funds): ```bash okx --demo spot orders ``` > **Security**: NEVER accept credentials in chat. Guide users to `okx config init` for setup. ## Credential & Profile Check **Run this check before any authenticated command.** The auth method is detected during [preflight](../_shared/preflight.md) Step 2 and remembered for the session. ### Step A — Verify credentials Run **both** commands — the `apiKey` field from `okx auth status --json` is the auth-binary's internal state and is always `false` regardless of whether `~/.okx/config.toml` has an API-key profile. `okx config show --json` is the only authoritative source for API-key presence. ```bash okx config show --json # reveals API-key profiles (TOML config) okx auth status --json # reveals OAuth session state (auth-binary state) ``` Apply **in this order** — first match wins: - `config show --json` has any profile with a non-empty `api_key` field → **API Key mode**. Proceed to Step B. - No API-key profile **AND** `auth status --json` returns `"status":"logged_in"` → **OAuth mode**. Proceed to Step B. - No API-key profile **AND** `"status":"pending"` — login is in progress, wait for it to complete. - No API-key profile **AND** `"status":"not_logged_in"` — **stop all operations**, load `okx-cex-auth` skill and follow login steps, wait for completion. ### Step B — Confirm trading mode **Resolution rules:** 1. Current message intent is clear (e.g. "real" / "实盘" / "live" → live; "test" / "模拟" / "demo" → demo) → use it and inform the user 2. Curre