okx-market
它能做什么
这项技能从 OKX 交易所获取加密货币价格和市场信息。适合希望获取当前或历史加密货币数据、却不想注册账户的人。
适用场景
- ✓当你想查看 OKX 上某种加密货币最新价格或 24 小时涨跌幅的时候。
- ✓当你需要现货、永续或期货市场的 K 线历史的时候。
- ✓当你想查看某个加密货币合约的资金费率或未平仓量的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/okx-market/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请告诉我 OKX 上 ETH 当前的价格和 24 小时涨跌幅。”
每周 5 个新技能,1 分钟读完。
工作原理
它会向 OKX 的公开行情数据接口发送请求,无需登录。然后它会把返回的数据整理成易于阅读或分析的表格。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
OKX Market
Overview
The OKX V5 REST API provides comprehensive cryptocurrency market data covering spot, perpetual swaps, delivery futures, options, and more. All market-data endpoints are public and can be called directly without authentication. The data comes from OKX, the world's second-largest cryptocurrency exchange.
Quick Start
- Install a Python runtime (Python 3.9+ recommended) and the required
requestsdependency.
pip install requests pandas
- No account registration or token configuration is required. Market-data endpoints are fully open.
- Review the endpoint documentation below and locate the interface you need.
- Use Python code to retrieve data according to the documentation. Example for the spot ticker endpoint:
import requests
import pandas as pd
BASE_URL = "https://www.okx.com/api/v5"
# Get the latest BTC-USDT market quote
resp = requests.get(f"{BASE_URL}/market/ticker", params={"instId": "BTC-USDT"})
data = resp.json()["data"][0]
print(f"BTC last price: {data['last']} 24h change: {float(data['last'])/float(data['open24h'])*100-100:.2f}%")
Parameter Format Reference
- Instrument format (
instId):- Spot:
BTC-USDT,ETH-USDT - Perpetual swap:
BTC-USDT-SWAP,ETH-USDT-SWAP - Delivery futures:
BTC-USDT-250328(expiry date inYYMMDD) - Options:
BTC-USD-250328-95000-C(expiry-strike-C/P) - Index:
BTC-USD,ETH-USD
- Spot:
- Candlestick interval (
bar):1m,3m,5m,15m,30m,1H,2H,4H,6H,12H,1D,1W,1M - Instrument type (
instType):SPOT(spot),SWAP(perpetual),FUTURES(delivery),OPTION(option) - Timestamp: millisecond Unix timestamp (for example
1773763200000) - Response format: JSON.
code=0indicates success, and data is returned in thedatafield
Link convention: every link to
references/in this document is written relative to this document (for examplereferences/...) — the form GitHub resolves when someone opens the file in a browser. Theread_filetool resolves the same string against the skill that owns it, so the agent and a human reader reach one file. When adding new skill docs, always use the relative form, and keep reference paths unique across skills: a path two skills both carry is reported as ambiguous rather than guessed.
Python Script Examples
Market Data Endpoint List
| ID | Endpoint Path | Title (Detailed Documentation) | Category | Description |
|---|---|---|---|---|
| 1 | /market/ticker | Single Ticker | Spot Market | Retrieve the latest market data for a single trading instrument, including last price, bid/ask, 24h volume, and more |
| 2 | /market/tickers | Batch Tickers | Spot Market | Retrieve all market data for a given instrument class (SPOT/SWAP/FUTURES/OPTION) in batch |
| 3 | /market/candles | Candlestick Data | Spot Market | Retrieve candlestick (OHLCV) data with multiple supported intervals |
| 4 | /market/trades | Recent Trades | Spot Market | Retrieve recent trade-level details |
| 5 | /public/instruments | Instrument List | Spot Market | Retrieve metadata for all tradable instruments, including minimum order size and price precision |
| 6 | /market/books | Order Book Depth | Spot Market | Retrieve bid/ask order book depth data |
| 7 | /public/funding-rate | Funding Rate | Derivatives Market | Retrieve current and historical funding rates for perpetual contracts |
| 8 | /public/funding-rate-history | Historical Funding Rate | Derivatives Market | Retrieve historical funding-rate data for perpetual contracts |
| 9 | /public/mark-price | Mark Price | Derivatives Market | Retrieve mark prices for derivatives, used for PnL and liquidation calculations |
| 10 | /public/open-interest | Open Interest | Derivatives Market | Retrieve open-interest data for derivatives |
| 11 | /public/price-limit | Price Limit | Derivatives Market | Retrieve the curre |
常见问题
我需要 OKX 账户吗?
不需要。行情数据接口是公开的,因此无需账户或令牌。
如何表示交易对?
现货使用 BTC-USDT 格式,永续合约使用 BTC-USDT-SWAP,期货和期权则使用类似的代码。
它需要特殊的 Python 软件包吗?
需要 requests 和 pandas,这两个都是常见的 Python 库。
详情
作者的原始描述
OKX cryptocurrency market data interface. Uses the OKX V5 REST API to retrieve spot, derivatives, index, and other crypto market data, including real-time prices, candlesticks, funding rates, open interest, and more. No authentication required, free to use.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7535
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …