Install
openclaw skills install chainup-spot-tradingChainUp/OpenAPI V2 spot and margin trading skill. Prefer using the Python script to call `sapi` endpoints through one unified entrypoint and avoid ad hoc sig...
openclaw skills install chainup-spot-tradingUse this skill immediately when the user mentions OpenAPI V2, spot trading, margin trading, X-CH-SIGN, /sapi/v2/order, /sapi/v1/margin/*, /sapi/v1/account, or similar ChainUp trading/account scenarios.
Goals:
TODO) first and let the user fill them in later.Unified entry script:
scripts/chainup_api.pyCore capabilities:
X-CH-APIKEY, X-CH-SIGN, X-CH-TSContent-Type, admin-language, User-Agentaction -> endpoint mapping--confirm CONFIRM by default--prepare-only: fetch symbol rules via spot_symbols first, then preprocess price / volume--show-todo to display unresolved required placeholders for the current actionscripts/chainup_api.py first. Do not restate API parameter planning in natural language before using the script.Confirm before calling the script.Confirm.spot_create_order, spot_test_order, and margin_create_order, run the script with --prepare-only before asking for confirmation. The script will call spot_symbols, fetch symbol precision, and round down using pricePrecision / quantityPrecision.preparedBody from --prepare-only. Do not show the unadjusted raw order payload.Confirm, execute the live balance-changing action and keep using --confirm CONFIRM.spot_create_order succeeds, follow up with spot_get_order by default.scripts/chainup_api.py.curl, handwritten signing, or any backup HTTP implementation.Prefer /root/TOOLS.md first:
BASE_URL: ...API_KEY: ...SECRET_KEY: ...Use environment variables only as the next fallback:
CHAINUP_BASE_URLCHAINUP_API_KEYCHAINUP_SECRET_KEYCLI arguments are also supported:
--base-url--api-key--secret-keyConfig resolution priority:
CLI arguments > /root/TOOLS.md > environment variables/root/TOOLS.md already contains usable credentials, use them directly and do not require the user to set environment variables first.Sensitive data handling:
CHAINUP_API_KEY and CHAINUP_SECRET_KEY are sensitive. Never print them in full in the terminal, natural-language responses, execution summaries, error relays, or example commands.***, for example 915c***815e.python /root/.codex/skills/chainup-spot/scripts/chainup_api.py <action> \
--query-json '<json-object>' \
--body-json '<json-object>' \
--show-todo
Notes:
--query-json for GET actions--body-json for POST actions--prepare-only can be used first to return precision-adjusted preparedBody for confirmation--confirm CONFIRM only after the user sends a standalone ConfirmPublic:
spot_ping -> GET /sapi/v2/pingspot_time -> GET /sapi/v2/timespot_symbols -> GET /sapi/v2/symbolsspot_depth -> GET /sapi/v2/depthspot_ticker -> GET /sapi/v2/tickerspot_trades -> GET /sapi/v2/tradesspot_klines -> GET /sapi/v2/klinesSpot Signed:
spot_create_order -> POST /sapi/v2/orderspot_test_order -> POST /sapi/v2/order/testspot_batch_orders -> POST /sapi/v2/batchOrdersspot_get_order -> GET /sapi/v2/orderspot_cancel_order -> POST /sapi/v2/cancelspot_batch_cancel -> POST /sapi/v2/batchCancelspot_open_orders -> GET /sapi/v2/openOrdersspot_my_trades -> GET /sapi/v2/myTradesAccount Signed:
spot_account -> GET /sapi/v1/accountasset_transfer -> POST /sapi/v1/asset/transferasset_transfer_query -> POST /sapi/v1/asset/transferQueryMargin Signed:
margin_create_order -> POST /sapi/v1/margin/ordermargin_get_order -> GET /sapi/v1/margin/ordermargin_cancel_order -> POST /sapi/v1/margin/cancelmargin_open_orders -> GET /sapi/v1/margin/openOrdersmargin_my_trades -> GET /sapi/v1/margin/myTrades--prepare-only returns originalBody, preparedBody, adjustments, and symbolRule so the user can review the precision-adjusted live order payload before confirmation.spot_create_order, immediately follow with spot_get_order by default and return the latest order details.symbol + orderId from the create-order response. If the gateway also returns orderIdString, preserve it as well.spot_account is filtered directly in the Python script and returns only assets where free > 0 or locked > 0.api-key, secret-key, or other credentials, mask them before showing anything.Confirm manually before execution, then use --confirm CONFIRM.--no-confirm-gate may be used. This is high risk and should only be used with explicit user authorization.Query spot balances:
python /root/.codex/skills/chainup-spot/scripts/chainup_api.py spot_account --query-json '{}'
Spot market order preparation (live request requires confirmation):
python /root/.codex/skills/chainup-spot/scripts/chainup_api.py spot_create_order \
--body-json '{"symbol":"BTC/USDT","volume":"100.123456","side":"BUY","type":"MARKET"}' \
--prepare-only
Execute the live request after confirmation:
python /root/.codex/skills/chainup-spot/scripts/chainup_api.py spot_create_order \
--body-json '{"symbol":"BTC/USDT","volume":"100","side":"BUY","type":"MARKET"}' \
--confirm CONFIRM --show-todo
Additional spot order conventions:
type=MARKET and side=BUY, volume is interpreted in the quote asset.ETH/USDT, volume=1 with side=BUY means buying ETH with 1 USDT at market.type=MARKET and side=SELL, volume is interpreted in the base asset amount.ETH/USDT, volume=0.1 with side=SELL means selling 0.1 ETH at market.LIMIT, volume is still interpreted as the base asset amount.spot_create_order succeeds, the default next step is not just returning the order receipt. The script should continue with spot_get_order and return the latest order information.Margin limit order:
python /root/.codex/skills/chainup-spot/scripts/chainup_api.py margin_create_order \
--body-json '{"symbol":"BTC/USDT","volume":"0.001","side":"BUY","type":"LIMIT","price":"30000"}' \
--confirm CONFIRM --show-todo
references/authentication.mdreferences/spot-endpoints.mdreferences/margin-endpoints.md