Manages OKX server-side trading bots: Grid, DCA Martingale, Smart Portfolio (auto-rebalancing), and Recurring Buy strategies. Covers create, stop, pause, amend, P&L monitoring, TP/SL, margin adjustment, AI parameters, and backtesting. Requires API credentials.
Ships in okx-agent-trade-kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Grid, DCA (Spot & Contract Martingale), Smart Portfolio and Recurring Buy (定投) management on OKX. All bots are native OKX server-side — they run on OKX and do not require a local process.
Before running any command, follow ../_shared/preflight.md.
Use metadata.version from this file's frontmatter as the reference for Step 2.
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 initfor setup.
Run before every authenticated command. The auth method is detected during preflight Step 2 and remembered for the session.
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.
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.auth status --json returns "status":"logged_in" → OAuth mode. Proceed to Step B."status":"pending" — login is in progress, wait for it to complete."status":"not_logged_in" — stop, load okx-cex-auth skill and follow login steps, wait for completion.Resolution:
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 |
okx config show --json to discover available profile names and their demo settings.--demo for simulated trading.After every command: append [mode: live] or [mode: demo]
Authentication error (error contains "401", "Session expired", or "Run okx auth login first"):
okx-cex-auth skill and follow re-authentication steps| 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 / Smart Portfolio / Recurring Buy bots | okx-cex-bot (this skill) |
| Command | Type | Description |
|---|---|---|
okx bot grid create | WRITE | Create a grid bot (spot or contract) |
okx bot grid amend | WRITE | Amend price range, grid count, or TP/SL of a running grid bot |
okx bot grid stop | WRITE | Stop a grid bot |
okx bot grid positions | READ | Query open contract-grid positions (liquidation price, margin ratio, unrealized PnL) |
okx bot grid liquidate-price | READ | Estimate liquidation price for a contract-grid bot |
okx bot grid close-position | WRITE | Close remaining position after bot stopped with stopType=2 |
okx bot grid orders | READ | List active or history grid bots |
okx bot grid details | READ | Grid bot details + PnL |
okx bot grid sub-orders | READ | Individual grid fills or pending orders |
| Command | Type | Description |
|---|---|---|
okx bot dca create | WRITE | Create a DCA (Martingale) bot (spot or contract) |
okx bot dca stop | WRITE | Stop a DCA bot (spot or contract) |
okx bot dca orders | READ | List active or history DCA bots (default: contract_dca) |
okx bot dca positions | READ | DCA bot position info (avgPx, upl, liqPx, ...) |
okx bot dca details | READ | Deprecated - use okx bot dca positions (same endpoint) |
okx bot dca sub-orders | READ | DCA cycles and orders within a cycle |
okx bot dca add-margin | WRITE | Add margin to a running contract DCA bot |
okx bot dca reduce-margin | WRITE | Reduce margin on a running contract DCA bot |
okx bot dca update-tp | WRITE | Update take-profit price on a running contract DCA bot |
Note: Load with
--modules bot.smartportfolioorbot.all(not in default modules).
| Command | Type | Description |
|---|---|---|
okx bot smart-portfolio create | WRITE | Create a Smart Portfolio bot (2–10 assets, ratios summing to exactly 1, deltaRatio threshold) |
okx bot smart-portfolio stop | WRITE | Stop a running Smart Portfolio bot |
okx bot smart-portfolio orders | READ | List Smart Portfolio bots (default: running; add --history for stopped) |
okx bot smart-portfolio details | READ | Get Smart Portfolio bot details and current allocation |
okx bot smart-portfolio amend-rebalance | WRITE | Update rebalance threshold and interval (both --deltaRatio and --interval required) |
okx bot smart-portfolio instant-rebalance | WRITE | Trigger an immediate rebalance (triggered ≠ trades executed) |
okx bot smart-portfolio manual-pause | WRITE | Pause automatic rebalancing (bot keeps running, nothing is sold) |
okx bot smart-portfolio manual-resume | WRITE | Lift the manual pause and trigger a rebalance check |
okx bot smart-portfolio add-investment | WRITE | Add funds, target coins and weights unchanged (real funds; trading-account balance pre-check) |
okx bot smart-portfolio edit-portfolio | WRITE | Replace the COMPLETE target coins and weights, optionally with a top-up (takes effect immediately) |
okx bot smart-portfolio recommend-zones | READ | Browse OKX-recommended portfolio zone configurations |
okx bot smart-portfolio zones-backtest | READ | Get historical backtest results for a recommended zone |
Note: CLI-only (
okx bot recurring ...); no--modulesflag is needed.
| Command | Type | Description |
|---|---|---|
okx bot recurring create | WRITE | Create a Recurring Buy strategy (coins + ratios, period, time, amount per cycle, --tdMode required) |
okx bot recurring orders | READ | List strategies (default: running/paused; add --history for stopped) |
okx bot recurring details | READ | Strategy details with per-coin holdings, average price and PnL |
okx bot recurring sub-orders | READ | Buy orders executed by a strategy |
okx bot recurring pause | WRITE | Pause a strategy |
okx bot recurring restart | WRITE | Restart a paused strategy |
okx bot recurring stop | WRITE | Stop a strategy (permanent) |
okx bot recurring amend-name | WRITE | Rename a strategy |
okx bot recurring amend-price-range | WRITE | Change the per-coin buy price range |
okx bot recurring amend-amount | WRITE | Change the amount invested per cycle |
okx bot recurring amend-time | WRITE | Change period/day/time/time zone |
okx bot recurring add-investment | WRITE | Add an extra one-off investment |
Parse user request → determine module (Grid / DCA / Smart Portfolio / Recurring Buy) and action (create / stop / list / details).
DCA and Recurring Buy are different products — route by the user's wording:
okx bot dca (the Martingale bot with safety orders).okx bot recurring; name "Recurring Buy / 定投" in the confirmation summary.READ commands (orders, details, sub-orders): run immediately after profile confirmation.
WRITE commands (create, amend, stop; for Recurring Buy also pause, restart, add-investment; for Smart Portfolio also manual-pause, manual-resume, add-investment, edit-portfolio): confirm key parameters with user once before executing.
Write-operation checklist — Smart Portfolio operations (details and wording: {baseDir}/references/smart-portfolio-commands.md):
algoId from the user, otherwise smart-portfolio orders and let the user pick; never guess. Read details --json (state, portfolioList, tradeQuoteCcy, quote, total investment) before any write.add-investment, and edit-portfolio with --addInvest: check the trading-account available balance of the strategy currency (okx account balance <ccy> --json, availBal). Never use the funding account (asset-balance), balance-all totals or valuations; never transfer funds for the user. Insufficient or unknown balance is a risk to state in the summary ("the transfer may fail"), not a block: the user may still confirm.Write-operation confirmation checklist — Recurring Buy:
recurring create: confirm coins and ratios, period + day/hour + time + --timeZone, --amt, --investmentCcy and --tdMode. Run okx account config first, read acctLv and follow {baseDir}/references/recurring-commands.md: 1 → cash; 2 → ask the user cash (spot) or cross (real leverage — state the risk), cash if no preference; 3 and 4 → cross only (executed as spot), never cash (on 4 the server answers success but does not trade). State the choice in the summary, never guess acctLv (ask if unreadable or not 1–4), and always pass --tdMode.recurring pause / restart: confirm algoId and the strategy name, and read details first (pause needs state running, restart needs pause; otherwise tell the user instead of running it). Say that pause stops scheduled purchases and restart resumes them (do not say whether cycles missed while paused are bought later), and wait for an explicit yes. Afterwards check details (nextInvestTime) — (OK) is not proof.recurring stop / add-investment: real money and irreversible — confirm algoId (from recurring orders) and, for add-investment, the amount; before add-investment note investmentAmt from details and the newest sub-orders entry.recurring amend-*: confirm algoId and the new values; negative time zones use --timeZone=-5. amend-time --recurringTimeType 2 (and create --recurringTimeType 2) buys immediately and is not idempotent — say so, get an explicit yes, then check sub-orders and details.orders command to confirm activedetails --algoId <id> to confirm updated config (Recurring Buy amend-time type 2: also recurring sub-orders)orders --history to confirm stoppedsmart-portfolio orders --history to confirm stoppedsmart-portfolio details --algoId <id> --json once and report what it shows. The write response only means the request was accepted: it is not proof of a new state, of funds having arrived, or of any trade. Do not poll repeatedly and do not quote fields that do not exist (no cumulative top-up total, no per-top-up status)recurring orders --history to confirm stopped; after pause/restart/amend → run recurring details --algoId <id>recurring sub-orders --algoId <id> for the new buy order (normally ordType manual_add_order) and compare investmentAmt in details with the value read before (if it did not rise, rely on sub-orders; (OK) alone is not proof)create that fails with "returned no algoId" — the write may still have happened, and the lists can lag, so finding nothing is not proof either. Do not act on a "retry later" hint. Check (orders and --history for create; sub-orders and details for add-investment and amend-time --recurringTimeType 2; details otherwise), wait a moment and check once more, tell the user what you found, and re-run only after they explicitly ask or agree. For create, add-investment and amend-time --recurringTimeType 2, warn that a retry may duplicate the strategy or buy again.add-investment, edit-portfolio, manual-pause, manual-resume). After a timeout, dropped connection, 5xx or rate-limit error, the write may or may not have happened: check details (and the trading-account balance for a top-up), tell the user what you found, and re-run only if they explicitly ask. Never swap the currency or amount to "make it work"; explain backend errors instead (see the error table in {baseDir}/references/smart-portfolio-commands.md).algoId is the bot's algo order ID (from create or list output). It is NOT a normal ordId. Never fabricate — always obtain from a prior command.algoOrdType for grid must match the bot's actual type. Always use the value from bot grid orders — do not infer from user description alone. Mismatch causes error 50016.tpTriggerPx/tpRatio and slTriggerPx/slRatio are mutually exclusive pairs.For Grid Bot command syntax, parameter tables, Quickstart examples, and edge cases,
read {baseDir}/references/grid-commands.md.
For DCA Bot command syntax, parameter tables, Quickstart examples, and edge cases,
read {baseDir}/references/dca-commands.md.
For Smart Portfolio Bot command syntax, parameter tables, and examples,
read {baseDir}/references/smart-portfolio-commands.md.
For Recurring Buy command syntax, the acctLv → tdMode selection rule, parameter tables, and edge cases,
read {baseDir}/references/recurring-commands.md.
For cross-skill workflow examples (chaining okx-cex-market/okx-cex-portfolio with bot
creation), read {baseDir}/references/workflows.md.
{base}and{quote}: extract frominstIdby splitting on-. E.g.,BTC-USDT-SWAP→ base=BTC, quote=USDT.
--json returns the raw OKX API v5 response by default. Add --env to wrap the output as {"env": "<live|demo>", "profile": "<name>", "data": <response>}--gridNum range: 2–100What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
okx, cex, grid-bot, dca, martingale, smart-portfolio, recurring-buy, trading-bot
10 skills in this plugin
/earn-hunterAutomatically monitors OKX Flash Earn, Fixed Earn and Flexible Earn opportunities, sends push notifications, and guides subscription. 自动监控 OKX 闪赚、定期和活期赚币机会,推送通知并引导申购。Use when user says: 有闪赚通知我, 监控赚币, monitor earn, notify me about earn, 定时检查理财, 执行 earn-hunter 扫描, earn-hunter scan, 活期年化高了通知我, 监控活期./okx-cex-authUse this skill when the user wants to 'login/log in/sign in', 'authenticate', 'authorize', 'connect OKX account', 'set up credentials', 'first time setup', 'configure okx', '登录', '授权', '认证', '连接账户', '首次配置'. Also when any OKX CLI command fails with an auth error: 'Run okx auth login first', 'Session expired', 'not authenticated', 'requires_auth', '401 Unauthorized', 'token expired/not found', 'StorageNotFoundError', '会话过期', '未认证', '需要登录'. Also when the user asks about login status or the login was interrupted. Also when the user wants to install/update/check/remove the okx-auth binary — 'install/update/remove auth', 'download okx-auth', '安装/更新/卸载认证', 'auth binary status', 'Failed to spawn okx-auth'. Also use before using okx-cex-trade/portfolio/earn/bot for the first time. Do NOT use for market data queries (use okx-cex-market)./okx-cex-earnManages OKX Simple Earn (flexible savings/lending), Flash Earn, On-chain Earn (staking/DeFi), Dual Investment (DCD/双币赢), and AutoEarn (自动赚币) via the okx CLI. Use this skill whenever the user wants to check earn balances, browse flash-earn projects, subscribe or redeem earn products, view or set lending rates, monitor on-chain staking orders, interact with dual investment structured products, or manage auto-earn — even if phrased casually as 活期赚币, 定期赚币, 闪赚, 赚币, 申购, 赎回, 链上赚币, 质押, 理财, 双币赢, 双币理财, 双币申购, 高卖, 低买, dual investment, DCD, flash earn, buy low, sell high structured product, earn with target price, 目标价, 自动赚币, auto earn, auto-earn, 自动借出, 自动质押, auto lend, auto staking, USDG earn, USDG 赚币, 闲置资金自动理财, fixed earn, fixed deposit, term deposit, 定期理财, 定期. Also use when the user asks about idle funds and whether to earn on them./okx-cex-marketUse this skill when the user asks for: price of any asset, ticker, order book, candles, OHLCV, funding rate, open interest, OI change scanner, market screener (top movers, high-volume, newly listed), mark price, index price, recent trades, instrument list, stock tokens, metals prices (gold, XAU, XAG), commodities (oil, OIL), forex rates (EUR/USD, EURUSDT), bond instruments, non-crypto assets, or any technical indicator query (RSI, MACD, EMA, Bollinger Bands, KDJ, SuperTrend, AHR999, BTC rainbow, and 70+ more). All commands are read-only and do NOT require API credentials. Do NOT use for account balance/positions (okx-cex-portfolio), placing/cancelling orders (okx-cex-trade), or bots (okx-cex-bot). Do NOT use when the user wants to TRADE a directional view as an event contract — that is okx-cex-trade. Merely ASKING which way an asset's price is moving is a market-data question and belongs here./okx-cex-portfolioThis skill should be used when the user asks about 'account balance', 'how much USDT do I have', 'my funding account', 'show my positions', 'open positions', 'position P&L', 'unrealized PnL', 'closed positions', 'position history', 'realized PnL', 'account bills', 'transaction history', 'trading fees', 'fee tier', 'account config', 'max order size', 'how much can I buy', 'withdrawable amount', 'transfer funds', 'move USDT to trading account', or 'switch position mode'. Also use for '总资产', 'full balance', 'all assets', 'total holdings', 'net worth', 'how much do I have in total', 'show all my balances', 'all account balances', 'asset overview', 'aggregated balance', 'asset snapshot', '资产快照'. Requires API credentials. Do NOT use for market prices (use okx-cex-market), placing/cancelling orders (use okx-cex-trade), or grid/DCA bots (use okx-cex-bot)./okx-cex-skill-mpUse this skill when the user asks to: 'find a trading skill', 'search for skills', 'install a skill', 'add a skill', 'download a skill', 'browse skill marketplace', 'what skills are available', 'update a skill', 'check for skill updates', 'remove a skill', 'uninstall a skill', 'list installed skills', 'show my skills', 'skill categories', 'verify skill signature', 'verify installed skill', 're-verify a skill', 'check skill integrity', or any request to discover, install, update, verify, or manage AI trading skills from the OKX Skills Marketplace. This skill covers searching, browsing categories, installing via CLI, downloading zip packages, checking for updates, removing installed skills, and verifying Ed25519 signatures of installed skills. Requires API credentials for marketplace API access. Do NOT use for placing orders (use okx-cex-trade), market data (use okx-cex-market), or bot management (use okx-cex-bot)./okx-okx-agent-trade-kit:okx-cex-botfrom okx-agent-trade-kit
Generated from the plugin's indexed repository (okx/agent-trade-kit) — no native marketplace selected
npx claudepluginhub p/okx-okx-agent-trade-kit2 plugins ship this exact skill · first indexed Nov 27, 2026
Other plugins' skills for the same job