okx-cex-portfolio

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OKX CEX Portfolio & Account CLI

OKX CEX 投资组合与账户CLI

Account balance, positions, P&L, bills, fees, and fund transfers on OKX exchange. Requires API credentials.
用于查询OKX交易所的账户余额、持仓、盈亏、账单、手续费,以及资金划转操作。需要API凭据。

Prerequisites

前置要求

  1. Install
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. Configure credentials:
    bash
    okx config init
    Or set environment variables:
    bash
    export OKX_API_KEY=your_key
    export OKX_SECRET_KEY=your_secret
    export OKX_PASSPHRASE=your_passphrase
  3. Test with demo mode:
    bash
    okx --demo account balance
  1. 安装
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. 配置凭据:
    bash
    okx config init
    或者设置环境变量:
    bash
    export OKX_API_KEY=your_key
    export OKX_SECRET_KEY=your_secret
    export OKX_PASSPHRASE=your_passphrase
  3. 演示模式测试:
    bash
    okx --demo account balance

Demo vs Live Mode

演示模式 vs 实盘模式

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 default
Run a single command in demo mode by prepending
--demo
:
bash
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
    ,
    set-position-mode
    ): before executing, explicitly confirm with the user: "Execute on live account or demo (simulated)?"
  • When executing in demo mode, prefix your response summary with
    [DEMO]
  • When executing on live account, prefix with
    [LIVE]
执行任何写入类命令前必须确认用户想要使用演示模式还是实盘模式执行。
查询当前激活的模式:
bash
okx config show       # 展示当前配置文件,以及演示模式是否设为默认
在命令前添加
--demo
即可单条命令使用演示模式:
bash
okx --demo account balance          # 模拟账户余额
okx --demo account transfer ...     # 模拟划转(不会移动真实资金)
本Skill使用规则:
  • 读取类命令(余额、持仓、账单等):两种模式都可直接执行 —— 执行后必须说明使用的是哪种模式
  • 写入类命令(
    transfer
    set-position-mode
    ):执行前必须明确和用户确认:「要在实盘账户还是演示(模拟)账户执行?」
  • 演示模式下执行时,响应摘要前要添加前缀
    [DEMO]
  • 实盘账户下执行时,响应摘要前要添加前缀
    [LIVE]

Skill Routing

Skill路由

  • 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
  • 市场数据(价格、K线、深度、资金费率)→ 使用
    okx-cex-market
  • 账户余额、盈亏、持仓、手续费、划转 → 使用
    okx-cex-portfolio
    (本Skill)
  • 常规现货/合约/期货/算法订单 → 使用
    okx-cex-trade
  • 网格和DCA交易机器人 → 使用
    okx-cex-bot

Quickstart

快速入门

bash
undefined
bash
undefined

Trading account balance (all currencies with balance > 0)

交易账户余额(所有余额>0的币种)

okx account balance
okx account balance

Check USDT balance only

仅查询USDT余额

okx account balance USDT
okx account balance USDT

Funding account balance

资金账户余额

okx account asset-balance
okx account asset-balance

All open positions

所有持仓仓位

okx account positions
okx account positions

Closed position history with realized PnL

已平仓持仓历史及已实现盈亏

okx account positions-history
okx account positions-history

Recent account bills (last 100)

近期账户账单(最近100条)

okx account bills
okx account bills

My trading fee tier

我的交易手续费等级

okx account fees --instType SPOT
okx account fees --instType SPOT

Transfer 100 USDT from funding (18) to trading (6)

划转100 USDT从资金账户(18)到交易账户(6)

okx account transfer --ccy USDT --amt 100 --from 18 --to 6
undefined
okx account transfer --ccy USDT --amt 100 --from 18 --to 6
undefined

Command Index

命令索引

Read Commands

读取类命令

#CommandTypeDescription
1
okx account balance [ccy]
READTrading account equity, available, frozen
2
okx account asset-balance [ccy]
READFunding account balance
3
okx account positions
READOpen contract/swap positions
4
okx account positions-history
READClosed positions + realized PnL
5
okx account bills
READAccount ledger (deposits, withdrawals, trades)
6
okx account fees --instType <type>
READMy trading fee tier (maker/taker)
7
okx account config
READAccount level, position mode, UID
8
okx account max-size --instId <id> --tdMode <mode>
READMax buy/sell size at current price
9
okx account max-avail-size --instId <id> --tdMode <mode>
READAvailable size for next order
10
okx account max-withdrawal [ccy]
READMax withdrawable per currency
#CommandTypeDescription
1
okx account balance [ccy]
READ交易账户权益、可用金额、冻结金额
2
okx account asset-balance [ccy]
READ资金账户余额
3
okx account positions
READ持仓合约/swap仓位
4
okx account positions-history
READ已平仓仓位 + 已实现盈亏
5
okx account bills
READ账户流水(充值、提现、交易)
6
okx account fees --instType <type>
READ我的交易手续费等级(maker/taker)
7
okx account config
READ账户等级、持仓模式、UID
8
okx account max-size --instId <id> --tdMode <mode>
READ当前价格下最大买卖额度
9
okx account max-avail-size --instId <id> --tdMode <mode>
READ下一订单可用额度
10
okx account max-withdrawal [ccy]
READ各币种最大可提现额度

Write Commands

写入类命令

#CommandTypeDescription
11
okx account set-position-mode <mode>
WRITESwitch net/hedge position mode
12
okx account transfer
WRITETransfer funds between accounts
#CommandTypeDescription
11
okx account set-position-mode <mode>
WRITE切换逐仓/对冲持仓模式
12
okx account transfer
WRITE账户间资金划转

Cross-Skill Workflows

跨Skill工作流

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.1
用户:「我想买0.1 BTC —— 我有足够的USDT吗?」
1. okx-cex-portfolio okx account balance USDT               → 查询可用权益
2. okx-cex-market    okx market ticker BTC-USDT              → 查询当前价格
        ↓ 用户确认
3. okx-cex-trade     okx spot place --instId BTC-USDT --side buy --ordType market --sz 0.1

Pre-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 1000
用户:「我想用1000 USDT启动一个BTC网格机器人」
1. okx-cex-portfolio okx account balance USDT               → 确认可用资金 ≥ 1000
2. okx-cex-market    okx market candles BTC-USDT --bar 4H --limit 50  → 确定价格区间
        ↓ 用户确认
3. okx-cex-bot       okx bot grid create --instId BTC-USDT --algoOrdType grid \
                       --minPx 90000 --maxPx 100000 --gridNum 10 --quoteSz 1000

Review 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 entry
用户:「展示我当前的持仓以及收益情况」
1. okx-cex-portfolio okx account positions                  → 带未实现盈亏的持仓
2. okx-cex-portfolio okx account positions-history          → 近期已平仓仓位
3. okx-cex-market    okx market ticker BTC-USDT-SWAP        → 对比当前价格和开仓价格

Transfer 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 ...
用户:「从我的资金账户转500 USDT用来交易BTC」
1. okx-cex-portfolio okx account asset-balance USDT         → 确认资金账户余额 ≥ 500
        ↓ 用户确认
2. okx-cex-portfolio okx account transfer --ccy USDT --amt 500 --from 18 --to 6
3. okx-cex-portfolio okx account balance USDT               → 确认交易账户余额已更新
        ↓ 可进行交易
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 reference
用户:「我用全仓保证金可以买多少BTC?」
1. okx-cex-portfolio okx account balance                    → 总权益
2. okx-cex-portfolio okx account max-size --instId BTC-USDT-SWAP --tdMode cross  → 最大买卖额度
3. okx-cex-market    okx market ticker BTC-USDT-SWAP        → 当前价格参考

Operation Flow

操作流程

Step 1: Identify account action

步骤1:识别账户操作类型

  • Check balance →
    okx account balance
    (trading) or
    okx account asset-balance
    (funding)
  • 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
  • 查询余额 →
    okx account balance
    (交易账户)或
    okx account asset-balance
    (资金账户)
  • 查看持仓 →
    okx account positions
  • 查看已平仓仓位+盈亏 →
    okx account positions-history
  • 查看交易历史 →
    okx account bills
  • 查询手续费等级 →
    okx account fees
  • 查询账户设置 →
    okx account config
  • 计算订单额度 →
    okx account max-size
    okx account max-avail-size
  • 查询提现限额 →
    okx account max-withdrawal
  • 资金划转 →
    okx account transfer
  • 修改持仓模式 →
    okx account set-position-mode

Step 2: Run read commands immediately — confirm writes

步骤2:读取类命令直接执行 —— 写入类命令先确认

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
    =trading,
    18
    =funding); verify source balance first
读取类命令(1–10):直接执行,无需确认。
  • ccy
    过滤器:使用币种符号例如
    USDT
    BTC
    ETH
  • 手续费/持仓查询的
    --instType
    参数:
    SPOT
    SWAP
    FUTURES
    OPTION
  • 账单查询的
    --archive
    参数:访问默认窗口以外的更早记录
  • 最大额度查询的
    --tdMode
    参数:
    cash
    (现货)、
    cross
    (全仓)、
    isolated
    (逐仓)
写入类命令(11–12):执行前确认一次。
  • set-position-mode
    :确认模式(
    net
    = 单向持仓,
    long_short_mode
    = 对冲模式);切换可能影响现有持仓
  • transfer
    :确认
    --ccy
    --amt
    --from
    --to
    (账户类型:
    6
    =交易账户,
    18
    =资金账户);首先校验源账户余额

Step 3: Verify after writes

步骤3:写入操作后校验

  • 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
  • 执行
    set-position-mode
    后:运行
    okx account config
    确认
    posMode
    已更新
  • 执行
    transfer
    后:运行
    okx account balance
    okx account asset-balance
    确认余额已更新

CLI Command Reference

CLI命令参考

Account Balance — Trading Account

账户余额 —— 交易账户

bash
okx account balance [ccy] [--json]
ParamRequiredDefaultDescription
ccy
No-Filter to a single currency (e.g.,
USDT
)
Returns table:
currency
,
equity
,
available
,
frozen
. Only shows currencies with balance > 0.

bash
okx account balance [ccy] [--json]
参数必填默认值说明
ccy
-筛选单个币种(例如
USDT
返回表格:
currency
equity
available
frozen
。仅展示余额>0的币种。

Asset Balance — Funding Account

资产余额 —— 资金账户

bash
okx account asset-balance [ccy] [--json]
ParamRequiredDefaultDescription
ccy
No-Filter to a single currency
Returns:
ccy
,
bal
,
availBal
,
frozenBal
. Only shows currencies with balance > 0.

bash
okx account asset-balance [ccy] [--json]
参数必填默认值说明
ccy
-筛选单个币种
返回:
ccy
bal
availBal
frozenBal
。仅展示余额>0的币种。

Positions — Open Positions

持仓 —— 已开仓仓位

bash
okx account positions [--instType <type>] [--instId <id>] [--json]
ParamRequiredDefaultDescription
--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.

bash
okx account positions [--instType <type>] [--instId <id>] [--json]
参数必填默认值说明
--instType
-筛选:
SWAP
FUTURES
OPTION
--instId
-筛选特定交易对
返回:
instId
instType
side
(posSide)、
pos
avgPx
upl
(未实现盈亏)、
lever
。仅展示仓位≠0的持仓。

Positions History — Closed Positions

持仓历史 —— 已平仓仓位

bash
okx account positions-history [--instType <type>] [--instId <id>] [--limit <n>] [--json]
Returns:
instId
,
direction
,
openAvgPx
,
closeAvgPx
,
realizedPnl
,
uTime
.

bash
okx account positions-history [--instType <type>] [--instId <id>] [--limit <n>] [--json]
返回:
instId
direction
openAvgPx
closeAvgPx
realizedPnl
uTime

Bills — Account Ledger

账单 —— 账户流水

bash
okx account bills [--archive] [--instType <type>] [--ccy <ccy>] [--limit <n>] [--json]
ParamRequiredDefaultDescription
--archive
NofalseAccess older records (archive endpoint)
--instType
No-Filter by instrument type
--ccy
No-Filter by currency
--limit
No100Number of records
Returns:
billId
,
instId
,
type
,
ccy
,
balChg
,
bal
,
ts
.

bash
okx account bills [--archive] [--instType <type>] [--ccy <ccy>] [--limit <n>] [--json]
参数必填默认值说明
--archive
false访问更早的记录(归档接口)
--instType
-按交易对类型筛选
--ccy
-按币种筛选
--limit
100记录数量
返回:
billId
instId
type
ccy
balChg
bal
ts

Fees — Trading Fee Tier

手续费 —— 交易手续费等级

bash
okx account fees --instType <type> [--instId <id>] [--json]
ParamRequiredDefaultDescription
--instType
Yes-
SPOT
,
SWAP
,
FUTURES
,
OPTION
--instId
No-Specific instrument (optional)
Returns:
level
,
maker
,
taker
,
makerU
,
takerU
,
ts
.

bash
okx account fees --instType <type> [--instId <id>] [--json]
参数必填默认值说明
--instType
-
SPOT
SWAP
FUTURES
OPTION
--instId
-特定交易对(可选)
返回:
level
maker
taker
makerU
takerU
ts

Config — Account Configuration

配置 —— 账户配置

bash
okx account config [--json]
Returns:
uid
,
acctLv
(account level),
posMode
(net/long_short_mode),
autoLoan
,
greeksType
,
level
,
levelTmp
.

bash
okx account config [--json]
返回:
uid
acctLv
(账户等级)、
posMode
(净持仓/双向持仓模式)、
autoLoan
greeksType
level
levelTmp

Max Size — Maximum Order Size

最大额度 —— 最大订单额度

bash
okx account max-size --instId <id> --tdMode <mode> [--px <price>] [--json]
ParamRequiredDefaultDescription
--instId
Yes-Instrument ID
--tdMode
Yes-
cash
(spot),
cross
, or
isolated
--px
No-Reference price (uses mark price if omitted)
Returns:
instId
,
maxBuy
,
maxSell
.

bash
okx account max-size --instId <id> --tdMode <mode> [--px <price>] [--json]
参数必填默认值说明
--instId
-交易对ID
--tdMode
-
cash
(现货)、
cross
(全仓)、
isolated
(逐仓)
--px
-参考价格(省略则使用标记价格)
返回:
instId
maxBuy
maxSell

Max Available Size

最大可用额度

bash
okx account max-avail-size --instId <id> --tdMode <mode> [--json]
Returns:
instId
,
availBuy
,
availSell
— the immediately available size for the next order.

bash
okx account max-avail-size --instId <id> --tdMode <mode> [--json]
返回:
instId
availBuy
availSell
—— 下一订单可立即使用的额度。

Max Withdrawal

最大提现额度

bash
okx account max-withdrawal [ccy] [--json]
Returns table:
ccy
,
maxWd
,
maxWdEx
(with borrowing). Shows all currencies if no filter.

bash
okx account max-withdrawal [ccy] [--json]
返回表格:
ccy
maxWd
maxWdEx
(含借贷额度)。无筛选则展示所有币种。

Set Position Mode

设置持仓模式

bash
okx account set-position-mode <net|long_short_mode> [--json]
ValueBehavior
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.

bash
okx account set-position-mode <net|long_short_mode> [--json]
行为
net
单向持仓(默认)—— 多空仓位抵消
long_short_mode
对冲模式 —— 多空仓位可同时存在
警告:有持仓时切换模式可能导致异常行为。请先查询
okx account positions

Transfer Funds

资金划转

bash
okx account transfer --ccy <ccy> --amt <n> --from <acctType> --to <acctType> \
  [--transferType <type>] [--subAcct <name>] [--json]
ParamRequiredDefaultDescription
--ccy
Yes-Currency to transfer (e.g.,
USDT
)
--amt
Yes-Amount to transfer
--from
Yes-Source account type:
6
=trading,
18
=funding
--to
Yes-Destination account type:
6
=trading,
18
=funding
--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
.

bash
okx account transfer --ccy <ccy> --amt <n> --from <acctType> --to <acctType> \
  [--transferType <type>] [--subAcct <name>] [--json]
参数必填默认值说明
--ccy
-划转币种(例如
USDT
--amt
-划转金额
--from
-源账户类型:
6
=交易账户,
18
=资金账户
--to
-目标账户类型:
6
=交易账户,
18
=资金账户
--transferType
0
0
=账户内划转,
1
=划转子账户,
2
=子账户划入
--subAcct
-子账户名称(子账户划转必填)
返回:
transId
ccy
amt

MCP Tool Reference

MCP工具参考

ToolDescription
account_get_balance
Trading account balance
account_get_asset_balance
Funding account balance
account_get_positions
Open positions
account_get_positions_history
Closed position history
account_get_bills
Account bills (recent)
account_get_bills_archive
Account bills (archive)
account_get_trade_fee
Trading fee tier
account_get_config
Account configuration
account_get_max_size
Max order size
account_get_max_avail_size
Max available size
account_get_max_withdrawal
Max withdrawable
account_set_position_mode
Set position mode
account_transfer
Transfer between accounts

工具说明
account_get_balance
交易账户余额
account_get_asset_balance
资金账户余额
account_get_positions
持仓仓位
account_get_positions_history
已平仓持仓历史
account_get_bills
账户账单(近期)
account_get_bills_archive
账户账单(归档)
account_get_trade_fee
交易手续费等级
account_get_config
账户配置
account_get_max_size
最大订单额度
account_get_max_avail_size
最大可用额度
account_get_max_withdrawal
最大可提现额度
account_set_position_mode
设置持仓模式
account_transfer
账户间划转

Input / Output Examples

输入输出示例

"How much USDT do I have?"
bash
okx account balance USDT
「我有多少USDT?」
bash
okx account balance USDT

→ currency: USDT | equity: 5000.00 | available: 4500.00 | frozen: 500.00

→ currency: USDT | equity: 5000.00 | available: 4500.00 | frozen: 500.00


**"Show all my open positions"**
```bash
okx account positions

**「展示我所有的持仓」**
```bash
okx account positions

→ table: instId, instType, side, pos, avgPx, upl, lever

→ table: instId, instType, side, pos, avgPx, upl, lever


**"What's my trading history and realized PnL?"**
```bash
okx account positions-history

**「我的交易历史和已实现盈亏是什么?」**
```bash
okx account positions-history

→ table: instId, direction, openAvgPx, closeAvgPx, realizedPnl, uTime

→ table: instId, direction, openAvgPx, closeAvgPx, realizedPnl, uTime


**"Show my recent account activity"**
```bash
okx account bills --limit 20

**「展示我近期的账户活动」**
```bash
okx account bills --limit 20

→ table: billId, instId, type, ccy, balChg, bal, ts

→ table: billId, instId, type, ccy, balChg, bal, ts


**"What are my trading fees for SWAP?"**
```bash
okx account fees --instType SWAP

**「我的SWAP交易手续费是多少?」**
```bash
okx account fees --instType SWAP

→ level: VIP1 | maker: -0.0001 | taker: 0.0005

→ 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

**「全仓模式我可以买多少BTC?」**
```bash
okx account max-size --instId BTC-USDT-SWAP --tdMode cross

→ instId: BTC-USDT-SWAP | maxBuy: 12.5 | maxSell: 12.5

→ 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

**「从资金账户转200 USDT到交易账户」**
```bash
okx account transfer --ccy USDT --amt 200 --from 18 --to 6

→ Transfer: TXN123456 (USDT 200)

→ Transfer: TXN123456 (USDT 200)


**"Check my account config"**
```bash
okx account config

**「查看我的账户配置」**
```bash
okx account config

→ uid: 123456789 | acctLv: 2 | posMode: net | autoLoan: false

→ uid: 123456789 | acctLv: 2 | posMode: net | autoLoan: false

undefined
undefined

Edge 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
    net
    if you have both long and short positions on the same instrument
  • transfer --from/--to codes:
    6
    =trading account,
    18
    =funding account; other values exist for sub-account flows
  • max-size vs max-avail-size:
    max-size
    is the theoretical maximum;
    max-avail-size
    accounts for existing orders and reserved margin
  • Demo mode:
    okx --demo account balance
    shows simulated balances, not real funds
  • 无余额展示:余额默认筛选>0的币种 —— 如果无内容返回,说明所有币种余额均为0
  • 持仓命令返回空:无持仓合约;现货持仓不在这里展示(使用
    account balance
    查询)
  • bills --archive:查询7天以上的交易记录必填(默认窗口);响应可能更慢
  • set-position-mode:如果同一交易对同时持有多空仓位,无法切换为
    net
    模式
  • transfer --from/--to 编码
    6
    =交易账户,
    18
    =资金账户;子账户流程使用其他值
  • max-size vs max-avail-size
    max-size
    是理论最大值;
    max-avail-size
    已扣除现有订单和预留保证金
  • 演示模式
    okx --demo account balance
    展示模拟余额,不是真实资金

Global Notes

通用注意事项

  • All write commands require valid credentials in
    ~/.okx/config.toml
    or env vars
  • --profile <name>
    switches between multiple account configurations
  • --json
    returns raw OKX API v5 response
  • 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:
    6
    =Unified Trading Account (spot + derivatives),
    18
    =Funding Account (deposits/withdrawals)
  • 所有写入类命令都需要
    ~/.okx/config.toml
    或环境变量中的有效凭据
  • --profile <name>
    可切换多个账户配置
  • --json
    返回原始OKX API v5响应
  • 限流规则:账户接口每2秒最多10次请求
  • 展示的持仓属于统一交易账户;资金账户资产独立
  • 账户类型:
    6
    =统一交易账户(现货+衍生品),
    18
    =资金账户(充值/提现)