From okxoutcomes
Account state + signed trading on OKX Outcomes via the Rust `okx-outcomes` CLI. Use whenever the user wants to: check account balance / open orders / closed orders / positions / trade history (OAuth-authenticated reads); place orders (limit or market, base or quote size, GTC/GTD/IOC/FOK/ALO); cancel orders (by server OID, cancel-all, or dead-man heartbeat); split / merge / redeem CTF tokens; subscribe to private WebSocket channels (orders / positions / balance / user-trades / pnl); run a status health check or the TUI trading terminal; show the derived wallet address. (First-time onboarding / sign-in / wallet binding is owned by the `okx-outcomes-setup` skill.) Triggers include: '我的余额', 'my balance', '我的委托', 'open orders', '历史委托', 'closed orders', '我的持仓', 'my positions', '成交记录', 'trade history', '下单', 'place order', '限价单', '市价单', '买 YES', '卖 NO', 'cancel', '撤单', '一键撤单', 'cancel-all', 'heartbeat', '拆分', 'split CTF', '合并', 'merge CTF', '赎回', 'redeem winners', '私有频道', 'private channel', 'live pnl', 'TUI terminal', 'trade terminal', '健康检查', 'status check', '钱包地址', 'wallet show'.
How this skill is triggered — by the user, by Claude, or both
Slash command
/okxoutcomes:okx-outcomes-tradeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Drive the account-state and write side of the `okx-outcomes` Rust
Drive the account-state and write side of the okx-outcomes Rust
CLI: account reads, EIP-712 signed orders, CTF token ops, private
WebSocket streams, status, TUI terminal. (Onboarding / sign-in / wallet
binding lives in the okx-outcomes-setup skill — route there if the
account isn't configured.)
Before any command, run these in order and stop on first failure.
Binary on PATH
command -v okx-outcomes || echo "NOT_INSTALLED"
Missing? cargo install --locked --path . or
download the prebuilt binary.
Credentials configured
bash skills/okx-outcomes-trade/scripts/preflight.sh | jq -r '.ready_for.write_ops'
(Richer per-field detail, optional:
bash "${CLAUDE_PLUGIN_ROOT:-.}/skills/okx-outcomes-trade/scripts/preflight.sh".)
false? Hand off to the okx-outcomes-setup skill — it owns onboarding
and walks the user through the three pieces in order (region Global/US →
OAuth sign-in → EOA wallet binding), one step at a time. It ultimately
drives the interactive okx-outcomes setup wizard in the user's own
terminal (don't try to drive that from chat): the wizard auto-generates a
fresh signing wallet (the 64-hex key is never displayed), prints a QR +
https://okx.com/ul/... universal short link (tap on mobile to launch
the OKX app, or paste into any browser) to bind the EOA address, and
lands credentials in the OS keyring (with an AES-256-GCM
encrypted file fallback at ~/.okx-outcomes/keyring.enc; the file
fallback guards a single-file leak, not a reader of the home dir — see
the README "Credentials" section). Re-runs replace the wallet (old EOA
binding becomes invalid; a yellow warning surfaces the old address).
OAuth session (required for account / private WS commands, and for
the account-auth half of signed writes). Established by okx-outcomes setup (or a separate okx-outcomes auth login). The token is brokered
by okx-auth; the CLI never displays it. This OAuth bearer token is the
only account-auth path — there is no HMAC and no API-key trio.
Signing key present (required for all write ops + wallet show).
Stored under keyring key agent_private_key (written by setup). It is
the only secret in the keyring. There is no env-var override and no
--key flag — the key is always resolved from the keyring.
Corporate proxy — --proxy <URL> if the user mentions VPN /
firewall.
One-shot helper: bash skills/okx-outcomes-trade/scripts/preflight.sh
emits JSON for all five checks.
agent_private_key) are never displayed by the CLI; don't attempt to
surface them. Report auth state as logged-in / not-logged-in.0x****
(catches 64-hex private keys, 130-hex signatures). Wallet addresses
(40 hex) and tx hashes (64 hex from tx_hash response fields) are
public — display in full or truncated as 0xAbCd...1234.okx-outcomes-market
(no signing key, lighter surface).$P is the binary (default okx-outcomes, override via
OKX_OUTCOMES_BIN). Always pass -j for JSON, parse with jq,
re-render as a table.
The CLI also accepts --theme auto|light|dark (or the OKX_THEME env
var) for color output. This skill never needs to set it — -j strips
colors entirely and we render the table ourselves — so leave --theme
unset unless the user explicitly asks about it.
| User intent | Command |
|---|---|
| portfolio / available / positions value | $P account balance -j |
| single order detail | $P account order <orderId> -j |
| open orders | $P account orders -j (defaults to --status open) |
| closed orders (filled / cancelled / expired / failed) | $P account orders --status closed [--cursor ...] -j |
| positions (open) | $P account positions -j (defaults to open) |
| closed positions | $P account positions --status closed -j |
| positions for a market | $P account positions --market <id> -j |
| trade history | $P account trades [--market <id>] [--side BUY|SELL] [--start-time <ms>] [--end-time <ms>] [--cursor ...] [--limit 20] -j |
| wallet address (derived from signing key) | $P wallet show -j |
clob order / orders / trades are thin aliases for account.* — same
output, same auth path. Use either; this skill prefers the account
form for clarity.
All commands below MUST go through the Step-by-Step Write Protocol
(§5). Never call them directly without dry-run + exact confirm <action>. Read references/safety-write-ops.md before every write op.
| User intent | Command |
|---|---|
| limit order | $P clob create-order --asset <id> --side buy|sell --price <0..1> --size <s> [--tif gtc|gtd|ioc|fok|alo] [--expiry <ms>] [--size-type base|quote] |
| market order (book-walked + IOC/FOK) | $P clob market-order --market <id> --outcome yes|no --side buy|sell --size <s> [--tif ioc|fok] [--size-type base|quote] (recommended; NO priced off the inverted YES book). Deprecated: --asset <id> (YES-only) |
| cancel by server OID | $P clob cancel-oid --oid <orderId> --asset <assetId> |
| cancel all | $P clob cancel-all |
| dead-man heartbeat (5 min) | $P clob heartbeat |
| split pts → YES + NO | $P ctf split --market <id> --amount <pts> |
| merge YES + NO → pts | $P ctf merge --market <id> --amount <size> |
| redeem winners (after settlement) | $P ctf redeem --market <id> |
When preparing a dry-run for clob create-order / clob market-order,
this skill calls the read-only CLOB commands too — they live mainly in
the okx-outcomes-market skill but the binary is the same:
| Step | Command |
|---|---|
| current bid/ask | $P clob price --asset <id> -j |
| midpoint | $P clob midpoint --asset <id> -j |
| top-5 book (for market-order worst-case price) | $P clob book --asset <id> --sz 5 -j |
To confirm fills / balance / position changes, poll REST instead —
account orders -j / account positions -j / account balance -j
give an authoritative snapshot without the token cost. The ws *
private channels emit unbounded NDJSON that floods context, so they are
not listed here. Only when the user explicitly wants a live private
feed, consult references/ws-protocol.md (login + channels) and cap
hard with | head -n 5. For sustained watching, use the TUI
(ws terminal).
| Need | Command |
|---|---|
| first-time onboarding | hand off to the okx-outcomes-setup skill (it drives $P setup / per-step commands in the user's own terminal) |
| health check | $P status [-j] (pings events + balance) |
| TUI trading terminal | $P ws terminal <assetId> (interactive ratatui) |
| REPL | $P shell (interactive) |
portfolio-check — "What do I hold?"
$P account balance -j → portfolio (cash + open-positions value), availableToTrade, positionsValue, plus the raw balances[] per oddsType.$P account positions -j → open positions.$P account positions --status closed -j → resolved positions.$P account orders --status closed -j → recent filled / cancelled / expired orders.$P account trades --limit 20 -j → recent fills.safe-place-order — "Place 80 pts on this market." (cross-cuts read-only commands from market skill, but stays in this skill end-to-end)
$P clob midpoint --asset <id> -j + $P clob book --asset <id> --sz 5 -j + $P data ticker <id> -j.confirm reply.$P clob create-order … or $P clob market-order ….$P account orders -j → confirm the order is live. Re-run it (or
account trades -j) to track fills — no streaming needed.resolve-and-redeem — "Settle and claim my winners."
$P account positions --status closed -j → rows with Status = Won
are settled and claimable (derived from winning_token, the
authoritative resolution signal). No separate confirmation stream is
needed — ctf redeem is rejected server-side before settlement.ctf redeem.confirm redeem, then $P ctf redeem --market <id>.Every command in the Write table goes through this 4-step flow.
No exceptions. Read references/safety-write-ops.md for the full
guardrail spec.
Step 1 — Collect parameters.
assetId ↔ market title via $P data event-markets <eventId> so the user sees what they're trading.Step 2 — Dry-run summary. Render a human-readable block:
About to: clob market-order --market 101663 --outcome yes --side buy --size 80 --size-type quote --tif ioc
Market: "Will candidate X win?" (--market 101663)
Outcome: YES (--outcome yes; resolves to asset 101664000)
Side: buy
Size: 80 pts (--size-type quote)
TIF: ioc
Wallet: 0xAbCd...1234 (from `wallet show`)
Available: 132.5 pts (from `account balance`)
Book top 5:
ask 78¢ × 50 | bid 72¢ × 40
ask 79¢ × 60 | bid 71¢ × 80
...
Worst price you'd pay: ~79¢ (book-walk for 80 pts)
Reply `confirm market-order` to proceed, or `cancel` to abort.
For market-order: ALWAYS include the book snapshot + worst-walked price.
For limit orders: include the limit price you'll sign.
For cancel-oid: show the order you're cancelling (run $P account order <oid> first).
For cancel-all: how many open orders will be touched.
For ctf split/merge/redeem: market title + position rows that change.
Step 3 — Wait for exact confirmation. Only proceed when the user
replies exactly confirm <action> (e.g. confirm market-order,
confirm cancel-oid, confirm redeem). Anything else — yes, go,
ok, 好的 — counts as "needs re-confirm".
Step 4 — Execute and report. Run the real command (it resolves
agent_private_key from the keyring automatically — there is no --key
flag). Print the tx hash.
Within 30 s:
$P account orders -j → show the new row.$P account orders -j → confirm the row is gone.$P account positions --status open -j + $P account balance -j → show deltas.<IMPORTANT> rulesokx-outcomes-market. Save context
and don't duplicate.clob heartbeat is a dead-man
switch — each invocation needs its own confirm.-j. Parse JSON, render table.ws * channels flood
context — poll account * for confirmations instead. Only on explicit
user request, per references/ws-protocol.md, capped with | head -n 5.okx-outcomes setup); there is no --key flag and no
env override. Never accept a pasted key.setup, shell, ws terminal) cannot
run from a non-TTY Bash invocation. Tell the user to run them in
their own terminal; offer a follow-up checkpoint instead.REST endpoints may lag 5–30 s vs. the matching engine — fine for
virtually all agent queries; re-run account balance / orders /
positions / trades for a fresh snapshot. Sub-second private live
feeds exist over WebSocket but are token-heavy; use them only on
explicit request (see references/ws-protocol.md) or via the TUI
(ws terminal).
For historical data, REST is authoritative (account trades --start-time / --end-time, account positions --status closed).
references/cli-reference.md — account + clob writes + ctf + private
ws + tools (trade-side slice).references/ws-protocol.md — private channel frame schemas + login
flow.references/safety-write-ops.md — READ before every write op.references/keyword-glossary.md — zh/EN trigger → command map (trade
side).references/env-vars.md — config (config.json) + OAuth/keyring auth
model + supported operational env vars.scripts/preflight.sh — readiness check (binary + OAuth session +
signing key in keyring), JSON output.account_read: false or
write_ops: false). Route to the okx-outcomes-setup skill (it owns
onboarding and drives the interactive wizard in the user's own terminal).wallet show; route to
the okx-outcomes-setup skill to re-run setup (no env-var fallback).NotAuthenticated; surface cleanly + route to the okx-outcomes-setup
skill to sign in.clob market-order. Refuse locally; suggest
clob create-order --tif gtc instead.clob market-order --tif fok insufficient depth. CLI rejects
locally before signing — relay error; offer --tif ioc or smaller
--size.ctf redeem on unresolved market. API returns error; relay it
and poll $P account positions --status closed -j (the row flips to
Status = Won once settled) instead of streaming.next_cursor to user; offer next page.--proxy http://corp-proxy:8080 on connection
errors.npx claudepluginhub okx/outcomes-cli --plugin okxoutcomesGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.