A share factor library

From aifinlab/FinClaw · View interactive version

A share factor library is an AI agent skill from the GitHub repository aifinlab/FinClaw. A股量化因子库/因子速查/因子计算公式查询。当用户说"因子库"、"有哪些因子"、"factor library"、"怎么算XX因子"、"价值因子"、"动量因子"、"质量因子"、"波动率因子"、"因子定义"、"因子公式"、"查因子"、"因子速查"、"列出所有因子"、"EP怎么算"、"BP公式"、"因子字段"时触发。MUST USE when user asks for factor definitions, formulas, or wants to look up how a specific quantitative factor is calculated. 提供A股常用量化因子的完整定义

How to use this skill

Skill file

A股常用因子库速查 (a-share-factor-library)

核心能力

数据来源

CLI 用法

SCRIPTS_DIR="$SKILLS_ROOT/a-share-factor-library/scripts"
CN_STOCK="$SKILLS_ROOT/cn-stock-data/scripts"

# 计算单个因子
python "$SCRIPTS_DIR/factor_calculator.py" --factor ep --codes SH600519,SZ000858

# 动量因子
python "$SCRIPTS_DIR/factor_calculator.py" --factor momentum_6m --codes SH600519

# 批量计算一类因子
python "$SCRIPTS_DIR/factor_calculator.py" --category value --codes SH600519,SZ000858

# 列出所有因子
python "$SCRIPTS_DIR/factor_calculator.py" --list

# 查看某个因子定义
python "$SCRIPTS_DIR/factor_calculator.py" --info ep

因子参考目录

详见 references/factor-library-catalog.md,包含全部 7 大类因子的:

Workflow (5 steps)

Step 1: 识别因子类别

根据用户请求判断:

Step 2: 查找因子定义与公式

从 references/factor-library-catalog.md 查找:

Step 3: 映射到 cn-stock-data 字段

将因子公式中的变量映射到实际数据接口:

Step 4: 计算因子值

调用 scripts/factor_calculator.py 或手动计算:

python "$SCRIPTS_DIR/factor_calculator.py" --factor <factor_name> --codes <code1,code2,...>

Step 5: 输出因子卡片

formal(研报风格):

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
因子名称: EP(盈利收益率)
英文全称: Earnings-to-Price Ratio
类别: 价值因子 | 方向: 正向(越大越便宜)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
公式: EP = EPS_TTM / Price = 1 / PE_TTM
数据源: cn-stock-data quote → pe_ttm
适用行业: 全行业(金融/周期股慎用)

计算结果:
| 股票 | EPS_TTM | Price | EP | 排名 |
|------|---------|-------|----|------|
| 贵州茅台 | 66.3 | 1895.5 | 0.035 | 1 |
| 五粮液 | 7.2 | 168.0 | 0.043 | 2 |

因子解读:
EP 值越大说明股票越"便宜",是经典价值因子。
建议与 BP、CFP 等因子组合使用,避免单一因子陷阱。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

brief(快速查询风格):

EP = 1/PE_TTM | 方向:正 | 数据:quote.pe_ttm
SH600519: EP=0.035 | SZ000858: EP=0.043

注意事项

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.