| name | stock_chan_theory_analysis |
| description | Use this standalone stock strategy skill for 缠论 (chan_theory) analysis. Accept one or more A-share stock codes, Chinese stock names, US stock tickers, or Hong Kong stock codes, collect market/news data, and produce a Codex-readable Markdown report focused on the 缠论 strategy. Source strategy: ~/daily_stock_analysis/strategies/chan_theory.yaml. |
缠论 Stock Analysis Skill
This skill is a strategy-specific variant of stock_ai_analysis. It uses the same bundled analyzer structure. User config, generated prompts, reports, and final reports for this strategy live under:
~/.stock_analysis/chan_theory/
Downloaded market-data caches are shared across strategies under ~/.stock_analysis/cache/ so users do not need to fetch the same data repeatedly.
Strategy Source
- Source file:
~/daily_stock_analysis/strategies/chan_theory.yaml
- Strategy id:
chan_theory
- Display name: 缠论
- Category: framework
- Aliases: 缠论, 缠论分析
- Required source tools: get_daily_history, analyze_trend, get_realtime_quote
- Summary: 基于缠论笔、线段、中枢结构,判断趋势级别、买卖点与背驰信号。
Workflow
- Work only inside this skill directory. Do not import, inspect, or depend on files outside it during normal analysis.
- The script creates and reads user config at
~/.stock_analysis/chan_theory/.env. Always run config check first:
python scripts/analyze.py --check-config
- First-run hard rule: if
--check-config shows CONFIG_CREATED: yes, explicitly tell the user initialization config is required before any analysis. Do not run --stocks in the same turn.
- Incomplete-config hard rule: if required capability keys are missing for the user request, stop and ask the user to complete configuration using
references/configuration.md before running analysis. Never run partial/incomplete analysis.
- Ask for stock codes, names, or tickers if not supplied. Accept
600487, 北方华创, AAPL, 00700.HK, or mixed input like 北方华创,600487,AAPL,00700.HK.
- Only after configuration is complete, run analysis:
python scripts/analyze.py --stocks <codes>
Use --no-llm for data-only smoke runs.
Use --send-email only after the user confirms email delivery.
Use --no-email for validation runs when EMAIL_ENABLED=true.
- Open the latest prompt files under
~/.stock_analysis/chan_theory/prompts/, use the current Codex agent to generate the final analysis, and write that analysis to a Markdown file under ~/.stock_analysis/chan_theory/final_reports/.
- The final analysis must apply the strategy rules below. Do not return a generic stock report when this skill is invoked.
- Send email only from a finalized current-agent report:
python scripts/analyze.py --send-final-report ~/.stock_analysis/chan_theory/final_reports/<report>.md
If a generated base report exists, merge the final analysis back into the original report before sending:
python scripts/analyze.py --send-final-report ~/.stock_analysis/chan_theory/final_reports/<report>.md --base-report ~/.stock_analysis/chan_theory/reports/<base_report>.md
Strategy Rules
缠论(Chan Theory / Zen Channel Theory)
核心框架:分型 → 笔 → 线段 → 中枢 → 趋势
分析步骤
1. 判断价格结构(中枢识别)
- 使用
get_daily_history 获取近 60 日日线数据。
- 识别近期价格的高低点序列,判断当前是否在
震荡中枢(1个以上中枢)还是趋势段(脱离中枢向上/向下)。
- 中枢:连续3段走势重叠区间,价格在此区间反复震荡。
- 趋势:连续3个同级别中枢均向同一方向移动。
2. 背驰判断(最高优先级信号)
- 顶背驰:价格创新高但MACD红柱面积缩小 → 卖出/减仓信号。
- 底背驰:价格创新低但MACD绿柱面积缩小 → 买入/加仓信号。
- 使用
analyze_trend 获取 MACD 数据,与价格高低点对比。
3. 买卖点判定
- 一买(最强):下跌趋势中,最后一个中枢出现底背驰。
- 二买:离开下跌中枢后的第一次回调不破中枢高点。
- 三买:中枢震荡后向上突破(不回中枢内)。
- 一卖/二卖/三卖:对称结构,方向相反。
- 当前价格所处的买卖点级别决定仓位大小。
4. 级别与仓位
- 日线级别买卖点可用较重仓位 (30-50%)。
- 周线级别买卖点可用较大仓位 (50-80%)。
- 多级别共振(日线+周线同方向)时信号最强。
5. 输出要求
- 明确说明当前处于:上涨趋势/下跌趋势/中枢震荡。
- 指出是否存在背驰信号及背驰级别。
- 给出当前买卖点类型(一买/二买/三买 等),若无则写"暂无明确买卖点"。
- 止损设于前低(买入时)或前高(卖出时)。
评分调整建议:
- 底背驰 + 一买信号:
sentiment_score +15
- 二买/三买共振:
sentiment_score +10
- 中枢震荡无明确方向:
sentiment_score 维持基准
- 顶背驰 / 趋势向下:
sentiment_score -15
Guardrails
- Never print real API keys, passwords, webhook URLs, or tokens.
- Ask before overwriting an existing
~/.stock_analysis/chan_theory/.env value.
- Ask before sending email. Do not enable
EMAIL_ENABLED=true unless the user explicitly wants automatic delivery.
- Do not block the user on optional keys. Offer a skip path and explain the consequence.
- Required-capability keys are not optional. If missing, stop and ask for config instead of running degraded analysis.
- First run always requires an explicit initialization prompt to the user before analysis.
- Never run partial or incomplete functionality; this is mandatory.
- Explain failures by impact: blocking, fallback succeeded, or data-quality degradation.
- Do not call local Hermes or other local agent CLIs from this skill. The current Codex agent is responsible for reading generated prompt files and writing the final analysis.
- Reports and emails must contain the strategy analysis result, not raw prompt context.
Bundled Resources
scripts/analyze.py: deterministic entry point.
scripts/stock_agent/: self-contained helper functions for config, data, search, LLM, and report rendering.
scripts/stock_agent/data.py: strategy-local data extraction code that reuses the shared ~/.stock_analysis/cache/ directory to avoid duplicate downloads across strategies.
assets/env.example: template copied to ~/.stock_analysis/chan_theory/.env on first run.
requirements.txt: Python dependency list.
references/configuration.md: API-key setup details for this strategy folder.
references/reporting.md: report and interface-status interpretation.