* feat: 新闻检索为空时在报告中如实标注 消息面章节此前是「有内容才渲染」,检索一条没拿到时整段直接消失, 读报告的人无从判断是确实没新闻,还是检索静默失败了(搜索源限流、 未配置可用渠道等)。这把「抓取失败」呈现成了「确实没有新闻」。 - src/analyzer.py: AnalysisResult 新增 news_result_count,默认 None - src/core/pipeline.py: 把 Step 4 已算好的计数交给结果对象 (此前只进了 diagnostic context snapshot,报告层拿不到) - src/notification.py: news_lines 为空且计数为 0 时,渲染明确提示, 并说明结论未纳入新闻维度证据 - tests: 新增 5 条用例,含两条负例——计数为 None 时不得报警 (那是未配置搜索渠道,不是失败)、拿到新闻时行为与改动前一致 不触碰任何检索路径,纯展示层增量。 * fix: 把新闻缺失提示放进真实渲染路径,并独立于模型输出判定 按 review 三条意见修正: P1-1 提示只存在于 generate_daily_report,而正常流程从不调用它—— _send_single_stock_notification 与聚合报告走的是 dashboard / brief / single_stock。原实现对所有标准 REPORT_TYPE 都不生效。 改为抽出共享判定 _empty_news_disclosure,四个渲染器统一接入。 P2 检索零命中但模型按 schema 写出了 market_sentiment / hot_topics 时, 原 elif 分支被跳过,报告会展示模型生成的情绪判断却隐瞒无新闻证据。 改为独立判定 news_result_count == 0,与模型是否产出文字无关。 P1-2 补 docs/CHANGELOG.md [Unreleased] 条目,并在 docs/data-source-stability.md 的「用户可见提示建议」一节记录该行为, 含 None / 0 / >0 三态语义表。 测试从 5 条增至 10 条,新增覆盖 dashboard、brief、single_stock 三个真实 渲染器,以及「模型有输出但检索为空」这一最糟组合。39 passed * fix: 把新闻零命中披露覆盖到模板链路与企业微信入口 按 review 指出的 blocker 修正。此前只接了字符串拼接分支,遗漏两类活路径: 1. REPORT_RENDERER_ENABLED=true 时,generate_dashboard_report / generate_brief_report / generate_wechat_dashboard 会先 return render(...), 模板链路一路不渲染披露; 2. generate_wechat_dashboard 的非模板 fallback 从未接入,而 pipeline 在 企业微信非 brief 场景会直接调用它。 后果是同一份分析结果在部分渠道披露、在另一些渠道沉默。 改法不再逐点打补丁,而是抽出单一事实来源: - 新增 src/services/empty_news.py 持有判定与中英文案 - src/notification.py 的 _empty_news_disclosure 改为委托该模块 - src/services/report_renderer.py 为每条结果预计算 empty_news_disclosure, 三个平台模板共用 - templates/report_markdown.j2 / report_brief.j2 / report_wechat.j2 各加渲染分支 - generate_wechat_dashboard 的 fallback 正文接入披露 新增 6 条回归测试:模板链路三个平台各一条、企业微信入口一条, 外加两条负例(未执行检索时模板与企业微信均不得提示)。 本文件测试 10 → 16 全过;全量 5824 passed,9 个既有失败与本 PR 无关 (干净 main 上同样失败,属测试顺序依赖)。 * fix: 修正计数源头的两处缺口(自查发现) 按 review 的 merge-base..HEAD 方法自查全链路,发现此前几轮都只盯着渲染出口, 从未核对计数源头,而源头本身在两条路径上是错的: 1. src/core/pipeline.py: news_result_count 只在 intel_results 非空时赋值, 搜索服务整体失败(正是所有搜索源限流全挂的场景)时停留在 None, 语义为「未执行检索」,于是本 PR 想解决的头号场景反而不提示。 改为检索一发起即置 0。 2. _analyze_with_agent: Agent 模式自行调用 search_stock_news 完成检索, 却从不回写计数,该路径下零命中永远静默。改为按检索结果回写 0 或实际条数。 渲染层再周全,源头数据不对则全部落空。 新增 2 条测试锁住这两处语义(18 passed,此前 16)。 全量 5826 passed,9 个既有失败与本 PR 无关。 * fix: disclose missing news search configuration * chore: remove unrelated agent guidance * test: run all empty news tests directly * fix: preserve empty news disclosure across reports * fix: 让 Agent 模式的新闻披露跟随实际消费的证据 原问题:agent_arch=multi 等受支持的 Agent 配置下,报告可能声称「未纳入新闻 面证据」而分析其实用了新闻,或反过来该提示而不提示。 根因:news_result_count 取自 executor.run() 结束后为持久化情报补打的一次 search_stock_news()。真实情报由 IntelAgent 通过 search_comprehensive_intel 取得,两者不等价,因此披露与真实证据链可能相反。 修复点:新增 src/agent/news_evidence.py,以运行期证据作用域收集 Agent 搜索 工具的真实返回条数;搜索渠道不可用为 None(未执行检索),可用则从 0 起步、 拿到多少算多少。pipeline 在 executor.run() 前后开启并读取该作用域,事后的 持久化补查不再回写计数。 回归风险:工具在 ThreadPoolExecutor 中执行,runner.py 以 contextvars.copy_context() 提交,故作用域中必须是可变累加器对象,换成不可变 值会让父线程读不到;已加回归测试锁住该机制。原 test_agent_path_records_count 断言的正是被修复的错误行为,已替换为反向断言。 Refs #2225 * fix: 让新闻披露以实际证据为准而非搜索命中数 原问题:本地已落库的资讯池或社交情绪进入 news_context 参与分析后,报告仍可能 声称「未配置搜索渠道,本次分析未纳入新闻面证据」或「零命中」。 根因:news_context 由三路来源拼成——实时检索、社交情绪(美股)、本地资讯池, 但只有实时检索会更新 news_result_count。披露断言的是「结论有没有用到新闻面 证据」,而计数只是「搜索命中了几条」,两者是不同命题,后两路参与时必然失真。 修复点:AnalysisResult 新增 news_evidence_present,由 news_context 是否非空 得出,pipeline 两条路径共用 src/services/empty_news.news_evidence_present() 这一个判定函数。披露改为先看有无证据;确无证据时才用计数解释原因 (None=未配置渠道,0=检索零命中)。历史重建同步恢复该字段。 回归风险:旧记录没有该字段,按计数回退推断,与该记录当时的报告表现一致,不会 追溯改变旧报告;已有用例锁住。review 只点名了本地资讯池,社交情绪属同一缺陷类, 本次一并修复并加测试。另加源码断言:任一 pipeline 路径改回只传计数即失败。 Refs #2225 * fix: 按来源登记新闻证据,不让零命中占位文本冒充证据 原问题:普通分析链路在「搜索已执行但一条证据都没拿到」时,报告不再显示零命中 披露——正是本 PR 要修的核心场景,反而比改动前更差。 根因:src/search_service.py 的 format_intel_report() 即使所有维度失败或为空, 也会输出「【XX 情报搜索结果】」标题和每个维度的「未找到相关信息」占位文本, 整段永远非空。上一版把拼好的 news_context 整段交给 news_evidence_present() 判定,于是 news_result_count == 0 时 evidence 被翻成 true,披露被吞掉,错误 状态还会经 to_dict() 持久化,继续影响历史、详情 API 与 Web。 修复点:判定改为按来源逐个登记——实时检索的真实命中数、社交情绪内容、本地 资讯池内容,任一为真才算有证据;两条 pipeline 路径都不再传拼好的整段。 news_evidence_present() 的契约随之改为接收各来源,并在文档串里写明为什么不能 传整段。 回归风险:新增反例用真实的 format_intel_report() 产出占位文本(不用 mock), 断言其不得被判成证据、且报告必须出现零命中披露。另有源码断言:谁把整段 news_context 交回判定函数即失败。上一版两条测试实际在保护该缺陷(一条名为 「任何非空 context 都算证据」,一条要求必须传入 news_context),已一并纠正。 Refs #2225 --------- Co-authored-by: Mach-Chan <zz-b240@zz-b240deMacBook-Air.local>
AI Stock Analysis System
AI-powered stock analysis system for A-shares / Hong Kong / US / Japanese / Korean / Taiwan stocks
Analyze your watchlist daily -> generate a decision dashboard -> push to Telegram / Discord / Slack / Email / WeChat Work / Feishu.
Product Preview · Key Features · Quick Start · Sample Output · Documentation Index · Full Guide
💖 Sponsors
🖥️ Product Preview
✨ Key Features
| Capability | Coverage |
|---|---|
| AI decision reports | Core conclusion, score, trend, entry/exit levels, risk alerts, catalysts, and action checklist |
| Multi-market data | Covers A-shares, Hong Kong, US, Japanese, Korean, Taiwan stocks, and ETFs, with quotes, K-lines, technical indicators, news, announcements, fundamentals, and report context. Data-source coverage and market boundaries are documented in market boundaries |
| Web / desktop workspace | Manual analysis, task progress, history, full Markdown reports, backtest, portfolio, settings, and light/dark themes |
| Agent strategy chat | Multi-turn Q&A with 15 built-in strategies across Web/Bot/API |
| Smart import & autocomplete | Image, CSV/Excel, clipboard import; code/name/pinyin/alias autocomplete |
| Automation & notifications | GitHub Actions, Docker, local scheduler, FastAPI service, and WeChat Work / Feishu / Telegram / Discord / Slack / Email delivery |
Detailed fields, fundamental P0 timeout semantics, trading rules, data-source priority, Web/API behavior, and troubleshooting live in the Full Guide.
Tech Stack & Data Sources
| Type | Supported |
|---|---|
| AI Models | Anspire, AIHubMix, Gemini, OpenAI-compatible providers, DeepSeek, Qwen, Claude, Ollama |
| Market Data | TickFlow, AkShare, Tushare, Pytdx, Baostock, YFinance, Longbridge |
| News Search | Anspire, SerpAPI, Tavily, Bocha, Brave, MiniMax, SearXNG |
| Social Sentiment | Stock Sentiment API for Reddit / X / Polymarket, US stocks only |
The project includes free market-data sources such as AkShare, Baostock, and YFinance and can run without extra data-source credentials. These free sources can be rate-limited, change upstream contracts, or fluctuate by network condition, so stability is not guaranteed. For scheduled runs, batch analysis, or steadier quotes, configure token-based sources such as TickFlow, Tushare, or Longbridge; market coverage, Actions mappings, and fallback rules are documented in Data Source Configuration.
🚀 Quick Start
Option 1: GitHub Actions (Recommended)
Deploy in about 5 minutes, with no server and no infrastructure cost.
1. Fork this repository
Click Fork in the upper-right corner. A star is very welcome if this project helps you.
2. Configure Secrets
Open your forked repository, then go to Settings -> Secrets and variables -> Actions -> New repository secret.
AI model configuration (configure at least one)
Start with one provider and one API key. For multi-model routing, image recognition, local models, or advanced routing, see the LLM Config Guide.
| Secret Name | Description | Required |
|---|---|---|
ANSPIRE_API_KEYS |
Anspire API key, one key for popular LLMs and web search with free quota for this project | Recommended |
AIHUBMIX_KEY |
AIHubMix API key, one key for multiple model families and a 10% top-up discount for this project | Recommended |
GEMINI_API_KEY |
Google Gemini API key | Optional |
ANTHROPIC_API_KEY |
Anthropic Claude API key | Optional |
OPENAI_API_KEY |
OpenAI-compatible API key, including DeepSeek and Qwen-compatible services | Optional |
OPENAI_BASE_URL / OPENAI_MODEL |
Fill these when using an OpenAI-compatible provider | Optional |
Ollama is better suited for local or Docker deployment. GitHub Actions is usually smoother with a cloud API.
Notification channels (configure at least one)
| Secret Name | Description |
|---|---|
WECHAT_WEBHOOK_URL |
WeChat Work bot |
FEISHU_WEBHOOK_URL |
Feishu bot |
TELEGRAM_BOT_TOKEN + TELEGRAM_CHAT_ID |
Telegram |
DISCORD_WEBHOOK_URL |
Discord webhook |
SLACK_BOT_TOKEN + SLACK_CHANNEL_ID |
Slack bot |
EMAIL_SENDER + EMAIL_PASSWORD |
Email push |
More channels, signatures, email groups, and Markdown-to-image settings are in Notification Configuration.
Watchlist (required)
| Secret Name | Description | Required |
|---|---|---|
STOCK_LIST |
Watchlist codes, such as 600519,hk00700,AAPL,7203.T,005930.KS,2330.TW |
✅ |
News sources (recommended)
News search strongly improves sentiment, announcements, events, and catalyst quality. Configure at least one search provider if possible.
| Secret Name | Description | Required |
|---|---|---|
ANSPIRE_API_KEYS |
Anspire AI Search, optimized for Chinese content and A-share analysis; the same key can also be used for Anspire LLM fallback examples | Recommended |
SERPAPI_API_KEYS |
SerpAPI, search-engine results for realtime financial news | Recommended |
TAVILY_API_KEYS |
Tavily, general news search API | Optional |
BOCHA_API_KEYS |
Bocha, Chinese search with AI summaries | Optional |
BRAVE_API_KEYS |
Brave Search, privacy-first search and US-stock news enrichment | Optional |
MINIMAX_API_KEYS |
MiniMax, structured search results | Optional |
SEARXNG_BASE_URLS |
Self-hosted SearXNG instances for quota-free fallback | Optional |
More search providers, social sentiment, and fallback behavior are in Search Configuration.
Market data sources (optional)
Free sources like AkShare, Baostock, and YFinance are used by default. "Not configured" messages in the logs are informational and do not affect execution. For more stable data, configure the following secrets per market:
| Secret Name | Market | Description |
|---|---|---|
TUSHARE_TOKEN |
A-shares | Improves historical data stability |
LONGBRIDGE_OAUTH_CLIENT_ID + LONGBRIDGE_OAUTH_TOKEN_CACHE_B64 |
HK/US stocks | Fills in volume ratio, turnover rate, P/E, and other fields |
3. Enable Actions
Open the Actions tab and click I understand my workflows, go ahead and enable them.
4. Manual Test
Actions -> Daily Stock Analysis -> Run workflow -> Run workflow.
Done
By default, the workflow runs every weekday at 18:00 Beijing time and skips non-trading days. Forced runs, trading-day checks, and resume rules are covered in the Full Guide.
Option 2: Local / Docker Deployment
# Clone the project
git clone https://github.com/ZhuLinsen/daily_stock_analysis.git && cd daily_stock_analysis
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env && vim .env
# Run analysis
python main.py
Common commands:
python main.py --debug
python main.py --dry-run
python main.py --stocks 600519,hk00700,AAPL,2330.TW
python main.py --market-review
python main.py --schedule
python main.py --serve-only
Docker deployment, scheduling, and cloud-server WebUI access are documented in the Full Guide.
📱 Sample Output
Decision Dashboard
🎯 2026-02-08 Decision Dashboard
Analyzed 3 stocks | 🟢 Buy:0 🟡 Watch:2 🔴 Sell:1
📊 Summary
🟡 000657: Watch | Score 65 | Bullish
🟡 600105: Watch | Score 48 | Range-bound
🔴 300260: Sell | Score 35 | Bearish
🚨 Risk Alerts:
Risk 1: Main-force funds showed notable outflow.
Risk 2: Chip concentration suggests short-term resistance.
✨ Positive Catalysts:
Catalyst 1: AI-server supply-chain exposure remains a market focus.
Catalyst 2: Recent earnings growth provides fundamental support.
Market Review
🎯 2026-01-10 Market Review
📊 Major Indices
- SSE Composite: 3250.12 (+0.85%)
- SZSE Component: 10521.36 (+1.02%)
- ChiNext: 2156.78 (+1.35%)
📈 Market Breadth
Up: 3920 | Down: 1349 | Limit up: 155 | Limit down: 3
⚙️ Configuration
Full environment variables, model routing, notification channels, data-source priority, trading rules, fundamental P0 semantics, and deployment details are in the Full Guide.
🖥️ Web UI
The Web workspace supports settings, task monitoring, manual analysis, history reports, full Markdown reports, Agent strategy chat, backtest, portfolio management, smart import, and light/dark themes.
python main.py --webui
python main.py --webui-only
Visit http://127.0.0.1:8000. Authentication, smart import, autocomplete, report copying, and cloud-server access are documented in Local WebUI Management.
🤖 Agent Strategy Chat
After configuring any available AI API key, the Web /chat page can use strategy chat. Set AGENT_MODE=false only if you want to disable it explicitly.
- Built-in strategies include moving-average crossovers, Chan theory, Elliott wave, bull trend, hot themes, event-driven, growth quality, expectation repricing, and more
- Calls realtime quotes, K-line data, technical indicators, news, and risk context
- Supports follow-up questions, session export, notification sending, and background execution
- Supports custom strategy files and experimental multi-agent orchestration
Agent parameters,
skillnaming compatibility, multi-agent mode, and budget guards are covered in the Full Guide and LLM Config Guide.
🧩 Related Projects
DSA focuses on daily analysis reports. Its screening implementation references AlphaSift, while AlphaEvo covers strategy validation and evolution.
| Project | Focus |
|---|---|
| AlphaSift | Reference project for DSA's screening implementation |
| AlphaEvo | Strategy backtesting and self-evolution experiments for validating rules and iteratively exploring strategy parameters and combinations |
📞 Contact
|
zhuls345@gmail.com Project consulting, deployment support, and feature extensions |
![]() Follow on Xiaohongshu |
|
| Xiaohongshu | Follow on Xiaohongshu | |
| Feedback | GitHub Issues · Discussions |
📄 License
MIT License © 2026 ZhuLinsen
If you use or build on this project, attribution with a link back to this repository is appreciated.
⚠️ Disclaimer
This project is for informational and educational purposes only. AI-generated analysis is not investment advice. Stock market investing involves risk; do your own research and consult a licensed financial advisor when needed.



