okx-cex-portfolio

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 fee

By okx · 9,364 installs

npx skills add okx/agent-skills --skill okx-cex-portfolio

Source repository · Upstream listing

OKX CEX Portfolio & Account CLI Account balance, positions, P&L, bills, fees, and fund transfers on OKX exchange. Requires API credentials. Preflight Before running any command, follow [ ../ shared/preflight.md ](../ shared/preflight.md). Use metadata.version from this file's frontmatter as the reference for Step 2. Prerequisites 1. Install okx CLI: 2. Configure credentials: 3. Test with demo mode (simulated trading, no real funds): Security : NEVER accept credentials in chat. Guide users to okx config init for setup. Credential & Profile Check Run this check before any authenticated command. The auth method is detected during [preflight](../ shared/preflight.md) Step 2 and remembered for the session. Step A — Verify credentials Check both sources (see [preflight Step 2](../ shared/preflight.md step 2 detect auth method once per session) for the decision table). okx auth status json alone is insufficient — its apiKey field is always false and does NOT reflect the TOML config. Branch in this order — first match wins: config show has any profile with a non empty api key — API Key mode . Proceed to Step B. No API key profile AND auth status returns "status": "logged in" — OAuth mode . Proceed to Step B. No API key profile AND auth status returns "status": "pending" — login in progress, wait. No API key profile AND auth status returns "status": "not logged in" — stop all operations , load okx cex auth skill and follow login steps, wait for completion. Step B — Confirm trading mode Resolution rules: 1. Current message intent is clear (e.g. "real" / "实盘" / "live" → live; "test" / "模拟" / "demo" → demo) → use it and inform the user 2. Current message has no explicit declaration → check conversation context for a previous choice: Found → reuse it, inform user Not found → ask: "Live (实盘) or Demo (模拟盘)?" — wait for answer before proceeding How to apply the mode depends on auth method (detected in Step A): Auth method Live (实盘) Demo (模拟盘) API Key profile <live profile profile <demo profile OAuth (no flag needed, live is default) demo API Key users : run okx config show json to discover available profile names and their demo settings. Use profile <name to select the correct one. OAuth users : omit flags for live trading; add demo for simulated trading. Do not use profile to switch modes. Handling Authentication Errors Authentication error (error contains "401", "Session expired", or "Run okx auth login first"): 1. Stop immediately — do not retry the same command 2. Inform the user: "Authentication failed. Your session may have expired." 3. Load okx cex auth skill and follow the re authentication steps 4. After successful re authentication, retry the original command Demo vs Live Mode Mode Funds API Key param OAuth param 实盘 (live) Real funds profile <live profile (default, no flag) 模拟盘 (demo) Simulated funds profile <demo profile demo Rules: Read commands (balance, positions, bills, etc.): always state which mode was used Write commands ( transfer , set position mode ): mode must be confirmed before execution (see "Credential & Profile Check" Step B); transfer especially — wrong mode means wrong account Every response after a command must append: [mode: live] or [mode: demo] Skill Routing For market data (prices, charts, depth, funding rates) → use okx cex market For account balance, P&L, positions, fees, transfers → use okx cex portfolio (this skill) For regular spot/swap/futures/algo orders → use okx cex trade For grid and DCA trading bots → use okx cex bot Quickstart Command Index Read Commands Command Type Description 1 okx account balance [ccy] READ Trading account equity, available, frozen 2a okx account asset balance [ccy] READ Funding account balance (per currency list) 2b okx account asset balance [ccy] valuation [ valuationCcy <ccy ] READ Same + total asset valuation across trading/funding/earn; denomination defaults to USDT, override with valuationCcy BTC 3 okx account positions READ Open contract/swap positions 4 okx account positions history READ Closed positions + realized PnL 5 okx account bills READ Account ledger (deposits, withdrawals, trades) 6 okx account fees instType <type READ My trading fee tier (maker/taker) 7 okx account config READ Account level, position mode, UID 8 okx account max size instId <id tdMode <mode READ Max buy/sell size at current price 9 okx account max avail size instId <id tdMode <mode READ Available size for next order 10 okx account max withdrawal [ccy] READ Max withdrawable per currency Write Commands Command Type Description 11 okx account set position mode <mode WRITE Switch net/hedge position mode 12 okx account transfer 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?" Pre bot balance check User: "I want to start a BTC grid bot with 1000 USDT" Review open positions and P&L User: "Show me my current positions and how they're performing" Transfer and trade User: "Move 500 USDT from my funding account to trade BTC" Check max position size before entering User: "How much BTC can I buy with cross margin?" Operation Flow Step 0 — Credential & Profile Check Before any authenticated command: see [Credential & Profile Check]( credential profile check). Determine auth method and trading mode before executing. After every command result: append [mode: live] or [mode: demo] to the response Step 1: Identify account action Check balance → okx account balance (trading equity only) or okx account asset balance (funding balances) or okx account asset balance valuation (total across all accounts in USDT) 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 → okx account max size or okx 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 profile (Step 0) then writes Read commands (1–10): run immediately, no confirmation needed. ccy filter: use currency symbol like USDT , BTC , ETH instType for fees/positions: SPOT , SWAP , FUTURES , OPTION archive for bills: access older records beyond the default window tdMode for max size: cash (spot), cross , or isolated Write commands (11–12): confirm once before executing. set position mode : confirm mode ( net = one directional, long short mode = hedge mode); switching may affect open positions transfer : confirm ccy , amt , from , to (account types: 6 =funding, 18 =trading); verify source balance first Step 3: Verify after writes After set position mode : run okx account config to confirm posMode updated After transfer : run okx account balance and okx account asset balance to confirm balances updated CLI Command Reference Account Balance — Trading Account Param Required Default Description ccy No Filter to a single currency (e.g., USDT ) Returns table: currency , equity , available , frozen . Only shows currencies with balance 0. Asset Balance — Funding Account Param Required Default Description ccy No Filter to a specific currency (e.g., USDT ); does not affect valuation denomination valuation No false Also show total asset valuation across all account types (trading/funding/earn) valuationCcy No USDT Currency in which to denominate the total asset valuation (e.g., USDT , BTC ). Only used when valuation is set. Returns: ccy , bal , availBal , frozenBal . Only shows currencies with balance 0. With valuation : additionally prints a valuation summary table with totalBal and per account type breakdown ( classic / earn / funding / trading ). The numbers are denominated in valuationCcy (default USDT ). Important : ccy (balance filter) and valuationCcy (valuation denomination) are independent parameters — ccy=BTC filters the balance list to BTC rows but does NOT change the valuation currency; set valuationCcy BTC explicitly for BTC denominated totals. Positions — Open Positions Param Required Default Description instType No Filter: SWAP , FUTURES , OPTION instId No Filter to specific instrument Returns: instId , instType , side (posSide), pos , avgPx , upl (unrealized PnL), lever . Only shows positions with size ≠ 0. Positions History — Closed Positions Returns: instId , direction , openAvgPx , closeAvgPx , realizedPnl , uTime . Bills — Account Ledger Param Required Default Description archive No false Access older records (archive endpoint) instType No Filter by instrument type ccy No Filter by currency limit No 100 Number of records Returns: billId , instId , type , ccy , balChg , bal , ts . Fees — Trading Fee Tier Param Required Default Description instType Yes SPOT , SWAP , FUTURES , OPTION instId No Specific instrument (optional) Returns: level , maker , taker , makerU , takerU , ts . Config — Account Configuration Returns: uid , acctLv (account level), posMode (net/long short mode), autoLoan , greeksType , level , levelTmp . Max Size — Maximum Order Size Param Required Default Description instId Yes Instrument ID tdMode Yes cash (spot), cross , or isolated px No Reference price (uses mark price if omitted) Returns: instId , maxBuy , maxSell . Max Available Size Returns: instId , availBuy , availSell — the immediately available size for the next order. Max Withdrawal Returns table: ccy , maxWd , maxWdEx (with borrowing). Shows all currencies if no filter. Set Position Mode Value Behavior net One directional (default) — long and short net out long short mode Hedge mode — long and short can coexist Warning : Switching modes when positions are open may cause unexpected behavior. Check okx account positions first. Transfer Funds Param Required Default Description ccy Yes Currency to transfer (e.g., USDT ) amt Yes Amount to transfer from Yes Source account type: 6 =funding, 18 =trading to Yes Destination account type: 6 =funding, 18 =trading transferType No 0 0 =within account, 1 =to sub account, 2 =from sub account subAcct No Sub account name (required for sub account transfers) Returns: transId , ccy , amt . MCP Tool Reference Tool Description account get balance Trading account balance account get asset balance Funding account balance. Use showValuation=true to include total asset valuation across trading/funding/earn accounts. Use valuationCcy (default "USDT" ) to set the denomination for the valuation total — e.g. valuationCcy="BTC" returns the total in BTC. account get positions Open positions account get positions history Closed position h