
okx-cex-bot
Manage Grid bots (spot/contract/coin-margined), DCA Martingale bots (Spot DCA 现货马丁 / Contract DCA 合约马丁), and Smart Portfolio bots (智能组合, auto-rebalancing multi-asset portfolio) on OKX. Covers create, stop, amend, monitor P&L, TP/SL, margin/investment adjustment, AI-recommended parameters, and recommended zone backtest. Requires API credentials. Not for regular orders (okx-cex-trade), market data (okx-cex-market), or account info (okx-cex-portfolio).
- Installs
- 10K
- Last 24h
- +18
- Trending rank
- #6310
- Security
- Warn
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/okx/agent-skills --skill okx-cex-bot- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads okx-cex-bot automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
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.
Use metadata.version from this file's frontmatter as the reference for Step 2.
Prerequisites
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.
Credential & Profile Check
Run before every authenticated command. The auth method is detected during preflight 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.
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 --jsonhas any profile with a non-emptyapi_keyfield → API Key mode. Proceed to Step B.- No API-key profile AND
auth status --jsonreturns"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, loadokx-cex-authskill and follow login steps, wait for completion.
Step B — Confirm trading mode
Resolution:
- User intent is clear ("real"/"实盘"/"live" → live; "test"/"模拟"/"demo" → demo) → use it, inform user
- No explicit declaration → check conversation context for previous choice → reuse if found
- 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 --jsonto discover available profile names and theirdemosettings. - OAuth users: omit flags for live; add
--demofor 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"):
- Stop immediately
- Load
okx-cex-authskill and follow re-authentication steps - 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 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 |
DCA Bot (Spot & Contract)
| 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 details | READ | DCA bot details + PnL |
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 |
Smart Portfolio 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 1.0, 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 |
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 |
Operation Flow
Step 1 — Identify bot type and action
Parse user request → determine module (Grid / DCA / Smart Portfolio) and action (create / stop / list / details).
Step 2 — Execute
READ commands (orders, details, sub-orders): run immediately after profile confirmation.
WRITE commands (create, amend, stop): confirm key parameters with user once before executing.
Step 3 — Verify after writes
- After create → run the corresponding
orderscommand to confirm active - After amend → run
details --algoId <id>to confirm updated config - After Grid/DCA stop → run
orders --historyto confirm stopped - After Smart Portfolio stop → run
smart-portfolio orders --historyto confirm stopped
Key Rules
- Never auto-transfer funds. If balance is insufficient for bot creation, report the shortfall (current available vs required) and ask the user how to proceed: (1) transfer funds manually, (2) reduce size, or (3) cancel.
algoIdis the bot's algo order ID (from create or list output). It is NOT a normalordId. Never fabricate — always obtain from a prior command.algoOrdTypefor grid must match the bot's actual type. Always use the value frombot grid orders— do not infer from user description alone. Mismatch causes error50016.- When operating on existing bots, always list first to get correct IDs, unless the user provides them explicitly.
- TP/SL constraints:
tpTriggerPx/tpRatioandslTriggerPx/slRatioare mutually exclusive pairs.
CLI Command Reference
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 cross-skill workflow examples (chaining okx-cex-market/okx-cex-portfolio with bot
creation), read {baseDir}/references/workflows.md.
Communication Guidelines
- Grid/DCA: use "bot" not "strategy" (e.g., "grid bot", "DCA bot")
- DCA: always say "DCA" or "Martingale" — DCA supports both Spot DCA and Contract DCA
- Chinese: Grid = "网格", Spot DCA = "现货马丁", Contract DCA = "合约马丁", Smart Portfolio = "智能组合"
- Use natural language for parameters — "What price range?" not "Enter minPx and maxPx"
- If the user already provides values, map directly — don't re-ask
{base}and{quote}: extract frominstIdby splitting on-. E.g.,BTC-USDT-SWAP→ base=BTC, quote=USDT.
Global Notes
- All bots run on OKX servers — stopping the CLI does not affect them
- Auth method and trading mode are determined in "Credential & Profile Check"; see that section for parameter rules
--jsonreturns the raw OKX API v5 response by default. Add--envto wrap the output as{"env": "<live|demo>", "profile": "<name>", "data": <response>}- Rate limit: 20 requests per 2 seconds per UID
- Grid
--gridNumrange: 2–100
FAQ
What does the okx-cex-bot skill do?
Manage Grid bots (spot/contract/coin-margined), DCA Martingale bots (Spot DCA 现货马丁 / Contract DCA 合约马丁), and Smart Portfolio bots (智能组合, auto-rebalancing multi-asset portfolio) on OKX. Covers create, stop, amend, monitor P&L, TP/SL, margin/investment adjustment, AI-recommended parameters, and recommended zone backtest. Requires API credentials. Not for regular orders (okx-cex-trade), market data (okx-cex-market), or account info (okx-cex-portfolio).
How do I install okx-cex-bot?
Run npx skills add https://github.com/okx/agent-skills --skill okx-cex-bot in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/okx-cex-bot/ (personal) or .claude/skills/okx-cex-bot/ (project).
Which AI agents can use okx-cex-bot?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is okx-cex-bot safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk flagged items to review; Runlayer flagged items to review; ZeroLeaks passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains okx-cex-bot?
It is published by okx in okx/agent-skills. It has 9,955 recorded installs.
More from okx/agent-skills
okx-cex-market
okx/agent-skills
Use 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-trade
okx/agent-skills
Use when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a position', 'close a position', 'set take profit', 'limit take profit', 'immediate TP', 'set stop loss', 'self-trade prevention', 'stpMode', 'auto-cancel on close', 'trailing stop', 'pending order', 'chase order', 'iceberg', 'TWAP', 'split order', 'large order', 'set leverage', 'check my orders', 'fill history', 'buy a call', 'sell a put', 'option chain', 'implied volatility', 'IV', 'Greeks', 'delta', 'gamma', 'event contract', 'buy Yes', 'buy No', 'buy Up', 'buy Down', 'prediction market', or any request to place, cancel, or amend spot, swap, futures, options, or event contract orders on OKX CEX. Covers conditional (TP/SL/trailing) algo orders. Requires API credentials. Do NOT use for market data (okx-cex-market), account balance (okx-cex-portfolio), or bots (okx-cex-bot).
okx-cex-portfolio
okx/agent-skills
This 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-earn
okx/agent-skills
Manages 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-skill-mp
okx/agent-skills
Use 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-sentiment-tracker
okx/agent-skills
Use this skill when the user asks about: 'any crypto news', 'latest news', 'market update', 'daily briefing', 'BTC news', 'ETH news', 'news on SOL', 'search SEC ETF', 'regulation news', 'Bitcoin halving', 'is BTC bullish or bearish', 'coin sentiment', 'sentiment trend', 'trending coins', 'top bullish coins', 'bearish sentiment', 'social buzz', 'market mood', 'fear and greed', 'full article', 'read more', 'economic calendar', '经济日历', 'macro data', '宏观数据', 'NFP', 'nonfarm', '非农', 'CPI', 'GDP', 'FOMC', '利率决议', 'interest rate decision', 'PMI', 'unemployment rate', '失业率', 'economic events', '经济事件', or any request for crypto news, market intelligence, sentiment analysis, social trend data, or macro-economic calendar. Requires API credentials. Do NOT use for market prices/candles (okx-cex-market), placing orders (okx-cex-trade), or account info (okx-cex-portfolio).
Popular business & finance skills
sales-enablement
coreyhaines31/marketingskills
When the user wants to create sales collateral, pitch decks, one-pagers, objection handling docs, or demo scripts. Also use when the user mentions 'sales deck,' 'pitch deck,' 'one-pager,' 'leave-behind,' 'objection handling,' 'deal-specific ROI analysis,' 'demo script,' 'talk track,' 'sales playbook,' 'proposal template,' 'buyer persona card,' 'battle card,' 'battlecard,' 'competitive one-pager,' 'win-loss analysis,' 'why are we losing deals,' 'loss reasons,' 'how do I respond to this objection,' 'prospect just said,' 'help my sales team,' 'sales materials,' or 'what should I give my sales reps,' 'cold call script,' or 'voicemail script.' Use this for any document or asset that helps a sales team close deals. For public competitor comparison pages, see competitors. For running buyer interviews or churn research, see customer-research. For marketing website copy, see copywriting. For cold outreach emails, see cold-email. For the offer being sold (bonuses, guarantees, pricing structure),
revops
coreyhaines31/marketingskills
When the user wants help with revenue operations, lead lifecycle management, or marketing-to-sales handoff processes. Also use when the user mentions 'RevOps,' 'revenue operations,' 'lead scoring,' 'outbound pipeline stages,' 'lead routing,' 'MQL,' 'SQL,' 'pipeline stages,' 'deal desk,' 'CRM automation,' 'marketing-to-sales handoff,' 'data hygiene,' 'leads aren't getting to sales,' 'pipeline management,' 'lead qualification,' or 'when should marketing hand off to sales.' Use this for anything involving the systems and processes that connect marketing to revenue. For cold outreach emails, see cold-email. For email drip campaigns, see emails. For pricing decisions, see pricing.
sales-funnel-blueprint
autonnel/autonnel-skills
Turn an offer into a concrete multi-step sales funnel spec - page-by-page structure, price ladder, copy outline and the metrics each step must hit. Use when asked to build a sales funnel, marketing funnel, landing page flow, lead magnet funnel, webinar funnel, tripwire or VSL funnel, when planning a product launch page flow, or when someone asks "what pages do I need" for selling something online.
pricing
coreyhaines31/marketingskills
When the user wants help with pricing decisions, packaging, or monetization strategy. Also use when the user mentions 'pricing,' 'pricing tiers,' 'freemium,' 'free trial,' 'packaging,' 'price increase,' 'value metric,' 'Van Westendorp,' 'willingness to pay,' 'monetization,' 'how much should I charge,' 'my pricing is wrong,' 'pricing page,' 'annual vs monthly,' 'per seat pricing,' 'should I offer a free plan,' 'pricing page teardown,' 'pricing page audit,' 'is my pricing page AI-readable,' or 'can AI read my pricing.' Use this whenever someone is figuring out what to charge, how to structure their plans, or wants to audit a pricing page (for humans and for the AI agents that shortlist tools). For in-app upgrade screens, see paywalls. For offer construction (bonuses, guarantees, value framing, naming) on services/courses/coaching/high-ticket B2B, see offers.
cross-border-ecommerce
nexscope-ai/ecommerce-skills
Cross-border e-commerce expansion advisor. Scores target markets on 8 weighted dimensions (market size, ecommerce penetration, competition, regulatory complexity, logistics infrastructure, payment ecosystem, cultural distance, IP protection), compares 5 fulfillment models with cost and transit data, provides country-by-country tax/duty compliance guides (EU VAT/IOSS, UK VAT, US sales tax, CA GST, AU GST, JP consumption tax), maps local payment preferences by market, and builds a phased expansion roadmap. No API key required.
pricing-strategy
coreyhaines31/marketingskills
When the user wants help with pricing decisions, packaging, or monetization strategy. Also use when the user mentions 'pricing,' 'pricing tiers,' 'freemium,' 'free trial,' 'packaging,' 'price increase,' 'value metric,' 'Van Westendorp,' 'willingness to pay,' 'monetization,' 'how much should I charge,' 'my pricing is wrong,' 'pricing page,' 'annual vs monthly,' 'per seat pricing,' or 'should I offer a free plan.' Use this whenever someone is figuring out what to charge or how to structure their plans. For in-app upgrade screens, see paywall-upgrade-cro.