CANSLIM scoring for Chinese A-shares, as an agent skill. A seven-factor scorecard and Excel report from six-digit stock codes, pulling live data from public endpoints with no API key.
按欧奈尔《笑傲股市》逐字母校准的 CANSLIM,落成本地可跑的 A股引擎。给一串代码 → 七要素打分卡 + Excel 报表 + 产业链批量快筛。
npx skills add micaho26/canslimDecision support, not a trading signal. Meeting X/4 is a screening starting point. See Disclaimer.
$ python3 scripts/canslim_cn.py 688017
======================================================================
A股 CANSLIM v2 · 东财财务+新浪K线+腾讯行情+东财F10机构 · 2026-08-02 08:35
M 大盘闸门: 🚦🔴 防守(300在50/200日线下) 近25日派发日: 6
======================================================================
■ 绿的谐波(688017) 现价303.65 PE407 PB15.8 总市值557亿(大盘) 股本1.83亿股
达标 2/4 (C·A·S·L) │ 2/4·强[C,L]弱[A,S]·A反转型
C 当季 🟢强 扣非+41.6%(=0.23亿) 营收+43.0%(=1.4亿) │ 趋势 减速↓ +25→+44→+115→+42
C辅助 🟡基本匹配 CFPS0.83/EPS0.69 溢价+20%
A 年度 🟡一般 净利+121.4%(=1.24亿) ROE3.57% │ 三年-46→-33→+121 [反转型]
S 需求 🟡平量 量能×1.0 │ 近10日吸0/派0
L 强度 🟢领先 6月超额+46.3% │ RS线否
I 机构 🟡中性 基金50只(ETF占59%) 机构持股7.09% 户数环比+6.2%
Note what that output does not do: it does not tell you to buy. It says C and L are strong, A is a turnaround so the foundation is weaker, C is decelerating despite still being +42%, and the market gate is red with 6 distribution days. That is a shortlist entry with three caveats attached — which is the point.
| Letter | Measures | Source | Green when |
|---|---|---|---|
| C | Current quarter non-recurring net profit YoY | Eastmoney KCFJCXSYJLRTZ |
≥ 25% |
| C(aux) | Cash flow per share vs EPS | Eastmoney MGJYXJJE ÷ EPSJB |
CFPS ≥ EPS × 1.2 |
| A | Annual net profit YoY + ROE | Eastmoney PARENTNETPROFITTZ, ROEJQ |
≥25% and ROE ≥15% |
| N | New product / management / industry | — | excluded from auto-scoring — qualitative |
| S | Volume ratio, last 20d vs prior 60d | Sina daily K-line | ≥ 1.2 |
| L | 6-month excess return vs CSI 300 | Sina daily K-line | ≥ 20% |
| I | Fund count, ETF share, institutional %, holder change | Eastmoney F10 | supporting only |
| M | CSI 300 vs MA50/MA200 + distribution days | Sina daily K-line | gate, not scored |
X/4 counts C·A·S·L only. Three deliberate design choices:
N is excluded. "New" is the fuel in CANSLIM and often the source of C and A — but it is irreducibly qualitative. A script that scored it would be inventing a number. It stays a human judgement, with pivot-entry discipline (breakout on volume, buy within 5% of the pivot) as the accompanying rule.
M is a gate, not a component. Roughly three quarters of stocks follow the index. A name scoring 6/6 still falls in a red market. So M does not add to the score — it tells you whether to act on the score at all.
CFPS is an EPS lie-detector. Accounting profit can be dressed up; operating cash flow is harder to fake. A growth name should show CFPS at least 20% above EPS. When it does not, the earnings quality is in question — the same concern as "one-off gains propping up EPS", made measurable.
Full definitions, thresholds, and an explicit table of where this engine falls short of textbook CANSLIM are in references/framework.md.
npx skills add micaho26/canslimWorks with Claude Code, Cursor, Codex, Copilot, Windsurf, Gemini CLI, Cline and others. The agent then knows how to run the engine and — more importantly — how to read the output, because references/framework.md tells it what each threshold means and what it cannot conclude.
git clone https://github.com/micaho26/canslim && cd canslim
pip install -r requirements.txt # openpyxl, only needed for Excel output
python3 scripts/canslim_cn.py 688017 300124 002472No API key, no account, no paid data feed.
# Console scorecard
python3 scripts/canslim_cn.py 688017 300124 002472
# Excel report, 46 columns including institutional ownership
python3 scripts/build_canslim_report.py 688017 300124 002472
# Batch screen — --fast skips the heaviest endpoint, --out splits per category
python3 scripts/build_canslim_report.py --fast --out 减速器 688017 002472 002896 603915
# Robotics supply chain: 34 names, 8 categories, one sheet
python3 scripts/run_robot_scan.py
# Consumer sector with a market-cap floor
python3 scripts/run_consumer_scan.py --min-cap 50 --limit 80
# Pull annual/quarterly report PDFs from cninfo
python3 scripts/fetch_reports.py --kind 年报 一季报 002946Codes are six digits — Shanghai 6…, Shenzhen 0…/3…. Hong Kong, US and unlisted names are not supported.
Rate limits: the engine paces itself (0.4s per name, 3s every 40). Use --fast for large batches and keep runs to ≤50 names. A throttled field returns ⚪ — that means not retrieved, not zero. Re-run those codes in a few minutes.
canslim/
├── SKILL.md the agent-facing skill definition
├── references/
│ └── framework.md the calibrated model — read this to interpret output
├── scripts/
│ ├── canslim_cn.py the engine — stdlib only, shells out to curl
│ ├── build_canslim_report.py Excel report generation
│ ├── run_robot_scan.py robotics supply-chain screen
│ ├── run_consumer_scan.py consumer sector screen
│ └── fetch_reports.py filing PDFs from cninfo
├── templates/
│ ├── positions.md blank — your holdings, never committed
│ └── investment-plan.md blank — your strategy, never committed
└── tests/
└── test_engine.py offline structural tests
templates/positions.md and templates/investment-plan.md ship blank. No holdings, no account values, no personal strategy is in this repository — and .gitignore excludes filled copies, generated .xlsx, logs and the fetch cache, so they cannot be committed by accident.
The engine talks only to public market-data endpoints (Eastmoney, Sina Finance, Tencent Quotes, cninfo). It sends no telemetry and stores nothing about you.
python3 -m unittest discover tests -vThe tests are deliberately offline — they check scoring thresholds, code validation, and output structure against fixtures rather than hitting live endpoints, so they pass on a plane and cannot fail because a data provider is throttling.
This is not investment advice. It is a screening tool that computes public financial ratios and formats them.
Meeting X/4 is a starting point for research, never a buy signal. The engine explicitly cannot judge entry points, base formation, sector leadership, follow-through days, or fund-manager quality — the parts of CANSLIM that most determine whether a trade works. Those need the framework document and your own judgement.
Data comes from free public endpoints and may be delayed, throttled, or wrong. Verify anything you act on against the primary filing. You are responsible for your own decisions and your own losses.
The methodology is William J. O'Neil's, from How to Make Money in Stocks. This repository is an A-share adaptation of it — the calibration notes in references/framework.md mark exactly where the adaptation departs from the original, and why.
MIT.