aicoin-trading
Original:🇺🇸 English
Translated
3 scripts
This skill should be used when the user asks about exchange trading, placing orders, checking balance, viewing positions, order history, market list, leverage, margin mode, transferring funds, or automated trading. Use when user says: 'buy BTC', 'sell ETH', 'check balance', 'place order', 'open long', 'open short', 'close position', 'set leverage', 'auto trade', 'view positions', '下单', '买入', '卖出', '查余额', '做多', '做空', '平仓', '设杠杆', '自动交易', '合约交易', '现货交易'. Supports Binance, OKX, Bybit, Bitget, Gate.io, HTX, KuCoin, MEXC, Coinbase, Hyperliquid. For crypto prices/charts/news, use aicoin-market. For Freqtrade strategies, use aicoin-freqtrade. For Hyperliquid whale tracking/analytics (not trading), use aicoin-hyperliquid.
13installs
Sourceaicoincom/aicoin-skills
Added on
NPX Install
npx skill4agent add aicoincom/aicoin-skills aicoin-tradingTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →CoinOS Trading
Exchange trading toolkit powered by AiCoin Open API. Buy, sell, manage positions across 9 major exchanges.
Version: 1.0.0
Critical Rules
- NEVER place orders without explicit user confirmation. returns a preview first. Show it, wait for "确认"/"yes", THEN re-run with
create_order."confirmed":"true" - NEVER auto-adjust order parameters (size, leverage). If balance is insufficient, tell the user.
- NEVER sell or close positions unless the user specifically asks.
- NEVER write custom CCXT/Python code. ALL exchange operations MUST go through .
exchange.mjs - NEVER run or
env— leaks API secrets.printenv - Scripts auto-load — never pass credentials inline.
.env
Quick Reference
| Task | Command |
|---|---|
| Balance | |
| Ticker | |
| Orderbook | |
| Buy (preview) | |
| Positions | |
| Set leverage | |
| Auto-trade setup | |
Supported Exchanges: Binance, OKX, Bybit, Bitget, Gate.io, HTX, KuCoin, MEXC, Coinbase, Hyperliquid.
Symbol format: CCXT format — (spot), (swap/futures).
BTC/USDTBTC/USDT:USDTSetup
Requires exchange API keys in and ccxt installed ( in this skill directory).
.envnpm install.env- Current working directory
~/.openclaw/workspace/.env~/.openclaw/.env
CEX (Centralized Exchanges)
All CEX use the same pattern — go to exchange API management page, create API key:
# Format: {EXCHANGE}_API_KEY / {EXCHANGE}_API_SECRET
# Supported: BINANCE, OKX, BYBIT, BITGET, GATE, HTX, KUCOIN, MEXC, COINBASE
BINANCE_API_KEY=xxx
BINANCE_API_SECRET=xxx
# OKX additionally needs passphrase:
OKX_API_KEY=xxx
OKX_API_SECRET=xxx
OKX_PASSWORD=your-passphrase
PROXY_URL=socks5://127.0.0.1:7890 # optionalHyperliquid (DEX — wallet-based, NOT API key)
Hyperliquid is a DEX. There is NO API key page. Authentication uses your wallet address + private key.
# Wallet address (0x...) — this is your public address, NOT an API key
HYPERLIQUID_API_KEY=0x1234...abcd
# Private key (0x...) — export from MetaMask/Rabby, or use HL Agent Wallet
HYPERLIQUID_API_SECRET=0xabcd...1234How to get these:
- = your EVM wallet address (the 0x... shown in MetaMask/Rabby)
HYPERLIQUID_API_KEY - = private key. Two options:
HYPERLIQUID_API_SECRET- Agent Wallet (recommended): On app.hyperliquid.xyz → Settings → Agent Wallet → Create. This gives a limited-permission key that can only trade (cannot withdraw).
- Wallet private key: Export from MetaMask (Settings → Security → Export Private Key). Full permissions — use with caution.
Symbol format: Hyperliquid uses USDC, not USDT: , .
BTC/USDC:USDCETH/USDC:USDCPre-Trade Checklist (MANDATORY)
Before placing ANY order:
- — Get
marketsandlimits.amount.min. NEVER guess minimums.contractSize - — Check available funds.
balance - Convert units — differs between spot and futures:
amount- Spot: amount = base currency (e.g., 0.01 = 0.01 BTC)
- Futures: amount = contracts (e.g., 1 = 1 contract). Use to convert.
contractSize
- Confirm with user — Show coin, direction, quantity, estimated cost, leverage. Ask "确认下单?"
| User says | Spot amount | Swap amount (OKX BTC, contractSize=0.01) |
|---|---|---|
| "0.01 BTC" | | |
| "1张合约" | N/A | |
| "100U" | | |
Scripts
scripts/exchange.mjs — Exchange Operations (CCXT)
Public (no API key)
| Action | Description | Params |
|---|---|---|
| Supported exchanges | None |
| Market list | |
| Real-time ticker | |
| Order book | |
| Recent trades | |
| OHLCV candles | |
Account (API key required)
| Action | Description | Params |
|---|---|---|
| Account balance | |
| Open positions | |
| Open orders | |
| Order history | |
| Trade history | |
| Order by ID | |
Trading (API key required)
| Action | Description | Params |
|---|---|---|
| Place order | Spot: |
| Cancel order | |
| Set leverage | |
| Margin mode | |
| Transfer funds | |
Transfer notes:
- Account names: ,
spot,future,delivery,margin(exact values).funding - OKX unified account: Spot and derivatives share balance. No transfer needed. Error 58123 = unified account.
- Binance: Requires explicit transfer between spot/futures.
scripts/auto-trade.mjs — Automated Trading
Config stored at .
~/.openclaw/workspace/aicoin-trade-config.json| Action | Description | Params |
|---|---|---|
| Save trading config | |
| Config + balance + positions | |
| Open position | |
| Close position + cancel orders | |
The action automatically: checks balance, calculates position size (capital_pct x balance x leverage), sets leverage, places market order, sets SL/TP.
openAutomated Trading Workflow
- Ask user: exchange, coin, capital, leverage
- with params
auto-trade.mjs setup - to verify
auto-trade.mjs status - Set up OpenClaw cron:
bash
openclaw cron add --name "BTC auto trade" --every 10m --session isolated \
--message "Use aicoin-market to fetch data, analyze, then use aicoin-trading auto-trade.mjs open/close"Cross-Skill References
| Need | Use |
|---|---|
| Prices, K-lines, news, signals | aicoin-market |
| Freqtrade strategies/backtest | aicoin-freqtrade |
| Hyperliquid whale tracking | aicoin-hyperliquid |
Common Errors
- — Paid AiCoin feature. Do NOT retry. See below.
errorCode 304 / HTTP 403 - — Use CCXT format:
Invalid symbol(spot),BTC/USDT(swap). Hyperliquid uses USDC:BTC/USDT:USDT.BTC/USDC:USDC - — Check balance first, don't auto-adjust. Tell user.
Insufficient balance - — Keys in
API key invalid, never inline. Check if user configured exchange keys..env - — Wait 1-2s between requests.
Rate limit exceeded - OKX error 58123 — Unified account, no transfer needed between spot/futures.
Paid Feature Guide
When a script returns 304 or 403: Do NOT retry. Tell the user:
- What happened: This feature needs a paid AiCoin API subscription.
- How to get a key: Visit https://www.aicoin.com/opendata to register and create an API key.
- Tier options:
| Tier | Price | Highlights |
|---|---|---|
| Free | $0 | Prices, K-lines, trending coins |
| Basic | $29/mo | + Funding rate, L/S ratio, news |
| Standard | $79/mo | + Whale orders, signals, grayscale |
| Advanced | $299/mo | + Liquidation map, indicator K-lines, depth |
| Professional | $699/mo | All endpoints: AI analysis, OI, stocks |
- How to configure: Add to file:
.env
AICOIN_ACCESS_KEY_ID=your-key-id
AICOIN_ACCESS_SECRET=your-secret- auto-loaded from: cwd →
.env→~/.openclaw/workspace/.env. After configuring, the same script command will work.~/.openclaw/.env