AI-Trader Market Intel
HKUDS/AI-Trader
Reads AI-Trader's read-only market snapshots, grouped financial news and events board through its market-intel endpoints, for context before trading or posting.
Framework for analyzing ETFs with emphasis on China's market: product types, tracking error, fees, premium and discount, liquidity, fund size and picking among ETFs on one index; Chinese text.
SKILL.md written in Chinese; this summary is our English description.
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install HKUDS/Vibe-Trading etf-analysis --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agent/src/skills/etf-analysis .claude/skills/etf-analysis && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .claude/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysisType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install HKUDS/Vibe-Trading etf-analysis --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .agents/skills && cp -r skills-src/agent/src/skills/etf-analysis .agents/skills/etf-analysis && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .agents/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install HKUDS/Vibe-Trading etf-analysis --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/agent/src/skills/etf-analysis .cursor/skills/etf-analysis && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .cursor/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/HKUDS/Vibe-Trading.git --path agent/src/skills/etf-analysis--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install HKUDS/Vibe-Trading etf-analysis --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/agent/src/skills/etf-analysis .gemini/skills/etf-analysis && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .gemini/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install HKUDS/Vibe-Trading etf-analysisInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .github/skills && cp -r skills-src/agent/src/skills/etf-analysis .github/skills/etf-analysis && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .github/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install HKUDS/Vibe-Trading etf-analysis --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/agent/src/skills/etf-analysis .opencode/skills/etf-analysis && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "etf-analysis" agent skill from https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/etf-analysis into .opencode/skills/etf-analysis/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "etf-analysis", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
etf-analysisFramework for analyzing ETFs with emphasis on China's market: product types, tracking error, fees, premium and discount, liquidity, fund size and picking among ETFs on one index; Chinese text.
The skill positions ETFs as core tools for passive investing and allocation and covers product analysis, selection, strategy use and features of the Chinese market. It classifies products by underlying asset, including broad-base, sector, thematic, smart beta, commodity, bond, cross-border QDII and money market ETFs with sample tickers, and by structure: ordinary ETFs, LOFs, feeder funds and multiple-exposure or inverse funds, whose long-term decay it flags. The instructions are written in Chinese.
Core metrics come with formulas and grading thresholds: tracking error and its sources, information ratio, premium or discount to IOPV, liquidity measures such as turnover and bid-ask spread, the combined fee rate and its compounding drag, and fund size thresholds that signal liquidation risk. A step-by-step comparison method is given for choosing among several ETFs that track the same index, starting with size screening and then fees and tracking error.
9 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit e532650. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are python).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
China ETF Analysis loads about 4.8k tokens when it runs. Until then it costs about 15 tokens; SKILL.md has 508 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from HKUDS/Vibe-Trading at commit e532650, republished under its MIT licence (© HKUDS). 508 words, ~4,774 tokens.
.claude/skills/etf-analysis/SKILL.md (or your agent's skills folder).ETF(交易所交易基金)是被动投资与资产配置的核心工具。本 skill 覆盖 ETF 产品分析、选择方法论、策略应用、中国市场特色以及数据驱动的量化分析方法,为构建基于 ETF 的量化策略与组合提供完整框架。
| 类型 | 代表产品 | 特点 |
|---|---|---|
| 宽基 ETF | 沪深300ETF (510300)、中证500ETF (510500)、创业板ETF (159915)、科创50ETF (588000) | 流动性最好,交易成本最低,适合核心仓位 |
| 行业 ETF | 消费ETF (159928)、医疗ETF (512170)、半导体ETF (512480)、银行ETF (512800) | 行业轮动工具,持仓集中度高 |
| 主题 ETF | 新能源ETF (516160)、碳中和ETF、元宇宙ETF | 主题炒作属性强,生命周期短 |
| 策略ETF / Smart Beta | 红利ETF (510880)、低波ETF、质量ETF、动量ETF | 因子暴露明确,费率通常略高于宽基 |
| 商品 ETF | 黄金ETF (518880)、豆粕ETF (159985)、原油ETF (162411) | 实物/期货支撑,注意展期损耗 |
| 债券 ETF | 国债ETF (511010)、信用债ETF、可转债ETF (511380) | 利率敏感,久期管理关键 |
| 跨境 ETF (QDII) | 纳指ETF (159632)、标普500ETF (513500)、日经225ETF (513880) | 汇率风险+溢价风险双重叠加 |
| 货币 ETF | 华宝添益 (511990)、银华日利 (511880) | T+0 申赎,流动性管理工具 |
衡量 ETF 复制指数能力的最核心指标。
日跟踪误差 = std(ETF日收益率 - 指数日收益率)
年化跟踪误差 = 日跟踪误差 × √252评级标准(A股宽基ETF):
跟踪误差来源:
IR = (ETF年化收益率 - 指数年化收益率) / 年化跟踪误差对 ETF 来说 IR 通常为负(因费率拖累),IR 越接近 0 越好。
折溢价率 = (ETF市价 - ETF净值IOPV) / ETF净值IOPV × 100%| 指标 | 含义 | 参考阈值 |
|---|---|---|
| 日均成交额 | 买卖方便程度 | 宽基 > 1亿,行业 > 2000万 |
| 买卖价差(Spread) | 即时交易成本 | < 0.05% 为优质 |
| 盘口深度 | 单笔大额交易冲击 | 买卖各5档累计 > 500万为佳 |
| 换手率 | 活跃程度 | 过低则流动性风险高 |
综合费率 = 管理费 + 托管费 + 指数使用费
(不含交易佣金、印花税、申赎费)长期费率影响公式:
N年费率复利损耗 = (1 - 年费率)^N
例:年费率0.5% vs 0.15%,10年差距 ≈ 3.5%,20年差距 ≈ 6.8%主流宽基 ETF 费率对比(2025年):
规模门槛:
10亿:流动性充足,做市商活跃
100亿:旗舰 ETF,机构首选
清盘风险信号:规模持续下滑、连续90天日均规模 < 5000万
同一指数往往有多只 ETF,选择步骤:
Step 1: 规模筛选 → 剔除 < 5亿的小规模产品
Step 2: 费率比较 → 同等条件下选费率最低
Step 3: 跟踪误差 → 近1年/近3年双维度比较
Step 4: 流动性 → 日均成交额、买卖价差
Step 5: 基金公司 → 指数化投资能力、历史口碑量化评分模型:
def etf_score(etf_data: dict) -> float:
"""
ETF 综合评分(越高越好,满分100)。
Args:
etf_data: 包含 scale, fee, tracking_error, avg_volume, spread 的字典
Returns:
综合评分 0~100
"""
score = 0.0
# 规模得分(30分)
scale = etf_data['scale_billion']
score += min(30, scale / 10 * 30)
# 费率得分(25分):费率越低越高分
fee = etf_data['total_fee_pct'] # 年费率百分比
score += max(0, 25 - fee * 50)
# 跟踪误差得分(30分):误差越小越高分
te = etf_data['tracking_error_annual_pct']
score += max(0, 30 - te * 60)
# 流动性得分(15分)
vol = etf_data['avg_daily_volume_million']
score += min(15, vol / 10 * 15)
return round(score, 2)import numpy as np
def fee_drag_analysis(annual_return: float, years: int, fee_rates: list[float]) -> dict:
"""
分析不同费率对长期收益的拖累效果。
Args:
annual_return: 指数年化收益率(小数,如0.08)
years: 投资年限
fee_rates: 待比较的费率列表(小数,如[0.002, 0.005, 0.015])
Returns:
各费率下的终值倍数和相对拖累字典
"""
results = {}
base_value = (1 + annual_return) ** years
for fee in fee_rates:
net_return = annual_return - fee
end_value = (1 + net_return) ** years
drag = (base_value - end_value) / base_value * 100
results[f'{fee*100:.2f}%'] = {
'end_value_multiple': round(end_value, 4),
'drag_pct': round(drag, 2)
}
return results
# 示例:8% 指数收益,20年期
# fee_drag_analysis(0.08, 20, [0.002, 0.005, 0.015])优质做市商体现在:
评估方法:
# 通过Level2数据计算有效价差
effective_spread = (ask_price - bid_price) / mid_price * 100 # 单位 %
# 价格冲击成本(Impact Cost)
# 买入N万元所需均价相对于中间价的偏离
impact_cost = (avg_buy_price - mid_price) / mid_price * 100| 维度 | 评估要点 |
|---|---|
| ETF 管理规模 | 全市场排名,指数化投资专业度 |
| 跟踪误差历史 | 长期维度(3年+)稳定性 |
| 产品线完整性 | 宽基、行业、跨境覆盖广度 |
| 申赎效率 | T+0 实物申赎处理能力 |
| 做市商合作质量 | 与头部券商做市商的合作稳定性 |
国内 ETF 管理头部公司(规模口径):华夏、易方达、华泰柏瑞、南方、嘉实、博时
总组合 = 核心仓位(70~80%)+ 卫星仓位(20~30%)
核心仓位:宽基ETF(沪深300/中证500/全A)
→ 获取市场beta,低费率,长期持有,减少交易摩擦
卫星仓位:行业ETF/主题ETF/Smart Beta ETF
→ 增强收益,主动暴露特定因子,允许更高换手再平衡触发条件:
动量轮动:
def sector_momentum_rotation(etf_returns: pd.DataFrame, lookback: int = 20, top_n: int = 3) -> list[str]:
"""
基于动量的行业ETF轮动选择。
Args:
etf_returns: 各行业ETF日收益率 DataFrame,列为ETF代码
lookback: 回看窗口(交易日数)
top_n: 持有ETF数量
Returns:
本期持有的ETF代码列表
"""
momentum = etf_returns.tail(lookback).sum()
selected = momentum.nlargest(top_n).index.tolist()
return selected宏观周期轮动:
| 经济周期 | 推荐行业 ETF |
|---|---|
| 复苏期(低增长→高增长,低通胀) | 消费、科技、中小盘 |
| 过热期(高增长,高通胀) | 能源、材料、工业 |
| 滞胀期(低增长,高通胀) | 能源、公用事业、消费 |
| 衰退期(高增长→低增长) | 医疗、公用事业、债券ETF |
主要因子及对应ETF:
| 因子 | 代表ETF | 历史有效性(A股) |
|---|---|---|
| 价值(低估值) | 沪深300价值ETF | 中等,受风格切换影响 |
| 红利(高股息) | 红利ETF (510880) | 较强,尤其熊市防御 |
| 低波动 | 中证低波ETF | 较强,夏普比优于宽基 |
| 质量(高ROE) | 中证质量ETF | 较强,长期复合效果好 |
| 动量 | 目前A股产品少 | 中短期有效,长期均值回归 |
| 小盘 | 中证1000ETF (512100) | 强,但流动性风险高 |
因子暴露分析代码:
import pandas as pd
import numpy as np
from scipy import stats
def factor_exposure_analysis(etf_returns: pd.Series, factor_returns: dict[str, pd.Series]) -> pd.DataFrame:
"""
分析ETF对各因子的暴露程度(单因子回归)。
Args:
etf_returns: ETF日收益率序列
factor_returns: 各因子收益率字典 {因子名: 收益率序列}
Returns:
包含 beta, t_stat, r_squared 的 DataFrame
"""
results = []
for factor_name, factor_ret in factor_returns.items():
aligned = pd.concat([etf_returns, factor_ret], axis=1).dropna()
x = aligned.iloc[:, 1].values
y = aligned.iloc[:, 0].values
slope, intercept, r_value, p_value, std_err = stats.linregress(x, y)
results.append({
'factor': factor_name,
'beta': round(slope, 4),
't_stat': round(slope / std_err, 2),
'r_squared': round(r_value ** 2, 4),
'p_value': round(p_value, 4)
})
return pd.DataFrame(results).set_index('factor')Beta 衰减(Volatility Decay)原理:
每日恒定杠杆 N 倍 → 复合效应导致长期收益 ≠ N × 指数收益
衰减量(近似)= N²(N-1)/2 × σ² × T
其中 σ 为指数日波动率,T 为持有天数数值示例:
适用场景:
折溢价套利(需要有实物申赎资格,通常门槛100万份):
溢价套利:
ETF市价 > IOPV + 交易成本
→ 买入一篮子成分股 → 申购ETF份额 → 卖出ETF
→ 套利利润 ≈ 溢价率 - 冲击成本 - 佣金
折价套利:
ETF市价 < IOPV - 交易成本
→ 买入ETF份额 → 赎回一篮子成分股 → 卖出成分股
→ 套利利润 ≈ 折价率 - 冲击成本 - 佣金跨市场套利(ETF vs 期货):
IF(沪深300股指期货)基差 = 期货价格 - 沪深300指数
当基差 > 合理基差(无风险利率×剩余期限)时:
→ 卖期货 + 买ETF(正向套利)
当基差 < 合理基差时:
→ 买期货 + 卖ETF(反向套利,需融券)统计套利(配对交易):
# 同类ETF(如不同公司发行的沪深300ETF)之间的价差均值回归
# 价差 = 价格差 或 价格比
# 当价差偏离历史均值2个标准差时建仓,回归时平仓
spread = etf_a_price / etf_b_price
z_score = (spread - spread.rolling(60).mean()) / spread.rolling(60).std()
signal = pd.Series(0, index=z_score.index)
signal[z_score > 2] = -1 # ETF_A 相对贵,卖A买B
signal[z_score < -2] = 1 # ETF_A 相对便宜,买A卖B| 维度 | 场内 ETF | 场外联接基金 |
|---|---|---|
| 购买渠道 | 证券账户,实时交易 | 银行/基金直销,T+1申赎 |
| 申赎方式 | 实物申赎(机构)或二级市场(个人) | 现金申赎 |
| 折溢价 | 存在(有套利机制) | 不存在 |
| 最小交易单位 | 100份(约10~100元) | 1元起投 |
| 费率 | 较低(管理费+交易佣金) | 略高(申购费+管理费) |
| 适合场景 | 波段操作、大额配置 | 定投、小额长期持有 |
溢价形成原因:
溢价率警戒线:
5%:高溢价,存在显著买入风险(净值回落但溢价收窄双杀)
汇率对冲:
LOF(上市开放式基金):
分级基金(已全面转型,2020年前历史参考):
宽基指数:
| 指数 | 成分股 | 特点 |
|---|---|---|
| 沪深300 | 沪深两市市值最大300只 | 大盘蓝筹,衍生品丰富(IF期货/300期权) |
| 中证500 | 300~800名中盘股 | 中盘成长,与300互补 |
| 中证1000 | 800~1800名小盘股 | 小盘因子,波动较大 |
| 上证50 | 沪市最大50只 | 超大盘,金融地产权重高 |
| 创业板指 | 创业板前100名 | 科技成长,波动大 |
| 科创50 | 科创板前50名 | 硬科技,上市时间短 |
| 北证50 | 北交所前50名 | 新兴市场,流动性弱 |
| 中证全指 / 万得全A | 全市场 | 最宽泛的基准 |
指数调整规律:
经典配置框架(可用ETF实现):
股债 60/40 中国版:
沪深300ETF 30% + 中证500ETF 20% + 中债ETF 40% + 黄金ETF 10%
全天候组合(中国版):
股票ETF(沪深300)25%
长期国债ETF 40%
中期国债ETF 15%
黄金ETF 7.5%
商品ETF 12.5%
哑铃策略:
宽基ETF(低风险核心)50%
行业/主题ETF(高弹性进攻)50%A股:沪深300ETF 510300 / 中证500ETF 510500
美股:纳指ETF 159632 / 标普500ETF 513500
港股:恒生ETF 159920 / 恒生科技ETF 513130
欧洲:德国DAX ETF / 欧洲50ETF(规模较小)
日本:日经225ETF 513880 / 东证ETF
新兴:越南ETF / 印度ETF(部分有QDII溢价)
固定收益:
国内:国债ETF 511010 / 政金债ETF
美国:美债ETF(QDII)
商品:
黄金ETF 518880
原油ETF 162411
CRB商品指数ETF(国内较少)再平衡成本:
单次再平衡成本 ≈ 交易金额 × (佣金率 + 价差/2 + 冲击成本)
≈ 交易金额 × 0.05%~0.15%(宽基ETF)
年化再平衡成本 = 单次成本 × 年均调仓次数最优再平衡频率建议:
免佣金再平衡技巧:
中国 ETF 税务规则:
税务效率策略:
import tushare as ts
import pandas as pd
def get_etf_list(pro: ts.pro_api) -> pd.DataFrame:
"""
获取全市场ETF列表。
Args:
pro: tushare pro_api 实例
Returns:
ETF基本信息 DataFrame
"""
df = pro.fund_basic(market='E', status='L') # E=ETF, L=上市中
return df[['ts_code', 'name', 'management', 'found_date', 'issue_date']]
def get_etf_nav(pro: ts.pro_api, ts_code: str, start_date: str, end_date: str) -> pd.DataFrame:
"""
获取ETF净值数据(IOPV)。
Args:
pro: tushare pro_api 实例
ts_code: ETF代码,如 '510300.SH'
start_date: 开始日期 'YYYYMMDD'
end_date: 结束日期 'YYYYMMDD'
Returns:
包含 trade_date, nav, accum_nav 的 DataFrame
"""
df = pro.fund_nav(ts_code=ts_code, start_date=start_date, end_date=end_date)
return df.sort_values('end_date').reset_index(drop=True)
def get_etf_daily(pro: ts.pro_api, ts_code: str, start_date: str, end_date: str) -> pd.DataFrame:
"""
获取ETF场内日行情(市价)。
Args:
pro: tushare pro_api 实例
ts_code: ETF代码
start_date: 开始日期
end_date: 结束日期
Returns:
包含 trade_date, open, high, low, close, vol, amount 的 DataFrame
"""
df = pro.fund_daily(ts_code=ts_code, start_date=start_date, end_date=end_date)
return df.sort_values('trade_date').reset_index(drop=True)
def get_index_daily(pro: ts.pro_api, index_code: str, start_date: str, end_date: str) -> pd.DataFrame:
"""
获取基准指数日行情(用于计算跟踪误差)。
Args:
pro: tushare pro_api 实例
index_code: 指数代码,如 '000300.SH'(沪深300)
start_date: 开始日期
end_date: 结束日期
Returns:
包含 trade_date, close 的 DataFrame
"""
df = pro.index_daily(ts_code=index_code, start_date=start_date, end_date=end_date)
return df[['trade_date', 'close', 'pct_chg']].sort_values('trade_date').reset_index(drop=True)import numpy as np
import pandas as pd
def calc_tracking_error(
etf_prices: pd.Series,
index_prices: pd.Series,
annualize: bool = True
) -> dict:
"""
计算ETF对标的指数的跟踪误差。
Args:
etf_prices: ETF净值序列(以date为索引)
index_prices: 指数价格序列(以date为索引)
annualize: 是否年化,默认True
Returns:
包含 tracking_error, avg_daily_diff, max_daily_diff 的字典
"""
# 对齐数据
aligned = pd.concat([etf_prices, index_prices], axis=1).dropna()
aligned.columns = ['etf', 'index']
# 计算日收益率差值
etf_ret = aligned['etf'].pct_change(fill_method=None).dropna()
idx_ret = aligned['index'].pct_change(fill_method=None).dropna()
daily_diff = etf_ret - idx_ret
# 跟踪误差 = 差值的标准差
te_daily = daily_diff.std()
te = te_daily * np.sqrt(252) if annualize else te_daily
return {
'tracking_error': round(te * 100, 4), # 百分比
'avg_daily_diff': round(daily_diff.mean() * 100, 4), # 平均日偏差 %
'max_daily_diff': round(daily_diff.abs().max() * 100, 4), # 最大单日偏差 %
'annualized': annualize
}
def compare_etfs_same_index(
etf_codes: list[str],
index_code: str,
pro,
start_date: str,
end_date: str
) -> pd.DataFrame:
"""
比较追踪同一指数的多只ETF的跟踪表现。
Args:
etf_codes: ETF代码列表
index_code: 基准指数代码
pro: tushare pro_api 实例
start_date: 开始日期
end_date: 结束日期
Returns:
各ETF的跟踪误差比较 DataFrame
"""
index_df = get_index_daily(pro, index_code, start_date, end_date)
index_prices = index_df.set_index('trade_date')['close']
results = []
for code in etf_codes:
nav_df = get_etf_nav(pro, code, start_date, end_date)
etf_prices = nav_df.set_index('end_date')['nav']
te_result = calc_tracking_error(etf_prices, index_prices)
te_result['ts_code'] = code
results.append(te_result)
return pd.DataFrame(results).set_index('ts_code').sort_values('tracking_error')def calc_premium_discount(
market_price: float,
iopv: float
) -> dict:
"""
计算ETF折溢价率及套利信号。
Args:
market_price: ETF场内市价
iopv: 实时净值(IOPV)
Returns:
包含 premium_pct, signal, arbitrage_feasible 的字典
"""
premium_pct = (market_price - iopv) / iopv * 100
if premium_pct > 0.3:
signal = 'PREMIUM_HIGH' # 溢价:卖出ETF或申购套利
feasible = premium_pct > 0.5 # 扣除成本后是否可套利
elif premium_pct < -0.3:
signal = 'DISCOUNT_HIGH' # 折价:买入ETF或赎回套利
feasible = premium_pct < -0.5
else:
signal = 'NORMAL'
feasible = False
return {
'premium_pct': round(premium_pct, 4),
'signal': signal,
'arbitrage_feasible': feasible
}
def monitor_qdii_premium(pro, qdii_codes: list[str], date: str) -> pd.DataFrame:
"""
监控QDII ETF溢价率(溢价过高时发出预警)。
Args:
pro: tushare pro_api 实例
qdii_codes: QDII ETF代码列表
date: 查询日期 'YYYYMMDD'
Returns:
各QDII ETF的溢价率和风险等级 DataFrame
"""
results = []
for code in qdii_codes:
# 获取市价
price_df = pro.fund_daily(ts_code=code, trade_date=date)
# 获取净值
nav_df = pro.fund_nav(ts_code=code, end_date=date)
if not price_df.empty and not nav_df.empty:
market_price = price_df.iloc[0]['close']
nav = nav_df.iloc[0]['nav']
premium_pct = (market_price - nav) / nav * 100
risk_level = (
'HIGH' if premium_pct > 5
else 'MEDIUM' if premium_pct > 2
else 'LOW'
)
results.append({
'ts_code': code,
'market_price': market_price,
'nav': nav,
'premium_pct': round(premium_pct, 2),
'risk_level': risk_level
})
return pd.DataFrame(results).sort_values('premium_pct', ascending=False)def etf_fund_flow_analysis(
pro,
ts_code: str,
start_date: str,
end_date: str
) -> pd.DataFrame:
"""
分析ETF规模变化与资金净流入/流出。
Args:
pro: tushare pro_api 实例
ts_code: ETF代码
start_date: 开始日期
end_date: 结束日期
Returns:
包含规模变化和资金流向估算的 DataFrame
"""
nav_df = get_etf_nav(pro, ts_code, start_date, end_date)
nav_df['end_date'] = pd.to_datetime(nav_df['end_date'])
nav_df = nav_df.sort_values('end_date')
# 规模(单位亿元)
nav_df['scale'] = nav_df['unit_nav'] * nav_df['fund_share'] / 1e8
# 净值变动引起的规模变化(被动)
nav_df['nav_return'] = nav_df['unit_nav'].pct_change(fill_method=None)
nav_df['passive_change'] = nav_df['scale'].shift(1) * nav_df['nav_return']
# 资金净流入 ≈ 规模变化 - 净值带来的被动变化
nav_df['net_flow'] = nav_df['scale'].diff() - nav_df['passive_change']
# 统计区间
summary = {
'total_net_flow': nav_df['net_flow'].sum(), # 区间总净流入(亿元)
'avg_daily_flow': nav_df['net_flow'].mean(), # 日均净流入
'inflow_days': (nav_df['net_flow'] > 0).sum(), # 净流入天数
'outflow_days': (nav_df['net_flow'] < 0).sum(), # 净流出天数
'current_scale': nav_df['scale'].iloc[-1] # 最新规模
}
return nav_df[['end_date', 'unit_nav', 'scale', 'net_flow']], summary
def cross_etf_flow_comparison(
pro,
etf_codes: list[str],
start_date: str,
end_date: str
) -> pd.DataFrame:
"""
比较同类ETF的资金流向,判断资金偏好。
Args:
pro: tushare pro_api 实例
etf_codes: 同类ETF代码列表
start_date: 开始日期
end_date: 结束日期
Returns:
各ETF资金流向汇总对比 DataFrame
"""
rows = []
for code in etf_codes:
_, summary = etf_fund_flow_analysis(pro, code, start_date, end_date)
summary['ts_code'] = code
rows.append(summary)
return pd.DataFrame(rows).set_index('ts_code').sort_values('total_net_flow', ascending=False)分析追踪 [沪深300/中证500/xxx] 指数的所有ETF,
维度:规模、费率、近1年跟踪误差、日均成交额、买卖价差。
给出综合评分排名,并推荐最适合[长期持有/波段操作/大额配置]的产品。基于过去 [20/60] 日动量,在以下行业ETF中选出前3名:
[消费、医疗、科技、能源、金融、工业、材料、公用事业]
同时排除近30日跌幅超过15%的ETF。构建以下ETF组合并回测 [2020-01-01 至 2025-12-31]:
- 沪深300ETF 40%
- 中证500ETF 20%
- 国债ETF 30%
- 黄金ETF 10%
每季度再平衡,计算年化收益、夏普比率、最大回撤、与沪深300的相关性。监控以下QDII ETF的实时折溢价率:[纳指ETF 159632、标普500 513500、日经225 513880]
溢价 > 3% 时发出预警,建议等待回落后再入场。© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in agent/src/skills/etf-analysis of HKUDS/Vibe-Trading.
Open the folder on GitHubat commit e532650
China ETF Analysis next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| China ETF Analysis this skillHKUDS/Vibe-Trading | 35k | — | ~4.8k | Automated safety check: Pass | MIT | |
| AI-Trader Market IntelHKUDS/AI-Trader | 23k | — | ~1.1k | Automated safety check: Pass | None | |
| Stock Deep Analysis Workflowwbh604/UZI-Skill | 7.1k | — | ~9.1k | Automated safety check: Notes | MIT | |
| Zhengxi Fund Manager Views Librarylyra81604/zhengxi-views | 1.8k | — | ~1.6k | Automated safety check: Pass | MIT | |
| Supply Chain Bottleneck Hunterxbtlin/ai-berkshire | 17k | — | ~2.6k | Automated safety check: Pass | MIT | |
| Deep Company Article Seriesxbtlin/ai-berkshire | 17k | — | ~2k | Automated safety check: Pass | MIT |
HKUDS/AI-Trader
Reads AI-Trader's read-only market snapshots, grouped financial news and events board through its market-intel endpoints, for context before trading or posting.
wbh604/UZI-Skill
Runs a staged deep analysis of a single stock on China A-share, Hong Kong and US markets, ending in an HTML report with valuation models and investor-panel scores.
lyra81604/zhengxi-views
Answers questions with sourced quotes from one Chinese fund manager's public writings, applies his stated investment method and compares his words with real fund holdings.
xbtlin/ai-berkshire
Scans a long-running industry trend for supply chain chokepoints, aiming to find second- and third-layer suppliers that the market has not yet priced in.
xbtlin/ai-berkshire
Plans and writes a three-to-eight-part long-form article series that breaks down one company, built on fact-checked financials, valuation and management analysis.
helsome/folio
Earnings analysis — pre- and post-earnings. An agent skill from helsome/folio.
HKUDS/Vibe-Trading
Index of Eastmoney's free, no-token market data interfaces for China A-shares and Hong Kong stocks: fund flows, dragon-tiger lists, margin trading, reports and news.
HKUDS/Vibe-Trading
Retrieves public OKX cryptocurrency market data such as spot prices, candlesticks, funding rates and open interest through the OKX V5 REST API, with no authentication.
HKUDS/Vibe-Trading
Fetches U.S. SEC EDGAR data: resolves tickers to CIK numbers, lists recent 10-K, 10-Q and 8-K filings with document URLs, and pulls XBRL financial series.
HKUDS/Vibe-Trading
Predicts whether a mainland China A-share company risks an ST or *ST warning after its next annual report, using financial thresholds and Sina penalty records.
HKUDS/Vibe-Trading
Breaks a structural trend such as AI infrastructure into its physical supply chain and ranks lesser-known listed companies sitting on each bottleneck.
HKUDS/Vibe-Trading
Plans and drafts an eight-part, roughly 120k-word investigative series on one company, built around a strict fact-check pass rather than fast drafting.
Categories
Framework for analyzing ETFs with emphasis on China's market: product types, tracking error, fees, premium and discount, liquidity, fund size and picking among ETFs on one index; Chinese text. The skill positions ETFs as core tools for passive investing and allocation and covers product analysis, selection, strategy use and features of the Chinese market. It classifies products by underlying asset, including broad-base, sector, thematic, smart beta, commodity, bond, cross-border QDII and money market ETFs with sample tickers, and by structure: ordinary ETFs, LOFs, feeder funds and multiple-exposure or inverse funds, whose long-term decay it flags.
China ETF Analysis fits situations like: choosing between several ETFs that track the same index; computing tracking error and information ratio for an ETF; checking premium or discount, liquidity and fund size before trading; understanding QDII, LOF and feeder fund differences in China.
Run `npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a claude-code`. Or copy the skill folder (agent/src/skills/etf-analysis in HKUDS/Vibe-Trading) into .claude/skills/etf-analysis in your project. Claude Code loads it when a task matches its description.
Run `npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a codex`. Or copy the skill folder (agent/src/skills/etf-analysis in HKUDS/Vibe-Trading) into .agents/skills/etf-analysis in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/Vibe-Trading --skill etf-analysis -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/etf-analysis, .gemini/skills/etf-analysis, .github/skills/etf-analysis and .opencode/skills/etf-analysis in your project.
SKILL.md names no scripts, command-line tools or credentials: China ETF Analysis is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
China ETF Analysis is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 4.8k tokens (SKILL.md is roughly 19k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with China ETF Analysis: AI-Trader Market Intel (HKUDS/AI-Trader, 23k stars), Stock Deep Analysis Workflow (wbh604/UZI-Skill, 7.1k stars), Zhengxi Fund Manager Views Library (lyra81604/zhengxi-views, 1.8k stars) and Supply Chain Bottleneck Hunter (xbtlin/ai-berkshire, 17k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
HKUDS (a GitHub organization) maintains it in HKUDS/Vibe-Trading, which has 35,043 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on October 8, 2026.
Source: HKUDS/Vibe-Trading on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.