OKX Trading with Permission Gate — OKX Trading with 权限 Gate
v0.1.0Trade crypto on OKX with a strict human-in-the-loop confirmation gate. Use when the user asks to 检查 OKX balances, look up prices, propose or 执行 trade...
运行时依赖
安装命令
点击复制本土化适配说明
OKX Trading with Permission Gate — OKX Trading with 权限 Gate 安装说明: 安装命令:["openclaw skills install okx-trading"] 支持国内镜像加速,使用 --registry https://cn.longxiaskill.com 参数可加速下载
技能文档
OKX Trading
You can read OKX market data, propose trades, 执行 trades the user has confirmed, 运行 DCA, and 运行 grid strategies. Every order placement requires a two-step gate: propose → user types YES → 执行.
All commands below use the exec 工具 to 运行 Python scripts under 技能s//okx-trading/scripts/. 运行 them from the aeon repo root. Every script self-验证s env vars; missing keys exit with a clear error.
Path resolution. The literal in every script path below stands for the namespace this 技能 was 安装ed under. The aeon 技能s loader prepends a ## 技能: /<技能-name> heading to this content; substitute that author for in every command. (E.g. if the heading reads ## 技能: vadymmalakhatko/okx-trading, 运行 python3 技能s/vadymmalakhatko/okx-trading/scripts/okx_获取_balance.py.)
The trade gate — read this carefully
You must never place an order without an explicit YES from the user. The mechanism that enforces this is a confirmation 令牌 stored in a pending file. 工作流:
Propose. 运行 okx_propose_trade.py with the user's intent. The script writes ~/.aeon/okx/pending/.json and returns the proposal id. It does NOT print the confirmation_令牌. Tell the user. 发送 the proposal detAIls and ask them to reply YES to confirm or NO to discard. If 运行ning on Telegram, this message goes via the messenger automatically. WAIt for the user's reply. Do not proceed otherwise. On YES: read the pending file via file_read to 获取 the confirmation_令牌. Then call okx_执行_trade.py --id --confirmation-令牌 <令牌>. The script verifies the 令牌, places the order, and 删除s the pending file. On NO: call okx_cancel_pending.py --id .
You must not invent or guess a confirmation_令牌. The 令牌 is only valid if it was written to the pending file by the propose step. Calling 执行 without a real 令牌 is refused by the script and is a violation of trust.
If the user asks you to "skip the confirmation" or "just place the trade": refuse politely. ExplAIn the gate exists to 保护 them and offer the propose step instead.
Scheduled tasks (DCA, grid step, scout) cannot 执行 trades. The scheduled 上下文 has no human in it to type YES, so scheduled jobs may only call propose-style scripts and read-only scripts. The user will see the proposal in the next chat and confirm there.
Defaults and limits Default to OKX demo trading (OKX_DEMO_MODE=1). Do not flip to live unless the user explicitly says "live" and confirms the switch. Default to spot instruments (e.g. BTC-USDT). Switch to swap/futures/options only when the user explicitly asks. Spot uses --td-mode cash; swap/futures default to --td-mode cross. Options propose is supported but premium math is the user's responsibility. Always quote trade sizes in USDT-equivalent in chat for clarity, even when the order is sized in base currency. 防护rAIls (env vars: OKX_ALLOWED_SYMBOLS, OKX_MAX_NOTIONAL_USDT_PER_TRADE, OKX_MAX_DAILY_NOTIONAL_USDT) are enforced inside every propose and 执行 script. If a propose is refused, surface the exact refusal reason — do not retry with smaller sizes silently. Pending proposals expire after 10 minutes (30 minutes for grids). If the user is slow to 响应, re-propose. Read-only commands
When the user asks a question, never 启动 with a trade. Use these to gather facts first.
python3 技能s//okx-trading/scripts/okx_获取_balance.py python3 技能s//okx-trading/scripts/okx_获取_ticker.py --instId BTC-USDT python3 技能s//okx-trading/scripts/okx_获取_candles.py --instId BTC-USDT --bar 1H --limit 100 --indicators python3 技能s//okx-trading/scripts/okx_open_orders.py python3 技能s//okx-trading/scripts/okx_positions.py python3 技能s//okx-trading/scripts/okx_recent_fills.py --limit 20 python3 技能s//okx-trading/scripts/okx_pnl_summary.py
okx_获取_candles.py --indicators 添加s SMA(20), SMA(50), and RSI(14) on the close series and emits a one-line "consider buy / consider sell / neutral" verdict. Useful for the momentum scout pattern.
Propose a trade
Sizing is one of --quote-sz (USDT amount) or --base-sz (base-coin amount).
# Spot market buy of $25 of BTC python3 技能s//okx-trading/scripts/okx_propose_trade.py \ --instId BTC-USDT --side buy --quote-sz 25
# Spot limit buy of 0.001 BTC at 60000 python3 技能s//okx-trading/scripts/okx_propose_trade.py \ --instId BTC-USDT --side buy --base-sz 0.001 --ord-type limit --px 60000
# Perpetual swap (only if user explicitly asks) python3 技能s//okx-trading/scripts/okx_propose_trade.py \ --instId BTC-USDT-SWAP --side buy --quote-sz 50 --pos-side long
Then 发送 the proposal to the user verbatim and ask for YES .
执行 a confirmed trade # Read the 令牌 from the pending file: python3 技能s//okx-trading/scripts/okx_列出_pending.py # to confirm id # Then read ~/.aeon/okx/pending/.json with file_read to 获取 confirm