Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ SCHEDULE_TIME=18:00
SCHEDULE_TIMES=
# Web/API runtime scheduler 单次分析硬超时(秒,最小 60 秒)
DSA_RUNTIME_SCHEDULER_TIMEOUT_SECONDS=2700
# 硬超时后是否推送已落库个股的部分完成通知(true/false;默认 true,未设置即开启,此前超时不推送)
DSA_TIMEOUT_PARTIAL_NOTIFY=true
# 定时模式启动时是否立即执行一次分析(true/false)
# 若未显式设置,定时模式会沿用 RUN_IMMEDIATELY 的运行时覆盖语义以兼容旧配置
SCHEDULE_RUN_IMMEDIATELY=true
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div align="center">
<p align="center">
<a href="https://open.anspire.cn/dsa?share_code=QFBC0FYC" target="_blank"><img src="./docs/assets/anspire.png" alt="Anspire Open 一站式模型和搜索服务" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis" target="_blank"><img src="./docs/assets/serpapi_banner_zh.png" alt="轻松抓取搜索引擎上的实时金融新闻数据 - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/github-daily-stock-analysis" target="_blank"><img src="./docs/assets/serpapi_banner_zh.png" alt="轻松抓取搜索引擎上的实时金融新闻数据 - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
</p>
</div>

Expand Down Expand Up @@ -56,7 +56,7 @@
|------|------|
| AI 模型 | [Anspire](https://open.anspire.cn/dsa?share_code=QFBC0FYC)、[AIHubMix](https://inferera.com/?aff=CfMq)、Gemini、OpenAI 兼容、DeepSeek、通义千问、Claude、Ollama 本地模型等 |
| 行情数据 | [TickFlow](https://tickflow.org/auth/register?ref=WDSGSPS5XC)、AkShare、Tushare、Pytdx、Baostock、YFinance、Longbridge |
| 新闻搜索 | [Anspire](https://open.anspire.cn/dsa/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 新闻搜索 | [Anspire](https://open.anspire.cn/dsa/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/github-daily-stock-analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 社交舆情 | [Stock Sentiment API](https://api.adanos.org/docs)(Reddit / X / Polymarket,仅美股,可选) |

> 项目默认内置 AkShare、Baostock、YFinance 等免费行情源,可零配置运行;免费源受上游限流、接口变动和网络波动影响,稳定性不保证。长期定时、批量分析或更稳定行情建议配置 TickFlow、Tushare、Longbridge 等 token 型数据源,适用市场、Actions 映射和 fallback 规则见 [数据源配置](docs/full-guide.md#数据源配置)。
Expand Down Expand Up @@ -117,7 +117,7 @@
| Secret 名称 | 说明 | 必填 |
|------------|------|:----:|
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://open.anspire.cn/dsa?share_code=QFBC0FYC):汇聚全球舆情信息,适配A股、美股、港股等新闻和舆情检索;同一Key可复用大模型服务,本项目新用户提供免费30元等额的免费点数 | **推荐** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis):搜索引擎结果补强,适合实时金融新闻 | **推荐** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/github-daily-stock-analysis):搜索引擎结果补强,适合实时金融新闻 | **推荐** |
| `TAVILY_API_KEYS` | [Tavily](https://tavily.com/):通用新闻搜索 API | 可选 |
| `BOCHA_API_KEYS` | [博查搜索](https://open.bocha.cn/):中文搜索优化,支持 AI 摘要 | 可选 |
| `BRAVE_API_KEYS` | [Brave Search](https://brave.com/search/api/):隐私优先,美股资讯补强 | 可选 |
Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- [新功能] Web/API runtime scheduler 硬超时后扫描已落库分析历史,**默认发送**部分完成通知(`DSA_TIMEOUT_PARTIAL_NOTIFY` 未设置或为 true;此前超时不推送已落库个股),并在 `last_error` 中记录 `completed/pending` 摘要;可用 `DSA_TIMEOUT_PARTIAL_NOTIFY=false` 关闭推送(Refs #2328)。
- [测试] 修复股票名称解析冷启动超时并发测试的同步竞态:在放行后台抓取前确认两个等待者均已结束并返回空结果,避免 Docker 发布门禁偶发失败。
- [文档] 将仓库内所有 SerpApi 链接统一更新为新的赞助转化追踪地址。
- [修复] 智能导入兼容带 UTF-8 BOM 的 CSV 与剪贴板文本,避免 `code` 表头被误当成数据并丢失有效股票代码。

<!-- 新条目格式:- [类型] 描述(类型取值:新功能/改进/修复/文档/测试/chore)-->
<!-- 每条独立一行追加到本段末尾,无需分类标题,合并时冲突最小 -->
Expand Down
6 changes: 3 additions & 3 deletions docs/README_CHT.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div align="center">
<p align="center">
<a href="https://open.anspire.cn/?share_code=QFBC0FYC" target="_blank"><img src="assets/anspire.png" alt="Anspire Open 一站式模型和搜尋服務" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis" target="_blank"><img src="assets/serpapi_banner_zh.png" alt="輕鬆抓取搜尋引擎上的即時金融新聞數據 - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/github-daily-stock-analysis" target="_blank"><img src="assets/serpapi_banner_zh.png" alt="輕鬆抓取搜尋引擎上的即時金融新聞數據 - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
</p>
</div>

Expand Down Expand Up @@ -58,7 +58,7 @@
|------|------|
| AI 模型 | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC)、[AIHubMix](https://inferera.com/?aff=CfMq)、Gemini、OpenAI 兼容、DeepSeek、通義千問、Claude、Ollama 本地模型等 |
| 行情數據 | [TickFlow](https://tickflow.org/auth/register?ref=WDSGSPS5XC)、AkShare、Tushare、Pytdx、Baostock、YFinance、Longbridge |
| 新聞搜尋 | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 新聞搜尋 | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC)、[SerpAPI](https://serpapi.com/github-daily-stock-analysis)、[Tavily](https://tavily.com/)、[Bocha](https://open.bocha.cn/)、[Brave](https://brave.com/search/api/)、[MiniMax](https://platform.minimaxi.com/)、SearXNG |
| 社交輿情 | [Stock Sentiment API](https://api.adanos.org/docs)(Reddit / X / Polymarket,僅美股,可選) |

> 專案預設內建 AkShare、Baostock、YFinance 等免費行情源,可零配置執行;免費源受上游限流、介面變動和網路波動影響,穩定性不保證。長期定時、批量分析或更穩定行情建議配置 TickFlow、Tushare、Longbridge 等 token 型數據源,適用市場、Actions 映射和 fallback 規則見 [數據源配置](./full-guide.md#数据源配置)。
Expand Down Expand Up @@ -118,7 +118,7 @@
| Secret 名稱 | 說明 | 必填 |
|-------------|------|:----:|
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://aisearch.anspire.cn/):中文內容特別優化,可增強 A 股分析效果;同一 Key 也可作為 Anspire 大模型網關兜底示例 | **推薦** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis):搜尋引擎結果補強,適合即時金融新聞 | **推薦** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/github-daily-stock-analysis):搜尋引擎結果補強,適合即時金融新聞 | **推薦** |
| `TAVILY_API_KEYS` | [Tavily](https://tavily.com/):通用新聞搜尋 API | 可選 |
| `BOCHA_API_KEYS` | [博查搜尋](https://open.bocha.cn/):中文搜尋優化,支援 AI 摘要 | 可選 |
| `BRAVE_API_KEYS` | [Brave Search](https://brave.com/search/api/):隱私優先,美股資訊補強 | 可選 |
Expand Down
6 changes: 3 additions & 3 deletions docs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ English | [简体中文](../README.md) | [繁體中文](README_CHT.md)
<div align="center">
<p align="center">
<a href="https://open.anspire.cn/?share_code=QFBC0FYC" target="_blank"><img src="assets/anspire.png" alt="Anspire Open all-in-one model and search service" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis" target="_blank"><img src="assets/serpapi_banner_en.png" alt="Easily scrape real-time financial news data from search engines - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
<a href="https://serpapi.com/github-daily-stock-analysis" target="_blank"><img src="assets/serpapi_banner_en.png" alt="Easily scrape real-time financial news data from search engines - SerpApi" width="300" height="141" style="width: 300px; height: 141px; object-fit: contain;"></a>
</p>
</div>

Expand Down Expand Up @@ -58,7 +58,7 @@ English | [简体中文](../README.md) | [繁體中文](README_CHT.md)
|------|-----------|
| AI Models | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC), [AIHubMix](https://inferera.com/?aff=CfMq), Gemini, OpenAI-compatible providers, DeepSeek, Qwen, Claude, Ollama |
| Market Data | [TickFlow](https://tickflow.org/auth/register?ref=WDSGSPS5XC), AkShare, Tushare, Pytdx, Baostock, YFinance, Longbridge |
| News Search | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC), [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis), [Tavily](https://tavily.com/), [Bocha](https://open.bocha.cn/), [Brave](https://brave.com/search/api/), [MiniMax](https://platform.minimaxi.com/), SearXNG |
| News Search | [Anspire](https://open.anspire.cn/?share_code=QFBC0FYC), [SerpAPI](https://serpapi.com/github-daily-stock-analysis), [Tavily](https://tavily.com/), [Bocha](https://open.bocha.cn/), [Brave](https://brave.com/search/api/), [MiniMax](https://platform.minimaxi.com/), SearXNG |
| Social Sentiment | [Stock Sentiment API](https://api.adanos.org/docs) 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](./full-guide_EN.md#data-source-configuration).
Expand Down Expand Up @@ -118,7 +118,7 @@ News search strongly improves sentiment, announcements, events, and catalyst qua
| Secret Name | Description | Required |
|-------------|-------------|:--------:|
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://aisearch.anspire.cn/), 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](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis), search-engine results for realtime financial news | **Recommended** |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/github-daily-stock-analysis), search-engine results for realtime financial news | **Recommended** |
| `TAVILY_API_KEYS` | [Tavily](https://tavily.com/), general news search API | Optional |
| `BOCHA_API_KEYS` | [Bocha](https://open.bocha.cn/), Chinese search with AI summaries | Optional |
| `BRAVE_API_KEYS` | [Brave Search](https://brave.com/search/api/), privacy-first search and US-stock news enrichment | Optional |
Expand Down
2 changes: 1 addition & 1 deletion docs/beginner-client-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ macOS 用户升级前建议先在客户端设置里导出一次配置备份。
按你的模型服务选择:

1. 用 Anspire Open:找到 `Anspire API Keys`,填入同一个 Anspire Key,保存成功后即可。
2. 用 AIHubMix:建议再申请 [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis) 或 [Tavily](https://tavily.com/) 的 Key,填到 `SerpAPI API Keys` 或 `Tavily API Keys`,保存成功后即可。
2. 用 AIHubMix:建议再申请 [SerpAPI](https://serpapi.com/github-daily-stock-analysis) 或 [Tavily](https://tavily.com/) 的 Key,填到 `SerpAPI API Keys` 或 `Tavily API Keys`,保存成功后即可。

想先试用也可以跳过新闻源,客户端仍然能生成基础分析。

Expand Down
7 changes: 6 additions & 1 deletion docs/full-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ daily_stock_analysis/
|------------|------|:----:|
| `STOCK_LIST` | 自选股代码,如 `600519,300750,002594,7203.T,005930.KS`;推荐使用英文逗号,中文逗号、顿号、分号、空格和换行会被识别并规范为英文逗号 | ✅ |
| `ANSPIRE_API_KEYS` | [Anspire AI Search](https://aisearch.anspire.cn/) 针对中文内容特别优化;同一 Key 可用于搜索与 Anspire 大模型网关的兜底示例(是否可用以控制台与账号权限为准) | 推荐 |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/baidu-search-api?utm_source=github_daily_stock_analysis) 搜索引擎结果补强,适合实时金融新闻 | 推荐 |
| `SERPAPI_API_KEYS` | [SerpAPI](https://serpapi.com/github-daily-stock-analysis) 搜索引擎结果补强,适合实时金融新闻 | 推荐 |
| `TAVILY_API_KEYS` | [Tavily](https://tavily.com/) 搜索 API(新闻搜索) | 可选 |
| `BOCHA_API_KEYS` | [博查搜索](https://open.bocha.cn/) Web Search API(中文搜索优化,支持AI摘要,多个key用逗号分隔) | 可选 |
| `BRAVE_API_KEYS` | [Brave Search](https://brave.com/search/api/) API(隐私优先,美股优化,多个key用逗号分隔) | 可选 |
Expand Down Expand Up @@ -496,6 +496,7 @@ daily_stock_analysis/
| `SCHEDULE_TIME` | 定时执行时间 | `18:00` |
| `SCHEDULE_TIMES` | 多个定时执行时间,逗号分隔;为空时使用 `SCHEDULE_TIME` | 空 |
| `DSA_RUNTIME_SCHEDULER_TIMEOUT_SECONDS` | Web/API runtime scheduler 单次分析硬超时(秒,最小 60 秒);超时后终止独立分析进程,不阻塞后续任务 | `2700` |
| `DSA_TIMEOUT_PARTIAL_NOTIFY` | **默认开启(行为变化)**:硬超时后对已落库个股发送「部分完成」通知;此前超时不推送。`false` 时仍写入结构化 `last_error`,但不推送 | `true` |
| `LOG_DIR` | 日志目录 | `./logs` |
| `SAVE_CONTEXT_SNAPSHOT` | 保存分析历史 `context_snapshot`;设为 `false` 时新历史不保存 enhanced_context、market_phase_summary、AnalysisContextPack overview 或诊断快照,但不关闭当次 Prompt 低敏摘要 | `true` |

Expand Down Expand Up @@ -890,10 +891,13 @@ python main.py --schedule --no-run-immediately
| `SCHEDULE_TIME` | 每日执行时间 (HH:MM) | `18:00` | `09:30` |
| `SCHEDULE_TIMES` | 多个每日执行时间,逗号分隔;为空时使用 `SCHEDULE_TIME` | 空 | `09:20,12:30,15:10,18:00` |
| `DSA_RUNTIME_SCHEDULER_TIMEOUT_SECONDS` | Web/API runtime scheduler 单次分析硬超时(秒,最小 60 秒) | `2700` | `3600` |
| `DSA_TIMEOUT_PARTIAL_NOTIFY` | **默认开启(行为变化)**:硬超时后是否推送已落库个股的部分完成通知;此前超时不推送 | `true` | `false` |
| `SCHEDULE_RUN_IMMEDIATELY` | 定时模式启动时是否立即运行一次;未显式设置时沿用 `RUN_IMMEDIATELY` 的运行时覆盖语义 | `true` | `false` |
| `RUN_IMMEDIATELY` | 非定时模式启动时是否立即运行一次;同时作为未显式设置 `SCHEDULE_RUN_IMMEDIATELY` 时的 legacy 回退 | `true` | `false` |
| `TRADING_DAY_CHECK_ENABLED` | 交易日检查:非交易日跳过执行;设为 `false` 可强制执行 | `true` | `false` |

> 超时部分完成排障:通知渠道异常只记 warning(`Partial timeout notification failed`)并跳过推送,**不抛出、不占用** `status().running`(notify 在分析锁释放后的后台线程)。扫库 / `src.storage` 导入失败同样 fail-open:API 上可能仍是 baseline `timed out after Ns`,或被 enrich 成 `completed=0`(与「确实没有落库」无法区分)。运维请搜 `Failed to collect completed analyses after timeout`、`Timeout partial delivery failed open`、`Partial timeout notification failed`。合入后首次发布请关注通知量,避免默认开启造成骚扰;可设 `DSA_TIMEOUT_PARTIAL_NOTIFY=false` 关闭推送。

例如在 Docker 中配置:

```bash
Expand Down Expand Up @@ -1472,6 +1476,7 @@ LITELLM_FALLBACK_MODELS=anthropic/claude-sonnet-4-6,openai/gpt-5.4-mini

- **AkShare 名称解析缓存**:名称→代码解析使用 AkShare 在线 fallback 时,结果缓存 1 小时(TTL),避免频繁请求;首次调用或缓存过期后会自动刷新。
- **CSV/Excel 列名**:支持 `code`、`股票代码`、`代码`、`name`、`股票名称`、`名称` 等(不区分大小写);无表头时默认第 1 列为代码、第 2 列为名称。
- **文本编码**:CSV 与剪贴板文本支持 UTF-8(含 BOM)和 GBK。
- **常见解析失败**:文件过大(>2MB)、编码非 UTF-8/GBK、Excel 工作表为空或损坏、CSV 分隔符/列数不一致时,API 会返回具体错误提示。

- **模型优先级**:`VISION_MODEL` > `LITELLM_MODEL` > 根据已有 API Key 推断(`OPENAI_VISION_MODEL` 已废弃,请改用 `VISION_MODEL`)
Expand Down
Loading
Loading