Agent skill

Okx Cex Trade

by okx in okx/agent-skills

A skill your agent uses when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a…

MITAuto-check passedBusiness, Finance & HR

Install Okx Cex Trade

skills CLI
$ npx skills add okx/agent-skills --skill okx-cex-trade -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install okx/agent-skills okx-cex-trade --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/okx/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/okx-cex-trade .claude/skills/okx-cex-trade && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
okx-cex-trade
GitHub stars
187
Used in
2 other repos
Token cost
~7k tokens
SKILL.md length
3,161 words
Files
9 (incl. references)
Skills in repo
10
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a…

  • Works in 4 steps: Credential & Profile Check → Identify instrument type and action → Confirm profile, then confirm write… → …
  • The user asks to buy BTC
  • SKILL.md covers Preflight, Prerequisites, Credential & Profile Check and Demo vs Live Mode, plus 6 more sections
  • Calls npm and curl; reaches okx.com

What it does

Okx Cex Trade is an agent skill from okx/agent-skills. Use when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a position', 'close a position', 'set take profit', 'limit take profit', 'immediate TP', 'set stop loss', 'self-trade prevention', 'stpMode', 'auto-cancel on close', 'trailing stop', 'pending order', 'chase order', 'iceberg', 'TWAP', 'split order', 'large order', 'set leverage', 'check my orders', 'fill history', 'buy a call', 'sell a put'…

Its SKILL.md is about 7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including reference files (for example `references/event-commands.md`, `references/event-workflows.md` and `references/futures-commands.md`).

It sits in Business, Finance & HR, covering Stock and market analysis and Trading and backtesting. It works with OKX. The repository describes itself as: Plug-and-play AI agent skills for OKX — letting any LLM agent trade, manage portfolios, query live market data, and run grid/DCA bots through a single okx CLI, no API wiring… The licence is MIT.

When your agent uses it

  • The user asks to buy BTC
  • Place a limit order
  • Place a market order
  • Cancel my order

Example prompts

  • “buy BTC”
  • “sell ETH”
  • “place a limit order”
  • “/okx-cex-trade”

Requirements

  • Node.js

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Credential & Profile Check
  2. Identify instrument type and action
  3. Confirm profile, then confirm write parameters
  4. Verify after writes

What it can do on your machine

Read from SKILL.md and the folder at commit 9c180cc. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • curl

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • okx.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Okx Cex Trade loads about 7k tokens when it runs, and up to ~29k if it reads all its reference files. Until then it costs about 243 tokens; SKILL.md has 3,161 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~243
When it runs · the whole SKILL.md, loaded when a task matches
~7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~29k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from okx/agent-skills at commit 9c180cc, republished under its MIT licence (© okx). 3,161 words, ~6,964 tokens.

Download SKILL.mdSave it as .claude/skills/okx-cex-trade/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.
name
okx-cex-trade
description
Use when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a position', 'close a position', 'set take profit', 'limit take profit', 'immediate TP', 'set stop loss', 'self-trade prevention', 'stpMode', 'auto-cancel on close', 'trailing stop', 'pending order', 'chase order', 'iceberg', 'TWAP', 'split order', 'large order', 'set leverage', 'check my orders', 'fill history', 'buy a call', 'sell a put', 'option chain', 'implied volatility', 'IV', 'Greeks', 'delta', 'gamma', 'event contract', 'buy Yes', 'buy No', 'buy Up', 'buy Down', 'prediction market', or any request to place, cancel, or amend spot, swap, futures, options, or event contract orders on OKX CEX. Covers conditional (TP/SL/trailing) algo orders. Requires API credentials. Do NOT use for market data (okx-cex-market), account balance (okx-cex-portfolio), or bots (okx-cex-bot).
license
MIT
metadata.author
okx
metadata.version
1.4.8
metadata.homepage
https://www.okx.com

OKX CEX Trading CLI

Spot, perpetual swap, delivery futures, options, and event contract order management on OKX exchange. Place, cancel, amend, and monitor orders; query option chains and Greeks; trade binary outcome event contracts (Yes/No, Up/Down); set take-profit/stop-loss and trailing stops; manage leverage and positions. Requires API credentials.

CLI vs MCP tool names — Subcommands use spaces (okx swap algo place, okx bot grid create), not hyphens. Do NOT convert an MCP tool identifier (swap_place_algo_order) into a hyphen-joined CLI command (okx swap place-algo) — that will be rejected with "Unknown command". Per-module mapping tables live in references/<module>-commands.md.

Preflight

Before running any command, follow ../_shared/preflight.md. Use metadata.version from this file's frontmatter as the reference for Step 2.

Prerequisites

  1. Install okx CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. Configure credentials:
    bash
    okx config init   # select site -> follow browser OAuth flow
  3. Test with demo mode (simulated trading, no real funds):
    bash
    okx --demo spot orders

Security: NEVER accept credentials in chat. Guide users to okx config init for setup.

Credential & Profile Check

Run this check before any 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.

bash
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 all operations, load okx-cex-auth skill and follow login steps, wait for completion.
Step B — Confirm trading mode

Resolution rules:

  1. Current message intent is clear (e.g. "real" / "实盘" / "live" → live; "test" / "模拟" / "demo" → demo) → use it and inform the user
  2. Current message has no explicit declaration → check conversation context for a previous choice:
    • Found → reuse it, inform user
    • Not found → ask: "Live (实盘) or Demo (模拟盘)?" — wait for answer 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. Use --profile <name> to select the correct one.
  • OAuth users: omit flags for live trading; add --demo for simulated trading. Do not use --profile to switch modes.
Handling Authentication Errors

Authentication error (error contains "401", "Session expired", or "Run okx auth login first"):

  1. Stop immediately — do not retry the same command
  2. Inform the user: "Authentication failed. Your session may have expired."
  3. Load okx-cex-auth skill and follow the re-authentication steps
  4. After successful re-authentication, retry the original command

Demo vs Live Mode

ModeFundsAPI Key paramOAuth param
实盘 (live)Real money — irreversible--profile <live-profile>(default, no flag)
模拟盘 (demo)Simulated — no real funds--profile <demo-profile>--demo

Rules:

  1. Trading mode is required on every authenticated command — determined in "Credential & Profile Check" Step B
  2. Every response after a command must append: [mode: live] or [mode: demo]

Skill Routing

  • For market data (prices, charts, depth, funding rates) → use okx-cex-market
  • For account balance, P&L, positions, fees, transfers → use okx-cex-portfolio
  • For regular spot/swap/futures/options/algo orders → use okx-cex-trade (this skill)
  • For browsing/discovering event contracts (what's available, how many, list active) → use okx-cex-trade with okx event browse / okx event series
  • For trading event contracts (place/cancel/amend prediction market orders) → use okx-cex-trade with okx event place / okx event cancel / okx event amend
  • For grid and DCA trading bots → use okx-cex-bot

Important: When user asks about "contracts" in the context of event contracts or prediction markets, route to this skill — NOT to okx-cex-portfolio. Portfolio does not handle event contracts — it covers account balance, positions, P&L, and transfers only.

Sz Handling for Derivatives

⚠ CRITICAL: Always verify contract face value before placing orders

Before placing any SWAP/FUTURES/OPTION order, call market_get_instruments to get ctVal (contract face value). Do NOT assume contract sizes — they vary by instrument (e.g. ETH-USDT-SWAP = 0.1 ETH/contract, BTC-USDT-SWAP = 0.01 BTC/contract).

Use ctVal to:

  • Calculate the correct number of contracts from user's intended position size
  • Verify margin requirements before submitting the order
  • Show the user the actual position value: sz × ctVal × price
SWAP and FUTURES orders

Three tgtCcy modes for USDT-denominated sizing:

--tgtCcysz meaningConversion formulaExample: "500U" at 10x lever
base_ccy (default)contract countno conversion500 contracts
quote_ccyUSDT notional valuefloor(sz / (ctVal * lastPx))500 USDT notional
marginUSDT margin costfloor(sz * lever / (ctVal * lastPx))500 USDT margin = 5000 USDT notional

When user specifies a USDT amount (e.g. "200U", "500 USDT", "$1000"): → AMBIGUOUS — this could mean notional value OR margin cost. You MUST ask the user to clarify before proceeding:

  • notional value: sz = position value in USDT (e.g. 500 USDT buys 500 USDT worth of contracts directly)
  • margin cost: actual position = sz × leverage (e.g. 500 USDT margin at 10× = 5000 USDT notional position) Wait for the user's answer before continuing.
  • If notional value → use --tgtCcy quote_ccy
  • If margin cost → use --tgtCcy margin

When user specifies contracts (e.g. "2 张", "5 contracts"): → First verify ctVal via market_get_instruments, then use --sz with the contract count. Confirm with user: "X contracts = X × ctVal underlying, total value ≈ $Y".

When user gives a plain number with no unit (for swap/futures): → AMBIGUOUS — You MUST ask the user to clarify before proceeding:

  • contract count: X contracts (each worth ctVal of underlying)
  • USDT notional value: position value in USDT
  • USDT margin cost: margin amount (actual position = X × leverage) Wait for the user's answer before continuing.

⚠ Inverse contracts (*-USD-SWAP, *-USD-YYMMDD): tgtCcy=quote_ccy and tgtCcy=margin also work (note: quote_ccy = USD, not USDT, for inverse instruments). Always warn: "This is an inverse contract. Margin and P&L are settled in BTC, not USDT."

Option orders

When the user specifies a USDT amount for options, use --tgtCcy quote_ccy (notional) or --tgtCcy margin (margin cost) and pass the amount as --sz. The system automatically converts to contracts. Note: option contracts typically have large face values (e.g. ctVal=1 BTC ≈ $84,000), so the minimum USDT amount for 1 contract is high. For option sellers (cross/isolated tdMode), margin mode accounts for leverage automatically.

Quickstart

bash
# Market buy 0.01 BTC (spot)
okx spot place --instId BTC-USDT --side buy --ordType market --sz 0.01

# Buy $10 worth of SOL (spot, USDT amount)
okx spot place --instId SOL-USDT --side buy --ordType market --sz 10 --tgtCcy quote_ccy

# Limit sell 0.01 BTC at $100,000 (spot)
okx spot place --instId BTC-USDT --side sell --ordType limit --sz 0.01 --px 100000

# Long 1 contract BTC perp (cross margin)
okx swap place --instId BTC-USDT-SWAP --side buy --ordType market --sz 1 \
  --tdMode cross --posSide long

# Long 1000 USDT notional value of BTC perp (auto-convert to contracts)
okx swap place --instId BTC-USDT-SWAP --side buy --ordType market --sz 1000 \
  --tgtCcy quote_ccy --tdMode cross --posSide long

# Long with 500 USDT margin at current leverage (e.g. 10x → 5000 USDT notional)
okx swap place --instId BTC-USDT-SWAP --side buy --ordType market --sz 500 \
  --tgtCcy margin --tdMode cross --posSide long

# Long 1 contract with attached TP/SL (one step)
okx swap place --instId BTC-USDT-SWAP --side buy --ordType market --sz 1 \
  --tdMode cross --posSide long \
  --tpTriggerPx 105000 --tpOrdPx=-1 --slTriggerPx 88000 --slOrdPx=-1

# Close BTC perp long position entirely at market
okx swap close --instId BTC-USDT-SWAP --mgnMode cross --posSide long

# Set 10x leverage on BTC perp (cross)
okx swap leverage --instId BTC-USDT-SWAP --lever 10 --mgnMode cross

# Set TP/SL on a spot BTC position
okx spot algo place --instId BTC-USDT --side sell --ordType oco --sz 0.01 \
  --tpTriggerPx 105000 --tpOrdPx=-1 \
  --slTriggerPx 88000 --slOrdPx=-1

# Place trailing stop on BTC perp long (callback 2%)
okx swap algo trail --instId BTC-USDT-SWAP --side sell --sz 1 \
  --tdMode cross --posSide long --callbackRatio 0.02

# View open spot orders
okx spot orders

# View open swap positions
okx swap positions

# Cancel a spot order
okx spot cancel --instId BTC-USDT --ordId <ordId>

# --- Event Contract ---
# List event series
okx event series

# Browse live markets in a series
okx event markets BTC-ABOVE-DAILY --state live

# Place event contract order
okx event place --instId BTC-ABOVE-DAILY-260224-1600-70000 --side buy --outcome YES --sz 10

Command Index

Spot Orders (12 commands)
#CommandTypeDescription
1okx spot placeWRITEPlace spot order (market/limit/post_only/fok/ioc)
2okx spot cancelWRITECancel spot order
3okx spot amendWRITEAmend spot order price or size
4okx spot algo placeWRITEPlace spot TP/SL algo order
5okx spot algo amendWRITEAmend spot TP/SL levels
6okx spot algo cancelWRITECancel spot algo order
7okx spot algo trailWRITEPlace spot trailing stop order
8okx spot ordersREADList open or historical spot orders
9okx spot getREADSingle spot order details
10okx spot fillsREADSpot trade fill history
11okx spot algo ordersREADList spot TP/SL algo orders
12okx spot leverageWRITESet leverage for spot margin (borrowing). Pair-level (--instId) or currency-level cross (--ccy, required for borrow-enabled / multi-ccy / portfolio margin)

For full command syntax, parameter tables, and edge cases, read {baseDir}/references/spot-commands.md.

Swap / Perpetual Orders (15 commands)
#CommandTypeDescription
13okx swap placeWRITEPlace perpetual swap order
14okx swap cancelWRITECancel swap order
15okx swap amendWRITEAmend swap order price or size
16okx swap closeWRITEClose entire position at market
17okx swap leverageWRITESet leverage for an instrument
18okx swap algo placeWRITEPlace swap TP/SL algo order
19okx swap algo trailWRITEPlace swap trailing stop order
20okx swap algo amendWRITEAmend swap algo order
21okx swap algo cancelWRITECancel swap algo order
22okx swap positionsREADOpen perpetual swap positions
23okx swap ordersREADList open or historical swap orders
24okx swap getREADSingle swap order details
25okx swap fillsREADSwap trade fill history
26okx swap get-leverageREADCurrent leverage settings
27okx swap algo ordersREADList swap algo orders

For full command syntax, parameter tables, and edge cases, read {baseDir}/references/swap-commands.md.

Futures / Delivery Orders (15 commands)
#CommandTypeDescription
28okx futures placeWRITEPlace delivery futures order
29okx futures cancelWRITECancel delivery futures order
30okx futures amendWRITEAmend delivery futures order price or size
31okx futures closeWRITEClose entire futures position at market
32okx futures leverageWRITESet leverage for a futures instrument
33okx futures algo placeWRITEPlace futures TP/SL algo order
34okx futures algo trailWRITEPlace futures trailing stop order
35okx futures algo amendWRITEAmend futures algo order
36okx futures algo cancelWRITECancel futures algo order
37okx futures ordersREADList delivery futures orders
38okx futures positionsREADOpen delivery futures positions
39okx futures fillsREADDelivery futures fill history
40okx futures getREADSingle delivery futures order details
41okx futures get-leverageREADCurrent futures leverage settings
42okx futures algo ordersREADList futures algo orders

For full command syntax, parameter tables, and edge cases, read {baseDir}/references/futures-commands.md.

Options Orders (10 commands)
#CommandTypeDescription
43okx option instrumentsREADOption chain: list available contracts for an underlying
44okx option greeksREADImplied volatility + Greeks (delta/gamma/theta/vega) by underlying
45okx option placeWRITEPlace option order (call or put, buyer or seller)
46okx option cancelWRITECancel unfilled option order
47okx option amendWRITEAmend option order price or size
48okx option batch-cancelWRITEBatch cancel up to 20 option orders
49okx option ordersREADList option orders (live / history / archive)
50okx option getREADSingle option order details
51okx option positionsREADOpen option positions with live Greeks
52okx option fillsREADOption trade fill history

For full command syntax, USDT-to-contracts conversion formula, tdMode rules, and edge cases, read {baseDir}/references/options-commands.md.

Event Contract Orders (9 commands)
#CommandTypeDescription
53okx event browseREADBrowse active event contracts grouped by type (series + live markets in one call)
54okx event seriesREADList event series (e.g. BTC-ABOVE-DAILY, BTC-UPDOWN-15MIN)
55okx event events <seriesId>READList events in a series
56okx event markets <seriesId>READList markets; expired includes Outcome and Settlement value
57okx event place ...WRITEPlace event order (outcome required)
58okx event amend <instId> <ordId>WRITEAmend event order (price/size)
59okx event cancel <instId> <ordId>WRITECancel event order
60okx event ordersREADPending or historical orders
61okx event fillsREADFill history

For full command syntax, parameter tables, and edge cases, read {baseDir}/references/event-commands.md.

Operation Flow

Step 0 — Credential & Profile Check

Before any authenticated command: see Credential & Profile Check. Determine auth method and trading mode before executing.

After every command result: append [mode: live] or [mode: demo].

Show full SKILL.md (1,351 more words)Show less
Step 1 — Identify instrument type and action

Spot (instId format: BTC-USDT):

  • Place/cancel/amend order → okx spot place/cancel/amend
  • TP/SL conditional → okx spot algo place/amend/cancel
  • Trailing stop → okx spot algo trail
  • Query → okx spot orders/get/fills/algo orders

Swap/Perpetual (instId format: BTC-USDT-SWAP):

  • Place/cancel/amend order → okx swap place/cancel/amend
  • Close position → okx swap close
  • Leverage → okx swap leverage / okx swap get-leverage
  • TP/SL conditional → okx swap algo place/amend/cancel
  • Trailing stop → okx swap algo trail
  • Query → okx swap positions/orders/get/fills/get-leverage/algo orders

Futures/Delivery (instId format: BTC-USDT-<YYMMDD>):

  • Place/cancel/amend order → okx futures place/cancel/amend
  • Close position → okx futures close
  • Leverage → okx futures leverage / okx futures get-leverage
  • TP/SL conditional → okx futures algo place/amend/cancel
  • Trailing stop → okx futures algo trail
  • Query → okx futures orders/positions/fills/get/get-leverage/algo orders

Options (instId format: BTC-USD-250328-95000-C or ...-P):

  • Step 1 (required): find valid instId → okx option instruments --uly BTC-USD
  • Step 2 (recommended): check IV and Greeks → okx option greeks --uly BTC-USD
  • Place/cancel/amend → okx option place/cancel/amend
  • Batch cancel → okx option batch-cancel --orders '[...]'
  • Query → okx option orders/get/positions/fills
  • tdMode: cash for buyers; cross or isolated for sellers

Event Contracts:

Instrument ID (instId, API field) format: {UNDERLYING}-{TYPE}-{YYMMDD}-{HHMM}-{STRIKE} for "Price Above Target" / "One Touch" contracts (e.g. BTC-ABOVE-DAILY-260224-1600-70000), or {UNDERLYING}-{TYPE}-{YYMMDD}-{START}-{END} for "Price Direction (Up/Down)" contracts (e.g. BTC-UPDOWN-15MIN-260224-1600-1615). Always obtain the instrument ID from okx event markets <seriesId> — never guess or use placeholders.

Series ID (seriesId, API field): human-readable (e.g. BTC-ABOVE-DAILY, BTC-UPDOWN-15MIN) or internal random string (e.g. FMQRZ). Both are valid for subsequent commands. Obtain from okx event series.

Event contract trading flow:

  1. Discover → okx event browse (preferred, returns series + live markets in one call) or okx event series — present results grouped by type; highlight named series; always show the Series ID
  2. Browse live markets → okx event markets <seriesId> --state live — obtains the instrument ID for each tradeable contract; if a live Price is shown, it is the event contract price (0.01–0.99), not the underlying asset price — reflects the market-implied probability when actively trading
  3. Check event details → okx event events <seriesId>
  4. Confirm + Place → okx event place <instId> <side> <outcome> <sz> — only after user explicitly confirms
  5. Track → okx event orders --status open / okx account positions --instType EVENTS
  6. Exit or settle → sell via okx event place <instId> sell <outcome> <sz>, or wait for --state expired

Edge cases:

  • Settled results: okx event markets <seriesId> --state expired — no separate ended tool

Event Contract sz Rules:

  • Market order (ordType=market): --sz is quote currency amount.
  • Limit order (ordType=limit / post_only): --sz is number of contracts (integer). Each contract settles at 1 unit of quote currency; cost per contract = px (event contract price, 0.01–0.99). E.g. 10 contracts at px=0.5 costs 5.
  • px semantics: px is the event contract price (0.01–0.99), NOT the underlying asset price. When actively trading, it reflects the market-implied probability. Example: px=0.6 means the market is pricing the event at roughly 60%.
  • Outcome display: expired/result views show translated values. For price_up_down, treat YES/NO as UP/DOWN.

For event contract workflows and step-by-step examples, read {baseDir}/references/event-workflows.md.

For cross-skill workflows and step-by-step examples, read {baseDir}/references/workflows.md.

Step 2 — Confirm profile, then confirm write parameters

Read commands (orders, positions, fills, get, get-leverage, algo orders): run immediately.

  • --history flag: defaults to active/open; use --history only if user explicitly asks for history
  • --ordType for algo: conditional = single TP or SL; oco = both TP and SL together
  • --tdMode for swap/futures: cross or isolated; spot always uses cash (set automatically)
  • --posSide for hedge mode: long or short; omit in net mode

Write commands (place, cancel, amend, close, leverage, algo): confirm the key order details once before executing:

  • Spot place: confirm --instId, --side, --ordType, --sz (and --tgtCcy quote_ccy if quote-currency amount)
  • Swap/Futures place: confirm --instId, --side, --sz, --tdMode, and explicitly confirm order mode when user specifies a USDT amount: --tgtCcy quote_ccy (notional value, sz = position value) or --tgtCcy margin (margin cost, actual position = sz * leverage). Always state which mode is being used.
  • Option place: confirm --instId, --side, --sz, --tdMode (and --tgtCcy quote_ccy or --tgtCcy margin if USDT amount — system auto-converts); do NOT attach TP/SL
  • Event Contract place: confirm --instId, --side, --outcome, --sz, --ordType; for market orders sz is quote currency amount, for limit orders sz is number of contracts + --px required
  • Swap/Futures close: confirm --instId, --mgnMode, --posSide
  • Leverage: confirm new leverage and impact on existing positions. Pre-checks to avoid common 400s: (a) --lever must be a positive number within the instrument's max (see okx market instruments → lever); (b) for --mgnMode isolated in hedge pos mode, --posSide is required — each side (long, short) must be set separately, setting one does NOT auto-apply to the other; (c) portfolio-margin accounts cannot adjust cross leverage for SWAP/FUTURES — OKX will reject; if unsure, run okx account config and check acctLv first. If set-leverage fails (error mentions "cancel orders or stop bots"): troubleshoot in priority order — (1) query pending algo orders first (swap/futures algo-orders --status pending), as this is the most common blocker; (2) only if no algo orders, check active bots (bot grid-orders). Do NOT automatically cancel orders or stop bots — present findings and let the user decide
  • Algo place (TP/SL): confirm trigger prices; use --tpOrdPx=-1 for market execution
  • Algo trail: confirm --callbackRatio (e.g., 0.02 = 2%) or --callbackSpread

For full parameter details per command, read the relevant reference file.

Error-suggested remediation safeguard

When an OKX API error message suggests a fix that involves write operations (cancel orders, close positions, stop bots/strategies, transfer funds, etc.), you MUST NOT automatically execute those actions. Instead:

  1. Report the error and its suggestion to the user verbatim
  2. Diagnose — run read-only queries to identify what is blocking (e.g., algo-orders --status pending, positions, bot grid-orders --status active)
  3. Present findings — show the user what was found and which specific items would need to be cancelled/closed/stopped
  4. Wait for explicit confirmation before executing any remediation

This applies to all error codes whose messages suggest destructive actions, including but not limited to:

  • Set-leverage blocked by pending algo orders or active bots
  • Account setting changes requiring order/position/strategy cleanup (e.g., error codes 59000, 59002, 59007)
  • Margin mode switches requiring position closure
  • Any error containing phrases like "cancel", "close", "stop", "transfer … before"

Rationale: Error messages list all possible blockers generically — the actual blocker is often just one item (e.g., a single TP/SL order). Blindly following the error text can cause unnecessary position closures or bot shutdowns that the user did not intend.

Step 3 — Verify after writes
  • After spot place: run okx spot orders to confirm order is live or okx spot fills if market order
  • After swap place: run okx swap orders or okx swap positions to confirm
  • After swap close: run okx swap positions to confirm position size is 0
  • After futures place: run okx futures orders or okx futures positions to confirm
  • After futures close: run okx futures positions to confirm position size is 0
  • After spot algo place/trail: run okx spot algo orders to confirm algo is active
  • After swap algo place/trail: run okx swap algo orders to confirm algo is active
  • After futures algo place/trail: run okx futures algo orders to confirm algo is active
  • After cancel: run okx spot orders / okx swap orders / okx futures orders / okx event orders to confirm order is gone
  • After event place: run okx event orders --status open to confirm order is pending
  • After event cancel: run okx event orders to confirm order is gone

Global Notes

  • All write commands require valid credentials (OAuth session or API key in ~/.okx/config.toml)
  • 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>} — useful when you need to know the active environment and credential profile
  • Rate limit: 60 order operations per 2 seconds per UID
  • Batch operations (batch cancel, batch amend) are available via MCP tools directly if needed
  • Position mode (net vs long_short_mode) affects whether --posSide is required
  • Network errors: If commands fail with a connection error, prompt user to check VPN: curl -I https://www.okx.com
  • Capability discovery: Run okx list-tools --json to get a machine-readable JSON listing of all CLI commands, tool names, and parameters — useful for programmatic enumeration without parsing --help text

For MCP tool reference, output conventions, and order amount safety rules, read {baseDir}/references/templates.md.

© okx, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 8 other files (references) in skills/okx-cex-trade of okx/agent-skills.

  • SKILL.md
  • references/event-commands.md
  • references/event-workflows.md
  • references/futures-commands.md
  • references/options-commands.md
  • references/spot-commands.md
  • references/swap-commands.md
  • references/templates.md
  • references/workflows.md

Open the folder on GitHubat commit 9c180cc

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in okx/agent-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Okx Cex Trade next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Okx Cex Trade compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Okx Cex Trade this skillokx/agent-skills1872 repos~7kAutomated safety check: PassMIT
Okx Sentiment Trackerdex-original/okx-agent-trade-kit1101 repos~3.8kAutomated safety check: PassMIT
Vibe-Trading Finance ToolkitHKUDS/Vibe-Trading35k—~6.5kAutomated safety check: PassMIT
Minute-Level Data and BacktestingHKUDS/Vibe-Trading35k—~868Automated safety check: PassMIT
Market Data Source RouterHKUDS/Vibe-Trading35k—~2.4kAutomated safety check: PassMIT
Tushare Datazillionare/zillionare3222 repos~2.3kAutomated safety check: PassNone

Similar skills

  • Okx Sentiment Tracker

    dex-original/okx-agent-trade-kit

    A skill your agent uses when the user asks about: 'any crypto news', 'latest news', 'market update', 'daily briefing', 'BTC news', 'ETH news', 'news on SOL', 'search SEC ETF', 'regulation news'…

    110 GitHub starsUsed in 1 repo~3.8k tokens
    Business, Finance & HRAuto-check passed
  • Finance research toolkit with backtesting, factor analysis, a library of prebuilt alphas, options pricing and a Shadow Account loop that tests rules extracted from your trade journal.

    35k GitHub stars~6.5k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Fetches minute candlesticks from OKX, Tushare or yfinance, computes intraday VWAP, TWAP and volume distribution, and runs minute-level backtests by setting an interval in config.json.

    35k GitHub stars~868 tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Market Data Source Router

    HKUDS/Vibe-Trading

    Maps backtest data sources and research data needs to the right provider or tool, with each one's markets, required environment keys and network constraints.

    35k GitHub stars~2.4k tokensUpdated today
    Business, Finance & HRAuto-check passed
  • Tushare Data

    zillionare/zillionare

    面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。

    322 GitHub starsUsed in 2 repos~2.3k tokens
    Business, Finance & HRAuto-check passed
  • Tradingview MCP

    atilaahmettaner/tradingview-mcp

    AI Trading Intelligence — live prices, 30+ technical indicators, backtesting (6 strategies), walk-forward overfitting detection, trade logs, equity curves, licensed news sentiment (Marketaux), and…

    5k GitHub stars~1.3k tokensUpdated yesterday
    Business, Finance & HRAuto-check passed

More from okx/agent-skills

All 10 skills in this repo
  • Okx Cex Earn

    okx/agent-skills

    Manages OKX Simple Earn (flexible savings/lending), Flash Earn, On-chain Earn (staking/DeFi), Dual Investment (DCD/双币赢), and AutoEarn (自动赚币) via the okx CLI.

    187 GitHub starsUsed in 2 repos~3.3k tokens
    Auto-check passed
  • Earn Hunter

    okx/agent-skills

    Automatically monitors OKX Flash Earn, Fixed Earn and Flexible Earn opportunities, sends push notifications, and guides subscription.

    187 GitHub stars~7.8k tokensUpdated 17 days ago
    Auto-check passed
  • Okx Cex Auth

    okx/agent-skills

    A skill your agent uses when the user wants to 'login/log in/sign in', 'authenticate', 'authorize', 'connect OKX account', 'set up credentials', 'first time setup', 'configure okx', '登录', '授权'…

    187 GitHub starsUsed in 2 repos~4.5k tokens
    Auto-check passed
  • Okx Cex Market

    okx/agent-skills

    A skill your agent uses when the user asks for: price of any asset, ticker, order book, candles, OHLCV, funding rate, open interest, OI change scanner, market screener (top movers, high-volume…

    187 GitHub stars~3.4k tokensUpdated 17 days ago
    Auto-check passed
  • Okx Cex Skill Mp

    okx/agent-skills

    A skill your agent uses when the user asks to: 'find a trading skill', 'search for skills', 'install a skill', 'add a skill', 'download a skill', 'browse skill marketplace', 'what skills are…

    187 GitHub starsUsed in 2 repos~2.3k tokens
    Auto-check passed
  • Okx Cex Smartmoney

    okx/agent-skills

    Smart Money analytics on OKX: leaderboard traders, position tracking, trade records, closed-position history, aggregated consensus signals, and signal history.

    187 GitHub stars~2.8k tokensUpdated 17 days ago
    Auto-check passed

Works with

Questions about Okx Cex Trade

What does Okx Cex Trade do?

A skill your agent uses when the user asks to 'buy BTC', 'sell ETH', 'place a limit order', 'place a market order', 'cancel my order', 'amend my order', 'long BTC perp', 'short ETH swap', 'open a…. Okx Cex Trade is an agent skill from okx/agent-skills.

When should I use Okx Cex Trade?

Okx Cex Trade fits situations like: the user asks to buy BTC; place a limit order; place a market order; cancel my order.

How do I install Okx Cex Trade in Claude Code?

Run `npx skills add okx/agent-skills --skill okx-cex-trade -a claude-code`. Or copy the skill folder (skills/okx-cex-trade in okx/agent-skills) into .claude/skills/okx-cex-trade in your project. Claude Code loads it when a task matches its description.

How do I install Okx Cex Trade in Codex?

Run `npx skills add okx/agent-skills --skill okx-cex-trade -a codex`. Or copy the skill folder (skills/okx-cex-trade in okx/agent-skills) into .agents/skills/okx-cex-trade in your project. Codex loads it when a task matches its description.

Can I use Okx Cex Trade in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add okx/agent-skills --skill okx-cex-trade -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/okx-cex-trade, .gemini/skills/okx-cex-trade, .github/skills/okx-cex-trade and .opencode/skills/okx-cex-trade in your project.

What does Okx Cex Trade need to run?

Going by SKILL.md and its folder, Okx Cex Trade needs the command-line tools its instructions call (npm and curl). Our summary lists: Node.js.

Does Okx Cex Trade access the network?

SKILL.md names 1 domain. In commands or code: okx.com; the agent is likely to contact it when it follows the instructions. This is read from the text; nothing was executed.

Is Okx Cex Trade safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Okx Cex Trade use?

Okx Cex Trade is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Okx Cex Trade use?

About 7k tokens (SKILL.md is roughly 28k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 22k tokens, read only when the agent opens those files.

What are the alternatives to Okx Cex Trade?

Skills that share tags, products or a category with Okx Cex Trade: Okx Sentiment Tracker (dex-original/okx-agent-trade-kit, 110 stars), Vibe-Trading Finance Toolkit (HKUDS/Vibe-Trading, 35k stars), Minute-Level Data and Backtesting (HKUDS/Vibe-Trading, 35k stars) and Market Data Source Router (HKUDS/Vibe-Trading, 35k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Okx Cex Trade?

okx (a GitHub organization) maintains it in okx/agent-skills, which has 187 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on September 23, 2026.

Source: okx/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.