okx-cex-trade

okx/agent-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/okx/agent-skills --skill okx-cex-trade
0 commentsdiscussion
summary

Spot, perpetual swap, delivery futures, and options order management on OKX exchange.

  • Place, cancel, amend, and monitor orders across four asset classes: spot, perpetual swap, delivery futures, and options (calls/puts with Greeks and IV data)
  • Set take-profit, stop-loss, and trailing stops; manage leverage and positions; query option chains and implied volatility
  • Requires OKX API credentials configured locally; supports both live (实盘) and demo (模拟盘) trading modes via --profile flag
skill.md

OKX CEX Trading CLI

Spot, perpetual swap, delivery futures, and options order management on OKX exchange. Place, cancel, amend, and monitor orders; query option chains and Greeks; set take-profit/stop-loss and trailing stops; manage leverage and positions. Requires API credentials.

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:
    npm install -g @okx_ai/okx-trade-cli
    
  2. Configure credentials:
    okx config init
    
    Or set environment variables:
    export OKX_API_KEY=your_key
    export OKX_SECRET_KEY=your_secret
    export OKX_PASSPHRASE=your_passphrase
    
  3. Test with demo mode (simulated trading, no real funds):
    okx --profile demo spot orders
    

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.

Value Mode Funds
live 实盘 Real funds
demo 模拟盘 Simulated funds

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:

--profile Mode Funds
live 实盘 Real money — irreversible
demo 模拟盘 Simulated — no real 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

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 grid and DCA trading bots → use okx-cex-bot

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

When user specifies a USDT amount (e.g. "200U", "500 USDT", "$1000"): → Use --tgtCcy quote_ccy and pass the amount directly as --sz. The API converts to contracts automatically.

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 — ask before proceeding: "您输入的 X 是合约张数还是 USDT 金额?" Wait for the user's answer before continuing.

Inverse contracts (*-USD-SWAP, *-USD-YYMMDD): tgtCcy=quote_ccy also works (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

Options do NOT support tgtCcy. When the user specifies a USDT amount for options, you must convert manually. For the full conversion formula and validation steps, read {baseDir}/references/options-commands.md.

Quickstart

# 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 worth 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 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>

Command Index

Spot Orders (11 commands)

# Command Type Description
1 okx spot place WRITE Place spot order (market/limit/post_only/fok/ioc)
2 okx spot cancel WRITE Cancel spot order
3 okx spot amend WRITE Amend spot order price or size
4 okx spot algo place WRITE Place spot TP/SL algo order
5 okx spot algo amend WRITE Amend spot TP/SL levels
6 okx spot algo cancel WRITE Cancel spot algo order
7 okx spot algo trail WRITE Place spot trailing stop order
8 okx spot orders READ List open or historical spot orders
9 okx spot get READ Single spot order details
10 okx spot fills READ Spot trade fill history
11 okx spot algo orders READ List spot TP/SL algo orders

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

Swap / Perpetual Orders (15 commands)

# Command Type Description
12 okx swap place WRITE Place perpetual swap order
13 okx swap cancel WRITE Cancel swap order
14 okx swap amend WRITE Amend swap order price or size
15 okx swap close WRITE Close entire position at market
16 okx swap leverage WRITE Set leverage for an instrument
17 okx swap algo place WRITE Place swap TP/SL algo order
18 okx swap algo trail WRITE Place swap trailing stop order
19 okx swap algo amend WRITE Amend swap algo order
20 okx swap algo cancel WRITE Cancel swap algo order
21 okx swap positions READ Open perpetual swap positions
22 okx swap orders READ List open or historical swap orders
23 okx swap get READ Single swap order details
24 okx swap fills READ Swap trade fill history
25 okx swap get-leverage READ Current leverage settings
26 okx swap algo orders READ List swap algo orders

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

Futures / Delivery Orders (15 commands)

# Command Type Description
27 okx futures place WRITE Place delivery futures order
28 okx futures cancel WRITE Cancel delivery futures order
29 okx futures amend WRITE Amend delivery futures order price or size
30 okx futures close WRITE Close entire futures position at market
31 okx futures leverage WRITE Set leverage for a futures instrument
32 okx futures algo place WRITE Place futures TP/SL algo order
33 okx futures algo trail WRITE Place futures trailing stop order
34 okx futures algo amend WRITE Amend futures algo order
35 okx futures algo cancel WRITE Cancel futures algo order
36 okx futures orders READ List delivery futures orders
37 okx futures positions READ Open delivery futures positions
38 okx futures fills READ Delivery futures fill history
39 okx futures get READ Single delivery futures order details
40 okx futures get-leverage READ Current futures leverage settings
41 okx futures algo orders READ List futures algo orders

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

Options Orders (10 commands)

# Command Type Description
42 okx option instruments READ Option chain: list available contracts for an underlying
43 okx option greeks READ Implied volatility + Greeks (delta/gamma/theta/vega) by underlying
44 okx option place WRITE Place option order (call or put, buyer or seller)
45 okx option cancel WRITE Cancel unfilled option order
46 okx option amend WRITE Amend option order price or size
47 okx option batch-cancel WRITE Batch cancel up to 20 option orders
48 okx option orders READ List option orders (live / history / archive)
49 okx option get READ Single option order details
50 okx option positions READ Open option positions with live Greeks
51 okx option fills READ Option trade fill history

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

Operation Flow

Step 0 — Credential & Profile Check

Before any authenticated command: see Credential & Profile Check. Determine profile (live or demo) before executing.

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

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 (ins

how to use okx-cex-trade

How to use okx-cex-trade on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add okx-cex-trade
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/okx/agent-skills --skill okx-cex-trade

The skills CLI fetches okx-cex-trade from GitHub repository okx/agent-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/okx-cex-trade

Reload or restart Cursor to activate okx-cex-trade. Access the skill through slash commands (e.g., /okx-cex-trade) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.533 reviews
  • Naina Jackson· Dec 28, 2024

    okx-cex-trade reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Shikha Mishra· Dec 24, 2024

    We added okx-cex-trade from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Meera Johnson· Dec 16, 2024

    okx-cex-trade has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Anaya Thompson· Dec 4, 2024

    okx-cex-trade fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Anika Park· Nov 19, 2024

    We added okx-cex-trade from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Yash Thakker· Nov 15, 2024

    okx-cex-trade reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Mia Jackson· Oct 10, 2024

    Keeps context tight: okx-cex-trade is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Dhruvi Jain· Oct 6, 2024

    okx-cex-trade is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Noor Shah· Sep 9, 2024

    Solid pick for teams standardizing on skills: okx-cex-trade is focused, and the summary matches what you get after install.

  • Noor Jackson· Aug 28, 2024

    I recommend okx-cex-trade for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

showing 1-10 of 33

1 / 4