minute-analysis
它能做什么
这项技能获取短周期的价格 K 线,例如 1 分钟或 5 分钟的 K 线,并在其上运行日内测试。适合只在单个交易日内进行交易的交易者。
适用场景
- ✓当你想查看某只加密货币或股票的 5 分钟或 1 小时价格 K 线的时候。
- ✓当你想用过去的分钟数据测试日内策略的时候。
- ✓当你需要 VWAP 或 TWAP 等日内指标来辅助某笔交易的时候。
技能链接
https://github.com/HKUDS/Vibe-Trading/blob/main/agent/src/skills/minute-analysis/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请获取比特币最近两周的 5 分钟 K 线,并测试一个简单的策略。”
每周 5 个新技能,1 分钟读完。
工作原理
它会从数据源下载 K 线,并计算 VWAP 等日内指标。当你在配置中设置较短的时间间隔时,这些 K 线也可以输入回测引擎。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Minute-Level Data Analysis and Backtesting
Purpose
Retrieve minute-level candlestick data through data-source APIs and calculate intraday indicators (VWAP, TWAP, volume distribution, and more).
Supports minute-level backtesting: set "interval": "5m" in config.json and use the backtest tool to run intraday strategies.
Backtest Configuration
For minute-level backtests, simply add the interval field in config.json:
{
"source": "okx",
"codes": ["BTC-USDT"],
"start_date": "2026-03-01",
"end_date": "2026-03-15",
"interval": "5m",
"initial_cash": 1000000,
"commission": 0.0005
}
- The annualization factor is inferred automatically from
source + interval(OKX 5m = 365 x 288 = 105120) - Minute-level datasets are large. Recommended time limits: no more than 7 days for
1m, no more than 30 days for5m, and no more than 1 year for1H
Supported Data Sources and Intervals
| Data Source | Supported Intervals | Notes |
|---|---|---|
| OKX | 1m/5m/15m/30m/1H/4H | Cryptocurrency, trades 7x24 |
| Tushare | 1m/5m/15m/30m/1H | China A-shares, requires score >= 2000 |
| yfinance | 1m/5m/15m/30m/1H | Hong Kong / US equities (free, no key required) |
OKX Minute Candlestick API
import requests
import pandas as pd
resp = requests.get("https://www.okx.com/api/v5/market/candles", params={
"instId": "BTC-USDT",
"bar": "1m", # 1m/5m/15m/30m/1H/4H
"limit": "300", # At most 300 rows per request
})
data = resp.json()["data"]
columns = ["ts", "open", "high", "low", "close", "vol", "volCcy", "volCcyQuote", "confirm"]
df = pd.DataFrame(reversed(data), columns=columns)
df["ts"] = pd.to_datetime(df["ts"].astype("int64"), unit="ms")
for col in ["open", "high", "low", "close", "vol"]:
df[col] = df[col].astype(float)
Indicator Calculation Templates
VWAP (Volume-Weighted Average Price)
typical_price = (df["high"] + df["low"] + df["close"]) / 3
df["vwap"] = (typical_price * df["vol"]).cumsum() / df["vol"].cumsum()
TWAP (Time-Weighted Average Price)
df["twap"] = df["close"].expanding().mean()
Volume Distribution
df["vol_pct"] = df["vol"] / df["vol"].sum() * 100
hourly_vol = df.set_index("ts").resample("1h")["vol"].sum()
Parameters
| Parameter | Description |
|---|---|
| inst_id | Trading pair, such as "BTC-USDT" |
| bar / interval | Candlestick interval: 1m/5m/15m/30m/1H/4H |
| limit | Number of records to retrieve (OKX returns at most 300 per request) |
Common Pitfalls
- OKX returns at most 300 rows per request. The loader paginates automatically, but
1mdatasets are still very large - The time range for minute-level backtests should not be too long, otherwise both data retrieval and backtesting will become slow or time out
- Tushare minute endpoints require a score >= 2000. If the score is insufficient, the API returns empty data
- Timestamps are Unix timestamps in milliseconds and should be converted with
unit="ms" - Transaction costs for minute strategies should be set lower (for example 0.05% instead of 0.1%) because intraday trading is frequent
Dependencies
pip install pandas numpy requests
常见问题
它支持哪些数据源?
加密货币使用 OKX,A 股使用 Tushare,香港股票和美股使用 yfinance。
我能请求的数据量有限制吗?
有。技能建议 1 分钟数据最多请求 7 天,5 分钟数据最多请求 30 天。
它需要 API 密钥吗?
OKX 和 yfinance 不需要密钥。Tushare 需要一个积分至少为 2000 的账户。
详情
作者的原始描述
Minute-level data analysis and backtesting. Retrieves minute candlesticks through OKX/Tushare/yfinance and can be used both for analysis and as input to the backtest engine.
repo: HKUDS/Vibe-Trading
热度
- GitHub 星标
- 37k
- 排名
- #7532
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …