## 交易产品列表 ---- 接口:GET /api/v5/public/instruments 描述:获取所有可交易产品的基础信息,包括交易对名称、最小下单量、价格精度、合约面值等。 限频:20次/2s **输入参数** | 名称 | 类型 | 必选 | 描述 | | ---- | ---- | ---- | ---- | | instType | str | Y | 产品类型:`SPOT`、`SWAP`、`FUTURES`、`OPTION` | | instId | str | N | 产品ID,如 `BTC-USDT`(可选过滤) | **输出参数** | 名称 | 类型 | 描述 | | ---- | ---- | ---- | | instType | str | 产品类型 | | instId | str | 产品ID | | baseCcy | str | 基础货币(如 BTC) | | quoteCcy | str | 计价货币(如 USDT) | | tickSz | str | 最小价格变动(价格精度) | | lotSz | str | 最小交易数量(下单精度) | | minSz | str | 最小下单量 | | ctVal | str | 合约面值(仅合约) | | lever | str | 最大杠杆(仅合约) | | listTime | str | 上市时间 | | state | str | 状态:`live`(交易中)/ `suspend`(暂停) | **接口示例** ```python import requests import pandas as pd BASE_URL = "https://www.okx.com/api/v5" # 获取所有现货交易对 resp = requests.get(f"{BASE_URL}/public/instruments", params={"instType": "SPOT"}) instruments = resp.json()["data"] print(f"现货交易对数量: {len(instruments)}") # 筛选 USDT 交易对 usdt_pairs = [i for i in instruments if i["quoteCcy"] == "USDT"] df = pd.DataFrame(usdt_pairs)[["instId", "baseCcy", "minSz", "tickSz", "lotSz"]] print(df.head(10)) # 获取所有永续合约 resp = requests.get(f"{BASE_URL}/public/instruments", params={"instType": "SWAP"}) swaps = resp.json()["data"] print(f"永续合约数量: {len(swaps)}") ```