okx-cex-portfolio
Original:🇺🇸 English
Translated
This skill should be used when the user asks about 'account balance', 'how much USDT do I have', 'my funding account', 'show my positions', 'open positions', 'position P&L', 'unrealized PnL', 'closed positions', 'position history', 'realized PnL', 'account bills', 'transaction history', 'trading fees', 'fee tier', 'account config', 'max order size', 'how much can I buy', 'withdrawable amount', 'transfer funds', 'move USDT to trading account', or 'switch position mode'. Requires API credentials. Do NOT use for market prices (use okx-cex-market), placing/cancelling orders (use okx-cex-trade), or grid/DCA bots (use okx-cex-bot).
17installs
Sourceokx/agent-skills
Added on
NPX Install
npx skill4agent add okx/agent-skills okx-cex-portfolioTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →OKX CEX Portfolio & Account CLI
Account balance, positions, P&L, bills, fees, and fund transfers on OKX exchange. Requires API credentials.
Prerequisites
- Install CLI:
okxbashnpm install -g @okx_ai/okx-trade-cli - Configure credentials:
Or set environment variables:bash
okx config initbashexport OKX_API_KEY=your_key export OKX_SECRET_KEY=your_secret export OKX_PASSPHRASE=your_passphrase - Test with demo mode:
bash
okx --demo account balance
Demo vs Live Mode
Always clarify before any write command whether the user wants demo or live execution.
Check which mode is active:
bash
okx config show # shows current profile and whether demo is set as defaultRun a single command in demo mode by prepending :
--demobash
okx --demo account balance # simulated account balance
okx --demo account transfer ... # simulated transfer (no real funds moved)Rules for this skill:
- Read commands (balance, positions, bills, etc.): run immediately in both modes — always state which mode you used
- Write commands (,
transfer): before executing, explicitly confirm with the user: "Execute on live account or demo (simulated)?"set-position-mode - When executing in demo mode, prefix your response summary with
[DEMO] - When executing on live account, prefix with
[LIVE]
Skill Routing
- For market data (prices, charts, depth, funding rates) → use
okx-cex-market - For account balance, P&L, positions, fees, transfers → use (this skill)
okx-cex-portfolio - For regular spot/swap/futures/algo orders → use
okx-cex-trade - For grid and DCA trading bots → use
okx-cex-bot
Quickstart
bash
# Trading account balance (all currencies with balance > 0)
okx account balance
# Check USDT balance only
okx account balance USDT
# Funding account balance
okx account asset-balance
# All open positions
okx account positions
# Closed position history with realized PnL
okx account positions-history
# Recent account bills (last 100)
okx account bills
# My trading fee tier
okx account fees --instType SPOT
# Transfer 100 USDT from funding (18) to trading (6)
okx account transfer --ccy USDT --amt 100 --from 18 --to 6Command Index
Read Commands
| # | Command | Type | Description |
|---|---|---|---|
| 1 | | READ | Trading account equity, available, frozen |
| 2 | | READ | Funding account balance |
| 3 | | READ | Open contract/swap positions |
| 4 | | READ | Closed positions + realized PnL |
| 5 | | READ | Account ledger (deposits, withdrawals, trades) |
| 6 | | READ | My trading fee tier (maker/taker) |
| 7 | | READ | Account level, position mode, UID |
| 8 | | READ | Max buy/sell size at current price |
| 9 | | READ | Available size for next order |
| 10 | | READ | Max withdrawable per currency |
Write Commands
| # | Command | Type | Description |
|---|---|---|---|
| 11 | | WRITE | Switch net/hedge position mode |
| 12 | | WRITE | Transfer funds between accounts |
Cross-Skill Workflows
Pre-trade balance check
User: "I want to buy 0.1 BTC — do I have enough USDT?"
1. okx-cex-portfolio okx account balance USDT → check available equity
2. okx-cex-market okx market ticker BTC-USDT → check current price
↓ user approves
3. okx-cex-trade okx spot place --instId BTC-USDT --side buy --ordType market --sz 0.1Pre-bot balance check
User: "I want to start a BTC grid bot with 1000 USDT"
1. okx-cex-portfolio okx account balance USDT → confirm available funds ≥ 1000
2. okx-cex-market okx market candles BTC-USDT --bar 4H --limit 50 → determine price range
↓ user approves
3. okx-cex-bot okx bot grid create --instId BTC-USDT --algoOrdType grid \
--minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000Review open positions and P&L
User: "Show me my current positions and how they're performing"
1. okx-cex-portfolio okx account positions → open positions with UPL
2. okx-cex-portfolio okx account positions-history → recently closed positions
3. okx-cex-market okx market ticker BTC-USDT-SWAP → check current price vs entryTransfer and trade
User: "Move 500 USDT from my funding account to trade BTC"
1. okx-cex-portfolio okx account asset-balance USDT → confirm funding balance ≥ 500
↓ user approves
2. okx-cex-portfolio okx account transfer --ccy USDT --amt 500 --from 18 --to 6
3. okx-cex-portfolio okx account balance USDT → confirm trading balance updated
↓ ready to trade
4. okx-cex-trade okx spot place ...Check max position size before entering
User: "How much BTC can I buy with cross margin?"
1. okx-cex-portfolio okx account balance → total equity
2. okx-cex-portfolio okx account max-size --instId BTC-USDT-SWAP --tdMode cross → max buy/sell size
3. okx-cex-market okx market ticker BTC-USDT-SWAP → current price referenceOperation Flow
Step 1: Identify account action
- Check balance → (trading) or
okx account balance(funding)okx account asset-balance - View open positions →
okx account positions - View closed positions + PnL →
okx account positions-history - View transaction history →
okx account bills - Check fee tier →
okx account fees - Check account settings →
okx account config - Calculate order size → or
okx account max-sizeokx account max-avail-size - Check withdrawal limit →
okx account max-withdrawal - Transfer funds →
okx account transfer - Change position mode →
okx account set-position-mode
Step 2: Run read commands immediately — confirm writes
Read commands (1–10): run immediately, no confirmation needed.
- filter: use currency symbol like
ccy,USDT,BTCETH - for fees/positions:
--instType,SPOT,SWAP,FUTURESOPTION - for bills: access older records beyond the default window
--archive - for max-size:
--tdMode(spot),cash, orcrossisolated
Write commands (11–12): confirm once before executing.
- : confirm mode (
set-position-mode= one-directional,net= hedge mode); switching may affect open positionslong_short_mode - : confirm
transfer,--ccy,--amt,--from(account types:--to=trading,6=funding); verify source balance first18
Step 3: Verify after writes
- After : run
set-position-modeto confirmokx account configupdatedposMode - After : run
transferandokx account balanceto confirm balances updatedokx account asset-balance
CLI Command Reference
Account Balance — Trading Account
bash
okx account balance [ccy] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| No | - | Filter to a single currency (e.g., |
Returns table: , , , . Only shows currencies with balance > 0.
currencyequityavailablefrozenAsset Balance — Funding Account
bash
okx account asset-balance [ccy] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| No | - | Filter to a single currency |
Returns: , , , . Only shows currencies with balance > 0.
ccybalavailBalfrozenBalPositions — Open Positions
bash
okx account positions [--instType <type>] [--instId <id>] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| No | - | Filter: |
| No | - | Filter to specific instrument |
Returns: , , (posSide), , , (unrealized PnL), . Only shows positions with size ≠ 0.
instIdinstTypesideposavgPxuplleverPositions History — Closed Positions
bash
okx account positions-history [--instType <type>] [--instId <id>] [--limit <n>] [--json]Returns: , , , , , .
instIddirectionopenAvgPxcloseAvgPxrealizedPnluTimeBills — Account Ledger
bash
okx account bills [--archive] [--instType <type>] [--ccy <ccy>] [--limit <n>] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| No | false | Access older records (archive endpoint) |
| No | - | Filter by instrument type |
| No | - | Filter by currency |
| No | 100 | Number of records |
Returns: , , , , , , .
billIdinstIdtypeccybalChgbaltsFees — Trading Fee Tier
bash
okx account fees --instType <type> [--instId <id>] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | |
| No | - | Specific instrument (optional) |
Returns: , , , , , .
levelmakertakermakerUtakerUtsConfig — Account Configuration
bash
okx account config [--json]Returns: , (account level), (net/long_short_mode), , , , .
uidacctLvposModeautoLoangreeksTypelevellevelTmpMax Size — Maximum Order Size
bash
okx account max-size --instId <id> --tdMode <mode> [--px <price>] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | Instrument ID |
| Yes | - | |
| No | - | Reference price (uses mark price if omitted) |
Returns: , , .
instIdmaxBuymaxSellMax Available Size
bash
okx account max-avail-size --instId <id> --tdMode <mode> [--json]Returns: , , — the immediately available size for the next order.
instIdavailBuyavailSellMax Withdrawal
bash
okx account max-withdrawal [ccy] [--json]Returns table: , , (with borrowing). Shows all currencies if no filter.
ccymaxWdmaxWdExSet Position Mode
bash
okx account set-position-mode <net|long_short_mode> [--json]| Value | Behavior |
|---|---|
| One-directional (default) — long and short net out |
| Hedge mode — long and short can coexist |
Warning: Switching modes when positions are open may cause unexpected behavior. Checkfirst.okx account positions
Transfer Funds
bash
okx account transfer --ccy <ccy> --amt <n> --from <acctType> --to <acctType> \
[--transferType <type>] [--subAcct <name>] [--json]| Param | Required | Default | Description |
|---|---|---|---|
| Yes | - | Currency to transfer (e.g., |
| Yes | - | Amount to transfer |
| Yes | - | Source account type: |
| Yes | - | Destination account type: |
| No | | |
| No | - | Sub-account name (required for sub-account transfers) |
Returns: , , .
transIdccyamtMCP Tool Reference
| Tool | Description |
|---|---|
| Trading account balance |
| Funding account balance |
| Open positions |
| Closed position history |
| Account bills (recent) |
| Account bills (archive) |
| Trading fee tier |
| Account configuration |
| Max order size |
| Max available size |
| Max withdrawable |
| Set position mode |
| Transfer between accounts |
Input / Output Examples
"How much USDT do I have?"
bash
okx account balance USDT
# → currency: USDT | equity: 5000.00 | available: 4500.00 | frozen: 500.00"Show all my open positions"
bash
okx account positions
# → table: instId, instType, side, pos, avgPx, upl, lever"What's my trading history and realized PnL?"
bash
okx account positions-history
# → table: instId, direction, openAvgPx, closeAvgPx, realizedPnl, uTime"Show my recent account activity"
bash
okx account bills --limit 20
# → table: billId, instId, type, ccy, balChg, bal, ts"What are my trading fees for SWAP?"
bash
okx account fees --instType SWAP
# → level: VIP1 | maker: -0.0001 | taker: 0.0005"How much BTC can I buy in cross margin?"
bash
okx account max-size --instId BTC-USDT-SWAP --tdMode cross
# → instId: BTC-USDT-SWAP | maxBuy: 12.5 | maxSell: 12.5"Transfer 200 USDT from funding to trading"
bash
okx account transfer --ccy USDT --amt 200 --from 18 --to 6
# → Transfer: TXN123456 (USDT 200)"Check my account config"
bash
okx account config
# → uid: 123456789 | acctLv: 2 | posMode: net | autoLoan: falseEdge Cases
- No balance shown: balance is filtered to > 0 — if nothing shows, all currencies have zero balance
- Positions command returns empty: no open contracts; spot holdings are not shown here (use )
account balance - bills --archive: required for transactions older than 7 days (default window); may be slower
- set-position-mode: cannot switch to if you have both long and short positions on the same instrument
net - transfer --from/--to codes: =trading account,
6=funding account; other values exist for sub-account flows18 - max-size vs max-avail-size: is the theoretical maximum;
max-sizeaccounts for existing orders and reserved marginmax-avail-size - Demo mode: shows simulated balances, not real funds
okx --demo account balance
Global Notes
- All write commands require valid credentials in or env vars
~/.okx/config.toml - switches between multiple account configurations
--profile <name> - returns raw OKX API v5 response
--json - Rate limit: 10 requests per 2 seconds for account endpoints
- Positions shown are for the unified trading account; funding account assets are separate
- Account types: =Unified Trading Account (spot + derivatives),
6=Funding Account (deposits/withdrawals)18