Agent Skills › qusong0627/QuantMind › smart-strategy-stock-picking

smart-strategy-stock-picking

GitHub

基于QuantDB数据,通过自然语言、结构化条件或DSL进行智能选股,构建股票池并输出量化指标。

skills/smart-strategy-stock-picking/SKILL.md qusong0627/QuantMind

Trigger Scenarios

筛选股票 股票池 条件选股 智能策略 按条件选股 自然语言选股 帮我选出

Install

npx skills add qusong0627/QuantMind --skill smart-strategy-stock-picking -g -y
More Options

Use without installing

npx skills use qusong0627/QuantMind@smart-strategy-stock-picking

指定 Agent (Claude Code)

npx skills add qusong0627/QuantMind --skill smart-strategy-stock-picking -a claude-code -g -y

安装 repo 全部 skill

npx skills add qusong0627/QuantMind --all -g -y

预览 repo 内 skill

npx skills add qusong0627/QuantMind --list

SKILL.md

Frontmatter
{
    "name": "smart-strategy-stock-picking",
    "description": "智能策略选股 — 基于 QuantDB 数据的条件选股。在 QuantBot \/ Claude Code 中按自然语言或条件筛选股票、构建股票池、生成策略时使用。触发词:筛选股票、股票池、条件选股、智能策略、按条件选股、自然语言选股、帮我选出"
}

⚙️ 本技能遵循公共运行环境契约(最高优先级,先于本文其余内容执行): 详见 _shared/env-contract.md,执行前先读它。

智能策略选股技能

基于 QuantDB 数据的条件选股。支持自然语言、结构化条件、DSL 三种方式,选出符合要求的股票池并附带量化指标。

数据基础

选股完全基于 QuantDB 本地 parquet。字段映射以后端字典为准:backend/services/engine/ai_strategy/steps/step1_stock_selection.py(DSL 字段 → QuantDB 表/列),覆盖以下数据源:

QuantDB 数据源 字段 覆盖
l1_factors 66 动量/流动性/概念热度/资金流
technical_indicators 24 均线/RSI/KDJ/MACD/波动率
financial 20 财务指标
valuation 15 PE/PB/市值/ROE
sentiment 14 市场情绪
margin 10 融资融券
stock_list 6 行业/ST/上市天数
daily/turnover 3 量价

认证

BASE=http://127.0.0.1:8000
TOKEN=$(curl -s -X POST $BASE/api/v1/auth/login -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123","tenant_id":"default"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin).get('access_token',''))")
AUTH="Authorization: Bearer $TOKEN"
CT="Content-Type: application/json"

1. 常用选股因子(前 30 高频字段)

字段 含义 单位
market_cap / total_mv 总市值 亿
float_mv 流通市值 亿
pe / pe_ttm 市盈率 —
pb 市净率 —
roe 净资产收益率 %
close 收盘价 元
pct_change 当日涨跌幅 %
turnover_rate 换手率 %
ma5 / ma10 / ma20 / ma60 均线 元
ma_gap_5 / ma_gap_20 均线偏离度 %
rsi_6 / rsi_14 RSI —
kdj_k / kdj_d / kdj_j KDJ —
macd_dif / macd_dea / macd_hist MACD —
future_return_1d / future_return_3d / future_return_5d / future_return_20d / future_return_60d 未来 N 日收益(标签,勿作过滤) %
vol_std_5 / vol_std_20 / vol_std_60 波动率 %
vol_atr_14 14日ATR —
beta_20 20日Beta —
volume_ratio_5 / volume_ratio_20 量比 —
main_flow 主力资金净流入 元
flow_net_amount 资金净流入总额 万元(2026-09 起;读入归一为元)
inst_ownership 机构持仓 %
concept_ai / concept_chip 等 概念热度 —
industry 行业 —
is_st 是否ST —
listed_days 上市天数 天

完整字段清单与映射以后端字段字典为准(backend/services/engine/ai_strategy/steps/step1_stock_selection.py + api/schemas/stock_pool.py)。⚠️ 前端 electron/src/features/strategy-wizard/factors/dictionary.ts 已移除,勿再引用。

2. 方式一:自然语言解析(推荐给用户用)

# 解析自然语言为 DSL(内部:可先用此步确认字段能否被识别)
curl -s -X POST "$BASE/api/v1/strategy/parse-text" -H "$AUTH" -H "$CT" \
  -d '{"text":"市值大于500亿且ROE大于15%的沪深300成分股,剔除ST"}' \
  -o /tmp/pt.json -w "HTTP %{http_code}\n"
cat /tmp/pt.json | python3 -m json.tool --no-ensure-ascii | head -30

3. 方式二:结构化条件解析(最可控)

curl -s -X POST "$BASE/api/v1/strategy/parse-conditions" -H "$AUTH" -H "$CT" \
  -d '{"conditions":{"type":"numeric","factor":"pe","operator":"<","threshold":15}}' \
  -o /tmp/pc.json -w "HTTP %{http_code}\n"
cat /tmp/pc.json | python3 -m json.tool --no-ensure-ascii

条件结构:

  • 数值条件:{"type":"numeric","factor":"pe","operator":"<|<=|>|>=|=","threshold":15}
  • 趋势条件:{"type":"trend","factor":"ma5","window":5,"direction":"above|below"}
  • 复合条件:{"type":"composite","op":"and|or","children":[...]}(可嵌套)

返回:dsl(如 SELECT symbol WHERE pe < 15)+ mapping + quantdb_filters(如 [{field:"pe_ttm", operator:"<", value:15, table:"quantdb_valuation"}])

4. 方式三:DSL 直接查询(执行选股)

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE pe < 15 AND roe > 10","market":"CN","exchange":"SH"}'

参数:

  • dsl:SELECT symbol WHERE 条件 [AND/OR 条件...](字段用上面的因子名)
  • market:CN / HK / US / CRYPTO
  • exchange:SH / SZ / BJ(仅 A 股)

返回:items(每只股票 symbol/name/metrics,metrics 含市值/PE/ROE 等)+ summary(matchRate/totalCandidates/universeTotal/asOf)

5. 实战示例(可直接复用)

5.1 低估值蓝筹(PE<15 且 市值>500亿)

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE pe < 15 AND market_cap > 500 AND roe > 10","market":"CN"}'

5.2 动量强势(过去 20 日收益>10% 且 RSI>60)

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE mom_ret_20d > 0.10 AND rsi_14 > 60 AND turnover_rate < 20","market":"CN"}'

勿用 future_return_*(旧名 return_*)做选股过滤——那是未来收益标签,会造成泄漏。

5.3 高波动小盘(波动大 + 市值小)

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE vol_std_20 > 5 AND market_cap < 100 AND pct_change > 0","market":"CN"}'

5.4 资金流入 + 概念热门(AI/半导体)

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE main_flow > 10000000 AND concept_ai > 0.5","market":"CN"}'

5.5 剔除 ST + 特定行业 + 换手活跃

curl -s -X POST "$BASE/api/v1/strategy/query-pool" -H "$AUTH" -H "$CT" \
  -d '{"dsl":"SELECT symbol WHERE is_st = false AND industry = 半导体 AND turnover_rate BETWEEN 3 AND 15","market":"CN"}'

6. 分析建议

选出的股票池可结合其他技能深入分析:

  • 查新闻:/news/articles 带 tickers 看利好/利空 → [[quantmind-operations]] 第 7 节
  • 查推理分数:/models/inference/stock/{symbol}/history 看模型评分
  • 挖新因子:[[rd-agent-factor-mining]] 补充更多筛选维度
  • 训练模型:选出的池子可喂给模型训练 → [[quantmind-operations]] 第 1 节

7. 常见问题

现象 原因 处理
422 字段不匹配 DSL 用了映射表外字段 用上面的常用因子名,或查后端字典 step1_stock_selection.py
选股结果为空 条件过严 放宽阈值,或去掉 AND 条件
summary.matchRate 极低 条件偏窄 检查 totalCandidates 是否正常
想要全市场 dsl 用 SELECT symbol WHERE true 返回全部候选

Version History

  • 69bf990 Current 2026-09-22 00:24

    移除环境契约细节,简化为引用公共契约;更新字段说明,强调资金流单位归一及后端字典为准。

  • 2b47c67 2026-09-02 21:03

Same Skill Collection

skills/ai-ide-strategy-writing/SKILL.md
skills/backtest-center/SKILL.md
skills/batch-inference-analysis/SKILL.md
skills/daily-review/SKILL.md
skills/install-futu-opend/SKILL.md
skills/market-analysis/SKILL.md
skills/model-train-infer-backtest-report/SKILL.md
skills/news-sentiment-finbert/SKILL.md
skills/news-sentiment-research/SKILL.md
skills/quantdb-data-structure/SKILL.md
skills/quantdb-fields/SKILL.md
skills/quantdb-sdk/SKILL.md
skills/quantmind-deploy/SKILL.md
skills/quantmind-operations/SKILL.md
skills/rd-agent-factor-mining/SKILL.md
skills/simulation-trading/SKILL.md
skills/stock-market-analysis/SKILL.md
skills/stock-picks/SKILL.md
skills/stock-research/SKILL.md
skills/tdx-live-trading/SKILL.md
skills/trading-agents/SKILL.md
skills/futuapi/SKILL.md
skills/ibkr-cli/SKILL.md
skills/tigeropen-cpp/SKILL.md
skills/tigeropen-csharp/SKILL.md
skills/tigeropen-go/SKILL.md
skills/tigeropen-java/SKILL.md
skills/tigeropen-rust/SKILL.md
skills/tigeropen-typescript/SKILL.md
skills/tigeropen/SKILL.md

Metadata

Files
0
Version
69bf990
Hash
e53dec23
Indexed
2026-09-02 21:03

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-27 00:45
浙ICP备14020137号-1