okx-cex-market

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OKX CEX Market Data CLI

OKX CEX 市场数据CLI

Public market data for OKX exchange: prices, order books, candles, funding rates, open interest, and instrument info. All commands are read-only and do not require API credentials.
OKX交易所公开市场数据查询工具,支持查询价格、订单簿、K线、资金费率、持仓量和交易品种信息。所有命令都是只读的,不需要API凭证

Prerequisites

前置要求

  1. Install
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. No credentials needed for market data — all commands are public.
  3. Verify install:
    bash
    okx market ticker BTC-USDT
  1. 安装
    okx
    CLI:
    bash
    npm install -g @okx_ai/okx-trade-cli
  2. 查询市场数据不需要凭证——所有命令都是公开的。
  3. 验证安装:
    bash
    okx market ticker BTC-USDT

Demo vs Live Mode

演示模式 vs 线上模式

Market data commands are public and read-only — demo mode has no effect. The same data is returned with or without
--demo
. No confirmation needed before running any market command.
市场数据命令是公开且只读的——演示模式不会产生任何影响。无论是否添加
--demo
参数,返回的数据都相同。运行任何市场数据命令前都不需要确认。

Skill Routing

技能路由

  • For market data (prices, charts, depth, funding rates) → use
    okx-cex-market
    (this skill)
  • For account balance, P&L, positions, fees, transfers → use
    okx-cex-portfolio
  • For regular spot/swap/futures/algo orders → use
    okx-cex-trade
  • For grid and DCA trading bots → use
    okx-cex-bot
  • 查询市场数据(价格、图表、深度、资金费率)→ 使用
    okx-cex-market
    (本技能)
  • 查询账户余额、盈亏、持仓、手续费、转账 → 使用
    okx-cex-portfolio
  • 普通现货/永续/合约/算法订单操作 → 使用
    okx-cex-trade
  • 网格和DCA交易机器人操作 → 使用
    okx-cex-bot

Quickstart

快速开始

bash
undefined
bash
undefined

Current BTC spot price

BTC现货当前价格

okx market ticker BTC-USDT
okx market ticker BTC-USDT

All SWAP (perp) tickers

所有SWAP(永续合约)行情

okx market tickers SWAP
okx market tickers SWAP

BTC perp order book (top 5 levels each side)

BTC永续合约订单簿(买卖各5档)

okx market orderbook BTC-USDT-SWAP
okx market orderbook BTC-USDT-SWAP

BTC hourly candles (last 20)

BTC小时级K线(最近20根)

okx market candles BTC-USDT --bar 1H --limit 20
okx market candles BTC-USDT --bar 1H --limit 20

BTC perp current funding rate

BTC永续合约当前资金费率

okx market funding-rate BTC-USDT-SWAP
okx market funding-rate BTC-USDT-SWAP

BTC perp funding rate history

BTC永续合约历史资金费率

okx market funding-rate BTC-USDT-SWAP --history
okx market funding-rate BTC-USDT-SWAP --history

Open interest for all SWAP instruments

所有SWAP品种的持仓量

okx market open-interest --instType SWAP
okx market open-interest --instType SWAP

List all active SPOT instruments

列出所有活跃现货交易对

okx market instruments --instType SPOT
undefined
okx market instruments --instType SPOT
undefined

Command Index

命令索引

#CommandTypeDescription
1
okx market ticker <instId>
READSingle instrument: last price, 24h high/low/vol
2
okx market tickers <instType>
READAll tickers for an instrument type
3
okx market instruments --instType <type>
READList tradeable instruments
4
okx market orderbook <instId> [--sz <n>]
READOrder book top asks/bids
5
okx market candles <instId> [--bar] [--limit]
READOHLCV candlestick data
6
okx market index-candles <instId> [--bar] [--limit]
READIndex OHLCV candles
7
okx market funding-rate <instId> [--history]
READCurrent or historical funding rate
8
okx market trades <instId> [--limit <n>]
READRecent public trades
9
okx market mark-price --instType <type> [--instId <id>]
READMark price for contracts
10
okx market index-ticker [--instId <id>] [--quoteCcy <ccy>]
READIndex price (e.g., BTC-USD)
11
okx market price-limit <instId>
READUpper/lower price limits for contracts
12
okx market open-interest --instType <type> [--instId <id>]
READOpen interest in contracts and coins
#CommandType描述
1
okx market ticker <instId>
READ单个交易对:最新价格、24小时高低价/成交量
2
okx market tickers <instType>
READ某类交易对的全部行情
3
okx market instruments --instType <type>
READ列出可交易的品种
4
okx market orderbook <instId> [--sz <n>]
READ订单簿买卖盘档位
5
okx market candles <instId> [--bar] [--limit]
READOHLCV K线数据
6
okx market index-candles <instId> [--bar] [--limit]
READ指数OHLCV K线
7
okx market funding-rate <instId> [--history]
READ当前或历史资金费率
8
okx market trades <instId> [--limit <n>]
READ最近公开成交记录
9
okx market mark-price --instType <type> [--instId <id>]
READ合约标记价格
10
okx market index-ticker [--instId <id>] [--quoteCcy <ccy>]
READ指数价格(例如BTC-USD)
11
okx market price-limit <instId>
READ合约涨跌停价格限制
12
okx market open-interest --instType <type> [--instId <id>]
READ合约持仓量(张和币本位)

Cross-Skill Workflows

跨技能工作流

Check price before placing an order

下单前查询价格

User: "What's the current BTC price? I want to place a limit buy."
1. okx-cex-market    okx market ticker BTC-USDT              → check last price and 24h range
        ↓ user decides price
2. okx-cex-portfolio okx account balance USDT                → confirm available funds
        ↓ user approves
3. okx-cex-trade     okx spot place --instId BTC-USDT --side buy --ordType limit --px <px> --sz <sz>
用户:"当前BTC价格是多少?我想挂一个限价买单。"
1. okx-cex-market    okx market ticker BTC-USDT              → 查看最新价格和24小时波动区间
        ↓ 用户确定下单价格
2. okx-cex-portfolio okx account balance USDT                → 确认可用资金
        ↓ 用户确认操作
3. okx-cex-trade     okx spot place --instId BTC-USDT --side buy --ordType limit --px <px> --sz <sz>

Check funding rate before holding a perp position

持有永续合约前查询资金费率

User: "Is the BTC perp funding rate high right now?"
1. okx-cex-market    okx market funding-rate BTC-USDT-SWAP   → current rate + next funding time
2. okx-cex-market    okx market funding-rate BTC-USDT-SWAP --history  → trend over recent periods
        ↓ decide whether to hold position
3. okx-cex-portfolio okx account positions                   → check existing exposure
用户:"现在BTC永续合约的资金费率高吗?"
1. okx-cex-market    okx market funding-rate BTC-USDT-SWAP   → 当前费率 + 下一次资金费结算时间
2. okx-cex-market    okx market funding-rate BTC-USDT-SWAP --history  → 最近几期的费率走势
        ↓ 决定是否持有仓位
3. okx-cex-portfolio okx account positions                   → 查看现有持仓敞口

Research market before creating a grid bot

创建网格机器人前调研市场

User: "I want to set up a BTC grid bot — what's the recent range?"
1. okx-cex-market    okx market candles BTC-USDT --bar 4H --limit 50  → recent OHLCV for range
2. okx-cex-market    okx market ticker BTC-USDT                        → current price
3. okx-cex-market    okx market orderbook BTC-USDT --sz 20             → liquidity check
        ↓ decide minPx / maxPx
4. okx-cex-bot       okx bot grid create --instId BTC-USDT ...
用户:"我想搭建一个BTC网格机器人,最近的价格区间是多少?"
1. okx-cex-market    okx market candles BTC-USDT --bar 4H --limit 50  → 查看最近OHLCV确定价格区间
2. okx-cex-market    okx market ticker BTC-USDT                        → 当前价格
3. okx-cex-market    okx market orderbook BTC-USDT --sz 20             → 流动性检查
        ↓ 确定最低/最高价格
4. okx-cex-bot       okx bot grid create --instId BTC-USDT ...

Compare perp vs spot premium

对比永续合约和现货的溢价

User: "Is there a premium between BTC spot and BTC perp?"
1. okx-cex-market    okx market ticker BTC-USDT              → spot last price
2. okx-cex-market    okx market ticker BTC-USDT-SWAP         → perp last price
3. okx-cex-market    okx market mark-price --instType SWAP --instId BTC-USDT-SWAP  → mark price
用户:"BTC现货和BTC永续合约之间有没有溢价?"
1. okx-cex-market    okx market ticker BTC-USDT              → 现货最新价格
2. okx-cex-market    okx market ticker BTC-USDT-SWAP         → 永续合约最新价格
3. okx-cex-market    okx market mark-price --instType SWAP --instId BTC-USDT-SWAP  → 标记价格

Discover and price an option

查询期权品种和价格

User: "What's the price of a BTC call option expiring this week?"
1. okx-cex-market    okx market open-interest --instType OPTION --instId BTC-USD  → list active option instIds
        ↓ pick target instId from the list (e.g., BTC-USD-250328-95000-C)
2. okx-cex-market    okx market ticker BTC-USD-250328-95000-C → option last price and stats
3. okx-cex-market    okx market orderbook BTC-USD-250328-95000-C → bid/ask spread
Note:
okx market instruments --instType OPTION
requires
--uly <underlying>
(e.g.,
--uly BTC-USD
). If the underlying is unknown, use
open-interest
first to discover active option instIds.
用户:"本周到期的BTC看涨期权价格是多少?"
1. okx-cex-market    okx market open-interest --instType OPTION --instId BTC-USD  → 列出活跃的期权品种ID
        ↓ 从列表中选择目标品种ID(例如BTC-USD-250328-95000-C)
2. okx-cex-market    okx market ticker BTC-USD-250328-95000-C → 期权最新价格和统计数据
3. okx-cex-market    okx market orderbook BTC-USD-250328-95000-C → 买卖价差
注意
okx market instruments --instType OPTION
需要指定
--uly <underlying>
(例如
--uly BTC-USD
)。如果不知道标的资产,可以先使用
open-interest
查询活跃的期权ID,再用这些ID调用
okx market ticker <instId>

Operation Flow

操作流程

Step 1: Identify the data needed

步骤1:确定所需数据

  • Current price →
    okx market ticker
  • All prices for a category →
    okx market tickers
  • Order book depth →
    okx market orderbook
  • Price history/chart →
    okx market candles
  • Funding cost →
    okx market funding-rate
  • Contract valuation →
    okx market mark-price
    or
    okx market price-limit
  • Market volume/OI →
    okx market open-interest
  • What instruments exist →
    okx market instruments
  • 当前价格 →
    okx market ticker
  • 某类品种的全部价格 →
    okx market tickers
  • 订单簿深度 →
    okx market orderbook
  • 价格历史/图表 →
    okx market candles
  • 资金成本 →
    okx market funding-rate
  • 合约估值 →
    okx market mark-price
    okx market price-limit
  • 市场成交量/持仓量 →
    okx market open-interest
  • 可用交易品种查询 →
    okx market instruments

Step 2: Run commands immediately

步骤2:直接运行命令

All market data commands are read-only — no confirmation needed.
  • --instType
    values:
    SPOT
    ,
    SWAP
    ,
    FUTURES
    ,
    OPTION
  • --bar
    values:
    1m
    ,
    3m
    ,
    5m
    ,
    15m
    ,
    30m
    ,
    1H
    ,
    2H
    ,
    4H
    ,
    6H
    ,
    12H
    ,
    1D
    ,
    1W
    ,
    1M
  • --limit
    : number of results (default varies per endpoint, typically 100)
  • --history
    : for
    funding-rate
    , returns historical records instead of current rate
所有市场数据命令都是只读的——不需要确认。
  • --instType
    可选值:
    SPOT
    ,
    SWAP
    ,
    FUTURES
    ,
    OPTION
  • --bar
    可选值:
    1m
    ,
    3m
    ,
    5m
    ,
    15m
    ,
    30m
    ,
    1H
    ,
    2H
    ,
    4H
    ,
    6H
    ,
    12H
    ,
    1D
    ,
    1W
    ,
    1M
  • --limit
    :返回结果数量(不同接口默认值不同,通常为100)
  • --history
    :用于
    funding-rate
    命令时,返回历史记录而非当前费率

Step 3: No writes — no verification needed

步骤3:无写入操作——无需验证

All commands in this skill are read-only. No post-execution verification required.
本技能的所有命令都是只读的,执行后不需要做验证。

CLI Command Reference

CLI命令参考

Ticker — Single Instrument

行情查询——单个交易对

bash
okx market ticker <instId> [--json]
Returns:
last
,
24h high/low
,
24h volume
,
sodUtc8
(24h change %).

bash
okx market ticker <instId> [--json]
返回:
last
(最新价)、
24h high/low
(24小时高低价)、
24h volume
(24小时成交量)、
sodUtc8
(24小时涨跌幅%)。

Tickers — All Instruments of a Type

行情查询——某类全部交易对

bash
okx market tickers <instType> [--json]
ParamRequiredValuesDescription
instType
Yes
SPOT
,
SWAP
,
FUTURES
,
OPTION
Instrument type
Returns table:
instId
,
last
,
high24h
,
low24h
,
vol24h
.

bash
okx market tickers <instType> [--json]
参数必填可选值描述
instType
SPOT
,
SWAP
,
FUTURES
,
OPTION
交易品种类型
返回表格:
instId
last
high24h
low24h
vol24h

Instruments — List Tradeable Instruments

交易品种——列出可交易标的

bash
okx market instruments --instType <type> [--instId <id>] [--json]
ParamRequiredDefaultDescription
--instType
Yes-
SPOT
,
SWAP
,
FUTURES
,
OPTION
--instId
No-Filter to a single instrument
Returns:
instId
,
ctVal
,
lotSz
,
minSz
,
tickSz
,
state
. Displays up to 50 rows.

bash
okx market instruments --instType <type> [--instId <id>] [--json]
参数必填默认值描述
--instType
-
SPOT
,
SWAP
,
FUTURES
,
OPTION
--instId
-过滤单个交易对
返回:
instId
ctVal
lotSz
minSz
tickSz
state
。最多展示50行。

Order Book

订单簿

bash
okx market orderbook <instId> [--sz <n>] [--json]
ParamRequiredDefaultDescription
instId
Yes-Instrument ID (e.g.,
BTC-USDT-SWAP
)
--sz
No5Depth levels per side (1–400)
Displays top 5 asks (ascending) and bids (descending) with price and size.

bash
okx market orderbook <instId> [--sz <n>] [--json]
参数必填默认值描述
instId
-交易对ID(例如
BTC-USDT-SWAP
--sz
5每边展示的档位数量(1–400)
展示买盘(降序)和卖盘(升序)的前5档价格和数量。

Candles — OHLCV

K线——OHLCV

bash
okx market candles <instId> [--bar <bar>] [--limit <n>] [--json]
ParamRequiredDefaultDescription
instId
Yes-Instrument ID
--bar
No
1m
Time granularity (
1m
,
1H
,
4H
,
1D
, etc.)
--limit
No100Number of candles to return
Returns columns:
time
,
open
,
high
,
low
,
close
,
vol
.

bash
okx market candles <instId> [--bar <bar>] [--limit <n>] [--json]
参数必填默认值描述
instId
-交易对ID
--bar
1m
时间粒度(
1m
1H
4H
1D
等)
--limit
100返回的K线数量
返回列:
time
open
high
low
close
vol

Index Candles

指数K线

bash
okx market index-candles <instId> [--bar <bar>] [--limit <n>] [--history] [--json]
Same params as
candles
. Use index instrument IDs like
BTC-USD
(not
BTC-USDT
).

bash
okx market index-candles <instId> [--bar <bar>] [--limit <n>] [--history] [--json]
参数和
candles
相同。使用指数ID例如
BTC-USD
(不是
BTC-USDT
)。

Funding Rate

资金费率

bash
okx market funding-rate <instId> [--history] [--limit <n>] [--json]
ParamRequiredDefaultDescription
instId
Yes-SWAP instrument (e.g.,
BTC-USDT-SWAP
)
--history
NofalseReturn historical funding rates
--limit
No-Number of historical records
Current (no
--history
): returns
fundingRate
,
nextFundingRate
,
fundingTime
,
nextFundingTime
. Historical (
--history
): table with
fundingRate
,
realizedRate
,
fundingTime
.

bash
okx market funding-rate <instId> [--history] [--limit <n>] [--json]
参数必填默认值描述
instId
-SWAP交易对(例如
BTC-USDT-SWAP
--history
false返回历史资金费率
--limit
-历史记录数量
当前费率(无
--history
参数):返回
fundingRate
nextFundingRate
fundingTime
nextFundingTime
。 历史费率(带
--history
参数):返回表格包含
fundingRate
realizedRate
fundingTime

Recent Trades

最近成交

bash
okx market trades <instId> [--limit <n>] [--json]
Returns:
tradeId
,
px
,
sz
,
side
,
ts
.

bash
okx market trades <instId> [--limit <n>] [--json]
返回:
tradeId
px
sz
side
ts

Mark Price

标记价格

bash
okx market mark-price --instType <type> [--instId <id>] [--json]
Returns:
instId
,
instType
,
markPx
,
ts
. Used for liquidation price calculation and contract valuation.

bash
okx market mark-price --instType <type> [--instId <id>] [--json]
返回:
instId
instType
markPx
ts
。用于计算爆仓价格和合约估值。

Index Ticker

指数行情

bash
okx market index-ticker [--instId <id>] [--quoteCcy <ccy>] [--json]
ParamRequiredDefaultDescription
--instId
Cond.-Index ID (e.g.,
BTC-USD
)
--quoteCcy
Cond.-Filter by quote currency (e.g.,
USD
,
USDT
)
Returns:
idxPx
,
high24h
,
low24h
.

bash
okx market index-ticker [--instId <id>] [--quoteCcy <ccy>] [--json]
参数必填默认值描述
--instId
条件必填-指数ID(例如
BTC-USD
--quoteCcy
条件必填-按计价货币过滤(例如
USD
USDT
返回:
idxPx
high24h
low24h

Price Limit

涨跌停限制

bash
okx market price-limit <instId> [--json]
Returns:
buyLmt
(max buy price),
sellLmt
(min sell price). Applies to SWAP and FUTURES only.

bash
okx market price-limit <instId> [--json]
返回:
buyLmt
(最高买价)、
sellLmt
(最低卖价)。仅适用于SWAP和FUTURES品种。

Open Interest

持仓量

bash
okx market open-interest --instType <type> [--instId <id>] [--json]
Returns:
oi
(contracts),
oiCcy
(base currency amount),
ts
.

bash
okx market open-interest --instType <type> [--instId <id>] [--json]
返回:
oi
(合约张数)、
oiCcy
(标的货币数量)、
ts

MCP Tool Reference

MCP工具参考

ToolDescription
market_get_ticker
Single instrument ticker
market_get_tickers
All tickers for instType
market_get_instruments
List instruments
market_get_orderbook
Order book depth
market_get_candles
OHLCV candles
market_get_index_candles
Index OHLCV candles
market_get_funding_rate
Funding rate (current or history)
market_get_trades
Recent public trades
market_get_mark_price
Mark price for contracts
market_get_index_ticker
Index price ticker
market_get_price_limit
Price limits for contracts
market_get_open_interest
Open interest

工具描述
market_get_ticker
单个交易对行情
market_get_tickers
某类交易对全部行情
market_get_instruments
交易品种列表
market_get_orderbook
订单簿深度
market_get_candles
OHLCV K线
market_get_index_candles
指数OHLCV K线
market_get_funding_rate
资金费率(当前或历史)
market_get_trades
最近公开成交记录
market_get_mark_price
合约标记价格
market_get_index_ticker
指数价格行情
market_get_price_limit
合约涨跌停限制
market_get_open_interest
持仓量

Input / Output Examples

输入/输出示例

"What's the price of BTC?"
bash
okx market ticker BTC-USDT
"BTC价格是多少?"
bash
okx market ticker BTC-USDT

→ instId: BTC-USDT | last: 95000.5 | 24h change %: +1.2% | 24h high: 96000 | 24h low: 93000

→ instId: BTC-USDT | last: 95000.5 | 24h change %: +1.2% | 24h high: 96000 | 24h low: 93000


**"Show me all SWAP tickers"**
```bash
okx market tickers SWAP

**"给我看所有SWAP行情"**
```bash
okx market tickers SWAP

→ table of all perpetual contracts with last price, 24h high/low/vol

→ 所有永续合约的表格,包含最新价格、24小时高低价/成交量


**"What's the BTC/USDT order book look like?"**
```bash
okx market orderbook BTC-USDT

**"BTC/USDT的订单簿是什么样的?"**
```bash
okx market orderbook BTC-USDT

Asks (price / size):

卖盘(价格 / 数量):

95100.0 2.5

95100.0 2.5

95050.0 1.2

95050.0 1.2

Bids (price / size):

买盘(价格 / 数量):

95000.0 3.1

95000.0 3.1

94950.0 0.8

94950.0 0.8


**"Show me BTC 4H candles for the last 30 periods"**
```bash
okx market candles BTC-USDT --bar 4H --limit 30

**"给我看最近30根BTC 4小时K线"**
```bash
okx market candles BTC-USDT --bar 4H --limit 30

→ table: time, open, high, low, close, vol

→ 表格:时间, 开盘价, 最高价, 最低价, 收盘价, 成交量


**"What's the current funding rate for BTC perp?"**
```bash
okx market funding-rate BTC-USDT-SWAP

**"BTC永续合约当前的资金费率是多少?"**
```bash
okx market funding-rate BTC-USDT-SWAP

→ fundingRate: 0.0001 | nextFundingRate: 0.00012 | fundingTime: ... | nextFundingTime: ...

→ fundingRate: 0.0001 | nextFundingRate: 0.00012 | fundingTime: ... | nextFundingTime: ...


**"Show historical funding rates for ETH perp"**
```bash
okx market funding-rate ETH-USDT-SWAP --history --limit 20

**"给我看ETH永续合约的历史资金费率"**
```bash
okx market funding-rate ETH-USDT-SWAP --history --limit 20

→ table: fundingRate, realizedRate, fundingTime

→ 表格:fundingRate, realizedRate, fundingTime


**"What's the open interest on BTC perp?"**
```bash
okx market open-interest --instType SWAP --instId BTC-USDT-SWAP

**"BTC永续合约的持仓量是多少?"**
```bash
okx market open-interest --instType SWAP --instId BTC-USDT-SWAP

→ oi: 125000 | oiCcy: 125000 | ts: ...

→ oi: 125000 | oiCcy: 125000 | ts: ...


**"List all available SPOT instruments"**
```bash
okx market instruments --instType SPOT

**"列出所有可用的现货交易对"**
```bash
okx market instruments --instType SPOT

→ table: instId, ctVal, lotSz, minSz, tickSz, state (up to 50 rows)

→ 表格:instId, ctVal, lotSz, minSz, tickSz, state(最多50行)

undefined
undefined

Edge Cases

边界情况

  • instId format: SPOT uses
    BTC-USDT
    ; SWAP uses
    BTC-USDT-SWAP
    ; FUTURES uses
    BTC-USDT-250328
    ; OPTION uses
    BTC-USD-250328-95000-C
    ; Index uses
    BTC-USD
  • OPTION instruments — cannot list directly:
    okx market instruments --instType OPTION
    requires
    --uly BTC-USD
    (underlying). If the underlying is unknown, run
    okx market open-interest --instType OPTION
    first to discover active option instIds from the results, then use those instIds with
    okx market ticker <instId>
  • No data returned: instrument may be delisted or instId is wrong — verify with
    okx market instruments
  • funding-rate: only applies to SWAP instruments; returns error for SPOT/FUTURES
  • price-limit: only applies to SWAP and FUTURES instruments
  • mark-price: available for SWAP, FUTURES, OPTION; not applicable to SPOT
  • candles --bar: use uppercase
    H
    ,
    D
    ,
    W
    ,
    M
    for hour/day/week/month (e.g.,
    1H
    not
    1h
    )
  • index-ticker: use
    BTC-USD
    format (not
    BTC-USDT
    ) for index IDs
  • orderbook --sz: max depth is 400; default display shows top 5 per side regardless of
    --sz
  • instId格式:现货用
    BTC-USDT
    ;永续合约用
    BTC-USDT-SWAP
    ;交割合约用
    BTC-USDT-250328
    ;期权用
    BTC-USD-250328-95000-C
    ;指数用
    BTC-USD
  • 期权品种——无法直接列出
    okx market instruments --instType OPTION
    需要指定
    --uly BTC-USD
    (标的资产)。如果不知道标的资产,先运行
    okx market open-interest --instType OPTION
    从结果中找到活跃的期权ID,再用这些ID调用
    okx market ticker <instId>
  • 无数据返回:交易对可能已退市或者instId错误——可以用
    okx market instruments
    验证
  • funding-rate:仅适用于SWAP品种;现货/交割合约调用会返回错误
  • price-limit:仅适用于SWAP和FUTURES品种
  • mark-price:支持SWAP、FUTURES、OPTION;不适用于现货
  • candles --bar:小时/天/周/月粒度要使用大写的
    H
    D
    W
    M
    (例如
    1H
    不是
    1h
  • index-ticker:指数ID使用
    BTC-USD
    格式(不是
    BTC-USDT
  • orderbook --sz:最大深度是400;无论
    --sz
    设置为多少,默认只展示每边前5档

Global Notes

全局说明

  • All market data commands are public — no API key required
  • --json
    returns raw OKX API v5 response for programmatic use
  • --profile <name>
    has no effect on market commands (no auth needed)
  • Rate limit: 20 requests per 2 seconds per IP for market data endpoints
  • Candle data is sorted newest-first by default
  • vol24h
    in tickers is in base currency (e.g., BTC for BTC-USDT)
  • 所有市场数据命令都是公开的——不需要API密钥
  • --json
    参数返回原始OKX API v5响应,适合程序调用
  • --profile <name>
    参数对市场命令无效(不需要鉴权)
  • 接口限流:每个IP每2秒最多请求20次市场数据接口
  • K线数据默认按时间倒序排列,最新的在前
  • 行情中的
    vol24h
    是标的货币计价的成交量(例如BTC-USDT的成交量单位是BTC)