
Trading Automation
okx
This Skill provides a developer-ready integration with the OKX cryptocurrency exchange, exposing spot, futures (up to 125x leverage), options, Earn (staking/savings/DeFi), token convert, and Web3 wallet functionality across 300+ trading pairs.
總覽
This Skill provides a developer-ready integration with the OKX cryptocurrency exchange, exposing spot, futures (up to 125x leverage), options, Earn (staking/savings/DeFi), token convert, and Web3 wallet functionality across 300+ trading pairs.
This Skill provides a developer-ready integration with the OKX cryptocurrency exchange, exposing spot, futures (up to 125x leverage), options, Earn (staking/savings/DeFi), token convert, and Web3 wallet functionality across 300+ trading pairs. It includes required environment variables (OKX_API_KEY, OKX_SECRET, OKX_PASSPHRASE), HMAC-SHA256 signature generation, and a base API URL for authenticated requests. Typical uses include automated trading bots, portfolio and balance monitoring, price/ticker feeds, order placement for spot/futures/options, DeFi interactions, and arbitrage strategies. Built-in referral support (REFERRAL_CODE=CYBERPAY) offers commission sharing (up to 50% in USDT), mystery rewards, and lifetime commissions for referred users. Core advantages are secure programmatic access, ready-made curl/snippet examples, and unified access to advanced trading features for production integrations.
Skill.md
這個 Skill 如何運作
This Skill provides a developer-ready integration with the OKX cryptocurrency exchange, exposing spot, futures (up to 125x leverage), options, Earn (staking/savings/DeFi), token convert, and Web3 wallet functionality across 300+ trading pairs.
OKX ⚫
Top 5 global cryptocurrency exchange. Trade 300+ cryptocurrencies with advanced features.
Environment Variables
| Variable | Description | Required |
|---|---|---|
OKX_API_KEY | API Key from OKX | Yes |
OKX_SECRET | API Secret | Yes |
OKX_PASSPHRASE | API Passphrase | Yes |
💎 Referral Configuration
This skill uses a referral code to earn commission on trading fees.
| Variable | Value | Description |
|---|---|---|
REFERRAL_CODE | CYBERPAY | Referral code for fee sharing |
Commission Structure:
- Up to 50% of trading fees in USDT
- Mystery Box rewards for new users
- Lifetime commission on referred users
💡 Users who sign up through this skill automatically use the referral code!
Features
- 📈 Spot Trading - 300+ trading pairs
- 📊 Futures & Perpetuals - Up to 125x leverage
- 🎯 Options Trading - BTC/ETH options
- 💰 Earn - Staking, savings, DeFi
- 🔄 Convert - Simple token swaps
- 🌐 Web3 Wallet - Built-in DeFi access
API Base URL
https://www.okx.com
Authentication
API_KEY="${OKX_API_KEY}"
SECRET="${OKX_SECRET}"
PASSPHRASE="${OKX_PASSPHRASE}"
# Generate signature
generate_signature() {
local timestamp="$1"
local method="$2"
local path="$3"
local body="$4"
local sign_string="${timestamp}${method}${path}${body}"
echo -n "$sign_string" | openssl dgst -sha256 -hmac "$SECRET" -binary | base64
}
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
Get Account Balance
METHOD="GET"
PATH="/api/v5/account/balance"
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "")
curl -s "https://www.okx.com${PATH}" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" | jq '.data[0].details[] | select(.cashBal != "0") | {ccy: .ccy, cashBal: .cashBal, availBal: .availBal}'
Get Ticker Price
INST_ID="BTC-USDT"
curl -s "https://www.okx.com/api/v5/market/ticker?instId=${INST_ID}" | jq '.data[0] | {instId: .instId, last: .last, high24h: .high24h, low24h: .low24h, vol24h: .vol24h}'
Get Order Book
curl -s "https://www.okx.com/api/v5/market/books?instId=${INST_ID}&sz=10" | jq '{
asks: .data[0].asks[:5],
bids: .data[0].bids[:5]
}'
Place Spot Order
METHOD="POST"
PATH="/api/v5/trade/order"
BODY='{
"instId": "BTC-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "limit",
"px": "40000",
"sz": "0.001"
}'
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "$BODY")
curl -s -X POST "https://www.okx.com${PATH}" \
-H "Content-Type: application/json" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-d "$BODY" | jq '.'
Place Market Order
BODY='{
"instId": "ETH-USDT",
"tdMode": "cash",
"side": "buy",
"ordType": "market",
"sz": "0.1"
}'
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "$BODY")
curl -s -X POST "https://www.okx.com${PATH}" \
-H "Content-Type: application/json" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-d "$BODY" | jq '.'
Get Open Orders
METHOD="GET"
PATH="/api/v5/trade/orders-pending"
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "")
curl -s "https://www.okx.com${PATH}" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" | jq '.data[] | {instId: .instId, side: .side, px: .px, sz: .sz, state: .state}'
Cancel Order
METHOD="POST"
PATH="/api/v5/trade/cancel-order"
BODY='{
"instId": "BTC-USDT",
"ordId": "12345678"
}'
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "$BODY")
curl -s -X POST "https://www.okx.com${PATH}" \
-H "Content-Type: application/json" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-d "$BODY" | jq '.'
Get Trade History
METHOD="GET"
PATH="/api/v5/trade/fills?instType=SPOT"
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "")
curl -s "https://www.okx.com${PATH}" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" | jq '.data[:10] | .[] | {instId: .instId, side: .side, fillPx: .fillPx, fillSz: .fillSz}'
Convert (Simple Swap)
# Get quote
METHOD="POST"
PATH="/api/v5/asset/convert/estimate-quote"
BODY='{
"baseCcy": "BTC",
"quoteCcy": "USDT",
"side": "buy",
"rfqSz": "100",
"rfqSzCcy": "USDT"
}'
SIGNATURE=$(generate_signature "$TIMESTAMP" "$METHOD" "$PATH" "$BODY")
curl -s -X POST "https://www.okx.com${PATH}" \
-H "Content-Type: application/json" \
-H "OK-ACCESS-KEY: ${API_KEY}" \
-H "OK-ACCESS-SIGN: ${SIGNATURE}" \
-H "OK-ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "OK-ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-d "$BODY" | jq '.'
Popular Trading Pairs
| Pair | Description |
|---|---|
| BTC-USDT | Bitcoin / Tether |
| ETH-USDT | Ethereum / Tether |
| SOL-USDT | Solana / Tether |
| XRP-USDT | XRP / Tether |
| OKB-USDT | OKB / Tether |
Order Types
| Type | Description |
|---|---|
| limit | Limit order |
| market | Market order |
| post_only | Post-only order |
| fok | Fill or kill |
| ioc | Immediate or cancel |
Safety Rules
- ALWAYS display order details before execution
- VERIFY trading pair and amount
- CHECK account balance before trading
- WARN about leverage risks
- NEVER execute without user confirmation
Error Handling
| Code | Cause | Solution |
|---|---|---|
| 51000 | Parameter error | Check parameters |
| 51008 | Insufficient balance | Check balance |
| 51009 | Order not exist | Check order ID |
Links
最適合用於
何時使用
This Skill provides a developer-ready integration with the OKX cryptocurrency exchange, exposing spot, futures (up to 125x leverage), options, Earn (staking/savings/DeFi), token convert, and Web3 wallet functionality across 300+ trading pairs.

01 · 會前準備
準備決策簡報
在投資委員會開會前,把零散證據整理成結構化的論據。

02 · 團隊協作
統一交接標準
讓分析師、投資組合經理與 Agent 產出一致的研究結果。

03 · 即時更新
更新投資邏輯
出現新催化劑、KPI 發布或財報結果後,更新情境假設。
社群回饋
越用越好用。
隨著 Skill 被使用與評審,回饋將顯示在這裡。
探索更多
相關 Skills
查看全部hyperliquid-trading
The Hyperliquid Trading skill provides a concise interface for trading on Hyperliquid’s spot and perpetual markets. Use it to place limit and market orders, cancel open orders, query order status,…
bankr
Bankr enables executing crypto trading and DeFi operations via natural-language commands. It offers two integration options: a batteries-included Bankr CLI and a REST API at https://api.bankr.bot,…
pine-backtester
pine-backtester provides comprehensive backtesting for Pine Script indicators and strategies. Use it to append performance metrics, analyze trades, generate equity curves, compute win rates, track…