Heurist Logo
Back to Skill Marketplace
okx

okx-cex-bot

VerifiedCryptoaccess level:high

This skill should be used when the user asks to 'start a grid bot', 'create a grid bot', 'stop the grid bot', 'show my grid bots', 'grid bot status', 'grid bot P&L', 'create a DCA bot', 'start a DCA bot', 'dollar cost average into BTC', 'set up a martingale bot', 'show my DCA bots', 'stop the DCA bot', 'DCA P&L', or any request involving creating, stopping, querying, or monitoring grid or DCA (Dollar Cost Averaging / Martingale) bots on OKX CEX. Grid and DCA each cover both spot and contract variants. Requires API credentials. Do NOT use for regular spot/swap/futures orders (use okx-cex-trade), market data (use okx-cex-market), or account balance/portfolio (use okx-cex-portfolio).

Install

npx @heurist-network/skills add okx-cex-bot

Installs

6

Stars

35

Timeline

Updated Mar 9, 2026

Created Mar 9, 2026

Verification

Reviewed and verified

SHA256: dcc94ad050984087...

Approved Mar 9, 2026 by admin

Access Level

high

Required Permissions

Requires API KeysRequires Exchange Keys

External APIs

OKX CEX API

Files (1)

SKILL.md

Summary

license
MIT
metadata
author: okxmoltbot: {"emoji":"๐Ÿค–","install":[{"id":"npm","bins":["okx"],"kind":"node","label":"Install okx CLI (npm)","package":"@okx_ai/okx-trade-cli"}],"requires":{"bins":["okx"]}}version: 1.0.0homepage: https://www.okx.com

SKILL.md

OKX CEX Bot Trading CLI

Grid and DCA (Dollar Cost Averaging / Martingale) trading bot management on OKX exchange. All grid and DCA bots in this skill are native OKX platform bots โ€” they run server-side on OKX and do not require a locally running process. Requires API credentials.

Prerequisites

  1. Install okx CLI:

    npm install -g @okx_ai/okx-trade-cli
    
  2. Configure credentials โ€” check first, then set up if missing:

    okx config show   # shows configured profiles; api_key shows last 4 chars if set
    

    If credentials are already configured โ†’ proceed to step 3.

    If not configured, choose one of:

    Option A โ€” Interactive wizard (run this yourself in terminal; preserves existing profiles):

    okx config init          # demo mode (opens browser โ†’ OKX demo API page)
    okx config init          # run again for live mode (creates a second profile)
    

    Creates okx-demo (demo) and/or okx-prod (live) profiles. Each run safely merges into the existing config file without overwriting other profiles.

    Option B โ€” Write config directly (use when no config file exists yet; agent can do this if user provides credentials in chat):

    # Demo only
    mkdir -p ~/.okx && cat > ~/.okx/config.toml << 'EOF'
    default_profile = "okx-demo"
    
    [profiles.okx-demo]
    api_key = "YOUR_API_KEY"
    secret_key = "YOUR_SECRET_KEY"
    passphrase = "YOUR_PASSPHRASE"
    demo = true
    EOF
    
    # Demo + live (both profiles)
    mkdir -p ~/.okx && cat > ~/.okx/config.toml << 'EOF'
    default_profile = "okx-demo"
    
    [profiles.okx-demo]
    api_key = "DEMO_API_KEY"
    secret_key = "DEMO_SECRET_KEY"
    passphrase = "DEMO_PASSPHRASE"
    demo = true
    
    [profiles.okx-prod]
    api_key = "PROD_API_KEY"
    secret_key = "PROD_SECRET_KEY"
    passphrase = "PROD_PASSPHRASE"
    demo = false
    EOF
    

    โš  If ~/.okx/config.toml already exists with other profiles, use Option A (okx config init) instead to avoid overwriting them.

    After writing config: CLI commands pick up the new credentials immediately. MCP tools require a reconnect (restart Claude Desktop or the MCP server process) to reload the config.

    Switch between profiles:

    okx config set default_profile okx-demo   # switch to demo
    okx config set default_profile okx-prod   # switch to live
    okx --profile okx-prod bot grid orders --algoOrdType grid  # one-off override
    
  3. Test with demo mode (simulated trading, no real funds):

    okx --profile demo bot grid orders --algoOrdType grid
    

Credential & Profile Check

Run this check before any authenticated command.

Step A โ€” Verify credentials

okx config show       # verify configuration status (output is masked)
  • If the command returns an error or shows no configuration: stop all operations, guide the user to run okx config init, and wait for setup to complete before retrying.
  • If credentials are configured: proceed to Step B.

Step B โ€” Confirm profile (required)

--profile is required for all authenticated commands. Never add a profile implicitly.

ValueModeFunds
liveๅฎž็›˜Real funds โ€” bot operates with real money
demoๆจกๆ‹Ÿ็›˜Simulated โ€” safe for testing bot configurations

Resolution rules:

  1. Current message intent is clear (e.g. "real" / "ๅฎž็›˜" / "live" โ†’ live; "test" / "ๆจกๆ‹Ÿ" / "demo" โ†’ demo) โ†’ use it and inform the user: "Using --profile live (ๅฎž็›˜)" or "Using --profile demo (ๆจกๆ‹Ÿ็›˜)"
  2. Current message has no explicit declaration โ†’ check conversation context for a previous profile:
    • Found โ†’ use it, inform user: "Continuing with --profile live (ๅฎž็›˜) from earlier"
    • Not found โ†’ ask: "Live (ๅฎž็›˜) or Demo (ๆจกๆ‹Ÿ็›˜)?" โ€” wait for answer before proceeding

Handling 401 Authentication Errors

If any command returns a 401 / authentication error:

  1. Stop immediately โ€” do not retry the same command
  2. Inform the user: "Authentication failed (401). Your API credentials may be invalid or expired."
  3. Guide the user to update credentials by editing the file directly with their local editor:
    ~/.okx/config.toml
    
    Update the fields api_key, secret_key, passphrase under the relevant profile. Do NOT paste the new credentials into chat.
  4. After the user confirms the file is updated, run okx config show to verify (output is masked)
  5. Only then retry the original operation

Demo vs Live Mode

Profile is the single control for ๅฎž็›˜/ๆจกๆ‹Ÿ็›˜ switching โ€” exactly two options:

--profileModeFunds
liveๅฎž็›˜Real funds โ€” bot operates with real money
demoๆจกๆ‹Ÿ็›˜Simulated โ€” no real funds
okx --profile live  bot grid create ...    # ๅฎž็›˜ โ€” real funds
okx --profile demo  bot grid create ...    # ๆจกๆ‹Ÿ็›˜ โ€” simulated funds

Rules:

  1. --profile is required on every authenticated command โ€” determined in "Credential & Profile Check" Step B
  2. Every response after a command must append: [profile: live] or [profile: demo]
  3. Do not use the --demo flag for mode switching โ€” use --profile instead
  4. For bot create/stop operations (write commands), profile must be explicitly confirmed before execution

Example

User: "Start a BTC grid bot"
Agent: "Live (ๅฎž็›˜) or Demo (ๆจกๆ‹Ÿ็›˜)?"
User: "Demo"
Agent runs: okx --profile demo bot grid create --instId BTC-USDT --algoOrdType grid ...
Agent replies: "Grid bot created: 12345678 (OK) โ€” simulated, no real funds used. [profile: demo]"

Skill Routing

  • For market data (prices, charts, depth, funding rates) โ†’ use okx-cex-market
  • For account balance, P&L, positions history, fees, transfers โ†’ use okx-cex-portfolio
  • For regular spot/swap/futures/algo orders โ†’ use okx-cex-trade
  • For grid and DCA trading strategies (native OKX platform bots) โ†’ use okx-cex-bot (this skill)

Quickstart

# Create a spot grid bot on BTC ($90kโ€“$100k, 10 grids, invest 1000 USDT)
okx bot grid create --instId BTC-USDT --algoOrdType grid \
  --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000

# Create a contract grid bot on BTC perp (neutral, 5x leverage, 100 contracts)
# basePos defaults to true for long/short (opens base position); neutral ignores it
okx bot grid create --instId BTC-USDT-SWAP --algoOrdType contract_grid \
  --minPx 90000 --maxPx 100000 --gridNum 10 \
  --direction neutral --lever 5 --sz 100

# List all active grid bots
okx bot grid orders --algoOrdType grid

# Get grid bot details and P&L
okx bot grid details --algoOrdType grid --algoId <algoId>

# Stop a grid bot (keep assets as-is)
okx bot grid stop --algoId <algoId> --algoOrdType grid --instId BTC-USDT --stopType 2

# Create a DCA bot on BTC (3% TP, 3 safety orders, each triggers at 5% drop)
okx bot dca create --instId BTC-USDT \
  --initOrdAmt 50 --safetyOrdAmt 30 --maxSafetyOrds 3 \
  --pxSteps 0.05 --pxStepsMult 1 --volMult 1 \
  --tpPct 0.03 --triggerType 1

# List all active spot DCA bots
okx bot dca orders

# Get DCA bot details
okx bot dca details --algoId <algoId>

# Stop a DCA bot (sell base and get quote)
okx bot dca stop --algoId <algoId> --instId BTC-USDT --stopType 1

Command Index

Grid Bot

#CommandTypeDescription
1okx bot grid createWRITECreate a grid bot
2okx bot grid stopWRITEStop a grid bot
3okx bot grid ordersREADList active or history grid bots
4okx bot grid detailsREADSingle grid bot details + PnL
5okx bot grid sub-ordersREADIndividual grid fills or live orders

DCA Bot

#CommandTypeDescription
6okx bot dca createWRITECreate a DCA bot (spot or contract)
7okx bot dca stopWRITEStop a DCA bot (spot or contract)
8okx bot dca ordersREADList active or history DCA bots
9okx bot dca detailsREADSingle DCA bot details + PnL
10okx bot dca sub-ordersREADIndividual DCA fills, live orders, or cycles

Use --type spot (default) or --type contract to switch between spot and contract DCA.

Cross-Skill Workflows

Spot Grid Bot

User: "Start a BTC grid bot between $90k and $100k with 10 grids, invest 1000 USDT"

1. okx-cex-market    okx market ticker BTC-USDT                     โ†’ confirm price is in range
2. okx-cex-portfolio okx account balance USDT                       โ†’ confirm available funds
        โ†“ user approves
3. okx-cex-bot       okx bot grid create --instId BTC-USDT --algoOrdType grid \
                       --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000
4. okx-cex-bot       okx bot grid orders --algoOrdType grid          โ†’ confirm bot is active
5. okx-cex-bot       okx bot grid details --algoOrdType grid --algoId <id> โ†’ monitor PnL

Contract Grid Bot (Long / Short / Neutral)

User: "Create a long grid bot on BTC perp from $90k to $100k, 10x leverage"

1. okx-cex-market    okx market ticker BTC-USDT-SWAP                โ†’ confirm current price
2. okx-cex-portfolio okx account balance USDT                       โ†’ confirm margin
        โ†“ user approves
3. okx-cex-bot       okx bot grid create --instId BTC-USDT-SWAP --algoOrdType contract_grid \
                       --minPx 90000 --maxPx 100000 --gridNum 10 \
                       --direction long --lever 10 --sz 100
                       # basePos defaults to true (opens base position for long/short)
                       # For short: --direction short; for neutral: --direction neutral
4. okx-cex-bot       okx bot grid orders --algoOrdType contract_grid โ†’ confirm active

Spot DCA Bot

User: "Set up a DCA bot on ETH, initial buy $100, 5 safety orders at 3% drops, 2% TP"

1. okx-cex-market    okx market ticker ETH-USDT                     โ†’ check current price
2. okx-cex-portfolio okx account balance USDT                       โ†’ confirm funds available
        โ†“ user approves
3. okx-cex-bot       okx bot dca create --instId ETH-USDT \
                       --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 5 \
                       --pxSteps 0.03 --pxStepsMult 1 --volMult 1 \
                       --tpPct 0.02 --triggerType 1
4. okx-cex-bot       okx bot dca orders                             โ†’ confirm bot is active
5. okx-cex-bot       okx bot dca details --algoId <id>              โ†’ monitor PnL

Contract DCA Bot (Long / Short)

User: "Start a short DCA bot on BTC perp, 3x leverage, $200 initial, 3% TP"

1. okx-cex-market    okx market ticker BTC-USDT-SWAP               โ†’ confirm current price
2. okx-cex-portfolio okx account balance USDT                       โ†’ confirm margin
        โ†“ user approves
3. okx-cex-bot       okx bot dca create --type contract --instId BTC-USDT-SWAP \
                       --initOrdAmt 200 --safetyOrdAmt 100 --maxSafetyOrds 3 \
                       --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 \
                       --tpPct 0.03 --lever 3 --side sell
                       # For long: --side buy
4. okx-cex-bot       okx bot dca orders --type contract             โ†’ confirm active
5. okx-cex-bot       okx bot dca details --type contract --algoId <id> โ†’ monitor PnL

Monitor and Stop All Bots

User: "Show all my active bots and stop the ones losing money"

1. okx-cex-bot       okx bot grid orders --algoOrdType grid         โ†’ list spot grid bots
2. okx-cex-bot       okx bot grid orders --algoOrdType contract_grid โ†’ list contract grid bots
3. okx-cex-bot       okx bot dca orders [--type contract]           โ†’ list DCA bots
4. okx-cex-bot       okx bot grid details --algoOrdType grid --algoId <id>  โ†’ check PnL
5. okx-cex-bot       okx bot grid stop --algoId <id> --algoOrdType grid --instId BTC-USDT --stopType 2

Operation Flow

Step 0 โ€” Credential & Profile Check

Before any authenticated command:

Determine profile (required):

  • Options: live (ๅฎž็›˜) or demo (ๆจกๆ‹Ÿ็›˜) โ€” exactly these two values
  1. Current message intent clear (e.g. "real"/"ๅฎž็›˜"/"live" โ†’ live; "test"/"ๆจกๆ‹Ÿ"/"demo" โ†’ demo) โ†’ use it, inform user: "Using --profile live (ๅฎž็›˜)"
  2. Current message has no explicit declaration โ†’ check conversation context for previous profile:
    • Found โ†’ use it, inform user: "Continuing with --profile live (ๅฎž็›˜) from earlier"
    • Not found โ†’ ask: "Live (ๅฎž็›˜) or Demo (ๆจกๆ‹Ÿ็›˜)?" โ€” wait for answer

If no credentials configured: guide user to run okx config init, stop all trading actions

After every command result: append [profile: live] or [profile: demo] to the response

Step 1: Identify Bot Type and Action

  • Grid bot create โ†’ okx bot grid create
  • Grid bot stop โ†’ okx bot grid stop
  • Grid bot status/P&L โ†’ okx bot grid orders + okx bot grid details
  • Grid individual fills โ†’ okx bot grid sub-orders
  • DCA bot create โ†’ okx bot dca create (add --type contract for contract DCA)
  • DCA bot stop โ†’ okx bot dca stop (add --type contract for contract DCA)
  • DCA bot status/P&L โ†’ okx bot dca orders + okx bot dca details
  • DCA individual fills/cycles โ†’ okx bot dca sub-orders

Step 2: Run Read Commands Immediately โ€” Confirm Profile (Step 0) then Writes

Read commands (orders, details, sub-orders): run immediately.

  • --algoOrdType for grid โ†’ infer from context (grid for spot, contract_grid for perp)
  • --type for DCA โ†’ defaults to spot; use --type contract for contract DCA
  • --history โ†’ use default (active); only query history if explicitly requested

Write commands (create, stop): confirm once before executing.

  • Grid create: confirm --minPx, --maxPx, --gridNum; verify --minPx < current price < --maxPx; confirm investment size
    • Spot grid: --quoteSz (USDT) or --baseSz (base currency)
    • Contract grid: --direction (long/short/neutral), --lever, --sz (number of contracts); --basePos defaults to true (open base position for long/short)
  • DCA create: confirm --initOrdAmt, --safetyOrdAmt, --maxSafetyOrds, --pxSteps, --tpPct
    • Spot DCA: requires --triggerType (1=instant, 2=RSI); default --type spot
    • Contract DCA: add --type contract, --lever, and --side (buy=long, sell=short)
  • Grid stop: confirm --stopType (default omitted โ†’ keep assets; 1=sell all to quote)
  • DCA stop: confirm --stopType (1=sell base to quote, default; 2=keep base)
  • Demo dry-run: suggest okx --profile demo bot grid create ... when user is unsure

โš  Insufficient balance โ€” NEVER auto-transfer funds. If the trading account balance is insufficient to create a bot, do NOT automatically initiate a fund transfer (account_transfer). Instead, inform the user of the shortfall (current available vs. required amount) and ask how they want to proceed. Suggested options to present:

  1. Transfer funds from funding account to trading account (specify amount)
  2. Reduce the investment size to fit available balance
  3. Cancel the bot creation

Step 3: Verify After Writes

  • After grid create: run okx bot grid orders to confirm bot is active; then okx bot grid details to monitor PnL
  • After DCA create: run okx bot dca orders to confirm bot is active; then okx bot dca details for details
  • After stop: run okx bot grid orders --history / okx bot dca orders --history to confirm bot is stopped

CLI Command Reference

Grid Bot โ€” Create

okx bot grid create --instId <id> --algoOrdType <type> \
  --maxPx <px> --minPx <px> --gridNum <n> \
  [--runType <1|2>] \
  [--quoteSz <n>] [--baseSz <n>] \
  [--direction <long|short|neutral>] [--lever <n>] [--sz <n>] \
  [--basePos] [--no-basePos] \
  [--json]
ParamRequiredDefaultDescription
--instIdYes-Instrument (e.g., BTC-USDT for spot grid, BTC-USDT-SWAP for contract grid)
--algoOrdTypeYes-grid (spot grid) or contract_grid (contract grid)
--maxPxYes-Upper price boundary
--minPxYes-Lower price boundary
--gridNumYes-Grid levels (2โ€“100)
--runTypeNo11=arithmetic spacing, 2=geometric spacing
--quoteSzCond.-USDT investment โ€” spot grid only (provide quoteSz or baseSz)
--baseSzCond.-Base currency investment โ€” spot grid only
--directionCond.-long, short, or neutral โ€” contract grid only
--leverCond.-Leverage (e.g., 5) โ€” contract grid only
--szCond.-Number of contracts to invest โ€” contract grid only
--basePos / --no-basePosNotrueOpen a base position at creation โ€” contract grid only (ignored for neutral direction). Default is true (opens base position). Use --no-basePos to disable.

Grid Bot โ€” Stop

okx bot grid stop --algoId <id> --algoOrdType <type> --instId <id> \
  [--stopType <1|2|3|5|6>] [--json]
--stopTypeBehavior
1Stop + sell/close all positions at market
2Stop + keep current assets as-is (default)
3Stop + close at limit prices
5Stop + partial close
6Stop without selling (smart arbitrage)

Grid Bot โ€” List Orders

okx bot grid orders --algoOrdType <type> [--instId <id>] [--algoId <id>] [--history] [--json]
ParamRequiredDefaultDescription
--algoOrdTypeYes-grid or contract_grid
--instIdNo-Filter by instrument
--algoIdNo-Filter by algo ID
--historyNofalseShow completed/stopped bots instead of active

Grid Bot โ€” Details

okx bot grid details --algoOrdType <type> --algoId <id> [--json]

Returns: bot config, current PnL (pnlRatio), grid range, number of grids, state, position info.


Grid Bot โ€” Sub-Orders

okx bot grid sub-orders --algoOrdType <type> --algoId <id> [--live] [--json]
FlagEffect
(default)Filled sub-orders (executed grid trades)
--livePending grid orders currently on the book

DCA Bot โ€” Create

# Spot DCA (default)
okx bot dca create --instId <id> \
  --initOrdAmt <n> --safetyOrdAmt <n> --maxSafetyOrds <n> \
  --pxSteps <ratio> --pxStepsMult <mult> --volMult <mult> \
  --tpPct <ratio> [--slPct <ratio>] \
  --triggerType <1|2> \
  [--reserveFunds <true|false>] [--json]

# Contract DCA
okx bot dca create --type contract --instId <id> \
  --initOrdAmt <n> --safetyOrdAmt <n> --maxSafetyOrds <n> \
  --pxSteps <ratio> --pxStepsMult <mult> --volMult <mult> \
  --tpPct <ratio> [--slPct <ratio>] \
  --lever <n> --side <buy|sell> \
  [--reserveFunds <true|false>] [--json]
ParamRequiredDefaultDescription
--typeNospotspot or contract
--instIdYes-Instrument (e.g., BTC-USDT for spot, BTC-USDT-SWAP for contract)
--initOrdAmtYes-Initial order amount in USDT
--safetyOrdAmtYes-Safety order amount in USDT
--maxSafetyOrdsYes-Max number of safety orders (e.g., 3)
--pxStepsYes-Price drop % per safety order (e.g., 0.03 = 3%)
--pxStepsMultYes-Price step multiplier between safety orders (e.g., 1.2)
--volMultYes-Safety order size multiplier (e.g., 1.5)
--tpPctYes-Take-profit ratio (e.g., 0.03 = 3%)
--slPctNo-Stop-loss ratio (e.g., 0.05 = 5%)
--reserveFundsNofalsePre-reserve full required assets upfront
--triggerTypeSpot only-1=instant start, 2=RSI signal trigger
--leverContract only-Leverage multiplier (e.g., 3)
--sideContract only-buy=long, sell=short

DCA Bot โ€” Stop

okx bot dca stop [--type <spot|contract>] --algoId <id> --instId <id> \
  [--stopType <1|2>] [--json]
--stopTypeBehavior
1Sell base currency to quote at market (cash out) โ€” default
2Keep base currency as-is

DCA Bot โ€” List Orders

okx bot dca orders [--type <spot|contract>] [--history] [--json]
ParamRequiredDefaultDescription
--typeNospotspot or contract
--historyNofalseShow completed/stopped bots instead of active

DCA Bot โ€” Details

okx bot dca details [--type <spot|contract>] --algoId <id> [--json]

Returns: bot config, current PnL (pnlRatio), safety orders triggered, state. Contract also returns direction, lever, avgPx.


DCA Bot โ€” Sub-Orders

okx bot dca sub-orders [--type <spot|contract>] --algoId <id> [--live] [--cycleId <id>] [--json]
Flag / ParamEffect
(default, spot)Filled sub-orders (executed DCA buys)
--liveSpot: pending orders currently on the book
(default, contract)List all cycles
--cycleId <id>Contract: show orders within a specific cycle

MCP Tool Reference

CLI and MCP tools share the same underlying tool layer. MCP tools accept type=spot or type=contract directly.

ToolDescription
dca_create_orderCreate spot or contract DCA bot
dca_stop_orderStop spot or contract DCA bot
dca_get_ordersList spot or contract DCA bots
dca_get_order_detailsSingle DCA bot details
dca_get_sub_ordersSub-orders (spot) or cycles (contract)

Input / Output Examples

"Start a BTC grid bot from $90k to $100k with 10 grids"

okx bot grid create --instId BTC-USDT --algoOrdType grid \
  --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000
# โ†’ Grid bot created: 12345678 (OK)

"Show all my active grid bots"

okx bot grid orders --algoOrdType grid

"What's the P&L on my BTC grid bot?"

okx bot grid details --algoOrdType grid --algoId 12345678
# โ†’ pnlRatio, pnl, investAmt, totalAnnRate, runType, gridNum, maxPx, minPx

"Stop my BTC grid bot and keep the assets"

okx bot grid stop --algoId 12345678 --algoOrdType grid --instId BTC-USDT --stopType 2

"Create a DCA bot on ETH: $100 initial, safety orders at 3% drops, 2% TP"

okx bot dca create --instId ETH-USDT \
  --initOrdAmt 100 --safetyOrdAmt 50 --maxSafetyOrds 3 \
  --pxSteps 0.03 --pxStepsMult 1 --volMult 1 \
  --tpPct 0.02 --triggerType 1
# โ†’ DCA bot created: 87654321 (OK)

"Show my active DCA bots"

okx bot dca orders

"How is my ETH DCA bot doing?"

okx bot dca details --algoId 87654321
# โ†’ current PnL, avg entry, safety orders triggered, TP target

"Stop my ETH DCA bot and sell everything"

okx bot dca stop --algoId 87654321 --instId ETH-USDT --stopType 1

"Create a contract DCA bot on BTC perp, long, 3x leverage, 2% TP"

okx bot dca create --type contract --instId BTC-USDT-SWAP \
  --initOrdAmt 200 --safetyOrdAmt 100 --maxSafetyOrds 3 \
  --pxSteps 0.03 --pxStepsMult 1.2 --volMult 1.5 \
  --tpPct 0.02 --lever 3 --side buy

Edge Cases

Grid Bot

  • Price out of range: --minPx must be < current price < --maxPx; check with okx-cex-market first
  • 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 (see Step 2)
  • Contract grid direction: long (buys more at lower prices), short (sells at higher), neutral (both)
  • Contract grid basePos: defaults to true โ€” long/short grids automatically open a base position at creation. Neutral direction ignores this. Pass --no-basePos to disable.
  • Contract grid --sz: number of contracts, not USDT amount
  • Stop type: stopType 1 sells/closes all; stopType 2 keeps assets; stopType 5/6 for contract grid positions
  • Already stopped bot: stop returns error โ€” check bot grid orders --history first to confirm state
  • Demo mode: okx --profile demo bot grid create ... โ€” safe for testing, no real funds

DCA Bot

  • 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 (see Step 2)
  • pxStepsMult: use 1.0 for equal price spacing; >1.0 to widen gaps between successive safety orders
  • volMult: use 1.0 for equal safety order sizes; >1.0 to increase size per safety order (Martingale)
  • triggerType 2 (RSI): requires additional RSI parameters โ€” use 1 (instant) unless specifically requested
  • Stop type: stopType 1 sells base to quote (cash out); stopType 2 keeps base currency as-is
  • Already stopped bot: stop returns error โ€” check bot dca orders --history first to confirm state
  • Contract DCA: add --type contract to any DCA CLI command; create also requires --lever and --side

Communication Guidelines

  • Use "bot" not "strategy" when referring to grid or DCA in user-facing responses (e.g., "grid bot", "DCA bot" โ€” not "grid strategy" or "DCA strategy").
  • Always refer to DCA bots as "DCA" โ€” do not translate to "ๅฎšๆŠ•" or "recurring buy". The underlying mechanism is Martingale (้ฉฌไธๆ ผๅฐ”), not simple dollar cost averaging. Use "DCA" in all user-facing responses regardless of language.
  • Grid bot can be referred to as "็ฝ‘ๆ ผ" in Chinese contexts.

Global Notes

  • Grid and DCA bots are native OKX platform bots โ€” they run entirely on OKX servers; stopping the CLI does not affect them
  • All write commands require valid credentials in ~/.okx/config.toml or env vars
  • --profile <name> is required for all authenticated commands; see "Credential & Profile Check" section
  • Every command result includes a [profile: <name>] tag for audit reference
  • --json returns raw OKX API v5 response
  • Rate limit: 20 requests per 2 seconds per UID for all bot operations
  • Grid --gridNum range: 2โ€“100
  • DCA safety orders are triggered sequentially as price drops by --pxSteps increments
  • Contract DCA automatically starts with an instant trigger (set by the tool internally)