okx-cex-trade

Place, amend, and cancel spot, swap, futures, options, and event contract orders on OKX via CLI.

Updated Aug 21, 2026
One-click install
npx skills add https://github.com/nickthelegend/xorr-monorepo --skill okx-cex-trade-nickthelegend
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: okx-cex-trade
Source: https://github.com/nickthelegend/xorr-monorepo/tree/main/.agents/skills/okx-cex-trade
Command: npx skills add https://github.com/nickthelegend/xorr-monorepo --skill okx-cex-trade-nickthelegend

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @okx_ai/okx-trade-cli, and includes references (resource) components.

What problem does it solve? Executing trades on OKX through an AI agent requires correct order parameters, contract sizing, margin modes, and credential handling; this Skill encodes the exact CLI commands, sizing rules, and safety checks so agents place and manage orders without parameter errors. ## Core Features & Use Cases - Multi-instrument order management: Place, cancel, amend, and query spot, perpetual swap, delivery futures, options, and event contract orders, including TP/SL, trailing stop, trigger, chase, iceberg, and TWAP algo orders. - Contract sizing and leverage control: Convert USDT notional or margin amounts to contract counts using ctVal, and set leverage per instrument with cross or isolated margin. - Event contract trading: Discover prediction-market series, read market-implied probabilities, and trade Yes/No or Up/Down outcomes with settlement tracking. - Use Case: A user says "long BTC perp with 500 USDT margin at 10x and set a stop loss at 88000" — the Skill resolves sizing mode, confirms parameters, places the swap order with attached SL, and verifies the position afterward. ## Quick Start Ask the agent to buy 0.01 BTC at market price on OKX spot in demo mode after running okx config init to set up credentials.

Frequently Asked Questions about okx-cex-trade

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I place a market or limit order on OKX from the command line?

Use okx spot place with --instId, --side, --ordType, and --sz; limit orders also require --px. For derivatives use okx swap place or okx futures place with --tdMode cross or isolated, and --posSide in hedge mode.

How do I set a stop loss or take profit on an OKX position?

Attach TP/SL directly when placing with --tpTriggerPx, --tpOrdPx=-1, --slTriggerPx, and --slOrdPx=-1, or place a separate algo order via okx swap algo place with ordType conditional or oco. Trailing stops use okx swap algo trail with --callbackRatio.

How does contract sizing work for OKX perpetual swaps?

By default --sz is a contract count, and each contract is worth ctVal of the underlying, so always check ctVal via market instruments first. For USDT amounts use --tgtCcy quote_ccy for notional value or --tgtCcy margin for margin cost, and the system converts to contracts.

Can I trade OKX options and event contracts with this CLI?

Yes. Options use okx option instruments to find the exact instId, okx option greeks for IV and Greeks, and okx option place with tdMode cash for buyers. Event contracts use okx event browse, event markets, and event place with an outcome of YES, NO, UP, or DOWN.

Why does setting leverage fail on OKX with a cancel-orders error?

Pending algo orders or active trading bots on that instrument block leverage changes under cross margin. Check okx swap algo orders for pending TP/SL orders first, then bot grid-orders; the Skill reports findings and never cancels orders without user confirmation.

What credentials are required to trade on OKX with this tool?

You need either an API-key profile in ~/.okx/config.toml or an OAuth session created via okx config init. Demo mode is available with --demo for OAuth or a demo profile for API keys, so you can test without real funds.