Claude Marketplaces
SkillsMCP serversMarketplacesDigestTools
Submit

This week in Claude

Every Monday: Claude Code, Agent SDK, MCP, and the Anthropic platform moves worth your time.

Skills by category
Frontend DevelopmentBackend & APIsTesting & QASecurityDevOps & CI/CDGit & Pull RequestsDocumentationCode Review & QualityAI & Agent BuildingSkill Development
MCP servers by category
Sales & MarketingWeb & Browser AutomationDatabasesAI & LLM ToolsCloud & InfrastructureCommunication & MessagingDeveloper ToolsDesign & CreativeDocuments & KnowledgeSearch & Web Crawling
Marketplaces by category
AI Agents & OrchestrationLLM IntegrationDevelopment ToolsFrontend & UIBackend & APIsDatabasesTesting & Code QualityDevOps & CloudSecurity & ComplianceGit & Version Control
Claude Marketplaces

An independent directory of skills, plugins and MCP servers for Claude Code. Not affiliated with Anthropic.

Browse

  • Skills
  • MCP servers
  • Marketplaces
  • Weekly digest
  • Skill index
  • MCP index
  • Marketplace index

Site

  • About
  • Tools
  • Submit
  • Feedback
  • Privacy
  • llms.txt
  • Plugins reference

Maker

  • Snug
  • Agent Caffeine
  • knobs
  • Wax
  • Vectoys
  • mertduzgun.com
Crafted at
Skills/Backend & APIs
okx avatar

Okx Cex Bot

okx/agent-skills

This lets Claude create and manage OKX's native server-side trading bots without you needing to run anything locally. It handles both grid bots (spot and contract, including coin-margined) and DCA Martingale strategies across spot and futures markets. The skill enforces a two-step auth check before every command to distinguish between API key and OAuth modes, then applies the right flags for live versus demo trading. Notable that it never auto-transfers funds when balance is insufficient, instead it reports the shortfall and asks you to decide. Commands cover the full lifecycle: create with AI-suggested parameters, amend price ranges or take-profit levels on running bots, stop execution, and monitor P&L and individual fills.

installs
9.9K
GitHub stars
195
last updated
Aug 21, 2026
View on GitHubSave

Install

$ npx -y skills add okx/agent-skills --skill okx-cex-bot --agent claude-code

Installs into .claude/skills of the current project.

Files

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 init for 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 --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 methodLive (实盘)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

NeedSkill
Market data, prices, depthokx-cex-market
Account balance, positions, feesokx-cex-portfolio
Regular spot/swap/futures ordersokx-cex-trade
Grid / DCA botsokx-cex-bot (this skill)

Command Index

Grid Bot

CommandTypeDescription
okx bot grid createWRITECreate a grid bot (spot or contract)
okx bot grid amendWRITEAmend price range, grid count, or TP/SL of a running grid bot
okx bot grid stopWRITEStop a grid bot
okx bot grid positionsREADQuery open contract-grid positions (liquidation price, margin ratio, unrealized PnL)
okx bot grid liquidate-priceREADEstimate liquidation price for a contract-grid bot
okx bot grid close-positionWRITEClose remaining position after bot stopped with stopType=2
okx bot grid ordersREADList active or history grid bots
okx bot grid detailsREADGrid bot details + PnL
okx bot grid sub-ordersREADIndividual grid fills or pending orders

DCA Bot (Spot & Contract)

CommandTypeDescription
okx bot dca createWRITECreate a DCA (Martingale) bot (spot or contract)
okx bot dca stopWRITEStop a DCA bot (spot or contract)
okx bot dca ordersREADList active or history DCA bots (default: contract_dca)
okx bot dca positionsREADDCA bot position info (avgPx, upl, liqPx, ...)
okx bot dca detailsREADDeprecated - use okx bot dca positions (same endpoint)
okx bot dca sub-ordersREADDCA cycles and orders within a cycle
okx bot dca add-marginWRITEAdd margin to a running contract DCA bot
okx bot dca reduce-marginWRITEReduce margin on a running contract DCA bot
okx bot dca update-tpWRITEUpdate take-profit price on a running contract DCA bot

Smart Portfolio Bot

Note: Load with --modules bot.smartportfolio or bot.all (not in default modules).

CommandTypeDescription
okx bot smart-portfolio createWRITECreate a Smart Portfolio bot (2–10 assets, ratios summing to 1.0, deltaRatio threshold)
okx bot smart-portfolio stopWRITEStop a running Smart Portfolio bot
okx bot smart-portfolio ordersREADList Smart Portfolio bots (default: running; add --history for stopped)
okx bot smart-portfolio detailsREADGet Smart Portfolio bot details and current allocation
okx bot smart-portfolio amend-rebalanceWRITEUpdate rebalance threshold and interval (both --deltaRatio and --interval required)
okx bot smart-portfolio instant-rebalanceWRITETrigger an immediate rebalance
okx bot smart-portfolio recommend-zonesREADBrowse OKX-recommended portfolio zone configurations
okx bot smart-portfolio zones-backtestREADGet 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 orders command to confirm active
  • After amend → run details --algoId <id> to confirm updated config
  • After Grid/DCA stop → run orders --history to confirm stopped
  • After Smart Portfolio stop → run smart-portfolio orders --history to 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.
  • 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.
  • When operating on existing bots, always list first to get correct IDs, unless the user provides them explicitly.
  • TP/SL constraints: tpTriggerPx/tpRatio and slTriggerPx/slRatio are 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 from instId by 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
  • --json returns the raw OKX API v5 response by default. Add --env to wrap the output as {"env": "<live|demo>", "profile": "<name>", "data": <response>}
  • Rate limit: 20 requests per 2 seconds per UID
  • Grid --gridNum range: 2–100
SKILL.md on GitHub

Sponsors

SnugThe clipboard manager you and your agent can use, safelyAgent CaffeineClose your lid, come back to finished workWaxBlock anything with supervision, without erasing your iPhoneOpen StepsSponsoredFree and open-source skills that make AI coding agents easier to understand, verify, and control.

Details

Repository
github.com/okx/agent-skills
Categories
Backend & APIs, DevOps & CI/CD, AI & Agent Building, Finance & Trading

More from okx/agent-skills

All 11
  • Okx Cex Earn9.3K
  • Okx Cex Skill Mp8.2K
  • Okx Sentiment Tracker8.1K
  • Okx Cex Auth5.9K
  • Okx Cex Smartmoney5.9K
  • Earn Hunter3.2K
  • Okx Outcomes2K
  • Okx Cex Market10.5K
  • Okx Cex Trade10.3K
  • Okx Cex Portfolio10.1K

Recommended

More Backend & APIs
1anthropics avatarcode-reviewanthropics/knowledge-work-pluginsReview code changes for security, performance, and correctness. Trigger with a PR URL or diff, "review this before I merge", "is this code safe?", or when check9.9Kinstalls
2teng-lin avatarnotebooklmteng-lin/notebooklm-pyComplete API for Google NotebookLM - full programmatic access including features not in the web UI. Create notebooks, add sources, generate all artifact types, 9.9Kinstalls
3tanstack-skills avatartanstack-querytanstack-skills/tanstack-skillsPowerful asynchronous state management, server-state utilities, and data fetching for TS/JS, React, Vue, Solid, Svelte & Angular.9.9Kinstalls
4okx avatarokx-aiokx/onchainos-skillsERC-8004 Agent identity: 注册/更新/上架/下架/搜索agent, register/update/activate/deactivate/search — User/ASP/Evaluator(买家/卖家/评审员, 旧称仲裁者亦可); 我的agent/ASP, 找做X的ASP/agent有什么9.9Kinstalls
5pskoett avatarself-improvementpskoett/self-improving-agentCaptures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude 9.7Kinstalls
6shopify avatarshopify-partnershopify/shopify-ai-toolkitThe Partner API lets you programmatically access data about your Partner Dashboard, including your apps, themes, and affiliate referrals.9.7Kinstalls