Tushare Data
zillionare/zillionare
面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。
Factor evaluation. An agent skill from VernonOY/alpha-skills.
$ npx skills add VernonOY/alpha-skills --skill alpha-evaluate -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install VernonOY/alpha-skills alpha-evaluate --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/VernonOY/alpha-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/alpha-evaluate .claude/skills/alpha-evaluate && 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 "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .claude/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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/VernonOY/alpha-skills/tree/main/skills/alpha-evaluateType 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 VernonOY/alpha-skills --skill alpha-evaluate -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install VernonOY/alpha-skills alpha-evaluate --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/VernonOY/alpha-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/alpha-evaluate .agents/skills/alpha-evaluate && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .agents/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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 VernonOY/alpha-skills --skill alpha-evaluate -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install VernonOY/alpha-skills alpha-evaluate --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/VernonOY/alpha-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/alpha-evaluate .cursor/skills/alpha-evaluate && 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 "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .cursor/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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/VernonOY/alpha-skills.git --path skills/alpha-evaluate--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 VernonOY/alpha-skills --skill alpha-evaluate -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install VernonOY/alpha-skills alpha-evaluate --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/VernonOY/alpha-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/alpha-evaluate .gemini/skills/alpha-evaluate && 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 "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .gemini/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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 VernonOY/alpha-skills alpha-evaluateInstalls 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 VernonOY/alpha-skills --skill alpha-evaluate -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/VernonOY/alpha-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/alpha-evaluate .github/skills/alpha-evaluate && 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 "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .github/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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 VernonOY/alpha-skills --skill alpha-evaluate -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install VernonOY/alpha-skills alpha-evaluate --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/VernonOY/alpha-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/alpha-evaluate .opencode/skills/alpha-evaluate && 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 "alpha-evaluate" agent skill from https://github.com/VernonOY/alpha-skills/tree/main/skills/alpha-evaluate into .opencode/skills/alpha-evaluate/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "alpha-evaluate", 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.
alpha-evaluateFactor evaluation. An agent skill from VernonOY/alpha-skills.
Alpha Evaluate is an agent skill from VernonOY/alpha-skills. Factor evaluation. Multi-level evaluation pipeline (IC/ICIR/quintile/robustness). 因子评估。多级评估管线(IC/ICIR/分层/多空/鲁棒性)。 Triggers: "evaluate factor", "test factor", "评估因子", "测试因子"
Its SKILL.md is about 5.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Business, Finance & HR, covering Trading and backtesting. The repository describes itself as: Quantitative factor research skills for AI coding assistants. The licence is Apache-2.0.
10 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit f58f80a. 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.
Shell commands in SKILL.md call:
pipFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.
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.
Alpha Evaluate loads about 5.7k tokens when it runs. Until then it costs about 47 tokens; SKILL.md has 962 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 VernonOY/alpha-skills at commit f58f80a, republished under its Apache-2.0 licence (© VernonOY). 962 words, ~5,735 tokens.
.claude/skills/alpha-evaluate/SKILL.md (or your agent's skills folder).你是一个专业量化分析师。当用户要求评估一个因子时,按照以下流程执行。 You are a professional quant analyst. Follow the pipeline below when evaluating a factor.
| English | 中文 |
|---|---|
| Factor | 因子 |
| IC (Information Coefficient) | 信息系数 |
| ICIR (IC Information Ratio) | IC信息比率 |
| Quintile | 五分位/分组 |
| Long-Short | 多空 |
| Sharpe Ratio | 夏普比率 |
| Max Drawdown | 最大回撤 |
| Monotonicity | 单调性 |
| Robustness | 鲁棒性 |
| Holding Period | 持有期 |
| Factor Registry | 因子注册表 |
| Backtest | 回测 |
| Gate Check | 门控检查 |
项目目录在用户的当前工作目录,其中: Project directory is the user's current working directory, containing:
data_cache/ — 本地缓存的行情数据 Local cached market data(Parquet格式 format)output/ — 报告输出目录 Report output directory.claude/alpha-agent.config.md — 用户自定义评估参数 User-defined evaluation parameters数据来源 / Data Source:技能支持任何数据源。优先检查用户配置中的 DATA_SOURCE 字段: The skill supports any data source. Check user config DATA_SOURCE field first:
tushare (默认 default) — 使用Tushare Pro API拉取A股数据 / Fetch A-share data via Tushare Pro APIcsv — 从用户指定目录读取CSV/Parquet文件 / Read CSV/Parquet from user-specified directorycustom — 用户提供自定义数据加载函数 / User-provided custom data loader如果用户已在项目中定义了自己的数据加载模块(如 my_data.py),优先使用用户的模块。
If the user has defined a custom data module (e.g., my_data.py), use it first.
检查方式:查看配置文件中是否有 DATA_MODULE 字段指定了自定义模块路径。
Check: look for DATA_MODULE field in config file for custom module path.
Multi-Market Support / 多市场支持:
Alpha Skills support A-share (default), HK, and US stocks via data adapters: Alpha Skills 通过数据适配器支持A股(默认)、港股和美股:
# .claude/alpha-agent.config.md
MARKET: A-share # or "HK" or "US"
DATA_MODULE: (leave empty for A-share Tushare default)
# or "examples.us_data_yfinance"
# or "examples.hk_data_yfinance"When a custom DATA_MODULE is set, the skill loads MARKET_CONFIG from that module to determine benchmark, cost rate, and trading rules. 设置自定义DATA_MODULE时,skill从该模块加载MARKET_CONFIG来确定基准、成本和交易规则。
Language Rule / 语言规则:
用户可能以以下方式提供因子 / Users may provide factors in these ways:
If the factor is provided as a source file or a Python expression longer than one line, offer to run qtype as a pre-flight check to catch look-ahead bias and time-leak bugs. qtype is an independent tool — check if it is installed:
如果用户提供的是源文件或多行 Python 表达式,建议先跑一遍 qtype 预检查,捕捉前视偏差和时间泄漏bug。qtype 是独立工具,先检查是否已安装:
which qtype || pip show qtypeIf installed and the factor is a file: 如果已安装且因子是文件:
qtype check <path_to_factor.py>Rules / 规则:
.shift(N) with negative literallead, look_forward, peek_future, etc..merge() without explicit join keyspct_change() assigned to forward_* / next_* / targetBehavior / 行为:
If qtype finds errors (QT001/QT002): stop evaluation and show the bug. Evaluating a factor with look-ahead bias produces fake alpha.
If qtype finds warnings (QT003/QT004/QT005): show them to the user and ask whether to proceed.
If qtype is not installed: skip this step silently. Do not block evaluation. Optionally mention qtype once: "Tip: install qtype to catch time-leak bugs automatically — pip install qtype."
If the factor is a built-in factor name (e.g., pv_diverge): skip this step entirely, built-ins are already verified.
如果 qtype 发现错误(QT001/QT002):停止评估并展示bug。带前视偏差的因子会产出虚假 alpha。
如果发现警告(QT003/QT004/QT005):展示给用户并询问是否继续。
如果 qtype 未安装:静默跳过,不要阻塞流程。可以提一句建议:"提示:安装 qtype 可自动捕捉时间泄漏bug — pip install qtype。"
如果因子是内置因子名(如 pv_diverge):跳过此步,内置因子已验证。
# 读取 .claude/alpha-agent.config.md 中的评估参数
# Read evaluation parameters from .claude/alpha-agent.config.md
# 如果文件不存在,使用默认值 / If file not found, use defaults默认值 Defaults:
从配置读取 MARKET 字段(默认 "A-share"):
Read MARKET field from config (default "A-share"):
如果配置了 DATA_MODULE,加载该模块并读取其 MARKET_CONFIG: If DATA_MODULE is configured, load module and read MARKET_CONFIG:
import importlib
if config.get("DATA_MODULE"):
data_mod = importlib.import_module(config["DATA_MODULE"])
market_config = data_mod.MARKET_CONFIG
cost_rate = market_config["cost_rate"]
benchmark_symbol = market_config["benchmark"]
price_limit = market_config.get("price_limit") # None表示无涨跌停首先检查用户是否有自定义数据加载方式(配置中 DATA_MODULE 或 DATA_SOURCE 字段)。 First check if user has a custom data loader (DATA_MODULE or DATA_SOURCE in config).
方式A: 用户自定义数据模块 / Method A: User Custom Data Module(优先 Priority)
如果配置了 DATA_MODULE: my_data,则 / If DATA_MODULE: my_data is configured:
import importlib
data_mod = importlib.import_module("my_data")
# 用户模块需提供以下函数(返回DataFrame):
# User module must provide these functions (returning DataFrame):
# data_mod.load_prices(start, end) → DataFrame with columns: ts_code, trade_date, open, high, low, close, vol, amount
# data_mod.load_adj_factor(start, end) → DataFrame with columns: ts_code, trade_date, adj_factor
# data_mod.load_daily_basic(start, end) → DataFrame with columns: ts_code, trade_date, pe_ttm, pb, turnover_rate_f, ...
# data_mod.load_financial(start, end) → DataFrame with columns: ts_code, ann_date, end_date, roe, roa, ...方式B: CSV/Parquet本地文件 / Method B: Local CSV/Parquet Files
如果配置了 DATA_SOURCE: csv 和 DATA_DIR: /path/to/data,则从指定目录读取文件:
If DATA_SOURCE: csv and DATA_DIR: /path/to/data are configured, read from specified directory:
DATA_DIR = config.get("DATA_DIR", "data")
daily_prices = pd.read_parquet(os.path.join(DATA_DIR, "daily_prices.parquet"))
# 或 / or pd.read_csv(os.path.join(DATA_DIR, "daily_prices.csv"))方式C: Tushare缓存 / Method C: Tushare Cache(默认 Default)
import sys, os, glob, warnings
warnings.filterwarnings("ignore")
PROJECT_DIR = "<用户当前工作目录的绝对路径 / absolute path to user's cwd>"
sys.path.insert(0, PROJECT_DIR)
import pandas as pd
import numpy as np
CACHE_DIR = os.path.join(PROJECT_DIR, "data_cache")
def load_and_merge(prefix):
files = sorted(glob.glob(os.path.join(CACHE_DIR, f"{prefix}_*.parquet")))
frames = [pd.read_parquet(f) for f in files if os.path.getsize(f) > 100]
return pd.concat(frames, ignore_index=True).drop_duplicates() if frames else pd.DataFrame()
daily_prices = load_and_merge("get_daily_prices")
adj_factor = load_and_merge("get_adj_factor")
daily_basic = load_and_merge("get_daily_basic")
fina = load_and_merge("get_financial_data")
stock_pool = load_and_merge("get_stock_pool")
index_data = load_and_merge("get_index_daily")数据格式约定 / Data Format Convention(无论哪种方式,最终数据需符合 regardless of method):
daily_prices: 必须含 must contain ts_code, trade_date, open, high, low, close, vol, amountadj_factor: 必须含 must contain ts_code, trade_date, adj_factortrade_date 格式 format: YYYYMMDD 字符串或可解析日期 string or parseable date# 过滤股票池 / Filter stock pool
valid_codes = set(stock_pool["ts_code"].tolist()) if not stock_pool.empty else set(daily_prices["ts_code"].unique())
dp = daily_prices[daily_prices["ts_code"].isin(valid_codes)].copy()
dp["trade_date"] = pd.to_datetime(dp["trade_date"], format="%Y%m%d")
# Pivot成宽表 / Pivot to wide format
close_raw = dp.pivot_table(index="trade_date", columns="ts_code", values="close").sort_index()
volume = dp.pivot_table(index="trade_date", columns="ts_code", values="vol").fillna(0)
high_raw = dp.pivot_table(index="trade_date", columns="ts_code", values="high")
low_raw = dp.pivot_table(index="trade_date", columns="ts_code", values="low")
# 前复权 / Forward adjustment
if not adj_factor.empty:
af = adj_factor[adj_factor["ts_code"].isin(valid_codes)].copy()
af["trade_date"] = pd.to_datetime(af["trade_date"], format="%Y%m%d")
adj_pivot = af.pivot_table(index="trade_date", columns="ts_code", values="adj_factor").sort_index()
common_dates = close_raw.index.intersection(adj_pivot.index)
common_stocks = close_raw.columns.intersection(adj_pivot.columns)
close_raw = close_raw.loc[common_dates, common_stocks]
adj_pivot = adj_pivot.loc[common_dates, common_stocks]
high_raw = high_raw.reindex(index=common_dates, columns=common_stocks)
low_raw = low_raw.reindex(index=common_dates, columns=common_stocks)
volume = volume.reindex(index=common_dates, columns=common_stocks)
adj_ratio = adj_pivot / adj_pivot.iloc[-1]
close = (close_raw * adj_ratio).ffill(limit=5)
high = high_raw * adj_ratio
low = low_raw * adj_ratio
else:
close = close_raw.ffill(limit=5)
high = high_raw
low = low_raw
# 过滤稀疏股票 / Filter sparse stocks
min_count = int(len(close) * 0.4)
valid_stocks = close.columns[close.notna().sum() >= min_count]
close = close[valid_stocks]根据用户输入的因子类型调用对应函数 / Call corresponding function based on user input:
import pandas as pd
import numpy as np
# ── 因子计算函数(自包含,无外部依赖)/ Factor functions (self-contained, no external deps) ──
def momentum(close, period=20):
return close.pct_change(period)
def reversal(close, period=5):
return -close.pct_change(period)
def volatility(close, period=20):
return -(close.pct_change().rolling(period).std() * np.sqrt(252))
def price_volume_divergence(close, volume, period=20):
price_ret = close.pct_change()
vol_ret = volume.pct_change()
result = pd.DataFrame(index=close.index, columns=close.columns, dtype=float)
for col in close.columns:
if col in volume.columns:
result[col] = price_ret[col].rolling(period).corr(vol_ret[col])
return -result
def rsi(close, period=14):
delta = close.diff()
gain = delta.clip(lower=0).rolling(period).mean()
loss = (-delta.clip(upper=0)).rolling(period).mean()
rs = gain / loss
return -(100 - 100 / (1 + rs) - 50)
def macd_divergence(close, fast=12, slow=26, signal=9):
ema_fast = close.ewm(span=fast, adjust=False).mean()
ema_slow = close.ewm(span=slow, adjust=False).mean()
dif = ema_fast - ema_slow
dea = dif.ewm(span=signal, adjust=False).mean()
return (dif - dea) / close
def bollinger_position(close, period=20, std_mult=2):
ma = close.rolling(period).mean()
std = close.rolling(period).std()
upper = ma + std_mult * std
lower = ma - std_mult * std
band_width = (upper - lower).replace(0, np.nan)
return -((close - lower) / band_width * 2 - 1)
def atr_ratio(high, low, close, period=14):
prev_close = close.shift(1)
tr = pd.DataFrame(
np.maximum(np.maximum((high-low).values, (high-prev_close).abs().values), (low-prev_close).abs().values),
index=close.index, columns=close.columns
)
atr = tr.rolling(period).mean()
return -(atr / close.replace(0, np.nan))
def turnover_rate(daily_basic_df, period=20):
df = daily_basic_df[["ts_code","trade_date","turnover_rate_f"]].copy()
df["trade_date"] = pd.to_datetime(df["trade_date"], format="%Y%m%d")
pivot = df.pivot_table(index="trade_date", columns="ts_code", values="turnover_rate_f")
return -pivot.rolling(period).mean()
def abnormal_turnover(daily_basic_df, period_short=5, period_long=60):
df = daily_basic_df[["ts_code","trade_date","turnover_rate_f"]].copy()
df["trade_date"] = pd.to_datetime(df["trade_date"], format="%Y%m%d")
pivot = df.pivot_table(index="trade_date", columns="ts_code", values="turnover_rate_f")
return -(pivot.rolling(period_short).mean() / pivot.rolling(period_long).mean() - 1)
def pe_ttm(daily_basic_df):
df = daily_basic_df[["ts_code","trade_date","pe_ttm"]].copy()
df["trade_date"] = pd.to_datetime(df["trade_date"], format="%Y%m%d")
pivot = df.pivot_table(index="trade_date", columns="ts_code", values="pe_ttm")
return -pivot.where(pivot > 0)
def pb(daily_basic_df):
df = daily_basic_df[["ts_code","trade_date","pb"]].copy()
df["trade_date"] = pd.to_datetime(df["trade_date"], format="%Y%m%d")
pivot = df.pivot_table(index="trade_date", columns="ts_code", values="pb")
return -pivot.where(pivot > 0)
def dividend_yield(daily_basic_df):
df = daily_basic_df[["ts_code","trade_date","dv_ttm"]].copy()
df["trade_date"] = pd.to_datetime(df["trade_date"], format="%Y%m%d")
return df.pivot_table(index="trade_date", columns="ts_code", values="dv_ttm")
# ── 预处理函数 / Preprocessing functions ──
def winsorize_mad(df, n=5):
median = df.median(axis=1)
mad = df.sub(median, axis=0).abs().median(axis=1)
upper = median + n * 1.4826 * mad
lower = median - n * 1.4826 * mad
return df.clip(lower, upper, axis=0)
def zscore_cross_section(df):
return df.sub(df.mean(axis=1), axis=0).div(df.std(axis=1), axis=0)
def standardize(df, mad_n=5):
return zscore_cross_section(winsorize_mad(df, n=mad_n))
# ── 计算因子 / Compute factor ──
factor_values = <因子函数>(close, ...) # 根据因子类型调用 call by factor type
factor_values = standardize(factor_values) # 截面标准化 cross-sectional standardize按上述模式现场编写更多因子 / Write more factors following the pattern above: 对于内置因子映射表中未在上面提供完整实现的因子(如 roe, roa, gross_margin, net_profit_growth 等基本面因子), AI应参考已有因子的实现模式,使用 pandas pivot + rolling 等操作现场编写代码。 For built-in factors not fully implemented above (e.g., roe, roa, gross_margin, net_profit_growth), the AI should write code on-the-fly following the same pattern using pandas pivot + rolling operations.
内置因子映射表 / Built-in Factor Mapping(用户说因子名时参考 reference when user mentions factor name):
momentum(close, 20)reversal(close, 5)volatility(close, 20)price_volume_divergence(close, volume, 20)turnover_rate(daily_basic, 20)abnormal_turnover(daily_basic)rsi(close, 14)macd_divergence(close)bollinger_position(close)atr_ratio(high, low, close)pe_ttm(daily_basic)pb(daily_basic)ps_ttm(daily_basic)dividend_yield(daily_basic)roe(fina)roa(fina)gross_margin(fina)net_profit_growth(fina)revenue_growth(fina)quality_score(fina)value_score(daily_basic)peg(daily_basic, fina)from scipy import stats
def compute_forward_returns(close, periods=5, shift_days=1):
future_close = close.shift(-shift_days - periods + 1)
entry_close = close.shift(-shift_days + 1)
return future_close / entry_close.replace(0, np.nan) - 1.0
def calc_ic_series(factor_values, forward_returns):
"""计算每期截面IC(Spearman秩相关) / Compute per-period cross-sectional IC (Spearman rank corr)"""
ic_values, ic_dates = [], []
common_dates = factor_values.index.intersection(forward_returns.index)
common_stocks = factor_values.columns.intersection(forward_returns.columns)
for date in common_dates:
f = factor_values.loc[date, common_stocks].dropna()
r = forward_returns.loc[date, common_stocks].dropna()
common = f.index.intersection(r.index)
if len(common) < 5:
continue
fv, rv = f[common].values, r[common].values
valid = np.isfinite(fv) & np.isfinite(rv)
if valid.sum() < 5:
continue
corr, _ = stats.spearmanr(fv[valid], rv[valid])
if np.isfinite(corr):
ic_values.append(corr)
ic_dates.append(date)
return pd.Series(ic_values, index=pd.DatetimeIndex(ic_dates), name="IC")
def calc_group_returns(factor_values, forward_returns, n_groups=5):
"""分层回测 / Quintile stratification backtest"""
group_data = {f"G{i+1}": [] for i in range(n_groups)}
valid_dates = []
common_dates = factor_values.index.intersection(forward_returns.index)
common_stocks = factor_values.columns.intersection(forward_returns.columns)
for date in common_dates:
f = factor_values.loc[date, common_stocks].dropna()
r = forward_returns.loc[date, common_stocks].dropna()
common = f.index.intersection(r.index)
if len(common) < n_groups:
continue
f, r = f[common], r[common]
valid = np.isfinite(f) & np.isfinite(r)
f, r = f[valid], r[valid]
if len(f) < n_groups:
continue
try:
labels = pd.qcut(f.rank(method="first"), n_groups, labels=False)
except ValueError:
continue
valid_dates.append(date)
for g in range(n_groups):
mask = labels == g
group_data[f"G{g+1}"].append(r[mask].mean() if mask.sum() > 0 else np.nan)
return pd.DataFrame(group_data, index=pd.DatetimeIndex(valid_dates))
# ── 运行评估 / Run evaluation ──
results = {}
for hp in holding_periods: # [5, 10, 20]
fwd_ret = compute_forward_returns(close, periods=hp)
# 对齐 / Align
cd = factor_values.index.intersection(fwd_ret.index)
cs = factor_values.columns.intersection(fwd_ret.columns)
fv = factor_values.loc[cd, cs]
fr = fwd_ret.loc[cd, cs]
ic_series = calc_ic_series(fv, fr)
group_ret = calc_group_returns(fv, fr, n_groups=5)
ic_mean = ic_series.mean()
icir = ic_series.mean() / ic_series.std() if ic_series.std() > 0 else 0
ic_pos_ratio = (ic_series > 0).mean()
# 多空收益 / Long-short returns
ls_ret = group_ret["G5"] - group_ret["G1"]
ls_cum = (1 + ls_ret).cumprod()
ls_sharpe = ls_ret.mean() / ls_ret.std() * np.sqrt(252 / hp) if ls_ret.std() > 0 else 0
ls_maxdd = ((ls_cum - ls_cum.cummax()) / ls_cum.cummax()).min()
# 单调性 / Monotonicity
group_means = [group_ret[f"G{g+1}"].mean() for g in range(5)]
mono_corr, mono_p = stats.spearmanr(range(5), group_means)
results[hp] = {
"ic_mean": ic_mean, "icir": icir, "ic_pos_ratio": ic_pos_ratio,
"ls_sharpe": ls_sharpe, "ls_maxdd": ls_maxdd,
"monotonic": abs(mono_corr) > 0.8 and mono_p < 0.1,
"mono_corr": mono_corr, "mono_p": mono_p,
"ic_series": ic_series, "group_ret": group_ret,
}import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams["font.sans-serif"] = ["SimHei", "Arial Unicode MS", "DejaVu Sans"]
matplotlib.rcParams["axes.unicode_minus"] = False
best_hp = max(results, key=lambda hp: abs(results[hp]["icir"]))
best = results[best_hp]
# 用matplotlib生成4子图报告 / Generate 4-subplot report with matplotlib:
# 子图1 Subplot1: IC时序图 IC time series (bar chart, color by positive/negative)
# 子图2 Subplot2: 累计IC Cumulative IC (line chart)
# 子图3 Subplot3: 分组累计收益 Quintile cumulative returns (5 lines, G1~G5)
# 子图4 Subplot4: 多空净值 Long-short NAV (line chart with drawdown shading)
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
fig.suptitle(f"Factor Report: {factor_name} (HP={best_hp}d)")
# Plot IC series, cumulative IC, group returns, long-short NAV
# ... (AI writes the specific plotting code based on results dict)
plt.tight_layout()
save_path = os.path.join(OUTPUT_DIR, f"eval_{factor_name}.png")
fig.savefig(save_path, dpi=150, bbox_inches="tight")
plt.close()向用户展示如下格式的结果(使用表格)/ Present results in this format (using tables):
📊 Factor Evaluation Report / 因子评估报告: <factor_name>
Expression 表达式: <factor expression or function call>
┌──────────────────────────────┬─────────────┬──────────────┬──────────────┐
│ Metric 指标 │ 5-day 5日 │ 10-day 10日 │ 20-day 20日 │
├──────────────────────────────┼─────────────┼──────────────┼──────────────┤
│ IC Mean IC均值 │ x.xxx │ x.xxx │ x.xxx │
│ ICIR │ x.xxx │ x.xxx │ x.xxx │
│ IC>0 Ratio IC>0占比 │ xx.x% │ xx.x% │ xx.x% │
│ L/S Sharpe 多空Sharpe │ x.xx │ x.xx │ x.xx │
│ L/S MaxDD 多空MaxDD │ -xx.x% │ -xx.x% │ -xx.x% │
│ Quintile Mono 分组单调 │ ✓/✗ │ ✓/✗ │ ✓/✗ │
└──────────────────────────────┴─────────────┴──────────────┴──────────────┘
Rating 评级: ⭐ Strong / ● Moderate / · Weak
Best Holding Period 最佳持有期: xx days/日
Quintile Monotonicity 分组单调性: Spearman=x.xx, p=x.xx
Report chart saved / 报告图表已保存: output/eval_<name>.png评级标准 Rating Criteria(从配置读取 read from config):
评估完成后询问用户 / After evaluation, ask the user:
/opt/anaconda3/bin/python 执行 / All Python code runs with /opt/anaconda3/bin/python© VernonOY, Apache-2.0. 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 skills/alpha-evaluate of VernonOY/alpha-skills.
Open the folder on GitHubat commit f58f80a
Alpha Evaluate 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 |
|---|---|---|---|---|---|---|
| Alpha Evaluate this skillVernonOY/alpha-skills | 117 | — | ~5.7k | Automated safety check: Pass | Apache-2.0 | |
| Tushare Datazillionare/zillionare | 321 | 2 repos | ~2.3k | Automated safety check: Pass | None | |
| Tradingview MCPatilaahmettaner/tradingview-mcp | 5k | — | ~1.3k | Automated safety check: Pass | MIT | |
| Digital Oraclekomako-workshop/digital-oracle | 875 | — | ~5.9k | Automated safety check: Pass | MIT | |
| Polyclawchainstacklabs/polyclaw | 359 | 1 repos | ~2k | Automated safety check: Pass | Apache-2.0 | |
| Markdownfacioquo/stock-indicators-dotnet | 1.2k | — | ~812 | Automated safety check: Pass | Apache-2.0 |
zillionare/zillionare
面向中文自然语言的 Tushare 数据研究技能。用于把“看看这只股票最近怎么样”“帮我查财报趋势”“最近哪个板块最强”“北向资金在买什么”“给我导出一份行情数据”这类请求,转成可执行的数据获取、清洗、对比、筛选、导出与简要分析流程。适用于 A 股、指数、ETF/基金、财务、估值、资金流、公告新闻、板块概念与宏观数据等研究场景。
atilaahmettaner/tradingview-mcp
AI Trading Intelligence — live prices, 30+ technical indicators, backtesting (6 strategies), walk-forward overfitting detection, trade logs, equity curves, licensed news sentiment (Marketaux), and…
komako-workshop/digital-oracle
Answer prediction questions using market trading data, not opinions.
chainstacklabs/polyclaw
Trade on Polymarket via split + CLOB execution. An agent skill from chainstacklabs/polyclaw.
facioquo/stock-indicators-dotnet
Format and lint Markdown in this repository against GitHub Flavored Markdown and its markdownlint-cli2 configuration — headers, lists, code fences, callouts (VitePress containers on docs-site pages…
MobiusQuant/OpenMobius-skill
Provides multi-school trading Q&A, chart/OHLCV analysis, annotation, and fresh-market workflows covering ICT/SMC, ChanLun, Wyckoff, Price Action, Order Flow, VSA, and Elliott Wave.
VernonOY/alpha-skills
Autonomous factor research loop. An agent skill from VernonOY/alpha-skills.
VernonOY/alpha-skills
Strategy backtest. An agent skill from VernonOY/alpha-skills.
VernonOY/alpha-skills
Factor discovery. An agent skill from VernonOY/alpha-skills.
VernonOY/alpha-skills
Factor library management. An agent skill from VernonOY/alpha-skills.
VernonOY/alpha-skills
Automated factor mining. An agent skill from VernonOY/alpha-skills.
VernonOY/alpha-skills
Factor monitoring. An agent skill from VernonOY/alpha-skills.
Categories
Factor evaluation. An agent skill from VernonOY/alpha-skills. Alpha Evaluate is an agent skill from VernonOY/alpha-skills. Factor evaluation.
Alpha Evaluate fits situations like: tasks that involve Trading and backtesting.
Run `npx skills add VernonOY/alpha-skills --skill alpha-evaluate -a claude-code`. Or copy the skill folder (skills/alpha-evaluate in VernonOY/alpha-skills) into .claude/skills/alpha-evaluate in your project. Claude Code loads it when a task matches its description.
Run `npx skills add VernonOY/alpha-skills --skill alpha-evaluate -a codex`. Or copy the skill folder (skills/alpha-evaluate in VernonOY/alpha-skills) into .agents/skills/alpha-evaluate 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 VernonOY/alpha-skills --skill alpha-evaluate -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/alpha-evaluate, .gemini/skills/alpha-evaluate, .github/skills/alpha-evaluate and .opencode/skills/alpha-evaluate in your project.
Going by SKILL.md and its folder, Alpha Evaluate needs the command-line tools its instructions call (pip). Our summary lists: Python 3.
SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. 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.
Alpha Evaluate is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 5.7k tokens (SKILL.md is roughly 23k 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 Alpha Evaluate: Tushare Data (zillionare/zillionare, 321 stars), Tradingview MCP (atilaahmettaner/tradingview-mcp, 5k stars), Digital Oracle (komako-workshop/digital-oracle, 875 stars) and Polyclaw (chainstacklabs/polyclaw, 359 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
VernonOY (a GitHub user) maintains it in VernonOY/alpha-skills, which has 117 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on April 14, 2026.
Source: VernonOY/alpha-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.