cn-stock-factor

A multi-factor stock-selection solution for A-shares (CSI 300), based solely on the westock-mcp data source. Implements 20 factors spanning value, size, momentum, volatility, sentiment, quality, growth, and technical categories for multi-factor research and stock screening.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "cn-stock-factor" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ed2b66ba7a6ff650db83e38770e999d7cf421a0c8bf9f5ae3c2896e840bd5e66. Verify the upstream source and version against https://skillhub.cn/skills/user_ecbd3b70/cn-stock-factor before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

A multi-factor stock-selection solution for A-shares (CSI 300), based solely on the westock-mcp data source. Implements 20 factors spanning value, size, momentum, volatility, sentiment, quality, growth, and technical categories for multi-factor research and stock screening.

0 Downloads

Introduction source: third_party · user_ecbd3b70 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: cn-stock-factor
description: A股(沪深300)多因子选股, 纯 westock-mcp 数据源. 20 因子(价值/规模/动量/波动/情绪/质量/成长/技术),
  截面 z-score 合成, 月度调仓回测. 不依赖通达信/mcporter/QClaw.

cn-stock-factor (A股 多因子选股, westock-native)

数据源

westock-mcp (腾讯自选股, WorkBuddy 原生连接器), 全部通过 DeferExecuteTool 调用, 支持 codes 批量:

  • data_kline(codes, period=day, fq=qfq, limit=520) → K线
  • data_quote(codes) → 估值/规模/52周/短期涨跌快照
  • data_finance(codes, type=income|balance, num=5) → 利润表/资产负债表(多期)
  • data_fund_flow(codes) → 主力/散户资金流快照
  • 基准: data_kline(code=sh000300, ...) 沪深300 指数

westock 是平台托管 MCP, Python 无法 spawn; 批量靠 AI 用 codes 一次多只调用, 大响应自动落盘, land.py 离线解析. 彻底不用 mcporter/QClaw.

目录

config/universe.csv      沪深300 标的 (ticker 纯6位)
scripts/land.py          原始 JSON -> 面板 (写入 sqlite data/stock.db, parquet 仅兼容备份)
scripts/calc_factors.py  20 因子 + 合成 composite (读 sqlite)
scripts/backtest.py      月度调仓回测 (读 sqlite)
scripts/report.py        选股 HTML+CSV 报告; 按收盘日命名 report/cn_factor_top{N}_{date}.html/.csv (不覆盖), 另写 report/cn_report.html (最新别名)
scripts/run_all.py       编排: land -> calc -> backtest -> report (全读/写 sqlite)
scripts/migrate_to_sqlite.py  一次性: 把历史 parquet 灌入 data/stock.db (首次迁移用)
scripts/fetch.py         (AI 用) 打印批次取数计划
scripts/save_raw.py      (AI 用) 存原始响应到 data/raw
data/raw/*.json          AI 取数落盘
data/stock.db            ★主库 (sqlite): price/spot_all/financial/fund_flow/benchmark/factor_panel
data/cache/*.parquet     面板 (兼容备份, 非主读路径)
data/factors/*.parquet   因子面板 + 回测 (兼容备份)

存储已迁移到 sqlite: 时间序列表(price/financial/benchmark/factor_panel)用 INSERT OR REPLACE 增量 upsert; 快照表(spot_all/fund_flow)无时间维, 每次补数据全量覆盖. parquet 仍写但仅作备份.

因子 (20, 方向高好+ / 低好-)

价值 ep+(1/pe) bp+(1/pb) div_yield+ ; 规模 ln_mv+ ; 动量 mom1m/mom3m/mom12m+ ; 波动 vol60- ; 情绪 turn60- main_net_flow+ main_net_flow_20d+ retail_net_flow+ main_inflow_circ_rate+ ; 质量 gpm+ op_margin+ roe+(np_ttm/equity) lev- ; 成长 revg+(营收YoY) npg+(净利YoY) ; 技术 pos_52w+(52周位置). composite = 各因子截面 z 的带符号均值.

工作流

默认动作 = 直接用现有数据算因子/回测/报告 (跳过取数). 拉取/刷新数据是选做——仅当用户明确说"补全数据/刷新/更新/拉最新/补数"时才先去取数; 否则直接进步骤 2, 跑 land→calc→backtest→report (用 data/stock.db 已有数据, 不浪费 token/限频).

  1. 补数据 (选做, 仅当用户明确要求时):
    • 触发条件: 用户说"补全/刷新/更新/拉最新数据" 或 本地 data/stock.db 不存在/空库(首次运行). 否则跳过此步, 直接进步骤 2.
    • 首次(本地无 data/stock.db 或空库): python migrate_to_sqlite.py 灌历史 parquet; 然后全量取数.
    • 日常补数: python fetch.py --kind kline 拿批次, AI 逐批 DeferExecuteTool 取 data_kline(codes=<批>, start=<末日+1>, end=today, limit=10) 并 save_raw 落盘; 同理 quote/fin_inc/fin_bal/fund/benchmark.
    • A股 300 只增量一次性可拉: data_kline(codes=<全部300以逗号连接>, start=<末日+1>, end=today, limit=10) 单批即可(已实测 successCount=300/errorCount=0, 每票3天). 价/财/资金为轻端点, 限频规避见下.
    • 限频安全模式(实测稳定): 第一轮 kline+finance 并发, 第二轮 quote+fund_flow 并发, 每轮≤2 并发; 每批 15~20 只.
    • 落盘后: python run_all.py 内的 land.py 会自动把 raw JSON upsert 进 sqlite (时间序列增量, 快照全量覆盖).
  2. 算因子+回测+报告: python run_all.py --top-pct 0.1 → 依次 land→calc→backtest→report, 末端自动生成报告. (land 解析 raw→sqlite; calc/backtest/report 全读 sqlite.)
  3. 选股结果: data/stock.db 表 factor_panel (含 composite); 回测: data/factors/backtest.csv; 报告输出(按行情收盘日命名, 不同日期互不覆盖):
    • report/cn_factor_top{N}_{date}.html — 净值曲线+KPI卡+最新选股因子表 (与 us/hk 风格对齐)
    • report/cn_factor_top{N}_{date}.csv — 选股明细 (UTF-8-sig, 列: 排名/代码/名称/综合分/各因子z/基准日), Excel 中文不乱码
    • report/cn_report.html — 最新一次运行的别名(每次覆盖), 便于快速打开
    • {date} = factor_panel 最新截面日期(即取数收盘日), {N} = 当次选股只数 (Top 10%≈29).

已知近似

估值/规模/质量/成长/资金流为最新快照因子 (westock quote/finance 仅给最新值), 在时间序列上恒为最新快照; 动量/波动/换手/52w 为真实时间序列. 回测据此评估, 不随时间重算估值.

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供专业的A股沪深300多因子选股功能,面向量化投资用户
  • 支持20个因子(价值/规模/动量/波动/情绪/质量/成长/技术)的截面z-score合成
  • 采用月度调仓回测机制,具有实际投资指导价值
Trigger Precision65/100

Areas to improve

  • 触发词描述不够具体 Reported severity: Minor

    description中描述了功能但未提供具体的触发词示例,用户可能不清楚如何准确触发该Skill

    Recommendation: 建议在文档中补充具体的触发词示例,如'多因子选股'、'A股选股'、'沪深300因子分析'等

Highlights

  • 功能描述清晰,明确指出是A股沪深300多因子选股工具
Structure and Standards88/100

Highlights

  • 文档结构完整,包含数据源、目录结构、因子定义、工作流等关键信息
  • 提供了详细的工作流程说明,包括数据获取、因子计算、回测和报告生成
  • 输出结果命名规范,按日期区分避免覆盖,便于用户管理
Execution Reliability85/100

Highlights

  • 工具来源明确,全部使用westock-mcp原生连接器
  • 提供了限频安全模式,确保API调用稳定可靠
  • 数据存储采用sqlite主库+parquet备份的双重机制,可靠性高
  • 支持增量更新和全量覆盖两种数据更新模式
Evidence Verifiability (mean of the first four)81/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.