ClawHub
SkillsPluginsOfficialDocsSupport
K
SkillsOkx Pro

Okx Pro

LostOmato@icenoodle
完整 OKX 交易所集成,U本位/币本位合约,杠杆交易,止盈止损,仓位管理

Install

$
openclaw skills install @icenoodle/okx-pro
Security check
Review
Version
1.1.0
Updated
May 18, 2026
License
MIT-0

Latest: v1.1.0

Version 1.1.0 introduces major documentation improvements.

  • Added detailed bilingual (Chinese/English) technical documentation, including trading parameters, order types, risk controls, and position management.
  • Clarified supported trading pairs and API operations in both languages.
  • Existing quick start instructions and signature helpers are preserved and reorganized for clarity.
  • No changes to core commands or logic, documentation only.
Finance
#交易

OKX Pro 🟧

专业 OKX 交易所交易技能 - 全球领先的加密货币合约交易所。

🚀 Quick Start

Setup Credentials

Save to ~/.openclaw/credentials/okx.json:

json
{
  "apiKey": "YOUR_API_KEY",
  "secretKey": "YOUR_SECRET_KEY",
  "passphrase": "YOUR_PASSPHRASE"
}

Environment Variables (alternative)

bash
export OKX_API_KEY="your_api_key"
export OKX_SECRET="your_secret_key"
export OKX_PASSPHRASE="your_passphrase"

📖 技术文档 | Technical Documentation

中文文档

1. 概述

OKX Pro 是一个完整的 OKX 交易所集成技能,支持:

  • 现货交易 (Spot Trading)
  • 合约交易 (Futures Trading)
  • U本位合约 / 币本位合约
  • 杠杆交易 (Leverage Trading)
  • 止盈止损 (Take Profit / Stop Loss)
  • 仓位管理 (Position Management)

2. API 版本

本技能使用 OKX V5 API:

  • 基础URL: https://www.okx.com
  • 所有请求需要签名认证

3. 支持的交易对

交易对说明
BTC-USDTBTC 现货
ETH-USDTETH 现货
BTC-USDT-SWAPBTC U本位永续合约
ETH-USDT-SWAPETH U本位永续合约
BTC-USD-SWAPBTC 币本位永续合约

4. 交易参数

参数说明示例
instId交易对IDBTC-USDT-SWAP
tdMode仓位模式cross(全仓) / isolated(逐仓)
side交易方向buy / sell
ordType订单类型market / limit / conditional
sz数量0.001
px价格50000
SL止损slTriggerPx
TP止盈tpTriggerPx

5. 订单类型详解

市价单 (Market Order)

立即以市场价成交

json
{"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"market","sz":"0.001"}

限价单 (Limit Order)

指定价格成交

json
{"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","sz":"0.001","px":"50000"}

条件单 (Conditional Order)

止盈止损订单

json
{
  "instId": "BTC-USDT-SWAP",
  "tdMode": "cross",
  "side": "sell",
  "ordType": "conditional",
  "sz": "0.001",
  "slTriggerPx": "45000",
  "slOrdPx": "-1"
}

6. 止盈止损详解

  • slTriggerPx: 止损触发价格
  • slOrdPx: 止损订单价格 (-1 = 市价)
  • tpTriggerPx: 止盈触发价格
  • tpOrdPx: 止盈订单价格

7. 仓位管理

操作API
查询仓位GET /api/v5/position/positions
设置杠杆POST /api/v5/account/set-leverage
追加保证金POST /api/v5/account/increase-margin
减少保证金POST /api/v5/account/decrease-margin

8. 风险控制

⚠️ 安全规则:

  1. 杠杆不超过10x(新手建议2-3x)
  2. 始终设置止损
  3. 大额订单先确认
  4. 测试网验证后再实盘

English Documentation

1. Overview

OKX Pro provides complete OKX exchange integration:

  • Spot Trading
  • Futures Trading (U-Margin / Coin-Margin)
  • Leverage Trading
  • Take Profit / Stop Loss
  • Position Management

2. API Version

Uses OKX V5 API:

  • Base URL: https://www.okx.com
  • All requests require signature authentication

3. Supported Trading Pairs

PairDescription
BTC-USDTBTC Spot
ETH-USDTETH Spot
BTC-USDT-SWAPBTC USDT-Margin Perpetual
ETH-USDT-SWAPETH USDT-Margin Perpetual

4. Trading Parameters

ParameterDescriptionExample
instIdInstrument IDBTC-USDT-SWAP
tdModeTrade Modecross / isolated
sideOrder Sidebuy / sell
ordTypeOrder Typemarket / limit / conditional
szSize0.001
pxPrice50000

5. Order Types

Market Order

Execute immediately at market price

json
{"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"market","sz":"0.001"}

Limit Order

Execute at specified price

json
{"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","sz":"0.001","px":"50000"}

Conditional Order

Stop loss / Take profit orders

json
{
  "instId": "BTC-USDT-SWAP",
  "tdMode": "cross",
  "side": "sell",
  "ordType": "conditional",
  "sz": "0.001",
  "slTriggerPx": "45000",
  "slOrdPx": "-1"
}

6. Stop Loss / Take Profit

  • slTriggerPx: Stop loss trigger price
  • slOrdPx: Stop loss order price (-1 = market)
  • tpTriggerPx: Take profit trigger price
  • tpOrdPx: Take profit order price

7. Position Management

OperationAPI
Get PositionsGET /api/v5/position/positions
Set LeveragePOST /api/v5/account/set-leverage
Increase MarginPOST /api/v5/account/increase-margin
Decrease MarginPOST /api/v5/account/decrease-margin

8. Risk Control

⚠️ Safety Rules:

  1. Leverage max 10x (beginners: 2-3x)
  2. Always set stop loss
  3. Confirm large orders
  4. Test on demo trading first

🔐 Signature Helper

bash
# 生成 OKX 签名的函数
okx_sign() {
  local method="$1"
  local request_path="$2"
  local body="$3"
  local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
  local message="${timestamp}${method}${request_path}${body}"
  local signature=$(echo -n "$message" | openssl dgst -sha256 -hmac "$OKX_SECRET" | cut -d' ' -f2)
  echo "$signature"
}

okx_request() {
  local method="$1"
  local endpoint="$2"
  local body="$3"
  local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
  local signature=$(okx_sign "$method" "$endpoint" "$body")
  
  curl -s -X "$method" "https://www.okx.com$endpoint" \
    -H "Content-Type: application/json" \
    -H "OKX-ACCESS-KEY: $OKX_API_KEY" \
    -H "OKX-ACCESS-SIGN: $signature" \
    -H "OKX-ACCESS-TIMESTAMP: $timestamp" \
    -H "OKX-ACCESS-PASSPHRASE: $OKX_PASSPHRASE" \
    -d "$body"
}

📊 Basic Queries

Check Balance

bash
okx_request "GET" "/api/v5/account/balance" ''

Get Current Price

bash
curl -s "https://www.okx.com/api/v5/market/ticker?instId=BTC-USDT" | jq '.data[0]'

Get All Positions

bash
okx_request "GET" "/api/v5/position/positions" ''

⚡ Futures Trading

Open LONG Position (Buy)

bash
INST_ID="BTC-USDT-SWAP"
SZ="0.001"
TD_MODE="cross"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"$TD_MODE\",\"side\":\"buy\",\"ordType\":\"market\",\"sz\":\"$SZ\"}"

Open SHORT Position (Sell)

bash
INST_ID="BTC-USDT-SWAP"
SZ="0.001"
TD_MODE="cross"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"$TD_MODE\",\"side\":\"sell\",\"ordType\":\"market\",\"sz\":\"$SZ\"}"

Set Stop Loss

bash
INST_ID="BTC-USDT-SWAP"
SZ="0.001"
STOP_PRICE="75000"
TD_MODE="cross"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"$TD_MODE\",\"side\":\"sell\",\"ordType\":\"conditional\",\"sz\":\"$SZ\",\"slTriggerPx\":\"$STOP_PRICE\",\"slOrdPx\":\"-1\"}"

Set Take Profit

bash
INST_ID="BTC-USDT-SWAP"
SZ="0.001"
TP_PRICE="85000"
TD_MODE="cross"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"$TD_MODE\",\"side\":\"sell\",\"ordType\":\"conditional\",\"sz\":\"$SZ\",\"tpTriggerPx\":\"$TP_PRICE\",\"tpOrdPx\":\"-1\"}"

Close Position (Market)

bash
INST_ID="BTC-USDT-SWAP"
SZ="0.001"
TD_MODE="cross"

okx_request "POST" "/api/v5/trade/close-position" "{\"instId\":\"$INST_ID\",\"mgnMode\":\"cross\",\"posSide\":\"long\"}"

Set Leverage

bash
INST_ID="BTC-USDT-SWAP"
LEVERAGE="10"
TD_MODE="cross"

okx_request "POST" "/api/v5/account/set-leverage" "{\"instId\":\"$INST_ID\",\"lever\":\"$LEVERAGE\",\"mgnMode\":\"$TD_MODE\"}"

📈 Spot Trading

Buy (Market)

bash
INST_ID="BTC-USDT"
SZ="0.001"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"cash\",\"side\":\"buy\",\"ordType\":\"market\",\"sz\":\"$SZ\"}"

Sell (Market)

bash
INST_ID="BTC-USDT"
SZ="0.001"

okx_request "POST" "/api/v5/trade/order" "{\"instId\":\"$INST_ID\",\"tdMode\":\"cash\",\"side\":\"sell\",\"ordType\":\"market\",\"sz\":\"$SZ\"}"

🔧 Utilities

View Open Orders

bash
okx_request "GET" "/api/v5/trade/orders-pending" ''

Cancel Order

bash
INST_ID="BTC-USDT-SWAP"
ORD_ID="123456789"

okx_request "POST" "/api/v5/trade/cancel-order" "{\"instId\":\"$INST_ID\",\"ordId\":\"$ORD_ID\"}"

View Trade History

bash
okx_request "GET" "/api/v5/trade/fills" ''

📋 Popular Pairs

InstIDDescription
BTC-USDTBitcoin U本位合约
ETH-USDTEthereum U本位合约
SOL-USDTSolana U本位合约
XRP-USDTXRP U本位合约
DOGE-USDTDogecoin U本位合约
BTC-USDT-SWAP永续合约
ETH-USDT-SWAPETH 永续合约

⚠️ Safety Rules

  1. ALWAYS verify position before closing
  2. ALWAYS set Stop Loss on leveraged trades
  3. NEVER use leverage higher than 10x without experience
  4. VERIFY pair and quantity before executing
  5. CONFIRM with user before executing large orders
  6. 注意:U本位合约用 USDT 计价,币本位用 USD/BTC 计价

🔗 Links

  • API Documentation
  • Create Account
  • Testnet

Related skills

More in Finance
ClawHub

Skills and plugins for OpenClaw agents. Part of the wider OpenClaw ecosystem.

Explore docs

SkillsPluginsOfficialAudits

Publish SkillPublish PluginCreate org

OverviewOpenClawDocsBlog

SupportGitHubDiscord

Built alongside the OpenClaw ecosystem

LobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projectsLobsterCrabboxClickClackCrabfleetOctopoolClawSweeperagent-skillsdiscrawlgitcrawlslacrawlnotcrawltelecrawlgraincrawlcrawlkitcrawlbaracpxmcporterTachikomaclawpatchclawbenchPeekaboocookbookplugin-inspectorwacrawlcrabpotAll projects

© 2026 OpenClaw Foundation

Privacy policy·Status·Deployed on Vercel·Powered by Convex

....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals
  hooks runners slash-commands skill.md templates scanners review-bots     safe browse paths   official gateways   publisher handles   org trust   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@
openclaw ecosystem    crabbox clickclack crawler packs gateway plugins   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship
---- downloads installs stars lineage ownership docs package integrity   >>> install scan publish verify    @@ gateway @@ registry @@ agents @@   :::: signed manifests ::::: moderated releases ::::: version history ::::
  safe browse paths   official gateways   publisher handles   org trust     30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship     hooks runners slash-commands skill.md templates scanners review-bots
....:: clawhub/openclaw ::....  skills plugins publishers trust signals   :::: signed manifests ::::: moderated releases ::::: version history ::::   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins
>>> install scan publish verify    @@ gateway @@ registry @@ agents @@     hooks runners slash-commands skill.md templates scanners review-bots   ---- downloads installs stars lineage ownership docs package integrity
  30 skills 12 plugins    /api/v1/skills   /owners   /audit   /ship   openclaw ecosystem    crabbox clickclack crawler packs gateway plugins     safe browse paths   official gateways   publisher handles   org trust
:::: signed manifests ::::: moderated releases ::::: version history ::::   ---- downloads installs stars lineage ownership docs package integrity   ....:: clawhub/openclaw ::....  skills plugins publishers trust signals