[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M730FTP044DSQQM9SS6KPRT7":3,"skill-same:01M730FTP044DSQQM9SS6KPRT7":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":39,"commitSha":40,"skillDirectory":41,"forksCount":14,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":6,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M730FTP044DSQQM9SS6KPRT7","okx-cex-bot",null,"Manage Grid bots (spot\u002Fcontract\u002Fcoin-margined) and DCA Martingale bots (Spot DCA 现货马丁 \u002F Contract DCA 合约马丁) on OKX. Covers create, stop, amend, monitor P&L, TP\u002FSL, margin\u002Finvestment adjustment, and AI-recommended parameters. Requires API credentials. Not for regular orders (okx-cex-trade), market data (okx-cex-market), or account info (okx-cex-portfolio).","JOHNadonis\u002Fclaude-code-skills","JOHNadonis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F31716775?v=4","01M72YRBKCVM4ZYJFF7Z71KVQQ","Hongcai Wang","01M72YRBMFSBZNVRJ4D48MWMZ3",0,"MIT","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fokx-cex-bot\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: okx-cex-bot\ndescription: Manage Grid bots (spot\u002Fcontract\u002Fcoin-margined) and DCA Martingale bots (Spot DCA 现货马丁 \u002F Contract DCA 合约马丁) on OKX. Covers create, stop, amend, monitor P&L, TP\u002FSL, margin\u002Finvestment adjustment, and AI-recommended parameters. Requires API credentials. Not for regular orders (okx-cex-trade), market data (okx-cex-market), or account info (okx-cex-portfolio).\nlicense: MIT\nmetadata:\n  author: okx\n  version: \"1.3.1\"\n  homepage: \"https:\u002F\u002Fwww.okx.com\"\n  agent:\n    emoji: \"🤖\"\n    requires:\n      bins: [\"okx\"]\n    install:\n      - id: npm\n        kind: node\n        package: \"@okx_ai\u002Fokx-trade-cli\"\n        bins: [\"okx\"]\n        label: \"Install okx CLI (npm)\"\n---\n\n# OKX CEX Bot Trading\n\nGrid 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.\n\n## Preflight\n\nBefore running any command, follow [`..\u002F_shared\u002Fpreflight.md`](..\u002F_shared\u002Fpreflight.md).\nUse `metadata.version` from this file's frontmatter as the reference for Step 2.\n\n## Prerequisites\n\n```bash\nnpm install -g @okx_ai\u002Fokx-trade-cli\n```\n\nCheck credentials, then set up if missing:\n\n```bash\nokx config show          # shows configured profiles (api_key shows last 4 chars)\nokx config init          # interactive wizard if not configured\n```\n\n> **Security**: NEVER accept API credentials in chat. Guide users to `okx config init` or edit `~\u002F.okx\u002Fconfig.toml` directly.\n\n## Credential & Profile Check\n\n**Run before every authenticated command.**\n\n### Step A — Verify credentials\n\n```bash\nokx config show\n```\n\nIf no configuration → stop, guide user to `okx config init`, wait for completion.\n\n### Step B — Determine profile (required)\n\n| `--profile` | Mode | Funds |\n|---|---|---|\n| `live` | 实盘 | Real money |\n| `demo` | 模拟盘 | Simulated, safe for testing |\n\nResolution:\n1. User intent is clear (\"real\"\u002F\"实盘\"\u002F\"live\" → `live`; \"test\"\u002F\"模拟\"\u002F\"demo\" → `demo`) → use it, inform user\n2. No explicit declaration → check conversation context for previous profile → use it if found\n3. Nothing found → ask: \"Live (实盘) or Demo (模拟盘)?\" — wait before proceeding\n\n**After every command**: append `[profile: live]` or `[profile: demo]`\n\n### Handling 401 Errors\n\nStop immediately. Guide user to update `~\u002F.okx\u002Fconfig.toml` with their editor. Verify with `okx config show` before retrying.\n\n## Skill Routing\n\n| Need | Skill |\n|---|---|\n| Market data, prices, depth | `okx-cex-market` |\n| Account balance, positions, fees | `okx-cex-portfolio` |\n| Regular spot\u002Fswap\u002Ffutures orders | `okx-cex-trade` |\n| **Grid \u002F DCA bots** | **`okx-cex-bot` (this skill)** |\n\n## Command Index\n\n### Grid Bot\n\n| Command | Type | Description |\n|---|---|---|\n| `okx bot grid create` | WRITE | Create a grid bot (spot or contract) |\n| `okx bot grid stop` | WRITE | Stop a grid bot |\n| `okx bot grid orders` | READ | List active or history grid bots |\n| `okx bot grid details` | READ | Grid bot details + PnL |\n| `okx bot grid sub-orders` | READ | Individual grid fills or pending orders |\n\n### DCA Bot (Spot & Contract)\n\n| Command | Type | Description |\n|---|---|---|\n| `okx bot dca create` | WRITE | Create a DCA (Martingale) bot (spot or contract) |\n| `okx bot dca stop` | WRITE | Stop a DCA bot (spot or contract) |\n| `okx bot dca orders` | READ | List active or history DCA bots (default: contract_dca) |\n| `okx bot dca details` | READ | DCA bot details + PnL |\n| `okx bot dca sub-orders` | READ | DCA cycles and orders within a cycle |\n\n## Operation Flow\n\n### Step 1 — Identify bot type and action\n\nParse user request → determine module (Grid \u002F DCA) and action (create \u002F stop \u002F list \u002F details).\n\n### Step 2 — Execute\n\n**READ commands** (orders, details, sub-orders): run immediately after profile confirmation.\n\n**WRITE commands** (create, stop): confirm key parameters with user once before executing.\n\n### Step 3 — Verify after writes\n\n- After create → run the corresponding `orders` command to confirm active\n- After stop → run `orders --history` to confirm stopped\n\n## Key Rules\n\n- **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.\n- **`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.\n- **`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`.\n- When operating on existing bots, **always list first** to get correct IDs, unless the user provides them explicitly.\n- **TP\u002FSL constraints**: `tpTriggerPx`\u002F`tpRatio` and `slTriggerPx`\u002F`slRatio` are mutually exclusive pairs.\n\n## CLI Command Reference\n\n### Grid Bot — Create\n\n```bash\nokx bot grid create --instId \u003Cid> --algoOrdType \u003Ctype> \\\n  --maxPx \u003Cpx> --minPx \u003Cpx> --gridNum \u003Cn> \\\n  [--runType \u003C1|2>] \\\n  [--quoteSz \u003Cn>] [--baseSz \u003Cn>] \\\n  [--direction \u003Clong|short|neutral>] [--lever \u003Cn>] [--sz \u003Cn>] \\\n  [--basePos] [--no-basePos] \\\n  [--tpTriggerPx \u003Cpx>] [--slTriggerPx \u003Cpx>] [--tpRatio \u003Cratio>] [--slRatio \u003Cratio>] \\\n  [--algoClOrdId \u003Cid>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--instId` | Yes | - | Instrument (e.g., `BTC-USDT` for spot, `BTC-USDT-SWAP` for USDT-M contract, `BTC-USD-SWAP` for coin-M contract) |\n| `--algoOrdType` | Yes | - | `grid` (spot grid) or `contract_grid` (contract grid, including coin-margined) |\n| `--maxPx` | Yes | - | Upper price boundary |\n| `--minPx` | Yes | - | Lower price boundary |\n| `--gridNum` | Yes | - | Grid levels (2–100) |\n| `--runType` | No | `1` | `1`=arithmetic spacing, `2`=geometric spacing |\n| `--quoteSz` | Cond. | - | USDT investment — spot grid only (provide `quoteSz` or `baseSz`) |\n| `--baseSz` | Cond. | - | Base currency investment — spot grid only |\n| `--direction` | Cond. | - | `long`, `short`, or `neutral` — required for contract grid |\n| `--lever` | Cond. | - | Leverage (e.g., `5`) — contract grid only |\n| `--sz` | Cond. | - | Investment margin in USDT (USDT-M) or coin (coin-M) — contract grid only |\n| `--basePos` \u002F `--no-basePos` | No | `true` | Open a base position at creation — contract grid only (ignored for neutral). Use `--no-basePos` to disable |\n| `--tpTriggerPx` | No | - | Take-profit trigger price (mutually exclusive with `--tpRatio`) |\n| `--slTriggerPx` | No | - | Stop-loss trigger price (mutually exclusive with `--slRatio`) |\n| `--tpRatio` | No | - | Take-profit ratio — contract grid only (mutually exclusive with `--tpTriggerPx`) |\n| `--slRatio` | No | - | Stop-loss ratio — contract grid only (mutually exclusive with `--slTriggerPx`) |\n| `--algoClOrdId` | No | - | Client-defined algo order ID (1-32 alphanumeric). Unique per user, enables idempotent creation |\n\n---\n\n### Grid Bot — Stop\n\n```bash\nokx bot grid stop --algoId \u003Cid> --algoOrdType \u003Ctype> --instId \u003Cid> \\\n  [--stopType \u003C1|2|3|5|6>] [--json]\n```\n\n> **`--algoId`** and **`--algoOrdType`** must come from `bot grid orders` output. The `algoOrdType` must match the bot's actual type — do not guess.\n\n| `--stopType` | Behavior |\n|---|---|\n| `1` | Stop + sell\u002Fclose all positions at market (default) |\n| `2` | Stop + keep current assets as-is |\n| `3` | Stop + close at limit prices |\n| `5` | Stop + partial close |\n| `6` | Stop without selling (smart arbitrage) |\n\n---\n\n### Grid Bot — List Orders\n\n```bash\nokx bot grid orders --algoOrdType \u003Ctype> [--instId \u003Cid>] [--algoId \u003Cid>] [--history] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `grid` (spot), `contract_grid` (contract), or `moon_grid` (moon) |\n| `--instId` | No | - | Filter by instrument |\n| `--algoId` | No | - | Filter by algo order ID. NOT a normal trade order ID |\n| `--history` | No | false | Show completed\u002Fstopped bots instead of active |\n\n---\n\n### Grid Bot — Details\n\n```bash\nokx bot grid details --algoOrdType \u003Ctype> --algoId \u003Cid> [--json]\n```\n\nReturns: bot config, current PnL (`pnlRatio`), grid range, number of grids, state, position info.\n\n---\n\n### Grid Bot — Sub-Orders\n\n```bash\nokx bot grid sub-orders --algoOrdType \u003Ctype> --algoId \u003Cid> [--live] [--json]\n```\n\n| Flag | Effect |\n|---|---|\n| *(default)* | Filled sub-orders (executed grid trades) |\n| `--live` | Pending grid orders currently on the book |\n\n---\n\n### DCA Bot — Create (Spot & Contract)\n\n```bash\nokx bot dca create --algoOrdType \u003Cspot_dca|contract_dca> --instId \u003Cid> --direction \u003Clong|short> \\\n  --initOrdAmt \u003Cn> --maxSafetyOrds \u003Cn> --tpPct \u003Cratio> \\\n  [--lever \u003Cn>] [--safetyOrdAmt \u003Cn>] [--pxSteps \u003Cratio>] [--pxStepsMult \u003Cmult>] [--volMult \u003Cmult>] \\\n  [--slPct \u003Cratio>] [--slMode \u003Climit|market>] [--allowReinvest] \\\n  [--triggerStrategy \u003Cinstant|price|rsi>] [--triggerPx \u003Cprice>] \\\n  [--triggerCond \u003Ccross_up|cross_down>] [--thold \u003Cthreshold>] [--timeframe \u003Ctimeframe>] [--timePeriod \u003Cperiod>] \\\n  [--algoClOrdId \u003Cid>] [--reserveFunds \u003Ctrue|false>] [--tradeQuoteCcy \u003Cccy>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `spot_dca` (Spot DCA) or `contract_dca` (Contract DCA) |\n| `--instId` | Yes | - | Instrument (e.g., `BTC-USDT` for spot, `BTC-USDT-SWAP` for contract) |\n| `--lever` | Cond. | - | Leverage multiplier (e.g., `3`). Required for `contract_dca` |\n| `--direction` | Yes | - | `long` or `short`. `spot_dca` must be `long` |\n| `--initOrdAmt` | Yes | - | Initial order amount (quote currency) |\n| `--maxSafetyOrds` | Yes | - | Max safety orders, integer [0, 100] (e.g., `3`; `0` = no DCA) |\n| `--safetyOrdAmt` | Cond. | - | Safety order amount (quote currency). Required when `maxSafetyOrds > 0` |\n| `--pxSteps` | Cond. | - | Initial price deviation [0.001, 0.5], e.g., `0.03` = 3%. Required when `maxSafetyOrds > 0` |\n| `--pxStepsMult` | Cond. | `1` | Price step multiplier (e.g., `1.2`). Required when `maxSafetyOrds > 0` |\n| `--volMult` | Cond. | `1` | Safety order size multiplier (e.g., `1.5`). Required when `maxSafetyOrds > 0` |\n| `--tpPct` | Yes | - | Take-profit ratio: long [0.001, 10], short [0.001, 0.9999] (e.g., `0.03` = 3%) |\n| `--slPct` | No | - | Stop-loss ratio, must exceed MPD (e.g., `0.05` = 5%). Must be used with `--slMode` |\n| `--slMode` | No | `market` | Stop-loss type: `limit` or `market`. Must be used with `--slPct` |\n| `--allowReinvest` | No | `true` | Reinvest profit into the next DCA cycle |\n| `--triggerStrategy` | No | `instant` | contract_dca: `instant`, `price`, `rsi`; spot_dca: `instant`, `rsi` |\n| `--triggerPx` | No | - | Trigger price — required when `triggerStrategy=price` (contract_dca only) |\n| `--triggerCond` | No | - | `cross_up` or `cross_down` — required when `triggerStrategy=rsi`, optional when `triggerStrategy=price` |\n| `--thold` | No | - | RSI threshold (e.g. `30`) — required when `triggerStrategy=rsi` |\n| `--timeframe` | No | - | RSI timeframe (e.g. `15m`) — required when `triggerStrategy=rsi` |\n| `--timePeriod` | No | `14` | RSI period — optional when `triggerStrategy=rsi` |\n| `--algoClOrdId` | No | - | Client-defined strategy order ID (1-32 alphanumeric) |\n| `--reserveFunds` | No | `true` | `true` or `false` — whether to reserve funds |\n| `--tradeQuoteCcy` | No | - | Trade quote currency |\n\n**Conditional required logic:**\n- Always required: `--algoOrdType`, `--instId`, `--direction`, `--initOrdAmt`, `--maxSafetyOrds`, `--tpPct`\n- When `algoOrdType=contract_dca`: also required `--lever`\n- When `maxSafetyOrds > 0`: also required `--safetyOrdAmt`, `--pxSteps`, `--pxStepsMult`, `--volMult`\n- `--slPct` and `--slMode` must be both set or both omitted\n\n---\n\n### DCA Bot — Stop\n\n```bash\nokx bot dca stop --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--stopType \u003C1|2>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `spot_dca` or `contract_dca` |\n| `--algoId` | Yes | - | DCA bot algo order ID (from create or list output). NOT a normal trade order ID |\n| `--stopType` | Cond. | `1` (contract_dca) | Required for `spot_dca`: `1`=sell all tokens, `2`=keep tokens. `contract_dca` always uses `1` (close position) |\n\n---\n\n### DCA Bot — List Orders\n\n```bash\nokx bot dca orders [--algoOrdType \u003Cspot_dca|contract_dca>] [--algoId \u003Cid>] [--instId \u003Cid>] [--history] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | No | `contract_dca` | Filter by strategy type |\n| `--algoId` | No | - | Filter by DCA bot algo order ID |\n| `--instId` | No | - | Filter by instrument |\n| `--history` | No | false | Show completed\u002Fstopped bots instead of active |\n\n---\n\n### DCA Bot — Details\n\n```bash\nokx bot dca details --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--json]\n```\n\nReturns: `avgPx`, `upl`, `liqPx`, `sz`, `tpPx`, `slPx`, `initPx`, `fundingFee`, `fee`, `fillSafetyOrds`, `algoClOrdId`, `baseSz`, `quoteSz`, `tradeQuoteCcy`.\n\n---\n\n### DCA Bot — Sub-Orders\n\n```bash\nokx bot dca sub-orders --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--cycleId \u003Cid>] [--json]\n```\n\n| Flag \u002F Param | Effect |\n|---|---|\n| *(default)* | List all cycles |\n| `--cycleId \u003Cid>` | Show orders within a specific cycle |\n\n## Quickstart\n\n```bash\n# Spot grid: BTC $90k–$100k, 10 grids, 1000 USDT\nokx bot grid create --instId BTC-USDT --algoOrdType grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000\n\n# Contract grid: BTC perp, neutral, 5x, 100 USDT margin\nokx bot grid create --instId BTC-USDT-SWAP --algoOrdType contract_grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 \\\n  --direction neutral --lever 5 --sz 100\n\n# Coin-margined contract grid: BTC inverse perp\nokx bot grid create --instId BTC-USD-SWAP --algoOrdType contract_grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 \\\n  --direction long --lever 5 --sz 0.01\n\n# Contract DCA bot: BTC perp, long, 3x, 3% TP\nokx bot dca create --algoOrdType contract_dca --instId BTC-USDT-SWAP --lever 3 --direction long \\\n  --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n  --pxSteps 0.03 --pxStepsMult 1 --volMult 1 --tpPct 0.03\n\n# Spot DCA bot: BTC spot, long, 5% TP\nokx bot dca create --algoOrdType spot_dca --instId BTC-USDT --direction long \\\n  --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n  --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 --tpPct 0.05\n\n# List all active bots\nokx bot grid orders --algoOrdType grid\nokx bot grid orders --algoOrdType contract_grid\nokx bot dca orders --algoOrdType contract_dca\nokx bot dca orders --algoOrdType spot_dca\n```\n\n## Cross-Skill Workflows\n\n### Spot Grid Bot\n> User: \"Start a BTC grid bot between $90k and $100k with 10 grids, invest 1000 USDT\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT                     → confirm price is in range\n2. okx-cex-portfolio okx account balance USDT                       → confirm available funds\n        ↓ user approves\n3. okx-cex-bot       okx bot grid create --instId BTC-USDT --algoOrdType grid \\\n                       --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000\n4. okx-cex-bot       okx bot grid orders --algoOrdType grid          → confirm bot is active\n5. okx-cex-bot       okx bot grid details --algoOrdType grid --algoId \u003Cid> → monitor PnL\n```\n\n### Contract DCA Bot\n> User: \"Start a long DCA bot on BTC perp, 3x leverage, $200 initial, 3% TP\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT-SWAP                → confirm current price\n2. okx-cex-portfolio okx account balance USDT                       → confirm margin\n        ↓ user approves\n3. okx-cex-bot       okx bot dca create --algoOrdType contract_dca --instId BTC-USDT-SWAP \\\n                       --lever 3 --direction long \\\n                       --initOrdAmt 200 --safetyOrdAmt 100 --maxSafetyOrds 3 \\\n                       --pxSteps 0.03 --pxStepsMult 1 --volMult 1 --tpPct 0.03\n4. okx-cex-bot       okx bot dca orders --algoOrdType contract_dca   → confirm active\n5. okx-cex-bot       okx bot dca details --algoOrdType contract_dca --algoId \u003Cid> → monitor PnL\n```\n\n### Spot DCA Bot\n> User: \"帮我在现货上 DCA BTC，首单 100 USDT，5% 止盈\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT                     → confirm current price\n2. okx-cex-portfolio okx account balance USDT                       → confirm funds\n        ↓ user approves\n3. okx-cex-bot       okx bot dca create --algoOrdType spot_dca --instId BTC-USDT \\\n                       --direction long \\\n                       --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n                       --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 --tpPct 0.05\n4. okx-cex-bot       okx bot dca orders --algoOrdType spot_dca       → confirm active\n```\n\n## Edge Cases\n\n### Grid Bot\n\n- **Price out of range**: `--minPx` must be \u003C current price \u003C `--maxPx`; check with `okx-cex-market` first\n- **Insufficient balance**: check `okx-cex-portfolio` → `account balance` before creating. If insufficient, **do NOT auto-transfer** — report the shortfall and ask the user for instructions\n- **Contract grid direction**: `long` (buys more at lower prices), `short` (sells at higher), `neutral` (both). Direction is required for contract grid\n- **Contract grid basePos**: defaults to `true` — long\u002Fshort grids automatically open a base position at creation. Neutral direction ignores this. Pass `--no-basePos` to disable\n- **Contract grid --sz**: investment margin in USDT (USDT-M) or coin (coin-M), not number of contracts\n- **Coin-margined grids**: use inverse instruments (e.g., `BTC-USD-SWAP`). Margin unit is the base coin (BTC), not USDT\n- **Stop type**: `stopType 1` sells\u002Fcloses all (default); `stopType 2` keeps assets; `stopType 5\u002F6` for contract grid positions\n- **TP\u002FSL**: `tpTriggerPx`\u002F`tpRatio` and `slTriggerPx`\u002F`slRatio` are mutually exclusive pairs. Ratio-based TP\u002FSL is contract grid only\n- **Already stopped bot**: stop returns error — check `bot grid orders --history` first to confirm state\n- **Insufficient margin (51340)**: extract required minimum from error, check balance via `okx-cex-portfolio`, report shortfall to user — do NOT auto-transfer\n- **Demo mode**: `okx --profile demo bot grid create ...` — safe for testing, no real funds\n- **algoClOrdId duplicate**: if the same `algoClOrdId` already exists, the API returns error code `51065`\n\n### DCA Bot\n\n- **Spot DCA direction**: must always be `long`. If user says \"short spot DCA\", explain that spot DCA only supports long direction\n- **Spot DCA stopType**: always ask user whether to sell all tokens (`1`) or keep them (`2`) when stopping\n- **Contract DCA lever**: required. If missing, the tool returns a validation error\n- **pxStepsMult**: `1.0` = equal spacing; `>1.0` = widen gaps between successive safety orders\n- **volMult**: `1.0` = equal sizes; `>1.0` = increase per safety order (Martingale scaling)\n- **triggerStrategy**: `instant` starts immediately; `price` waits for trigger price (contract_dca only); `rsi` waits for RSI condition (both spot_dca and contract_dca)\n- **Already stopped bot**: stop returns error — check `bot dca orders --history` first\n- **Demo mode**: `okx --profile demo bot dca create ...` — safe testing, no real funds\n- **INVALID_PRICE_STEPS_MULTIPLIER error**: adjust `slPct`. Recalculate MPD = Σ(pxSteps × pxStepsMult^i) for i = 0..maxSafetyOrds−1, then set `slPct` > MPD\n- **algoClOrdId duplicate**: error code `51065`\n\n## Communication Guidelines\n\n- **Grid\u002FDCA**: use \"bot\" not \"strategy\" (e.g., \"grid bot\", \"DCA bot\")\n- **DCA**: always say \"DCA\" or \"Martingale\" — DCA supports both Spot DCA and Contract DCA\n- **Chinese**: Grid = \"网格\", Spot DCA = \"现货马丁\", Contract DCA = \"合约马丁\"\n- Use natural language for parameters — \"What price range?\" not \"Enter minPx and maxPx\"\n- If the user already provides values, map directly — don't re-ask\n\n### Parameter Display Names\n\n> `{base}` and `{quote}`: extract from `instId` by splitting on `-`. E.g., `BTC-USDT-SWAP` → base=BTC, quote=USDT.\n\n#### Grid Bot — Spot (`algoOrdType=grid`)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `instId` | Trading pair | 交易对 |\n| `minPx` | Lower price bound | 网格下限价格 |\n| `maxPx` | Upper price bound | 网格上限价格 |\n| `gridNum` | Number of grids | 网格数量 |\n| `quoteSz` | Investment amount ({quote}) | 投入金额（{quote}） |\n| `baseSz` | Investment amount ({base}) | 投入金额（{base}） |\n| `runType` | Spacing mode (1=arithmetic, 2=geometric) | 网格间距模式（1=等差, 2=等比） |\n| `stopType` | Stop behavior | 停止方式 |\n\n#### Grid Bot — Contract (`algoOrdType=contract_grid`)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `instId` | Trading pair | 交易对 |\n| `minPx` | Lower price bound | 网格下限价格 |\n| `maxPx` | Upper price bound | 网格上限价格 |\n| `gridNum` | Number of grids | 网格数量 |\n| `sz` | Investment margin (USDT for USDT-M; {base} for coin-M) | 投入保证金（USDT-M 为 USDT；币本位为 {base}） |\n| `direction` | Direction (long \u002F short \u002F neutral) | 方向（做多 \u002F 做空 \u002F 中性） |\n| `lever` | Leverage | 杠杆倍数 |\n| `runType` | Spacing mode (1=arithmetic, 2=geometric) | 网格间距模式（1=等差, 2=等比） |\n| `basePos` | Open base position | 是否开底仓 |\n| `stopType` | Stop behavior | 停止方式 |\n\n#### DCA Bot (Spot & Contract)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `algoOrdType` | Strategy type (spot\u002Fcontract) | 策略类型（现货\u002F合约） |\n| `instId` | Trading pair | 交易对 |\n| `initOrdAmt` | Initial order amount ({quote}) | 首单金额（{quote}） |\n| `safetyOrdAmt` | Safety order amount ({quote}) | 补仓金额（{quote}） |\n| `maxSafetyOrds` | Max safety orders | 最大补仓次数 |\n| `pxSteps` | Price drop per safety order (%) | 补仓价格跌幅（%） |\n| `pxStepsMult` | Price step multiplier | 补仓跌幅倍数 |\n| `volMult` | Safety order size multiplier | 补仓金额倍数 |\n| `tpPct` | Take-profit ratio (%) | 止盈比例（%） |\n| `slPct` | Stop-loss ratio (%) | 止损比例（%） |\n| `slMode` | Stop-loss type (limit\u002Fmarket) | 止损类型（限价\u002F市价） |\n| `lever` | Leverage | 杠杆倍数 |\n| `direction` | Direction (long\u002Fshort) | 方向（做多\u002F做空） |\n| `allowReinvest` | Reinvest profit | 利润再投入 |\n| `triggerStrategy` | Trigger mode (contract_dca: instant\u002Fprice\u002Frsi; spot_dca: instant\u002Frsi) | 触发方式 |\n| `triggerPx` | Trigger price | 触发价格 |\n| `algoClOrdId` | Client order ID | 客户端策略订单 ID |\n| `stopType` | Stop type (sell all \u002F keep tokens) | 停止类型（卖出\u002F保留） |\n| `reserveFunds` | Reserve funds | 预留资金 |\n\n> **`slPct` stop-loss logic:**\n> - Long: stop-loss price = initial fill price × (1 − slPct)\n> - Short: stop-loss price = initial fill price × (1 + slPct)\n> When triggered and position fully closed, the bot ends.\n\n## Global Notes\n\n- All bots run on OKX servers — stopping the CLI does not affect them\n- `--profile` is required for all authenticated commands\n- `--json` returns the raw OKX API v5 response by default. Add `--env` to wrap the output as `{\"env\": \"\u003Clive|demo>\", \"profile\": \"\u003Cname>\", \"data\": \u003Cresponse>}`\n- Rate limit: 20 requests per 2 seconds per UID\n- Grid `--gridNum` range: 2–100\n","# OKX CEX Bot Trading\n\nGrid 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.\n\n## Preflight\n\nBefore running any command, follow [`..\u002F_shared\u002Fpreflight.md`](..\u002F_shared\u002Fpreflight.md).\nUse `metadata.version` from this file's frontmatter as the reference for Step 2.\n\n## Prerequisites\n\n```bash\nnpm install -g @okx_ai\u002Fokx-trade-cli\n```\n\nCheck credentials, then set up if missing:\n\n```bash\nokx config show          # shows configured profiles (api_key shows last 4 chars)\nokx config init          # interactive wizard if not configured\n```\n\n> **Security**: NEVER accept API credentials in chat. Guide users to `okx config init` or edit `~\u002F.okx\u002Fconfig.toml` directly.\n\n## Credential & Profile Check\n\n**Run before every authenticated command.**\n\n### Step A — Verify credentials\n\n```bash\nokx config show\n```\n\nIf no configuration → stop, guide user to `okx config init`, wait for completion.\n\n### Step B — Determine profile (required)\n\n| `--profile` | Mode | Funds |\n|---|---|---|\n| `live` | 实盘 | Real money |\n| `demo` | 模拟盘 | Simulated, safe for testing |\n\nResolution:\n1. User intent is clear (\"real\"\u002F\"实盘\"\u002F\"live\" → `live`; \"test\"\u002F\"模拟\"\u002F\"demo\" → `demo`) → use it, inform user\n2. No explicit declaration → check conversation context for previous profile → use it if found\n3. Nothing found → ask: \"Live (实盘) or Demo (模拟盘)?\" — wait before proceeding\n\n**After every command**: append `[profile: live]` or `[profile: demo]`\n\n### Handling 401 Errors\n\nStop immediately. Guide user to update `~\u002F.okx\u002Fconfig.toml` with their editor. Verify with `okx config show` before retrying.\n\n## Skill Routing\n\n| Need | Skill |\n|---|---|\n| Market data, prices, depth | `okx-cex-market` |\n| Account balance, positions, fees | `okx-cex-portfolio` |\n| Regular spot\u002Fswap\u002Ffutures orders | `okx-cex-trade` |\n| **Grid \u002F DCA bots** | **`okx-cex-bot` (this skill)** |\n\n## Command Index\n\n### Grid Bot\n\n| Command | Type | Description |\n|---|---|---|\n| `okx bot grid create` | WRITE | Create a grid bot (spot or contract) |\n| `okx bot grid stop` | WRITE | Stop a grid bot |\n| `okx bot grid orders` | READ | List active or history grid bots |\n| `okx bot grid details` | READ | Grid bot details + PnL |\n| `okx bot grid sub-orders` | READ | Individual grid fills or pending orders |\n\n### DCA Bot (Spot & Contract)\n\n| Command | Type | Description |\n|---|---|---|\n| `okx bot dca create` | WRITE | Create a DCA (Martingale) bot (spot or contract) |\n| `okx bot dca stop` | WRITE | Stop a DCA bot (spot or contract) |\n| `okx bot dca orders` | READ | List active or history DCA bots (default: contract_dca) |\n| `okx bot dca details` | READ | DCA bot details + PnL |\n| `okx bot dca sub-orders` | READ | DCA cycles and orders within a cycle |\n\n## Operation Flow\n\n### Step 1 — Identify bot type and action\n\nParse user request → determine module (Grid \u002F DCA) and action (create \u002F stop \u002F list \u002F details).\n\n### Step 2 — Execute\n\n**READ commands** (orders, details, sub-orders): run immediately after profile confirmation.\n\n**WRITE commands** (create, stop): confirm key parameters with user once before executing.\n\n### Step 3 — Verify after writes\n\n- After create → run the corresponding `orders` command to confirm active\n- After stop → run `orders --history` to confirm stopped\n\n## Key Rules\n\n- **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.\n- **`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.\n- **`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`.\n- When operating on existing bots, **always list first** to get correct IDs, unless the user provides them explicitly.\n- **TP\u002FSL constraints**: `tpTriggerPx`\u002F`tpRatio` and `slTriggerPx`\u002F`slRatio` are mutually exclusive pairs.\n\n## CLI Command Reference\n\n### Grid Bot — Create\n\n```bash\nokx bot grid create --instId \u003Cid> --algoOrdType \u003Ctype> \\\n  --maxPx \u003Cpx> --minPx \u003Cpx> --gridNum \u003Cn> \\\n  [--runType \u003C1|2>] \\\n  [--quoteSz \u003Cn>] [--baseSz \u003Cn>] \\\n  [--direction \u003Clong|short|neutral>] [--lever \u003Cn>] [--sz \u003Cn>] \\\n  [--basePos] [--no-basePos] \\\n  [--tpTriggerPx \u003Cpx>] [--slTriggerPx \u003Cpx>] [--tpRatio \u003Cratio>] [--slRatio \u003Cratio>] \\\n  [--algoClOrdId \u003Cid>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--instId` | Yes | - | Instrument (e.g., `BTC-USDT` for spot, `BTC-USDT-SWAP` for USDT-M contract, `BTC-USD-SWAP` for coin-M contract) |\n| `--algoOrdType` | Yes | - | `grid` (spot grid) or `contract_grid` (contract grid, including coin-margined) |\n| `--maxPx` | Yes | - | Upper price boundary |\n| `--minPx` | Yes | - | Lower price boundary |\n| `--gridNum` | Yes | - | Grid levels (2–100) |\n| `--runType` | No | `1` | `1`=arithmetic spacing, `2`=geometric spacing |\n| `--quoteSz` | Cond. | - | USDT investment — spot grid only (provide `quoteSz` or `baseSz`) |\n| `--baseSz` | Cond. | - | Base currency investment — spot grid only |\n| `--direction` | Cond. | - | `long`, `short`, or `neutral` — required for contract grid |\n| `--lever` | Cond. | - | Leverage (e.g., `5`) — contract grid only |\n| `--sz` | Cond. | - | Investment margin in USDT (USDT-M) or coin (coin-M) — contract grid only |\n| `--basePos` \u002F `--no-basePos` | No | `true` | Open a base position at creation — contract grid only (ignored for neutral). Use `--no-basePos` to disable |\n| `--tpTriggerPx` | No | - | Take-profit trigger price (mutually exclusive with `--tpRatio`) |\n| `--slTriggerPx` | No | - | Stop-loss trigger price (mutually exclusive with `--slRatio`) |\n| `--tpRatio` | No | - | Take-profit ratio — contract grid only (mutually exclusive with `--tpTriggerPx`) |\n| `--slRatio` | No | - | Stop-loss ratio — contract grid only (mutually exclusive with `--slTriggerPx`) |\n| `--algoClOrdId` | No | - | Client-defined algo order ID (1-32 alphanumeric). Unique per user, enables idempotent creation |\n\n---\n\n### Grid Bot — Stop\n\n```bash\nokx bot grid stop --algoId \u003Cid> --algoOrdType \u003Ctype> --instId \u003Cid> \\\n  [--stopType \u003C1|2|3|5|6>] [--json]\n```\n\n> **`--algoId`** and **`--algoOrdType`** must come from `bot grid orders` output. The `algoOrdType` must match the bot's actual type — do not guess.\n\n| `--stopType` | Behavior |\n|---|---|\n| `1` | Stop + sell\u002Fclose all positions at market (default) |\n| `2` | Stop + keep current assets as-is |\n| `3` | Stop + close at limit prices |\n| `5` | Stop + partial close |\n| `6` | Stop without selling (smart arbitrage) |\n\n---\n\n### Grid Bot — List Orders\n\n```bash\nokx bot grid orders --algoOrdType \u003Ctype> [--instId \u003Cid>] [--algoId \u003Cid>] [--history] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `grid` (spot), `contract_grid` (contract), or `moon_grid` (moon) |\n| `--instId` | No | - | Filter by instrument |\n| `--algoId` | No | - | Filter by algo order ID. NOT a normal trade order ID |\n| `--history` | No | false | Show completed\u002Fstopped bots instead of active |\n\n---\n\n### Grid Bot — Details\n\n```bash\nokx bot grid details --algoOrdType \u003Ctype> --algoId \u003Cid> [--json]\n```\n\nReturns: bot config, current PnL (`pnlRatio`), grid range, number of grids, state, position info.\n\n---\n\n### Grid Bot — Sub-Orders\n\n```bash\nokx bot grid sub-orders --algoOrdType \u003Ctype> --algoId \u003Cid> [--live] [--json]\n```\n\n| Flag | Effect |\n|---|---|\n| *(default)* | Filled sub-orders (executed grid trades) |\n| `--live` | Pending grid orders currently on the book |\n\n---\n\n### DCA Bot — Create (Spot & Contract)\n\n```bash\nokx bot dca create --algoOrdType \u003Cspot_dca|contract_dca> --instId \u003Cid> --direction \u003Clong|short> \\\n  --initOrdAmt \u003Cn> --maxSafetyOrds \u003Cn> --tpPct \u003Cratio> \\\n  [--lever \u003Cn>] [--safetyOrdAmt \u003Cn>] [--pxSteps \u003Cratio>] [--pxStepsMult \u003Cmult>] [--volMult \u003Cmult>] \\\n  [--slPct \u003Cratio>] [--slMode \u003Climit|market>] [--allowReinvest] \\\n  [--triggerStrategy \u003Cinstant|price|rsi>] [--triggerPx \u003Cprice>] \\\n  [--triggerCond \u003Ccross_up|cross_down>] [--thold \u003Cthreshold>] [--timeframe \u003Ctimeframe>] [--timePeriod \u003Cperiod>] \\\n  [--algoClOrdId \u003Cid>] [--reserveFunds \u003Ctrue|false>] [--tradeQuoteCcy \u003Cccy>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `spot_dca` (Spot DCA) or `contract_dca` (Contract DCA) |\n| `--instId` | Yes | - | Instrument (e.g., `BTC-USDT` for spot, `BTC-USDT-SWAP` for contract) |\n| `--lever` | Cond. | - | Leverage multiplier (e.g., `3`). Required for `contract_dca` |\n| `--direction` | Yes | - | `long` or `short`. `spot_dca` must be `long` |\n| `--initOrdAmt` | Yes | - | Initial order amount (quote currency) |\n| `--maxSafetyOrds` | Yes | - | Max safety orders, integer [0, 100] (e.g., `3`; `0` = no DCA) |\n| `--safetyOrdAmt` | Cond. | - | Safety order amount (quote currency). Required when `maxSafetyOrds > 0` |\n| `--pxSteps` | Cond. | - | Initial price deviation [0.001, 0.5], e.g., `0.03` = 3%. Required when `maxSafetyOrds > 0` |\n| `--pxStepsMult` | Cond. | `1` | Price step multiplier (e.g., `1.2`). Required when `maxSafetyOrds > 0` |\n| `--volMult` | Cond. | `1` | Safety order size multiplier (e.g., `1.5`). Required when `maxSafetyOrds > 0` |\n| `--tpPct` | Yes | - | Take-profit ratio: long [0.001, 10], short [0.001, 0.9999] (e.g., `0.03` = 3%) |\n| `--slPct` | No | - | Stop-loss ratio, must exceed MPD (e.g., `0.05` = 5%). Must be used with `--slMode` |\n| `--slMode` | No | `market` | Stop-loss type: `limit` or `market`. Must be used with `--slPct` |\n| `--allowReinvest` | No | `true` | Reinvest profit into the next DCA cycle |\n| `--triggerStrategy` | No | `instant` | contract_dca: `instant`, `price`, `rsi`; spot_dca: `instant`, `rsi` |\n| `--triggerPx` | No | - | Trigger price — required when `triggerStrategy=price` (contract_dca only) |\n| `--triggerCond` | No | - | `cross_up` or `cross_down` — required when `triggerStrategy=rsi`, optional when `triggerStrategy=price` |\n| `--thold` | No | - | RSI threshold (e.g. `30`) — required when `triggerStrategy=rsi` |\n| `--timeframe` | No | - | RSI timeframe (e.g. `15m`) — required when `triggerStrategy=rsi` |\n| `--timePeriod` | No | `14` | RSI period — optional when `triggerStrategy=rsi` |\n| `--algoClOrdId` | No | - | Client-defined strategy order ID (1-32 alphanumeric) |\n| `--reserveFunds` | No | `true` | `true` or `false` — whether to reserve funds |\n| `--tradeQuoteCcy` | No | - | Trade quote currency |\n\n**Conditional required logic:**\n- Always required: `--algoOrdType`, `--instId`, `--direction`, `--initOrdAmt`, `--maxSafetyOrds`, `--tpPct`\n- When `algoOrdType=contract_dca`: also required `--lever`\n- When `maxSafetyOrds > 0`: also required `--safetyOrdAmt`, `--pxSteps`, `--pxStepsMult`, `--volMult`\n- `--slPct` and `--slMode` must be both set or both omitted\n\n---\n\n### DCA Bot — Stop\n\n```bash\nokx bot dca stop --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--stopType \u003C1|2>] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | Yes | - | `spot_dca` or `contract_dca` |\n| `--algoId` | Yes | - | DCA bot algo order ID (from create or list output). NOT a normal trade order ID |\n| `--stopType` | Cond. | `1` (contract_dca) | Required for `spot_dca`: `1`=sell all tokens, `2`=keep tokens. `contract_dca` always uses `1` (close position) |\n\n---\n\n### DCA Bot — List Orders\n\n```bash\nokx bot dca orders [--algoOrdType \u003Cspot_dca|contract_dca>] [--algoId \u003Cid>] [--instId \u003Cid>] [--history] [--json]\n```\n\n| Param | Required | Default | Description |\n|---|---|---|---|\n| `--algoOrdType` | No | `contract_dca` | Filter by strategy type |\n| `--algoId` | No | - | Filter by DCA bot algo order ID |\n| `--instId` | No | - | Filter by instrument |\n| `--history` | No | false | Show completed\u002Fstopped bots instead of active |\n\n---\n\n### DCA Bot — Details\n\n```bash\nokx bot dca details --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--json]\n```\n\nReturns: `avgPx`, `upl`, `liqPx`, `sz`, `tpPx`, `slPx`, `initPx`, `fundingFee`, `fee`, `fillSafetyOrds`, `algoClOrdId`, `baseSz`, `quoteSz`, `tradeQuoteCcy`.\n\n---\n\n### DCA Bot — Sub-Orders\n\n```bash\nokx bot dca sub-orders --algoOrdType \u003Cspot_dca|contract_dca> --algoId \u003Cid> [--cycleId \u003Cid>] [--json]\n```\n\n| Flag \u002F Param | Effect |\n|---|---|\n| *(default)* | List all cycles |\n| `--cycleId \u003Cid>` | Show orders within a specific cycle |\n\n## Quickstart\n\n```bash\n# Spot grid: BTC $90k–$100k, 10 grids, 1000 USDT\nokx bot grid create --instId BTC-USDT --algoOrdType grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000\n\n# Contract grid: BTC perp, neutral, 5x, 100 USDT margin\nokx bot grid create --instId BTC-USDT-SWAP --algoOrdType contract_grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 \\\n  --direction neutral --lever 5 --sz 100\n\n# Coin-margined contract grid: BTC inverse perp\nokx bot grid create --instId BTC-USD-SWAP --algoOrdType contract_grid \\\n  --minPx 90000 --maxPx 100000 --gridNum 10 \\\n  --direction long --lever 5 --sz 0.01\n\n# Contract DCA bot: BTC perp, long, 3x, 3% TP\nokx bot dca create --algoOrdType contract_dca --instId BTC-USDT-SWAP --lever 3 --direction long \\\n  --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n  --pxSteps 0.03 --pxStepsMult 1 --volMult 1 --tpPct 0.03\n\n# Spot DCA bot: BTC spot, long, 5% TP\nokx bot dca create --algoOrdType spot_dca --instId BTC-USDT --direction long \\\n  --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n  --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 --tpPct 0.05\n\n# List all active bots\nokx bot grid orders --algoOrdType grid\nokx bot grid orders --algoOrdType contract_grid\nokx bot dca orders --algoOrdType contract_dca\nokx bot dca orders --algoOrdType spot_dca\n```\n\n## Cross-Skill Workflows\n\n### Spot Grid Bot\n> User: \"Start a BTC grid bot between $90k and $100k with 10 grids, invest 1000 USDT\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT                     → confirm price is in range\n2. okx-cex-portfolio okx account balance USDT                       → confirm available funds\n        ↓ user approves\n3. okx-cex-bot       okx bot grid create --instId BTC-USDT --algoOrdType grid \\\n                       --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000\n4. okx-cex-bot       okx bot grid orders --algoOrdType grid          → confirm bot is active\n5. okx-cex-bot       okx bot grid details --algoOrdType grid --algoId \u003Cid> → monitor PnL\n```\n\n### Contract DCA Bot\n> User: \"Start a long DCA bot on BTC perp, 3x leverage, $200 initial, 3% TP\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT-SWAP                → confirm current price\n2. okx-cex-portfolio okx account balance USDT                       → confirm margin\n        ↓ user approves\n3. okx-cex-bot       okx bot dca create --algoOrdType contract_dca --instId BTC-USDT-SWAP \\\n                       --lever 3 --direction long \\\n                       --initOrdAmt 200 --safetyOrdAmt 100 --maxSafetyOrds 3 \\\n                       --pxSteps 0.03 --pxStepsMult 1 --volMult 1 --tpPct 0.03\n4. okx-cex-bot       okx bot dca orders --algoOrdType contract_dca   → confirm active\n5. okx-cex-bot       okx bot dca details --algoOrdType contract_dca --algoId \u003Cid> → monitor PnL\n```\n\n### Spot DCA Bot\n> User: \"帮我在现货上 DCA BTC，首单 100 USDT，5% 止盈\"\n\n```\n1. okx-cex-market    okx market ticker BTC-USDT                     → confirm current price\n2. okx-cex-portfolio okx account balance USDT                       → confirm funds\n        ↓ user approves\n3. okx-cex-bot       okx bot dca create --algoOrdType spot_dca --instId BTC-USDT \\\n                       --direction long \\\n                       --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \\\n                       --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 --tpPct 0.05\n4. okx-cex-bot       okx bot dca orders --algoOrdType spot_dca       → confirm active\n```\n\n## Edge Cases\n\n### Grid Bot\n\n- **Price out of range**: `--minPx` must be \u003C current price \u003C `--maxPx`; check with `okx-cex-market` first\n- **Insufficient balance**: check `okx-cex-portfolio` → `account balance` before creating. If insufficient, **do NOT auto-transfer** — report the shortfall and ask the user for instructions\n- **Contract grid direction**: `long` (buys more at lower prices), `short` (sells at higher), `neutral` (both). Direction is required for contract grid\n- **Contract grid basePos**: defaults to `true` — long\u002Fshort grids automatically open a base position at creation. Neutral direction ignores this. Pass `--no-basePos` to disable\n- **Contract grid --sz**: investment margin in USDT (USDT-M) or coin (coin-M), not number of contracts\n- **Coin-margined grids**: use inverse instruments (e.g., `BTC-USD-SWAP`). Margin unit is the base coin (BTC), not USDT\n- **Stop type**: `stopType 1` sells\u002Fcloses all (default); `stopType 2` keeps assets; `stopType 5\u002F6` for contract grid positions\n- **TP\u002FSL**: `tpTriggerPx`\u002F`tpRatio` and `slTriggerPx`\u002F`slRatio` are mutually exclusive pairs. Ratio-based TP\u002FSL is contract grid only\n- **Already stopped bot**: stop returns error — check `bot grid orders --history` first to confirm state\n- **Insufficient margin (51340)**: extract required minimum from error, check balance via `okx-cex-portfolio`, report shortfall to user — do NOT auto-transfer\n- **Demo mode**: `okx --profile demo bot grid create ...` — safe for testing, no real funds\n- **algoClOrdId duplicate**: if the same `algoClOrdId` already exists, the API returns error code `51065`\n\n### DCA Bot\n\n- **Spot DCA direction**: must always be `long`. If user says \"short spot DCA\", explain that spot DCA only supports long direction\n- **Spot DCA stopType**: always ask user whether to sell all tokens (`1`) or keep them (`2`) when stopping\n- **Contract DCA lever**: required. If missing, the tool returns a validation error\n- **pxStepsMult**: `1.0` = equal spacing; `>1.0` = widen gaps between successive safety orders\n- **volMult**: `1.0` = equal sizes; `>1.0` = increase per safety order (Martingale scaling)\n- **triggerStrategy**: `instant` starts immediately; `price` waits for trigger price (contract_dca only); `rsi` waits for RSI condition (both spot_dca and contract_dca)\n- **Already stopped bot**: stop returns error — check `bot dca orders --history` first\n- **Demo mode**: `okx --profile demo bot dca create ...` — safe testing, no real funds\n- **INVALID_PRICE_STEPS_MULTIPLIER error**: adjust `slPct`. Recalculate MPD = Σ(pxSteps × pxStepsMult^i) for i = 0..maxSafetyOrds−1, then set `slPct` > MPD\n- **algoClOrdId duplicate**: error code `51065`\n\n## Communication Guidelines\n\n- **Grid\u002FDCA**: use \"bot\" not \"strategy\" (e.g., \"grid bot\", \"DCA bot\")\n- **DCA**: always say \"DCA\" or \"Martingale\" — DCA supports both Spot DCA and Contract DCA\n- **Chinese**: Grid = \"网格\", Spot DCA = \"现货马丁\", Contract DCA = \"合约马丁\"\n- Use natural language for parameters — \"What price range?\" not \"Enter minPx and maxPx\"\n- If the user already provides values, map directly — don't re-ask\n\n### Parameter Display Names\n\n> `{base}` and `{quote}`: extract from `instId` by splitting on `-`. E.g., `BTC-USDT-SWAP` → base=BTC, quote=USDT.\n\n#### Grid Bot — Spot (`algoOrdType=grid`)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `instId` | Trading pair | 交易对 |\n| `minPx` | Lower price bound | 网格下限价格 |\n| `maxPx` | Upper price bound | 网格上限价格 |\n| `gridNum` | Number of grids | 网格数量 |\n| `quoteSz` | Investment amount ({quote}) | 投入金额（{quote}） |\n| `baseSz` | Investment amount ({base}) | 投入金额（{base}） |\n| `runType` | Spacing mode (1=arithmetic, 2=geometric) | 网格间距模式（1=等差, 2=等比） |\n| `stopType` | Stop behavior | 停止方式 |\n\n#### Grid Bot — Contract (`algoOrdType=contract_grid`)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `instId` | Trading pair | 交易对 |\n| `minPx` | Lower price bound | 网格下限价格 |\n| `maxPx` | Upper price bound | 网格上限价格 |\n| `gridNum` | Number of grids | 网格数量 |\n| `sz` | Investment margin (USDT for USDT-M; {base} for coin-M) | 投入保证金（USDT-M 为 USDT；币本位为 {base}） |\n| `direction` | Direction (long \u002F short \u002F neutral) | 方向（做多 \u002F 做空 \u002F 中性） |\n| `lever` | Leverage | 杠杆倍数 |\n| `runType` | Spacing mode (1=arithmetic, 2=geometric) | 网格间距模式（1=等差, 2=等比） |\n| `basePos` | Open base position | 是否开底仓 |\n| `stopType` | Stop behavior | 停止方式 |\n\n#### DCA Bot (Spot & Contract)\n\n| API Field | EN | ZH |\n|---|---|---|\n| `algoOrdType` | Strategy type (spot\u002Fcontract) | 策略类型（现货\u002F合约） |\n| `instId` | Trading pair | 交易对 |\n| `initOrdAmt` | Initial order amount ({quote}) | 首单金额（{quote}） |\n| `safetyOrdAmt` | Safety order amount ({quote}) | 补仓金额（{quote}） |\n| `maxSafetyOrds` | Max safety orders | 最大补仓次数 |\n| `pxSteps` | Price drop per safety order (%) | 补仓价格跌幅（%） |\n| `pxStepsMult` | Price step multiplier | 补仓跌幅倍数 |\n| `volMult` | Safety order size multiplier | 补仓金额倍数 |\n| `tpPct` | Take-profit ratio (%) | 止盈比例（%） |\n| `slPct` | Stop-loss ratio (%) | 止损比例（%） |\n| `slMode` | Stop-loss type (limit\u002Fmarket) | 止损类型（限价\u002F市价） |\n| `lever` | Leverage | 杠杆倍数 |\n| `direction` | Direction (long\u002Fshort) | 方向（做多\u002F做空） |\n| `allowReinvest` | Reinvest profit | 利润再投入 |\n| `triggerStrategy` | Trigger mode (contract_dca: instant\u002Fprice\u002Frsi; spot_dca: instant\u002Frsi) | 触发方式 |\n| `triggerPx` | Trigger price | 触发价格 |\n| `algoClOrdId` | Client order ID | 客户端策略订单 ID |\n| `stopType` | Stop type (sell all \u002F keep tokens) | 停止类型（卖出\u002F保留） |\n| `reserveFunds` | Reserve funds | 预留资金 |\n\n> **`slPct` stop-loss logic:**\n> - Long: stop-loss price = initial fill price × (1 − slPct)\n> - Short: stop-loss price = initial fill price × (1 + slPct)\n> When triggered and position fully closed, the bot ends.\n\n## Global Notes\n\n- All bots run on OKX servers — stopping the CLI does not affect them\n- `--profile` is required for all authenticated commands\n- `--json` returns the raw OKX API v5 response by default. Add `--env` to wrap the output as `{\"env\": \"\u003Clive|demo>\", \"profile\": \"\u003Cname>\", \"data\": \u003Cresponse>}`\n- Rate limit: 20 requests per 2 seconds per UID\n- Grid `--gridNum` range: 2–100\n",{"name":5,"license":15,"metadata":24,"description":7},{"agent":25,"author":31,"version":37,"homepage":38},{"emoji":26,"install":27,"requires":35},"🤖",[28],{"id":29,"bins":30,"kind":32,"label":33,"package":34},"npm",[31],"okx","node","Install okx CLI (npm)","@okx_ai\u002Fokx-trade-cli",{"bins":36},[31],"1.3.1","https:\u002F\u002Fwww.okx.com","main","4ac29a24db9fc8bba16c61b1cdaa3f5058934247","skills\u002Fokx-cex-bot","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills","https:\u002F\u002Fgithub.com\u002FJOHNadonis","Java\u002FGo\u002FC++，student majoring in computer.","2026-10-26 22:44:45",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add JOHNadonis\u002Fclaude-code-skills --skill okx-cex-bot",{"tool":52,"command":53},"bunx","bunx skills add JOHNadonis\u002Fclaude-code-skills --skill okx-cex-bot",{"tool":55,"command":56},"pnpm","pnpm dlx skills add JOHNadonis\u002Fclaude-code-skills --skill okx-cex-bot","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fokx-cex-bot\u002FSKILL.md",true,[],[61,69,77,86,93,101],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":65,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7317QQ43D8KSNYCMQ9YSVV4","youtube-clipper","YouTube 视频智能剪辑工具。下载视频和字幕，AI 分析生成精细章节（几分钟级别）， 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频，并生成总结文案。 使用场景：当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词：视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":73,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7316R2JBWWT24DEVFGVZ1WW","yao-meta-skill","Create, refactor, evaluate, and package agent skills from workflows, prompts, transcripts, docs, or notes. Use when asked to create a skill, turn a repeated process into a reusable skill, improve an existing skill, add evals, or package a skill for team reuse.","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyao-meta-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyao-meta-skill\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":82,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7314XDMF1VN8H6GE0RXWX3V","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M73142X503419G1YEBQZVRWJ","vercel-react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-react-best-practices\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":97,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7313E33KEXPQSJ6JBSW7CT5","ui-test","AI-powered adversarial UI testing via the browse CLI. Analyzes git diffs to test only what changed, or explores the full app to find bugs. Tests functional correctness, accessibility, responsive layout, and UX heuristics. Use when the user asks to test UI changes, QA a pull request, audit accessibility, or run exploratory testing. Supports local browser (localhost) and remote Browserbase (deployed sites).","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fui-test\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Fui-test\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":81,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M73123QNJHSG1XT7XJPQD0HK","technical-seo-checker","Use when the user asks to \"technical SEO audit\", \"check page speed\", \"crawl issues\", \"Core Web Vitals\", \"site indexing problems\", \"my site is slow\", \"Google cannot crawl my site\", \"mobile issues\", or \"indexing problems\". Performs technical SEO audits covering site speed, crawlability, indexability, mobile-friendliness, security, and structured data. Identifies technical issues preventing optimal search performance. For content and heading element issues, see on-page-seo-auditor. For link architecture, see internal-linking-optimizer.","https:\u002F\u002Fgithub.com\u002FJOHNadonis\u002Fclaude-code-skills\u002Fblob\u002Fmain\u002Fskills\u002Ftechnical-seo-checker\u002FSKILL.md",[],[]]