
Okx Cex Bot
Operate OKX Grid and DCA Martingale bots from an agent via the okx CLI—create, tune, and watch P&L without hand-writing exchange API calls.
Overview
okx-cex-bot is an agent skill for the Operate phase that manages OKX Grid and DCA Martingale bots (create, amend, TP/SL, margin, and P&L monitoring) through the okx CLI after OAuth setup.
Install
npx skills add https://github.com/okx/agent-skills --skill okx-cex-botWhat is this skill?
- Manages native OKX server-side Grid bots (spot, contract, and coin-margined) and DCA Martingale bots (Spot DCA and Contr
- Full lifecycle: create, stop, amend, TP/SL, margin and investment adjustment, and AI-recommended parameters
- Authenticated commands via @okx_ai/okx-trade-cli with session preflight and credential checks before every call
- Explicitly scoped away from regular orders (okx-cex-trade), raw market data (okx-cex-market), and portfolio-only flows (
- Security-first setup: guide users to okx config init OAuth—never accept API secrets in chat
- Skill metadata version 1.3.2
- npm package @okx_ai/okx-trade-cli@1.3.2
- Covers Grid (spot, contract, coin-margined) and two DCA Martingale variants (Spot DCA, Contract DCA)
Adoption & trust: 6.8k installs on skills.sh; 134 GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You want grid or martingale automation on OKX but juggling bot APIs, margin tweaks, and P&L checks from chat is error-prone without a guided CLI workflow.
Who is it for?
Solo builders or indie traders who already use OKX, have run okx config init, and need agent-driven control of Grid or DCA bots—not discretionary spot tickets.
Skip if: Placing regular CEX orders, fetching market data only, or portfolio snapshots without bot management—use okx-cex-trade, okx-cex-market, or okx-cex-portfolio instead.
When should I use this skill?
You need to create, stop, amend, or monitor OKX Grid or DCA Martingale bots (not regular orders, market data, or portfolio-only queries).
What do I get? / Deliverables
Your agent runs documented okx CLI commands to configure, adjust, and monitor OKX bots with verified credentials and clear separation from manual trade or market-data skills.
- Executed okx CLI bot commands (create, stop, amend)
- Updated TP/SL, margin, or investment settings on active bots
- P&L and status summaries from bot monitoring commands
Recommended Skills
Journey fit
The skill is for live, server-side OKX bots after setup: start/stop, amend grids, adjust margin, and monitor TP/SL and P&L—classic production trading operations, not ideation or product build. Monitoring is the canonical shelf because the documented workflow centers on ongoing bot health, profit/loss visibility, and parameter changes while strategies run on OKX.
How it compares
Use this skill package for OKX bot lifecycle management via CLI, not as a general MCP market-data server or a one-shot order placement helper.
Common Questions / FAQ
Who is okx-cex-bot for?
It is for solo and indie builders who automate OKX Grid or DCA Martingale strategies and want their coding agent to run the official okx trade CLI with consistent preflight and auth checks.
When should I use okx-cex-bot?
Use it in Operate when you need to create, stop, or amend Grid or DCA bots, set TP/SL, change margin or investment, or review bot P&L on OKX—after CLI install and OAuth, not for simple spot orders or quote-only research.
Is okx-cex-bot safe to install?
The skill follows MIT licensing and directs users to browser OAuth via okx config init rather than pasting secrets in chat; review the Security Audits panel on this Prism page and treat live trading bots as high-risk financial automation.
SKILL.md
READMESKILL.md - Okx Cex Bot
# OKX CEX Bot Trading Grid and DCA (Spot & Contract Martingale) bot management on OKX. All bots are **native OKX server-side** — they run on OKX and do not require a local process. ## 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 ```bash npm install -g @okx_ai/okx-trade-cli okx config init # select site -> follow browser OAuth flow ``` > **Security**: NEVER accept credentials in chat. Guide users to `okx config init` for setup. ## Credential & Profile Check **Run before every 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, load `okx-cex-auth` skill and follow login steps, wait for completion. ### Step B — Confirm trading mode Resolution: 1. User intent is clear ("real"/"实盘"/"live" → live; "test"/"模拟"/"demo" → demo) → use it, inform user 2. No explicit declaration → check conversation context for previous choice → reuse if found 3. Nothing found → ask: "Live (实盘) or Demo (模拟盘)?" — wait before proceeding **How to apply the mode depends on auth method (detected in Step A):** | Auth method | Live (实盘) | Demo (模拟盘) | |---|---|---| | **API Key** | `--profile <live-profile>` | `--profile <demo-profile>` | | **OAuth** | *(no flag needed, live is default)* | `--demo` | - **API Key users**: run `okx config show --json` to discover available profile names and their `demo` settings. - **OAuth users**: omit flags for live; add `--demo` for simulated trading. **After every command**: append `[mode: live]` or `[mode: demo]` ### Handling 401 Errors **Authentication error** (error contains "401", "Session expired", or "Run `okx auth login` first"): 1. Stop immediately 2. Load `okx-cex-auth` skill and follow re-authentication steps 3. Retry original command ## Skill Routing | Need | Skill | |---|---| | Market data, prices, depth | `okx-cex-market` | | Account balance, positions, fees | `okx-cex-portfolio` | | Regular spot/swap/futures orders | `okx-cex-trade` | | **Grid / DCA bots** | **`okx-cex-bot` (this skill)** | ## Command Index ### Grid Bot | Command | Type | Description | |---|---|---| | `okx bot grid create` | WRITE | Create a grid bot (spot or contract) | | `okx bot grid amend` | WRITE | Amend pric