mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
- [改进] #1386 P6 复用市场阶段与 AnalysisContextPack 公开摘要联动告警、持仓手动分析、历史、回测和通知展示,不新增数据库迁移。
|
||||
|
||||
- [文档] 明确 AnalysisContextPack P6 文档、迁移与回滚边界,并同步既有 `SAVE_CONTEXT_SNAPSHOT` 到 `.env.example`、配置注册表、Web 设置帮助和完整指南。
|
||||
- [文档] 补齐 #1386 P7 盘前/盘中/盘后分析的入口、迁移、回滚和用户可见说明。
|
||||
|
||||
## [3.20.0] - 2026-06-03
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
| [Bot 命令与接入](bot-command.md) | Bot 命令、Webhook、平台接入和回调说明 |
|
||||
| [Bot 平台配置](bot/) | 飞书、钉钉、Discord 等 Bot 配置截图和补充说明 |
|
||||
| [实时告警中心](alerts.md) | EventMonitor 基线、Web 规则管理、通知结果、冷却状态和 Phase 边界 |
|
||||
| [分析上下文包契约、运行态消费与可见性](analysis-context-pack.md) | AnalysisContextPack 首版范围、字段质量状态、P1/P2 内部契约、P3 Prompt 摘要消费、P4 历史/API/Web 低敏可见性、P5 数据质量评分、P6 迁移回滚与源码锚点 |
|
||||
| [分析上下文包契约、运行态消费与可见性](analysis-context-pack.md) | AnalysisContextPack 首版范围、字段质量状态、P1/P2 内部契约、P3 Prompt 摘要消费、P4 历史/API/Web 低敏可见性、P5 数据质量评分、P6 迁移回滚与源码锚点;完整指南补充 #1386 阶段感知分析、迁移与回滚入口 |
|
||||
| [图片识别 Prompt](image-extract-prompt.md) | 图片识别股票信息的 Prompt 与使用边界 |
|
||||
| [OpenClaw Skill 集成](openclaw-skill-integration.md) | OpenClaw / Skill 外部集成说明 |
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ This is the entry point for project documentation. The README covers the project
|
||||
| [Bot Commands (EN)](bot-command_EN.md) | Bot commands, webhooks, platform integration, and callback behavior |
|
||||
| [Bot Platform Docs](bot/) <sub><sub></sub></sub> (Chinese-only) | Feishu, DingTalk, Discord, and related Bot configuration screenshots and notes |
|
||||
| [Real-Time Alert Center](alerts.md) <sub><sub></sub></sub> (Chinese-only) | EventMonitor baseline, Web rule management, notification attempts, cooldown state, and phase boundaries |
|
||||
| [Analysis Context Pack Contract, Runtime Consumption, And Visibility](analysis-context-pack.md) <sub><sub></sub></sub> (Chinese-only) | AnalysisContextPack first-scope boundaries, field quality states, P1/P2 internal contracts, P3 prompt-summary consumption, P4 history/API/Web low-sensitivity visibility, P5 data-quality scoring, and P6 migration/rollback notes, plus source anchors |
|
||||
| [Analysis Context Pack Contract, Runtime Consumption, And Visibility](analysis-context-pack.md) <sub><sub></sub></sub> (Chinese-only) | AnalysisContextPack first-scope boundaries, field quality states, P1/P2 internal contracts, P3 prompt-summary consumption, P4 history/API/Web low-sensitivity visibility, P5 data-quality scoring, and P6 migration/rollback notes, plus source anchors; the full guide adds #1386 market-phase analysis, migration, and rollback entry points |
|
||||
| [Image Extraction Prompt](image-extract-prompt.md) <sub><sub></sub></sub> (Chinese-only) | Prompt and boundaries for extracting stock information from images |
|
||||
| [OpenClaw Skill Integration](openclaw-skill-integration.md) <sub><sub></sub></sub> (Chinese-only) | OpenClaw / Skill external integration notes |
|
||||
|
||||
|
||||
@@ -343,6 +343,8 @@ P6 不做:
|
||||
- 告警通知只输出公开摘要:阶段标签、trigger source、partial-bar warning、数据质量等级和前两条 limitations。通知不得输出 raw context pack、Prompt、新闻正文、完整 diagnostics JSON、webhook URL、token 或持仓敏感细节。
|
||||
- Web 告警历史展示 phase badge、数据质量等级和 limitations 空态;旧触发记录缺少公开摘要时不影响列表读取。
|
||||
|
||||
#1386 P7 的用户边界:告警联动只解释触发时已经可公开的阶段和数据质量摘要,不会自动发起轻量 LLM 盘中分析,也不会新增告警表、规则类型、环境变量或 migration。需要阶段化分析时,仍应通过分析 API / Web 手动分析入口触发;告警通知只保留阶段标签、trigger source、partial-bar warning、数据质量等级和前两条 limitations。
|
||||
|
||||
回滚本联动只需要 revert 对 worker/API/Web 的改动;已有 `diagnostics.analysis_visibility` 会作为普通 JSON diagnostics 保留,旧代码不会读取该 sibling key。
|
||||
|
||||
## P7 大盘红绿灯结构化告警
|
||||
|
||||
@@ -845,6 +845,31 @@ P6 将既有 `market_phase_summary` 与 `analysis_context_pack_overview` 复用
|
||||
|
||||
通知摘要复用统一公开格式化 helper,只输出阶段标签、trigger source、partial-bar warning、数据质量等级和前两条 limitations;不会输出 raw context pack、Prompt、新闻正文或持仓敏感明细。Web 告警历史、持仓、历史列表、StockBar 和回测页同步展示阶段 badge、质量摘要、phase filter 与 breakdown。
|
||||
|
||||
#### 文档、配置与迁移说明(Issue #1386 P7)
|
||||
|
||||
P7 只做盘前 / 盘中 / 盘后分析的用户可见说明收口,不新增运行时能力、配置项、API 参数、数据库迁移、Web 阶段覆盖 selector、Bot phase 参数或 GitHub Actions 盘中 workflow。默认每日收盘分析、默认 GitHub Actions 和现有 schedule 行为保持不变。
|
||||
|
||||
推荐使用方式:
|
||||
|
||||
| 场景 | 推荐用途 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| 盘前 | 生成开盘计划和观察条件 | 不能把尚未发生的今日走势写成事实;重点看上一完整交易日、隔夜信息和开盘触发条件。 |
|
||||
| 盘中 / 午间 / 临近收盘 | 做实时状态判断、风险和机会提醒 | 关注当前价、实时行情新鲜度、partial bar、数据限制和下一步观察条件,不替代盘后完整复盘。 |
|
||||
| 盘后 | 保留完整复盘和次日计划 | 使用完整交易日语义,是默认每日分析最接近的场景。 |
|
||||
|
||||
入口与可见性:
|
||||
|
||||
| 入口 | 阶段行为 |
|
||||
| --- | --- |
|
||||
| `POST /api/v1/analysis/analyze` | 支持 `analysis_phase=auto|premarket|intraday|postmarket`;不传时默认 `auto`。 |
|
||||
| Web 主分析 / 重新分析 / 持仓手动分析 | 当前没有阶段覆盖 selector;前端调用默认传 `auto`。进行中任务面板展示请求阶段,最终报告页展示最终阶段标签。 |
|
||||
| Bot / CLI / schedule / 默认 GitHub Actions | 不传 `analysis_phase`,继续走 `auto` 推断;默认收盘分析行为不变。 |
|
||||
| 历史 / 回测 / 通知 / 告警 | 只消费公开 `market_phase_summary` 和低敏 `analysis_context_pack_overview`;不公开完整 pack、Prompt summary、新闻正文或持仓敏感明细。 |
|
||||
|
||||
`analysis_phase` 是请求覆盖值,最终报告阶段仍以 `report.meta.market_phase_summary.phase` 为准。旧调用不传 `analysis_phase` 时保持兼容;旧历史缺少 `market_phase_summary` 或 `analysis_context_pack_overview` 时返回空字段,不影响报告读取。回测查询支持 `analysis_phase=premarket|intraday|postmarket|unknown` 过滤,并按 P6 规则把午间和临近收盘归入 intraday。
|
||||
|
||||
`SAVE_CONTEXT_SNAPSHOT=false` 或 CLI `--no-context-snapshot` 只停止新历史持久化整份 `context_snapshot`,因此新历史不再公开 phase summary / pack overview / diagnostics snapshot 等持久化摘要;它不关闭当次 `AnalysisContextPack` 构建,不移除 Prompt 中的低敏 `analysis_context_pack_summary`,也不改变报告 JSON schema。调用方若要临时回到更接近旧盘后口径的输出,可固定传 `analysis_phase=postmarket`;若要彻底移除 P0-P6 阶段/pack runtime 接入,需要发布回滚或代码回滚。
|
||||
|
||||
#### 使用 Crontab
|
||||
|
||||
如果不想使用常驻进程,也可以使用系统的 Cron:
|
||||
|
||||
@@ -722,6 +722,31 @@ History lists, same-stock history, StockBar items, and details extract `market_p
|
||||
|
||||
Notification summaries use one public formatting helper and only include the phase label, trigger source, partial-bar warning, data-quality level, and the first two limitations. They do not output raw context packs, prompts, news body text, or sensitive portfolio details. The Web Alerts, Portfolio, History, StockBar, and Backtest pages display the new phase badges, quality summary, phase filter, and breakdown.
|
||||
|
||||
### Documentation, Configuration, And Migration Notes (Issue #1386 P7)
|
||||
|
||||
P7 is a user-facing documentation closeout for pre-market / intraday / post-market analysis only. It does not add runtime behavior, configuration keys, API parameters, database migrations, a Web phase override selector, Bot phase parameters, or a GitHub Actions intraday workflow. The default daily post-market analysis, default GitHub Actions run, and existing schedule behavior stay unchanged.
|
||||
|
||||
Recommended usage:
|
||||
|
||||
| Scenario | Recommended Use | Notes |
|
||||
| --- | --- | --- |
|
||||
| Pre-market | Build an opening plan and watch conditions | Do not describe today's not-yet-traded price action as fact; focus on the last complete trading day, overnight information, and opening triggers. |
|
||||
| Intraday / lunch break / near close | Check live state, risk, and opportunity alerts | Focus on current price, realtime quote freshness, partial bars, data limitations, and next watch conditions. This does not replace the full post-market review. |
|
||||
| Post-market | Keep the full review and next-day plan | Uses complete trading-day semantics and is closest to the default daily-analysis scenario. |
|
||||
|
||||
Entrypoints and visibility:
|
||||
|
||||
| Entrypoint | Phase Behavior |
|
||||
| --- | --- |
|
||||
| `POST /api/v1/analysis/analyze` | Supports `analysis_phase=auto|premarket|intraday|postmarket`; omitted values default to `auto`. |
|
||||
| Web main analysis / re-analysis / portfolio manual analysis | There is currently no phase override selector. The frontend defaults to `auto`, the in-progress task panel shows the requested phase, and the final report page shows the final phase label. |
|
||||
| Bot / CLI / schedule / default GitHub Actions | Do not pass `analysis_phase`; they continue to use `auto` inference, and the default post-market behavior is unchanged. |
|
||||
| History / backtest / notifications / alerts | Only consume public `market_phase_summary` and low-sensitivity `analysis_context_pack_overview`; they do not expose the full pack, prompt summary, news body text, or sensitive portfolio details. |
|
||||
|
||||
`analysis_phase` is the requested override value, while the final report phase remains `report.meta.market_phase_summary.phase`. Older callers that omit `analysis_phase` remain compatible. Older history rows without `market_phase_summary` or `analysis_context_pack_overview` return empty fields and still load normally. Backtest queries support `analysis_phase=premarket|intraday|postmarket|unknown` filtering, and P6 folds lunch-break and near-close phases into intraday.
|
||||
|
||||
`SAVE_CONTEXT_SNAPSHOT=false` or CLI `--no-context-snapshot` only stops persisting the full `context_snapshot` for new history rows, so new history no longer exposes persisted phase summary / pack overview / diagnostics snapshot data. It does not disable current-run `AnalysisContextPack` construction, does not remove the low-sensitivity `analysis_context_pack_summary` from prompts, and does not change the report JSON schema. Callers that need output closer to the old post-market wording can temporarily pin `analysis_phase=postmarket`; fully removing the P0-P6 phase/pack runtime integration requires a release rollback or code rollback.
|
||||
|
||||
---
|
||||
|
||||
## Notification Channel Configuration
|
||||
|
||||
@@ -279,6 +279,23 @@ def test_alerts_doc_defines_p7_market_light_scope() -> None:
|
||||
assert token in doc
|
||||
|
||||
|
||||
def test_alerts_doc_covers_issue_1386_p7_user_visibility_boundary() -> None:
|
||||
doc = _read_doc()
|
||||
p7_section = doc.split("#1386 P7 的用户边界:", 1)[1].split(
|
||||
"\n\n回滚本联动",
|
||||
1,
|
||||
)[0]
|
||||
|
||||
for token in (
|
||||
"触发时已经可公开的阶段和数据质量摘要",
|
||||
"不会自动发起轻量 LLM 盘中分析",
|
||||
"不会新增告警表、规则类型、环境变量或 migration",
|
||||
"分析 API / Web 手动分析入口",
|
||||
"告警通知只保留阶段标签、trigger source、partial-bar warning、数据质量等级和前两条 limitations",
|
||||
):
|
||||
assert token in p7_section
|
||||
|
||||
|
||||
def test_alerts_doc_defines_p8_user_and_deployment_boundaries() -> None:
|
||||
doc = _read_doc()
|
||||
|
||||
|
||||
@@ -429,12 +429,14 @@ def test_analysis_context_pack_doc_updates_indexes_and_changelog() -> None:
|
||||
|
||||
assert "[分析上下文包契约、运行态消费与可见性](analysis-context-pack.md)" in index
|
||||
assert "P1/P2 内部契约、P3 Prompt 摘要消费、P4 历史/API/Web 低敏可见性、P5 数据质量评分、P6 迁移回滚" in index
|
||||
assert "#1386 阶段感知分析、迁移与回滚入口" in index
|
||||
assert (
|
||||
"[Analysis Context Pack Contract, Runtime Consumption, And Visibility](analysis-context-pack.md) "
|
||||
"<sub><sub></sub></sub> "
|
||||
"(Chinese-only)"
|
||||
) in index_en
|
||||
assert "P1/P2 internal contracts, P3 prompt-summary consumption, P4 history/API/Web low-sensitivity visibility, P5 data-quality scoring, and P6 migration/rollback notes" in index_en
|
||||
assert "#1386 market-phase analysis, migration, and rollback entry points" in index_en
|
||||
assert "新增 AnalysisContextPack P0 上下文盘点" in changelog
|
||||
assert "新增 AnalysisContextPack P1 内部契约与脱敏序列化测试" in changelog
|
||||
assert "新增 AnalysisContextPack P2 builder" in changelog
|
||||
@@ -442,10 +444,66 @@ def test_analysis_context_pack_doc_updates_indexes_and_changelog() -> None:
|
||||
assert "AnalysisContextPack P4 低敏 overview 接入历史详情" in changelog
|
||||
assert "AnalysisContextPack P5 增加数据质量评分" in changelog
|
||||
assert "明确 AnalysisContextPack P6 文档、迁移与回滚边界" in changelog
|
||||
assert "#1386 P7 盘前/盘中/盘后分析的入口、迁移、回滚和用户可见说明" in changelog
|
||||
assert "#1386 P5 为个股分析报告新增 `dashboard.phase_decision`" in changelog
|
||||
assert "优化 Web 报告详情页信息层级" in changelog
|
||||
|
||||
|
||||
def test_full_guides_cover_issue_1386_p7_user_migration_closeout() -> None:
|
||||
guide = (PROJECT_ROOT / "docs" / "full-guide.md").read_text(encoding="utf-8")
|
||||
guide_en = (PROJECT_ROOT / "docs" / "full-guide_EN.md").read_text(encoding="utf-8")
|
||||
|
||||
for token in (
|
||||
"文档、配置与迁移说明(Issue #1386 P7)",
|
||||
"盘前 / 盘中 / 盘后分析",
|
||||
"生成开盘计划和观察条件",
|
||||
"盘中 / 午间 / 临近收盘",
|
||||
"做实时状态判断、风险和机会提醒",
|
||||
"`analysis_phase=auto|premarket|intraday|postmarket`",
|
||||
"最终报告阶段仍以 `report.meta.market_phase_summary.phase` 为准",
|
||||
"Web 主分析 / 重新分析 / 持仓手动分析",
|
||||
"当前没有阶段覆盖 selector",
|
||||
"进行中任务面板展示请求阶段",
|
||||
"最终报告页展示最终阶段标签",
|
||||
"Bot / CLI / schedule / 默认 GitHub Actions",
|
||||
"只消费公开 `market_phase_summary` 和低敏 `analysis_context_pack_overview`",
|
||||
"不公开完整 pack、Prompt summary、新闻正文或持仓敏感明细",
|
||||
"旧调用不传 `analysis_phase` 时保持兼容",
|
||||
"回测查询支持 `analysis_phase=premarket|intraday|postmarket|unknown`",
|
||||
"`SAVE_CONTEXT_SNAPSHOT=false`",
|
||||
"不关闭当次 `AnalysisContextPack` 构建",
|
||||
"低敏 `analysis_context_pack_summary`",
|
||||
"`analysis_phase=postmarket`",
|
||||
"需要发布回滚或代码回滚",
|
||||
):
|
||||
assert token in guide
|
||||
|
||||
for token in (
|
||||
"Documentation, Configuration, And Migration Notes (Issue #1386 P7)",
|
||||
"pre-market / intraday / post-market analysis",
|
||||
"opening plan and watch conditions",
|
||||
"Intraday / lunch break / near close",
|
||||
"live state, risk, and opportunity alerts",
|
||||
"`analysis_phase=auto|premarket|intraday|postmarket`",
|
||||
"final report phase remains `report.meta.market_phase_summary.phase`",
|
||||
"Web main analysis / re-analysis / portfolio manual analysis",
|
||||
"no phase override selector",
|
||||
"the in-progress task panel shows the requested phase",
|
||||
"the final report page shows the final phase label",
|
||||
"Bot / CLI / schedule / default GitHub Actions",
|
||||
"Only consume public `market_phase_summary` and low-sensitivity `analysis_context_pack_overview`",
|
||||
"do not expose the full pack, prompt summary, news body text, or sensitive portfolio details",
|
||||
"Older callers that omit `analysis_phase` remain compatible",
|
||||
"Backtest queries support `analysis_phase=premarket|intraday|postmarket|unknown`",
|
||||
"`SAVE_CONTEXT_SNAPSHOT=false`",
|
||||
"does not disable current-run `AnalysisContextPack` construction",
|
||||
"low-sensitivity `analysis_context_pack_summary`",
|
||||
"`analysis_phase=postmarket`",
|
||||
"requires a release rollback or code rollback",
|
||||
):
|
||||
assert token in guide_en
|
||||
|
||||
|
||||
def test_full_guides_clarify_pack_summary_does_not_replace_legacy_payload_channels() -> None:
|
||||
guide = (PROJECT_ROOT / "docs" / "full-guide.md").read_text(encoding="utf-8")
|
||||
guide_en = (PROJECT_ROOT / "docs" / "full-guide_EN.md").read_text(encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user