7.5kā
by bowen31337
weex-trading ā OpenClaw Skill
weex-trading is an OpenClaw Skills integration for ai ml workflows. WEEX Futures exchange integration. Trade USDT-M perpetual futures with up to 125x leverage on WEEX.
Skill Snapshot
| name | weex-trading |
| description | WEEX Futures exchange integration. Trade USDT-M perpetual futures with up to 125x leverage on WEEX. OpenClaw Skills integration. |
| owner | bowen31337 |
| repository | bowen31337/weex-trading-skills |
| language | Markdown |
| license | MIT |
| topics | |
| security | L1 |
| install | openclaw add @bowen31337/weex-trading-skills |
| last updated | Feb 7, 2026 |
Maintainer

name: weex-trading description: WEEX Futures exchange integration. Trade USDT-M perpetual futures with up to 125x leverage on WEEX. metadata: emoji: "šµ" category: "trading" tags: ["crypto", "futures", "trading", "weex", "derivatives"] requires: bins: ["curl", "jq", "python3", "openssl"] compatibility: - claude - openai - gemini - llama - mistral - any-agent
WEEX Futures Trading šµ
Open AI Agent Skill for USDT-margined perpetual futures trading on WEEX exchange. Up to 125x leverage.
Open Agent Skill: This skill is designed to work with any AI agent that supports bash/curl commands, including Claude, GPT, Gemini, LLaMA, Mistral, and other LLM-based agents.
Features
- š Futures Trading - USDT-M perpetual contracts up to 125x leverage
- š° Account Management - Balance, positions, margin settings
- š Market Data - Tickers, order book, candlesticks, funding rates
- šÆ Advanced Orders - Trigger orders, TP/SL, conditional orders
- š¤ AI Integration - Log AI trading decisions
- š Universal Compatibility - Works with any AI agent supporting shell commands
Environment Variables
| Variable | Description | Required |
|---|---|---|
WEEX_API_KEY | API Key from WEEX | Yes |
WEEX_API_SECRET | API Secret | Yes |
WEEX_PASSPHRASE | API Passphrase | Yes |
WEEX_BASE_URL | API base URL | No (default: https://api-contract.weex.com) |
Authentication
API_KEY="${WEEX_API_KEY}"
SECRET="${WEEX_API_SECRET}"
PASSPHRASE="${WEEX_PASSPHRASE}"
BASE_URL="${WEEX_BASE_URL:-https://api-contract.weex.com}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
# Generate signature
generate_signature() {
local method="$1"
local path="$2"
local body="$3"
local message="${TIMESTAMP}${method}${path}${body}"
echo -n "$message" | openssl dgst -sha256 -hmac "$SECRET" -binary | base64
}
Market Data Endpoints (No Auth)
Get Server Time
curl -s "${BASE_URL}/capi/v2/market/time" | jq '.'
Get All Contracts Info
curl -s "${BASE_URL}/capi/v2/market/contracts" | jq '.data[] | {symbol: .symbol, baseCoin: .underlying_index, quoteCoin: .quote_currency, contractVal: .contract_val, minLeverage: .minLeverage, maxLeverage: .maxLeverage, tickSize: .tick_size, sizeIncrement: .size_increment}'
Get Single Contract Info
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/contracts?symbol=${SYMBOL}" | jq '.data'
Get Ticker Price
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/ticker?symbol=${SYMBOL}" | jq '.data | {symbol: .symbol, last: .last, high: .high_24h, low: .low_24h, volume: .volume_24h, markPrice: .markPrice}'
Get All Tickers
curl -s "${BASE_URL}/capi/v2/market/tickers" | jq '.data[] | {symbol: .symbol, last: .last, change: .priceChangePercent, volume: .volume_24h}'
Get Order Book
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/depth?symbol=${SYMBOL}&limit=15" | jq '.data | {asks: .asks[:5], bids: .bids[:5]}'
Get Recent Trades
SYMBOL="cmt_btcusdt"
LIMIT="50"
curl -s "${BASE_URL}/capi/v2/market/trades?symbol=${SYMBOL}&limit=${LIMIT}" | jq '.data[] | {time: .time, price: .price, size: .size, side: (if .isBuyerMaker then "sell" else "buy" end)}'
Get Candlestick Data
SYMBOL="cmt_btcusdt"
GRANULARITY="1h" # 1m, 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w
LIMIT="100"
curl -s "${BASE_URL}/capi/v2/market/candles?symbol=${SYMBOL}&granularity=${GRANULARITY}&limit=${LIMIT}" | jq '.data[] | {timestamp: .[0], open: .[1], high: .[2], low: .[3], close: .[4], volume: .[5]}'
Get Index Price
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/index?symbol=${SYMBOL}" | jq '.data | {symbol: .symbol, index: .index, timestamp: .timestamp}'
Get Open Interest
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/open_interest?symbol=${SYMBOL}" | jq '.data[] | {symbol: .symbol, openInterest: .base_volume, value: .target_volume}'
Get Current Funding Rate
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/currentFundRate?symbol=${SYMBOL}" | jq '.data[] | {symbol: .symbol, rate: .fundingRate, nextSettlement: .timestamp}'
Get Historical Funding Rates
SYMBOL="cmt_btcusdt"
LIMIT="20"
curl -s "${BASE_URL}/capi/v2/market/getHistoryFundRate?symbol=${SYMBOL}&limit=${LIMIT}" | jq '.data[] | {symbol: .symbol, rate: .fundingRate, settleTime: .fundingTime}'
Get Next Funding Time
SYMBOL="cmt_btcusdt"
curl -s "${BASE_URL}/capi/v2/market/funding_time?symbol=${SYMBOL}" | jq '.data | {symbol: .symbol, nextFundingTime: .fundingTime}'
Account Endpoints (Auth Required)
Get Account Assets
PATH_URL="/capi/v2/account/assets"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {coin: .coinName, available: .available, frozen: .frozen, equity: .equity, unrealizedPnl: .unrealizePnl}'
Get Account List with Settings
PATH_URL="/capi/v2/account/getAccounts"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data'
Get Single Account by Coin
COIN="USDT"
PATH_URL="/capi/v2/account/getAccount?coin=${COIN}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data'
Get User Settings
SYMBOL="cmt_btcusdt"
PATH_URL="/capi/v2/account/settings?symbol=${SYMBOL}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data'
Change Leverage
SYMBOL="cmt_btcusdt"
LEVERAGE="20"
MARGIN_MODE="1" # 1=Cross, 3=Isolated
PATH_URL="/capi/v2/account/leverage"
BODY="{\"symbol\":\"${SYMBOL}\",\"marginMode\":${MARGIN_MODE},\"longLeverage\":\"${LEVERAGE}\",\"shortLeverage\":\"${LEVERAGE}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Adjust Position Margin (Isolated Only)
POSITION_ID="123456789" # Isolated position ID
AMOUNT="100" # Positive to add, negative to reduce
PATH_URL="/capi/v2/account/adjustMargin"
BODY="{\"coinId\":2,\"isolatedPositionId\":${POSITION_ID},\"collateralAmount\":\"${AMOUNT}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Auto Margin Top-Up (Isolated Only)
POSITION_ID="123456789" # Isolated position ID
AUTO_APPEND="true" # true to enable, false to disable
PATH_URL="/capi/v2/account/modifyAutoAppendMargin"
BODY="{\"positionId\":${POSITION_ID},\"autoAppendMargin\":${AUTO_APPEND}}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Get Account Bill History
COIN="USDT"
LIMIT="20"
PATH_URL="/capi/v2/account/bills"
BODY="{\"coin\":\"${COIN}\",\"limit\":${LIMIT}}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.data'
Position Endpoints (Auth Required)
Get All Positions
PATH_URL="/capi/v2/account/position/allPosition"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | select(.size != "0") | {symbol: .symbol, side: .side, size: .size, leverage: .leverage, unrealizedPnl: .unrealizePnl, entryPrice: .avg_cost}'
Get Single Position
SYMBOL="cmt_btcusdt"
PATH_URL="/capi/v2/account/position/singlePosition?symbol=${SYMBOL}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {symbol: .symbol, side: .side, size: .size, leverage: .leverage, unrealizedPnl: .unrealizePnl, entryPrice: .avg_cost, liquidationPrice: .liq_price}'
Change Margin Mode
SYMBOL="cmt_btcusdt"
MARGIN_MODE="1" # 1=Cross, 3=Isolated
PATH_URL="/capi/v2/account/position/changeHoldModel"
BODY="{\"symbol\":\"${SYMBOL}\",\"marginMode\":${MARGIN_MODE},\"separatedMode\":1}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Order Endpoints (Auth Required)
Place Market Order
SYMBOL="cmt_btcusdt"
SIZE="10" # Quantity in contracts
TYPE="1" # 1=Open Long, 2=Open Short, 3=Close Long, 4=Close Short
CLIENT_OID="order_$(date +%s)"
PATH_URL="/capi/v2/order/placeOrder"
BODY="{\"symbol\":\"${SYMBOL}\",\"client_oid\":\"${CLIENT_OID}\",\"size\":\"${SIZE}\",\"type\":\"${TYPE}\",\"order_type\":\"0\",\"match_price\":\"1\",\"price\":\"0\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Place Limit Order
SYMBOL="cmt_btcusdt"
SIZE="10"
TYPE="1" # 1=Open Long
PRICE="90000" # Limit price
ORDER_TYPE="0" # 0=Normal, 1=Post-only, 2=FOK, 3=IOC
CLIENT_OID="limit_$(date +%s)"
PATH_URL="/capi/v2/order/placeOrder"
BODY="{\"symbol\":\"${SYMBOL}\",\"client_oid\":\"${CLIENT_OID}\",\"size\":\"${SIZE}\",\"type\":\"${TYPE}\",\"order_type\":\"${ORDER_TYPE}\",\"match_price\":\"0\",\"price\":\"${PRICE}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Get Open Orders
PATH_URL="/capi/v2/order/current"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {orderId: .order_id, symbol: .symbol, side: .type, price: .price, size: .size, status: .status}'
Get Order Details
ORDER_ID="1234567890"
PATH_URL="/capi/v2/order/detail?orderId=${ORDER_ID}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data'
Get Order History
SYMBOL="cmt_btcusdt"
LIMIT="50"
PATH_URL="/capi/v2/order/history?symbol=${SYMBOL}&limit=${LIMIT}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {orderId: .order_id, symbol: .symbol, side: .type, price: .price, size: .size, filledSize: .filled_qty, status: .status}'
Get Trade Fills
SYMBOL="cmt_btcusdt"
LIMIT="50"
PATH_URL="/capi/v2/order/fills?symbol=${SYMBOL}&limit=${LIMIT}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {tradeId: .trade_id, orderId: .order_id, symbol: .symbol, price: .price, size: .size, fee: .fee, time: .created_at}'
Cancel Order
ORDER_ID="1234567890"
PATH_URL="/capi/v2/order/cancel_order"
BODY="{\"orderId\":\"${ORDER_ID}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Cancel All Orders
SYMBOL="cmt_btcusdt" # Optional: omit to cancel all
PATH_URL="/capi/v2/order/cancelAllOrders"
BODY="{\"symbol\":\"${SYMBOL}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Close All Positions
PATH_URL="/capi/v2/order/closePositions"
BODY="{}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Trigger Order Endpoints (Auth Required)
Place Trigger Order (Stop-Loss / Take-Profit)
SYMBOL="cmt_btcusdt"
SIZE="10"
TYPE="1" # 1=Open Long, 2=Open Short, 3=Close Long, 4=Close Short
TRIGGER_PRICE="95000" # Price that triggers the order
EXECUTE_PRICE="0" # 0 for market, or limit price
TRIGGER_TYPE="1" # 1=Fill price, 2=Mark price, 3=Index price
CLIENT_OID="trigger_$(date +%s)"
PATH_URL="/capi/v2/order/plan_order"
BODY="{\"symbol\":\"${SYMBOL}\",\"client_oid\":\"${CLIENT_OID}\",\"size\":\"${SIZE}\",\"type\":\"${TYPE}\",\"trigger_price\":\"${TRIGGER_PRICE}\",\"execute_price\":\"${EXECUTE_PRICE}\",\"trend_side\":\"1\",\"trigger_type\":\"${TRIGGER_TYPE}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Get Current Trigger Orders
SYMBOL="cmt_btcusdt"
PATH_URL="/capi/v2/order/currentPlan?symbol=${SYMBOL}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {orderId: .order_id, symbol: .symbol, triggerPrice: .trigger_price, size: .size, type: .type}'
Get Trigger Order History
SYMBOL="cmt_btcusdt"
LIMIT="50"
PATH_URL="/capi/v2/order/historyPlan?symbol=${SYMBOL}&limit=${LIMIT}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "GET" "$PATH_URL" "")
curl -s "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" | jq '.data[] | {orderId: .order_id, symbol: .symbol, triggerPrice: .trigger_price, status: .status}'
Cancel Trigger Order
ORDER_ID="1234567890"
PATH_URL="/capi/v2/order/cancel_plan"
BODY="{\"orderId\":\"${ORDER_ID}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
TP/SL Order Endpoints (Auth Required)
Place TP/SL Order
SYMBOL="cmt_btcusdt"
SIDE="1" # 1=Long position, 2=Short position
TP_PRICE="100000" # Take profit trigger price
SL_PRICE="85000" # Stop loss trigger price
TP_SIZE="10" # Take profit size (0 for entire position)
SL_SIZE="10" # Stop loss size (0 for entire position)
PATH_URL="/capi/v2/order/placeTpSlOrder"
BODY="{\"symbol\":\"${SYMBOL}\",\"side\":\"${SIDE}\",\"tp_trigger_price\":\"${TP_PRICE}\",\"sl_trigger_price\":\"${SL_PRICE}\",\"tp_size\":\"${TP_SIZE}\",\"sl_size\":\"${SL_SIZE}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Modify TP/SL Order
SYMBOL="cmt_btcusdt"
SIDE="1" # 1=Long position, 2=Short position
TP_PRICE="105000" # New take profit price
SL_PRICE="82000" # New stop loss price
PATH_URL="/capi/v2/order/modifyTpSlOrder"
BODY="{\"symbol\":\"${SYMBOL}\",\"side\":\"${SIDE}\",\"tp_trigger_price\":\"${TP_PRICE}\",\"sl_trigger_price\":\"${SL_PRICE}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
AI Integration (Auth Required)
Upload AI Trading Log
AI_LOG="Trading decision: Buy BTC based on momentum indicators"
ORDER_ID="1234567890"
PATH_URL="/capi/v2/order/uploadAiLog"
BODY="{\"orderId\":\"${ORDER_ID}\",\"aiLog\":\"${AI_LOG}\"}"
TIMESTAMP=$(python3 -c "import time; print(int(time.time() * 1000))")
SIGNATURE=$(generate_signature "POST" "$PATH_URL" "$BODY")
curl -s -X POST "${BASE_URL}${PATH_URL}" \
-H "ACCESS-KEY: ${API_KEY}" \
-H "ACCESS-SIGN: ${SIGNATURE}" \
-H "ACCESS-PASSPHRASE: ${PASSPHRASE}" \
-H "ACCESS-TIMESTAMP: ${TIMESTAMP}" \
-H "Content-Type: application/json" \
-d "$BODY" | jq '.'
Reference Tables
Order Types
| type | Description |
|---|---|
1 | Open Long (buy to open) |
2 | Open Short (sell to open) |
3 | Close Long (sell to close) |
4 | Close Short (buy to close) |
Execution Types
| order_type | Description |
|---|---|
0 | Normal order |
1 | Post-only (maker only) |
2 | FOK (fill or kill) |
3 | IOC (immediate or cancel) |
Price Types
| match_price | Description |
|---|---|
0 | Limit order |
1 | Market order |
Margin Modes
| marginMode | Description |
|---|---|
1 | Cross margin |
3 | Isolated margin |
Trigger Types
| trigger_type | Description |
|---|---|
1 | Fill price (last trade price) |
2 | Mark price |
3 | Index price |
Popular Trading Pairs
| Pair | Description |
|---|---|
| cmt_btcusdt | Bitcoin / USDT |
| cmt_ethusdt | Ethereum / USDT |
| cmt_solusdt | Solana / USDT |
| cmt_xrpusdt | XRP / USDT |
| cmt_dogeusdt | Dogecoin / USDT |
| cmt_bnbusdt | BNB / USDT |
Safety Rules
- ALWAYS display order details before execution
- VERIFY trading pair and quantity
- CHECK account balance before trading
- WARN about leverage risks (up to 125x)
- NEVER execute without user confirmation
- CONFIRM position closure before executing
Error Codes
| Code | Description | Solution |
|---|---|---|
00000 | Success | - |
40001 | Invalid parameter | Check parameter format |
40101 | Invalid API key/signature | Verify credentials and timestamp |
40301 | IP not whitelisted | Add IP to whitelist |
42901 | Rate limit exceeded | Reduce request frequency |
50001 | Internal error | Retry after delay |
Rate Limits
| Category | IP Limit | UID Limit |
|---|---|---|
| Market Data | 20 req/sec | N/A |
| Account Info | 10 req/sec | 10 req/sec |
| Order Placement | 10 req/sec | 10 req/sec |
Additional Resources
- WEEX
- Base URL:
https://api-contract.weex.com - API Reference
WEEX Futures Trading Skill šµ
An Open AI Agent Skill for trading USDT-margined perpetual futures on WEEX exchange with up to 125x leverage.
Universal Compatibility: This skill works with any AI agent that supports bash/curl commands, including Claude, GPT-4, Gemini, LLaMA, Mistral, and other LLM-based coding assistants.
Features
- Market Data - Real-time ticker, order book, trades, candlesticks, funding rates
- Account Management - Check balances, positions, leverage settings
- Order Operations - Place market/limit orders, cancel orders, close positions
- Position Management - Open long/short, close positions, adjust margin
- Trigger Orders - Stop-loss, take-profit, and conditional orders
- TP/SL Orders - Position-level take-profit and stop-loss
- AI Integration - Log AI trading decisions to WEEX
- Python CLI Client - Command-line tool for quick API interactions
Supported AI Agents
| Agent | Status | Notes |
|---|---|---|
| Claude (Anthropic) | ā Fully Supported | Claude Code, API |
| GPT-4 (OpenAI) | ā Fully Supported | ChatGPT, API with code interpreter |
| Gemini (Google) | ā Fully Supported | Gemini Pro, API |
| LLaMA (Meta) | ā Fully Supported | With code execution capability |
| Mistral | ā Fully Supported | With code execution capability |
| Other LLMs | ā Compatible | Any agent supporting bash/curl |
Installation
As AI Agent Skill
The skill can be loaded by any AI agent that reads markdown-based skill definitions:
# Clone the repository
git clone https://github.com/bowen31337/weex-futures-trading-skill.git
# Or download just the skill file
curl -L -o SKILL.md \
https://raw.githubusercontent.com/bowen31337/weex-futures-trading-skill/main/weex-trading/SKILL.md
For Claude Code
# Install to Claude Code skills directory
cp SKILL.md ~/.claude/skills/weex-trading.md
For Other AI Agents
Most AI agents can use this skill by:
- Loading the
SKILL.mdfile into the conversation context - Or referencing it as a system prompt
- Or using your agent's skill/plugin installation mechanism
As Standalone Python Client
git clone https://github.com/bowen31337/weex-futures-trading-skill.git
cd weex-futures-trading-skill
pip install requests
Configuration
Set your WEEX API credentials as environment variables:
export WEEX_API_KEY=your_api_key
export WEEX_API_SECRET=your_api_secret
export WEEX_PASSPHRASE=your_passphrase
export WEEX_BASE_URL=https://api-contract.weex.com # Optional
Getting API Keys
- Log in to your WEEX account at weex.com
- Navigate to API Management in account settings
- Create a new API key with required permissions:
- Read - View account info, positions, order history
- Trade - Place and cancel orders
- Save your API Key, API Secret, and Passphrase securely
Usage
Python CLI Client
# Market Data (no authentication required)
python scripts/weex_client.py time # Server time
python scripts/weex_client.py ticker cmt_btcusdt # Get BTC price
python scripts/weex_client.py depth cmt_btcusdt # Order book
python scripts/weex_client.py funding cmt_btcusdt # Funding rate
# Account Info (authentication required)
python scripts/weex_client.py assets # Account balances
python scripts/weex_client.py positions # All positions
python scripts/weex_client.py orders # Open orders
python scripts/weex_client.py settings # Leverage settings
# Trading
python scripts/weex_client.py buy cmt_btcusdt 10 # Market buy 10 contracts
python scripts/weex_client.py buy cmt_btcusdt 10 95000 # Limit buy at $95,000
python scripts/weex_client.py sell cmt_btcusdt 10 # Market short 10 contracts
python scripts/weex_client.py close_long cmt_btcusdt 10 # Close long position
python scripts/weex_client.py close_short cmt_btcusdt 10 # Close short position
# Order Management
python scripts/weex_client.py cancel 1234567890 # Cancel order by ID
python scripts/weex_client.py cancel_all # Cancel all orders
python scripts/weex_client.py close_all # Close all positions
# Account Settings
python scripts/weex_client.py leverage cmt_btcusdt 20 # Set 20x leverage
With AI Agents
Once loaded as a skill, any compatible AI agent can help you trade on WEEX:
You: What's the current BTC price on WEEX?
Agent: [Fetches ticker data and displays price]
You: Open a long position on BTC with 10 contracts
Agent: [Confirms order details and executes after your approval]
You: Show my current positions
Agent: [Displays all open positions with PnL]
You: Set a stop-loss at $90,000 for my BTC position
Agent: [Creates trigger order for risk management]
The skill provides curl commands that any AI agent with shell access can execute.
API Reference
Order Types
| Type | Description |
|---|---|
1 | Open Long (buy to open) |
2 | Open Short (sell to open) |
3 | Close Long (sell to close) |
4 | Close Short (buy to close) |
Execution Types
| Type | Description |
|---|---|
0 | Normal order |
1 | Post-only (maker only) |
2 | FOK (fill or kill) |
3 | IOC (immediate or cancel) |
Margin Modes
| Mode | Description |
|---|---|
1 | Cross margin |
3 | Isolated margin |
Popular Trading Pairs
| Symbol | Description |
|---|---|
cmt_btcusdt | Bitcoin / USDT |
cmt_ethusdt | Ethereum / USDT |
cmt_solusdt | Solana / USDT |
cmt_xrpusdt | XRP / USDT |
cmt_dogeusdt | Dogecoin / USDT |
Rate Limits
| Category | IP Limit | UID Limit |
|---|---|---|
| Market Data | 20 req/sec | N/A |
| Account Info | 10 req/sec | 10 req/sec |
| Order Operations | 10 req/sec | 10 req/sec |
Error Codes
| Code | Description | Solution |
|---|---|---|
40001 | Invalid parameter | Check parameter format |
40101 | Authentication failed | Verify credentials and timestamp |
40301 | IP not whitelisted | Add IP to API whitelist |
42901 | Rate limit exceeded | Reduce request frequency |
Safety Notes
- Always verify order details before confirming trades
- Check balance before placing orders
- Understand leverage risks - higher leverage = higher risk
- Use stop-loss orders to manage risk
- Start with small positions when testing
Project Structure
weex-trading/
āāā SKILL.md # Open AI Agent skill definition (37 API endpoints)
āāā README.md # This file
āāā scripts/
ā āāā weex_client.py # Python CLI client
āāā references/
āāā api_reference.md # API endpoint quick reference
Skill Coverage
The SKILL.md provides complete coverage of the WEEX Futures API:
| Category | Endpoints | Description |
|---|---|---|
| Market Data | 13 | Tickers, order book, candles, funding rates |
| Account | 8 | Balances, settings, leverage, margin |
| Position | 3 | View and manage positions |
| Order | 9 | Place, cancel, query orders |
| Trigger Order | 4 | Stop-loss, take-profit triggers |
| TP/SL | 2 | Position-level TP/SL orders |
| AI Integration | 1 | Log AI trading decisions |
| Total | 38 | 100% API coverage |
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -m 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Open a Pull Request
License
MIT License - see LICENSE for details.
What is an Open Agent Skill?
An Open Agent Skill is a markdown-based skill definition that can be used by any AI agent with code execution capabilities. Unlike proprietary plugin formats, open agent skills:
- š Human-readable - Written in Markdown with embedded code blocks
- š Universal - Work with any AI agent (Claude, GPT, Gemini, LLaMA, etc.)
- š ļø Self-contained - Include all necessary code snippets and documentation
- š Transparent - Users can inspect exactly what commands will be executed
- š¤ Shareable - Easy to distribute, fork, and contribute to
Links
Permissions & Security
Security level L1: Low-risk skills with minimal permissions. Review inputs and outputs before running in production.
Requirements
- OpenClaw CLI installed and configured.
- Language: Markdown
- License: MIT
- Topics:
FAQ
How do I install weex-trading?
Run openclaw add @bowen31337/weex-trading-skills in your terminal. This installs weex-trading into your OpenClaw Skills catalog.
Does this skill run locally or in the cloud?
OpenClaw Skills execute locally by default. Review the SKILL.md and permissions before running any skill.
Where can I verify the source code?
The source repository is available at https://github.com/openclaw/skills/tree/main/skills/bowen31337/weex-trading-skills. Review commits and README documentation before installing.
