alphasift 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. alphasift/__init__.py +52 -0
  2. alphasift/__main__.py +7 -0
  3. alphasift/audit.py +191 -0
  4. alphasift/candidate_context.py +738 -0
  5. alphasift/cli.py +2797 -0
  6. alphasift/config.py +705 -0
  7. alphasift/context.py +672 -0
  8. alphasift/daily.py +1256 -0
  9. alphasift/daily_brief.py +593 -0
  10. alphasift/daily_report.py +1115 -0
  11. alphasift/daily_report_html.py +1257 -0
  12. alphasift/doctor.py +1123 -0
  13. alphasift/dsa.py +302 -0
  14. alphasift/dsa_adapter.py +178 -0
  15. alphasift/dsa_provider.py +192 -0
  16. alphasift/evaluate.py +2418 -0
  17. alphasift/filter.py +517 -0
  18. alphasift/hotspot.py +1713 -0
  19. alphasift/industry.py +959 -0
  20. alphasift/llm_client.py +349 -0
  21. alphasift/market_digest.py +284 -0
  22. alphasift/market_news.py +446 -0
  23. alphasift/market_regime.py +578 -0
  24. alphasift/markets.py +160 -0
  25. alphasift/mcp.py +720 -0
  26. alphasift/models.py +315 -0
  27. alphasift/normalize.py +113 -0
  28. alphasift/notify.py +2608 -0
  29. alphasift/overview.py +225 -0
  30. alphasift/pack.py +1470 -0
  31. alphasift/pack_features.py +431 -0
  32. alphasift/pattern_replay.py +1449 -0
  33. alphasift/patterns/bottom_volume_yang.yaml +32 -0
  34. alphasift/patterns/box_breakout.yaml +36 -0
  35. alphasift/patterns/double_bottom_breakout.yaml +38 -0
  36. alphasift/patterns/ma20_shrink_pullback.yaml +37 -0
  37. alphasift/patterns/shooting_star_confirm.yaml +49 -0
  38. alphasift/patterns/single_yang_hold.yaml +44 -0
  39. alphasift/patterns/steady_trend_breakout.yaml +39 -0
  40. alphasift/patterns/three_white_soldiers.yaml +72 -0
  41. alphasift/patterns/three_white_soldiers_pullback.yaml +91 -0
  42. alphasift/patterns.py +1233 -0
  43. alphasift/performance_history.py +297 -0
  44. alphasift/pipeline.py +1010 -0
  45. alphasift/post_analysis.py +337 -0
  46. alphasift/ranker.py +990 -0
  47. alphasift/report.py +379 -0
  48. alphasift/result_schema.py +179 -0
  49. alphasift/risk.py +452 -0
  50. alphasift/run_history.py +164 -0
  51. alphasift/scorer.py +597 -0
  52. alphasift/server.py +680 -0
  53. alphasift/snapshot.py +1025 -0
  54. alphasift/snapshot_us.py +280 -0
  55. alphasift/snapshot_yahoo.py +358 -0
  56. alphasift/source_guard.py +70 -0
  57. alphasift/source_history.py +306 -0
  58. alphasift/store.py +294 -0
  59. alphasift/strategies/balanced_alpha.yaml +76 -0
  60. alphasift/strategies/blue_chip_income.yaml +87 -0
  61. alphasift/strategies/capital_heat.yaml +74 -0
  62. alphasift/strategies/dual_low.yaml +80 -0
  63. alphasift/strategies/global_value.yaml +65 -0
  64. alphasift/strategies/low_volatility_quality.yaml +95 -0
  65. alphasift/strategies/momentum_quality.yaml +81 -0
  66. alphasift/strategies/oversold_reversal.yaml +75 -0
  67. alphasift/strategies/quality_value.yaml +80 -0
  68. alphasift/strategies/shrink_pullback.yaml +77 -0
  69. alphasift/strategies/us_momentum_quality.yaml +74 -0
  70. alphasift/strategies/volume_breakout.yaml +78 -0
  71. alphasift/strategy.py +1090 -0
  72. alphasift/strategy_cards.py +424 -0
  73. alphasift/strategy_templates.py +291 -0
  74. alphasift/timeutil.py +38 -0
  75. alphasift/valuation_kr.py +149 -0
  76. alphasift/workbench_ui.py +1051 -0
  77. alphasift-0.3.1.data/data/.env.example +151 -0
  78. alphasift-0.3.1.data/data/LICENSE +184 -0
  79. alphasift-0.3.1.data/data/SKILL.md +190 -0
  80. alphasift-0.3.1.data/data/agents/openai.yaml +7 -0
  81. alphasift-0.3.1.dist-info/METADATA +312 -0
  82. alphasift-0.3.1.dist-info/RECORD +86 -0
  83. alphasift-0.3.1.dist-info/WHEEL +5 -0
  84. alphasift-0.3.1.dist-info/entry_points.txt +2 -0
  85. alphasift-0.3.1.dist-info/licenses/LICENSE +184 -0
  86. alphasift-0.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1257 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Standalone, self-contained printable HTML renderer for CN DailyReport payloads."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import html
7
+ import json
8
+ from pathlib import Path
9
+ from typing import Any
10
+ from urllib.parse import urlsplit
11
+
12
+ from alphasift.daily_brief import BRIEF_DISCLAIMER, resolve_strategy_display_names
13
+
14
+ _DIST_BUCKETS: tuple[tuple[str, str, str], ...] = (
15
+ ("le_neg7", "≤-7%", "down"),
16
+ ("neg7_neg3", "-7~-3%", "down"),
17
+ ("neg3_0", "-3~0%", "down"),
18
+ ("flat", "平盘", "flat"),
19
+ ("pos0_3", "0~3%", "up"),
20
+ ("pos3_7", "3~7%", "up"),
21
+ ("ge_pos7", "≥7%", "up"),
22
+ )
23
+ _GITHUB_URL = "https://github.com/ZhuLinsen/alphasift"
24
+
25
+
26
+ def _esc(val: object) -> str:
27
+ return html.escape("" if val is None else str(val), quote=True)
28
+
29
+
30
+ def _safe_detail_url(raw: object, fallback: str = "../index.html") -> str:
31
+ """Allow only http(s) URLs or clean same-origin relative paths without HTML/control delimiters."""
32
+ cleaned = str(raw or "").strip()
33
+ if not cleaned:
34
+ return fallback
35
+ if any(ch in cleaned for ch in '<>"\'\r\n\t\0'):
36
+ return fallback
37
+ if cleaned.startswith("//"):
38
+ return fallback
39
+ parsed = urlsplit(cleaned)
40
+ if parsed.scheme:
41
+ if parsed.scheme.lower() in {"http", "https"} and parsed.netloc:
42
+ return cleaned
43
+ return fallback
44
+ if parsed.netloc:
45
+ return fallback
46
+ if cleaned.startswith("../index.html") or (cleaned.startswith("/") and not cleaned.startswith("//")) or cleaned.startswith("index.html"):
47
+ return cleaned
48
+ return fallback
49
+
50
+
51
+ def _js_json(val: object) -> str:
52
+ """Serialize JSON safely for inline <script> blocks by escaping HTML-closing sequences."""
53
+ return (
54
+ json.dumps(val, ensure_ascii=False)
55
+ .replace("<", "\\u003c")
56
+ .replace(">", "\\u003e")
57
+ .replace("&", "\\u0026")
58
+ .replace("\u2028", "\\u2028")
59
+ .replace("\u2029", "\\u2029")
60
+ )
61
+
62
+
63
+ def _i18n(key: str, **vars_map: object) -> str:
64
+ if not vars_map:
65
+ return f'data-i18n="{_esc(key)}"'
66
+ payload = html.escape(json.dumps(vars_map, ensure_ascii=False), quote=True)
67
+ return f'data-i18n="{_esc(key)}" data-i18n-vars="{payload}"'
68
+
69
+
70
+ def _fmt_pct(val: object, digits: int = 2) -> str:
71
+ if val is None:
72
+ return '<span class="dim">–</span>'
73
+ try:
74
+ num = float(val)
75
+ except (TypeError, ValueError):
76
+ return '<span class="dim">–</span>'
77
+ if num != num:
78
+ return '<span class="dim">–</span>'
79
+ cls = "up" if num > 0 else ("down" if num < 0 else "")
80
+ sign = "+" if num > 0 else ""
81
+ return f'<span class="{cls}">{sign}{num:.{digits}f}%</span>'
82
+
83
+
84
+ def _fmt_num(val: object, digits: int = 1, suffix: str = "", suffix_i18n: str = "") -> str:
85
+ if val is None:
86
+ return '<span class="dim">–</span>'
87
+ try:
88
+ num = float(val)
89
+ except (TypeError, ValueError):
90
+ return '<span class="dim">–</span>'
91
+ if num != num:
92
+ return '<span class="dim">–</span>'
93
+ if suffix_i18n:
94
+ return f'{num:.{digits}f}<span {_i18n(suffix_i18n)}>{_esc(suffix)}</span>'
95
+ return f"{num:.{digits}f}{_esc(suffix)}"
96
+
97
+
98
+ def _render_dist_svg(dist: dict[str, Any] | None) -> str:
99
+ if not isinstance(dist, dict) or not dist:
100
+ return f'<div class="empty" {_i18n("no_dist")}>暂无涨跌幅分布统计</div>'
101
+ counts = [int(dist.get(k) or 0) for k, _, _ in _DIST_BUCKETS]
102
+ max_v = max(1, *counts)
103
+ width, height, top, bot = 360, 120, 18, 22
104
+ bar_h = height - top - bot
105
+ step = width / len(_DIST_BUCKETS)
106
+ bw = step * 0.58
107
+ parts: list[str] = []
108
+ for idx, (key, label, tone) in enumerate(_DIST_BUCKETS):
109
+ val = counts[idx]
110
+ h = max(4.0 if val > 0 else 0.0, (val / max_v) * bar_h)
111
+ x = idx * step + (step - bw) / 2.0
112
+ y = top + (bar_h - h)
113
+ fill = "var(--up)" if tone == "up" else ("var(--down)" if tone == "down" else "var(--muted)")
114
+ parts.append(
115
+ f'<rect x="{x:.1f}" y="{y:.1f}" width="{bw:.1f}" height="{h:.1f}" rx="3" fill="{fill}" opacity="0.88"/>'
116
+ )
117
+ parts.append(
118
+ f'<text x="{x + bw / 2:.1f}" y="{max(12.0, y - 4):.1f}" text-anchor="middle" font-size="10" '
119
+ f'font-family="var(--font-mono)" fill="var(--ink-2)">{val}</text>'
120
+ )
121
+ flat_attr = ' data-dist-flat="1"' if key == "flat" else ""
122
+ parts.append(
123
+ f'<text{flat_attr} x="{x + bw / 2:.1f}" y="{height - 5}" text-anchor="middle" font-size="10" '
124
+ f'font-family="var(--font-mono)" fill="var(--muted)">{_esc(label)}</text>'
125
+ )
126
+ return f'<svg class="dist-svg" viewBox="0 0 {width} {height}" role="img">{"".join(parts)}</svg>'
127
+
128
+
129
+ def _render_mini_kline_svg(bars: list[Any] | None) -> str:
130
+ if not isinstance(bars, list) or not bars:
131
+ return '<span class="dim">–</span>'
132
+ parsed: list[tuple[float, float, float, float]] = []
133
+ for item in bars:
134
+ if isinstance(item, (list, tuple)) and len(item) >= 4:
135
+ try:
136
+ parsed.append((float(item[0]), float(item[1]), float(item[2]), float(item[3])))
137
+ except (TypeError, ValueError):
138
+ continue
139
+ if not parsed:
140
+ return '<span class="dim">–</span>'
141
+ lo = min(b[2] for b in parsed)
142
+ hi = max(b[1] for b in parsed)
143
+ span = max(hi - lo, hi * 0.005, 1e-6)
144
+ w, h, pad = 96, 28, 2
145
+ step = (w - pad * 2) / len(parsed)
146
+ bw = max(1.8, step * 0.65)
147
+ shapes: list[str] = []
148
+ for i, (o, hi_p, lo_p, c) in enumerate(parsed):
149
+ cx = pad + (i + 0.5) * step
150
+ col = "var(--up)" if c >= o else "var(--down)"
151
+ y_hi = pad + (1.0 - (hi_p - lo) / span) * (h - pad * 2)
152
+ y_lo = pad + (1.0 - (lo_p - lo) / span) * (h - pad * 2)
153
+ y_top = pad + (1.0 - (max(o, c) - lo) / span) * (h - pad * 2)
154
+ y_bot = pad + (1.0 - (min(o, c) - lo) / span) * (h - pad * 2)
155
+ bh = max(1.4, y_bot - y_top)
156
+ shapes.append(f'<line x1="{cx:.1f}" x2="{cx:.1f}" y1="{y_hi:.1f}" y2="{y_lo:.1f}" stroke="{col}" stroke-width="1"/>')
157
+ shapes.append(f'<rect x="{cx - bw / 2:.1f}" y="{y_top:.1f}" width="{bw:.1f}" height="{bh:.1f}" rx="0.5" fill="{col}"/>')
158
+ return f'<svg class="kline" viewBox="0 0 {w} {h}" aria-label="{len(parsed)}D">{"".join(shapes)}</svg>'
159
+
160
+
161
+ def _render_ladder(ladder: dict[str, Any] | None) -> str:
162
+ if not isinstance(ladder, dict) or not ladder:
163
+ return f'<div class="empty" {_i18n("ladder_empty")}>今日无非 ST 连板或首板分布</div>'
164
+ items = sorted(((int(k), int(v)) for k, v in ladder.items() if int(v or 0) > 0), reverse=True)
165
+ if not items:
166
+ return f'<div class="empty" {_i18n("ladder_empty")}>今日无非 ST 连板分布</div>'
167
+ max_cnt = max(1, *(cnt for _, cnt in items))
168
+ rows = []
169
+ for board, cnt in items:
170
+ w = max(8.0, (cnt / max_cnt) * 100.0)
171
+ rows.append(
172
+ f'<div class="ladder-row"><span {_i18n("ladder_board", b=board)}>{board}板</span>'
173
+ f'<div class="ladder-track"><div class="ladder-fill" style="width:{w:.1f}%"></div></div>'
174
+ f'<span class="ladder-num" {_i18n("ladder_cnt", n=cnt)}>{cnt} 只</span></div>'
175
+ )
176
+ return f'<div class="ladder-list">{"".join(rows)}</div>'
177
+
178
+
179
+ def _render_case_studies(track_summary: dict[str, Any] | None) -> str:
180
+ if not isinstance(track_summary, dict):
181
+ return ""
182
+ comparisons = track_summary.get("track_comparison") or []
183
+ cards: list[str] = []
184
+ for cmp in comparisons:
185
+ if not isinstance(cmp, dict):
186
+ continue
187
+ windows = cmp.get("windows") or {}
188
+ win = windows.get("5") or next(iter(windows.values()), {})
189
+ cases = (win or {}).get("ai_case_studies") or {}
190
+ adds = cases.get("best_ai_adds") or []
191
+ avoids = cases.get("best_ai_avoids") or []
192
+ misses = cases.get("missed_by_ai") or []
193
+ if not (adds or avoids or misses):
194
+ continue
195
+ strat_key = str(cmp.get("strategy") or "")
196
+ strat = (track_summary.get("strategy_names") or {}).get(strat_key, strat_key)
197
+ bits: list[str] = []
198
+ if adds:
199
+ bits.append(
200
+ f'<li><b {_i18n("case_adds")}>AI 独选高光:</b>'
201
+ + ";".join(f"{_esc(x.get('date'))} {_esc(x.get('name'))}({_esc(x.get('code'))}) {_fmt_pct(x.get('excess_return_pct'))}" for x in adds)
202
+ + "</li>"
203
+ )
204
+ if avoids:
205
+ bits.append(
206
+ f'<li><b {_i18n("case_avoids")}>AI 避坑剔除:</b>'
207
+ + ";".join(f"{_esc(x.get('date'))} {_esc(x.get('name'))}({_esc(x.get('code'))}) {_fmt_pct(x.get('excess_return_pct'))}" for x in avoids)
208
+ + "</li>"
209
+ )
210
+ if misses:
211
+ bits.append(
212
+ f'<li><b {_i18n("case_misses")}>AI 错杀遗憾:</b>'
213
+ + ";".join(f"{_esc(x.get('date'))} {_esc(x.get('name'))}({_esc(x.get('code'))}) {_fmt_pct(x.get('excess_return_pct'))}" for x in misses)
214
+ + "</li>"
215
+ )
216
+ cards.append(
217
+ f'<div class="card"><div class="card-top"><h3><span data-strategy="{_esc(strat_key)}">{_esc(strat)}</span><span class="badge ai" {_i18n("case_badge")}>T+5 实盘案例</span></h3></div>'
218
+ f'<ul class="bullet-list" style="padding:10px 14px 12px 28px;margin:0;">{"".join(bits)}</ul></div>'
219
+ )
220
+ if not cards:
221
+ return ""
222
+ return f'<div style="margin-top:14px;"><h3 class="subhead" {_i18n("case_section_title")}>历史同日配对 · AI 个股级案例复盘</h3><div class="grid">{"".join(cards)}</div></div>'
223
+
224
+
225
+ def render_daily_report_html(
226
+ report: dict[str, Any],
227
+ *,
228
+ track_summary: dict[str, Any] | None = None,
229
+ ) -> str:
230
+ """Render a standalone, dependency-free, printable HTML daily research report."""
231
+ trade_date = _esc(report.get("trade_date") or "-")
232
+ pack_date = _esc(report.get("pack_trade_date") or "-")
233
+ detail_url = _safe_detail_url(report.get("detail_url"), fallback="../index.html")
234
+ is_stale = bool(report.get("pack_is_stale"))
235
+ stale_reason = str(report.get("stale_reason") or "").strip()
236
+
237
+ reg = report.get("market_regime") or {}
238
+ syn = report.get("cross_strategy_synthesis") or {}
239
+ brief = report.get("ai_brief") or {}
240
+ ann = report.get("announcement_risks") or {}
241
+ strategies = report.get("strategies") or []
242
+ ai_hl = report.get("ai_highlights") or []
243
+ pat_sec = report.get("patterns") or {}
244
+ degradation = report.get("degradation") or []
245
+ summary_names = (track_summary.get("strategy_names") or {}) if isinstance(track_summary, dict) else {}
246
+ report_names = report.get("strategy_display_names") if isinstance(report.get("strategy_display_names"), dict) else {}
247
+ strategy_names = resolve_strategy_display_names(overrides={**report_names, **summary_names})
248
+
249
+ def _sname_span(key: object) -> str:
250
+ raw = "" if key is None else str(key)
251
+ label = strategy_names.get(raw) or raw
252
+ return f'<span data-strategy="{_esc(raw)}">{_esc(label)}</span>'
253
+
254
+ # 1. Brief / Executive Summary
255
+ brief_mode = str(brief.get("mode") or "rule_fallback")
256
+ brief_model = str(brief.get("model") or "LLM")
257
+ brief_badge = (
258
+ f'<span class="badge ai" {_i18n("brief_badge_llm", model=brief_model)}>AI 深度合成 · {_esc(brief_model)}</span>'
259
+ if brief_mode == "llm"
260
+ else f'<span class="badge accent" {_i18n("brief_badge_rule")}>规则统计合成</span>'
261
+ )
262
+ warn_items = "".join(f"<li>{_esc(w)}</li>" for w in (brief.get("risk_warnings") or []))
263
+ watch_items = "".join(f"<li>{_esc(w)}</li>" for w in (brief.get("watch_points") or []))
264
+ brief_block = f"""
265
+ <section class="panel brief-box">
266
+ <div class="sec-head"><h2 {_i18n("sec_brief")}>盘后要点综述</h2>{brief_badge}</div>
267
+ <div class="brief-headline">{_esc(brief.get("headline") or "暂无摘要")}</div>
268
+ <div class="grid two-col">
269
+ <div class="sub-panel">
270
+ <h3 class="subhead" {_i18n("sub_regime")}>盘面宽度与情绪</h3>
271
+ <p class="prose">{_esc(brief.get("regime_interpretation") or "-")}</p>
272
+ </div>
273
+ <div class="sub-panel">
274
+ <h3 class="subhead" {_i18n("sub_consensus")}>策略共振与 AI 观察</h3>
275
+ <p class="prose">{_esc(brief.get("consensus_and_ai_edge") or "-")}</p>
276
+ </div>
277
+ </div>
278
+ <div class="grid two-col" style="margin-top:10px;">
279
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_risk")}>风险提示</h3><ul class="bullet-list">{warn_items or f'<li {_i18n("empty_warn")}>无额外提示</li>'}</ul></div>
280
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_watch")}>次日观察点</h3><ul class="bullet-list">{watch_items or f'<li {_i18n("empty_watch")}>关注开盘量能变化</li>'}</ul></div>
281
+ </div>
282
+ </section>
283
+ """
284
+
285
+ # 2. Panorama Section
286
+ adv_pct = _fmt_num(reg.get("advance_ratio_pct"), 1, "%")
287
+ med_pct = _fmt_pct(reg.get("median_return_pct"))
288
+ amt_str = _fmt_num(reg.get("total_amount_yi"), 0, " 亿", suffix_i18n="unit_yi")
289
+ seal_str = _fmt_num(reg.get("seal_rate_pct"), 1, "%")
290
+ prev_lu = _fmt_pct(reg.get("prev_limit_up_avg_return_pct"))
291
+ lu = int(reg.get("non_st_limit_up_count") or 0)
292
+ ld = int(reg.get("non_st_limit_down_count") or 0)
293
+ max_streak = int(reg.get("max_consecutive_limit_up") or 0)
294
+ reg_code = str(reg.get("regime_stage") or "-")
295
+ reg_label = str(reg.get("regime_stage_label") or "-")
296
+ stage_txt = f"盘面 · {_esc(reg_label)}"
297
+
298
+ panorama_block = f"""
299
+ <section class="panel" style="padding:0;overflow:hidden;">
300
+ <div class="sec-head" style="padding:14px 18px 10px;margin:0;">
301
+ <h2 {_i18n("sec_panorama", d=report.get("trade_date") or "-")}>A 股盘面全景({trade_date})</h2>
302
+ <span class="badge accent" data-regime="{_esc(reg_code)}" data-regime-raw="{_esc(reg_label)}">{stage_txt}</span>
303
+ </div>
304
+ <div class="kpi-strip">
305
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_adv")}>上涨占比</div><div class="val">{adv_pct}</div><div class="sub" {_i18n("kpi_adv_sub", adv=int(reg.get('advancing_count') or 0), dec=int(reg.get('declining_count') or 0))}>涨 {int(reg.get('advancing_count') or 0)} / 跌 {int(reg.get('declining_count') or 0)}</div></div>
306
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_med")}>全市场中位数</div><div class="val">{med_pct}</div><div class="sub" {_i18n("kpi_med_sub", n=int(reg.get('traded_count') or 0))}>成交 {int(reg.get('traded_count') or 0)} 只</div></div>
307
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_amt")}>两市成交额</div><div class="val">{amt_str}</div><div class="sub" {_i18n("kpi_amt_sub", seal=f"{float(reg.get('seal_rate_pct') or 0):.1f}%" if reg.get("seal_rate_pct") is not None else "–")}>封板率 {seal_str}</div></div>
308
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_luld")}>非ST 涨停 / 跌停</div><div class="val"><span class="up">{lu}</span> / <span class="down">{ld}</span></div><div class="sub" {_i18n("kpi_luld_sub", up=int(reg.get('one_price_limit_up_count') or 0), dn=int(reg.get('one_price_limit_down_count') or 0))}>一字 {int(reg.get('one_price_limit_up_count') or 0)}/{int(reg.get('one_price_limit_down_count') or 0)}</div></div>
309
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_streak")}>连板最高</div><div class="val" {_i18n("kpi_streak_val", n=max_streak)}>{max_streak} 板</div><div class="sub" {_i18n("kpi_streak_sub", n=int(reg.get('non_st_broken_board_count') or 0))}>炸板 {int(reg.get('non_st_broken_board_count') or 0)} 只</div></div>
310
+ <div class="kpi-cell"><div class="lbl" {_i18n("kpi_prevlu")}>昨涨停今日均收益</div><div class="val">{prev_lu}</div><div class="sub" {_i18n("kpi_prevlu_sub", win=f"{float(reg.get('prev_limit_up_win_rate_pct') or 0):.1f}%" if reg.get("prev_limit_up_win_rate_pct") is not None else "–")}>红盘率 {_fmt_num(reg.get('prev_limit_up_win_rate_pct'), 1, '%')}</div></div>
311
+ </div>
312
+ <div class="grid two-col" style="padding:14px 18px 18px;">
313
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_dist")}>7 档涨跌幅分布</h3>{_render_dist_svg(reg.get("return_distribution"))}</div>
314
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_ladder")}>连板高度梯队</h3>{_render_ladder(reg.get("consecutive_board_ladder"))}</div>
315
+ </div>
316
+ </section>
317
+ """
318
+
319
+ # 3. Announcement Risk Alerts & Spotlight
320
+ flagged = ann.get("flagged_items") or []
321
+ spotlight = syn.get("risk_spotlight") or []
322
+ checked = int(ann.get("checked_count") or 0)
323
+ if flagged:
324
+ flag_cards_parts: list[str] = []
325
+ for x in flagged:
326
+ ann_date = str(x.get("announcement_date") or "").strip()
327
+ recency = str(x.get("recency") or "").strip()
328
+ date_chip = f'<span class="badge">{_esc(ann_date)}</span> ' if ann_date else ""
329
+ old_chip = f'<span class="badge warn" {_i18n("ann_old")}>历史进展</span> ' if recency == "old" else ""
330
+ snip = x.get("matched_announcement") or x.get("announcement_summary") or "触发公告负面关键词"
331
+ flag_cards_parts.append(
332
+ f'<div class="alert-card"><b>{_esc(x.get("code"))} {_esc(x.get("name"))}</b> '
333
+ f'{date_chip}{old_chip}'
334
+ f'<span class="badge bad">{_esc("/".join(x.get("negative_event_flags") or []))}</span>'
335
+ f'<div class="small dim" style="margin-top:3px;">{_esc(snip)}</div></div>'
336
+ )
337
+ flag_cards = "".join(flag_cards_parts)
338
+ elif checked > 0:
339
+ flag_cards = f'<div class="ok-box" {_i18n("ann_ok", n=checked)}>✓ 已核验 {checked} 只重点候选,暂未发现减持 / 立案 / 退市等负面关键词。</div>'
340
+ else:
341
+ flag_cards = f'<div class="dim small" {_i18n("ann_skipped")}>本期日报跳过公告抽检或无候选股。</div>'
342
+ extra_risk = "".join(
343
+ f'<li>{_esc(r.get("code"))} {_esc(r.get("name"))} <span class="badge">{_esc("/".join(r.get("flags") or []))}</span></li>'
344
+ for r in spotlight
345
+ if r.get("source") != "announcement"
346
+ )
347
+ ann_block = f"""
348
+ <section class="panel {'alert-hot' if flagged else ''}">
349
+ <div class="sec-head">
350
+ <h2 {_i18n("sec_ann")}>⚠️ 公告排雷与风险聚焦</h2>
351
+ <span class="badge {'bad' if flagged else ''}" {_i18n("ann_badge", c=checked, f=len(flagged))}>抽检 {checked} · 高风险 {len(flagged)}</span>
352
+ </div>
353
+ {flag_cards}
354
+ {f'<div style="margin-top:8px;"><span class="small dim" {_i18n("ann_extra")}>候选附加风控标签:</span><ul class="bullet-list">{extra_risk}</ul></div>' if extra_risk else ""}
355
+ </section>
356
+ """
357
+
358
+ # 3b. Market News & Catalysts (when collected)
359
+ mnews = report.get("market_news") or {}
360
+ news_items = mnews.get("items") or []
361
+ news_sources = " · ".join(str(s) for s in (mnews.get("sources") or []) if s)
362
+ if news_items:
363
+ n_rows = "".join(
364
+ f'<li><span class="badge">{_esc(it.get("category") or "要闻")}</span> '
365
+ f'<b>{_esc(it.get("title"))}</b> '
366
+ f'<span class="dim small">{_esc(it.get("source") or "")} {_esc(it.get("published_at") or "")}</span></li>'
367
+ for it in news_items[:6]
368
+ if isinstance(it, dict) and it.get("title")
369
+ )
370
+ news_block = f"""
371
+ <section class="panel">
372
+ <div class="sec-head">
373
+ <h2 {_i18n("sec_news")}>📰 市场热点与政策快讯</h2>
374
+ {f'<span class="badge">{_esc(news_sources)}</span>' if news_sources else ""}
375
+ </div>
376
+ <ul class="bullet-list">{n_rows}</ul>
377
+ </section>
378
+ """
379
+ else:
380
+ news_block = ""
381
+
382
+ # 4. Cross-strategy Consensus, Sector Concentration & AI Attribution
383
+ consensus = syn.get("consensus_picks") or []
384
+ if consensus:
385
+ c_rows_parts: list[str] = []
386
+ for idx, c in enumerate(consensus, start=1):
387
+ ann_str = _esc("/".join(c.get("announcement_risk_flags") or [])) or '<span class="dim">–</span>'
388
+ strat_list = list(c.get("strategies") or [])
389
+ strat_badges = "".join(f'<span class="badge">{_sname_span(st)}</span>' for st in strat_list[:3])
390
+ if len(strat_list) > 3:
391
+ strat_badges += f' <span class="dim small">+{len(strat_list) - 3}</span>'
392
+ val_parts: list[str] = []
393
+ if c.get("price") is not None:
394
+ val_parts.append(f'¥{float(c["price"]):.2f}')
395
+ if c.get("pe_ratio") is not None:
396
+ val_parts.append(f'PE {float(c["pe_ratio"]):.1f}')
397
+ if c.get("pb_ratio") is not None:
398
+ val_parts.append(f'PB {float(c["pb_ratio"]):.2f}')
399
+ val_sub = f'<div class="small dim mono">{" · ".join(val_parts)}</div>' if val_parts else ""
400
+ reason_sub = ""
401
+ if c.get("reasons"):
402
+ reason_sub = f'<div class="small dim">{_esc(";".join(str(r) for r in c["reasons"][:1]))}</div>'
403
+ c_rows_parts.append(
404
+ f'<tr><td><span class="rank-num {"top" if idx <= 3 else ""}">{idx}</span></td>'
405
+ f'<td class="l"><strong>{_esc(c.get("name"))}</strong> <span class="mono dim small">{_esc(c.get("code"))}</span>{val_sub}{reason_sub}</td>'
406
+ f'<td class="l dim">{_esc(c.get("industry"))}</td>'
407
+ f'<td><span class="badge accent" {_i18n("n_strats", n=int(c.get("strategy_count") or 0))}>{int(c.get("strategy_count") or 0)} 策略</span></td>'
408
+ f'<td class="l">{strat_badges}</td>'
409
+ f'<td class="mono">{_fmt_num(c.get("avg_final_score"), 1)}</td>'
410
+ f'<td class="mono">{_fmt_pct(c.get("change_pct"))}</td>'
411
+ f'<td class="l">{ann_str}</td></tr>'
412
+ )
413
+ consensus_html = (
414
+ '<div class="scroll"><table><thead><tr><th>#</th>'
415
+ f'<th class="l" {_i18n("col_stock")}>股票</th>'
416
+ f'<th class="l" {_i18n("col_ind")}>行业</th>'
417
+ f'<th {_i18n("col_hits")}>命中策略数</th>'
418
+ f'<th class="l" {_i18n("col_strats")}>覆盖策略</th>'
419
+ f'<th {_i18n("col_score")}>均分</th>'
420
+ f'<th {_i18n("col_chg")}>涨跌</th>'
421
+ f'<th class="l" {_i18n("col_ann")}>公告预警</th></tr></thead>'
422
+ f'<tbody>{"".join(c_rows_parts)}</tbody></table></div>'
423
+ )
424
+ else:
425
+ consensus_html = f'<div class="empty" {_i18n("no_consensus")}>今日暂无 ≥2 个策略同时选中的共识标的。</div>'
426
+
427
+ sectors = syn.get("sector_concentration") or []
428
+ sector_html = (
429
+ "".join(
430
+ f'<div class="ladder-row"><span>{_esc(s.get("industry"))}</span>'
431
+ f'<div class="ladder-track"><div class="ladder-fill accent-bg" style="width:{min(100.0, float(s.get("share_pct") or 0.0)):.1f}%"></div></div>'
432
+ f'<span class="ladder-num">{int(s.get("pick_count") or 0)} ({_fmt_num(s.get("share_pct"), 1, "%")})</span></div>'
433
+ for s in sectors
434
+ )
435
+ or f'<div class="dim small" {_i18n("no_sector")}>暂无行业分布</div>'
436
+ )
437
+
438
+ ai_cards_parts: list[str] = []
439
+ none_span = f'<span {_i18n("none_lbl")}>无</span>'
440
+ for h in ai_hl:
441
+ overlap_txt = f"{float(h.get('overlap_pct')):.1f}%" if h.get("overlap_pct") is not None else "–"
442
+ mv = h.get("llm_market_view")
443
+ view_html = f'<div><b {_i18n("ai_view")}>市场观点:</b>{_esc(mv)}</div>' if mv else ""
444
+ added_names = "、".join(f'{x.get("name")}({x.get("code")})' for x in (h.get("added_by_ai") or []))
445
+ dropped_names = "、".join(f'{x.get("name")}({x.get("code")})' for x in (h.get("dropped_by_ai") or []))
446
+ added_html = _esc(added_names) if added_names else none_span
447
+ dropped_html = _esc(dropped_names) if dropped_names else none_span
448
+ ai_cards_parts.append(
449
+ f'<div class="card"><div class="card-top"><h3>{_sname_span(h.get("strategy"))}<span class="badge ai" {_i18n("ai_rebalance")}>AI 调仓</span></h3>'
450
+ f'<div class="sub" {_i18n("ai_sub", ov=overlap_txt, r=int(h.get("rules_pick_count") or 0), a=int(h.get("ai_pick_count") or 0))}>重合度 {overlap_txt} · 规则 {int(h.get("rules_pick_count") or 0)} / AI {int(h.get("ai_pick_count") or 0)}</div></div>'
451
+ f'<div class="prose small" style="padding:10px 14px;">{view_html}'
452
+ f'<div><b {_i18n("ai_add")}>AI 新增:</b>{added_html}</div>'
453
+ f'<div><b {_i18n("ai_drop")}>AI 剔除:</b>{dropped_html}</div>'
454
+ "</div></div>"
455
+ )
456
+ ai_cards = "".join(ai_cards_parts)
457
+
458
+ resonance = syn.get("strategy_pattern_resonance") or []
459
+ res_items: list[str] = []
460
+ for r in resonance:
461
+ strat_spans = ", ".join(_sname_span(s) for s in (r.get("strategies") or []))
462
+ pat_list = [*(r.get("active_patterns") or []), *(r.get("experimental_patterns") or [])]
463
+ pat_spans = ", ".join(f'<span data-pattern="{_esc(p)}">{_esc(p)}</span>' for p in pat_list)
464
+ res_items.append(
465
+ f'<li><b>{_esc(r.get("code"))} {_esc(r.get("name"))}</b> · '
466
+ f'<span {_i18n("res_strat")}>策略</span>[{strat_spans}] × '
467
+ f'<span {_i18n("res_pat")}>形态</span>[{pat_spans}]</li>'
468
+ )
469
+ res_html = (
470
+ f'<ul class="bullet-list">{"".join(res_items)}</ul>'
471
+ if res_items
472
+ else f'<div class="dim small" {_i18n("no_resonance")}>今日策略候选与扫描形态暂无重叠个股。</div>'
473
+ )
474
+
475
+ synthesis_block = f"""
476
+ <section class="panel">
477
+ <div class="sec-head"><h2 {_i18n("sec_syn")}>跨策略共识、行业分布与 AI 归因</h2></div>
478
+ <h3 class="subhead" {_i18n("sub_multi_cons")}>多策略共识标的</h3>
479
+ {consensus_html}
480
+ <div class="grid two-col" style="margin-top:12px;">
481
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_sector_conc")}>候选行业集中度</h3><div class="ladder-list">{sector_html}</div></div>
482
+ <div class="sub-panel"><h3 class="subhead" {_i18n("sub_res")}>策略 × 形态共振观察</h3>{res_html}</div>
483
+ </div>
484
+ {f'<div style="margin-top:12px;"><h3 class="subhead" {_i18n("sub_ai_today")}>今日 AI 调仓对比</h3><div class="grid">{ai_cards}</div></div>' if ai_cards else ""}
485
+ {_render_case_studies(track_summary)}
486
+ </section>
487
+ """
488
+
489
+ # 5. Strategy Picks Full Cards
490
+ strat_cards = []
491
+ for st in strategies:
492
+ tr = "ai" if st.get("track") == "ai" or st.get("llm_ranked") else "rules"
493
+ badge = '<span class="badge ai">AI</span>' if tr == "ai" else f'<span class="badge" {_i18n("badge_rules")}>规则</span>'
494
+ picks = st.get("picks") or []
495
+ if picks:
496
+ rows = "".join(
497
+ f'<tr><td><span class="rank-num {"top" if int(pk.get("rank") or 9) <= 3 else ""}">{int(pk.get("rank") or 0)}</span></td>'
498
+ f'<td class="l"><strong>{_esc(pk.get("name"))}</strong> <span class="mono dim small">{_esc(pk.get("code"))}</span></td>'
499
+ f'<td class="l dim">{_esc(pk.get("industry"))}</td>'
500
+ f'<td class="mono">{_fmt_num(pk.get("final_score"), 1)}</td>'
501
+ f'<td class="mono">{_fmt_pct(pk.get("change_pct"))}</td>'
502
+ f'<td class="l small">{_esc("/".join(pk.get("announcement_risk_flags") or [])) or _esc(pk.get("ranking_reason") or "–")}</td></tr>'
503
+ for pk in picks
504
+ )
505
+ tbl = (
506
+ '<div class="scroll"><table><thead><tr><th>#</th>'
507
+ f'<th class="l" {_i18n("col_stock")}>股票</th>'
508
+ f'<th class="l" {_i18n("col_ind")}>行业</th>'
509
+ f'<th {_i18n("col_total_score")}>综合分</th>'
510
+ f'<th {_i18n("col_chg")}>涨跌</th>'
511
+ f'<th class="l" {_i18n("col_note")}>备注/风险</th></tr></thead>'
512
+ f"<tbody>{rows}</tbody></table></div>"
513
+ )
514
+ else:
515
+ tbl = f'<div class="empty" {_i18n("no_picks")}>无入选股票</div>'
516
+ n_picks = int(st.get("pick_count") or len(picks))
517
+ strat_cards.append(
518
+ f'<div class="card"><div class="card-top"><h3>{_sname_span(st.get("strategy"))}{badge}</h3>'
519
+ f'<div class="sub" {_i18n("strat_picks_cnt", n=n_picks)}>入选 {n_picks} 只</div></div>{tbl}</div>'
520
+ )
521
+ strat_block = f"""
522
+ <section class="panel">
523
+ <div class="sec-head"><h2 {_i18n("sec_strats")}>今日策略精选全览</h2><span class="badge" {_i18n("strat_runs_badge", n=len(strategies))}>{len(strategies)} 组运行</span></div>
524
+ {f'<div class="grid">{"".join(strat_cards)}</div>' if strat_cards else f'<div class="empty" {_i18n("no_strats")}>未附加策略运行结果。</div>'}
525
+ </section>
526
+ """
527
+
528
+ # 6. Pattern Radar Cards (active + expectancy-tiered experimental)
529
+ pat_cards = []
530
+ for bucket, is_active in (("active", True), ("experimental", False)):
531
+ pats_list = list(pat_sec.get(bucket) or [])
532
+ if not is_active:
533
+ pats_list.sort(
534
+ key=lambda p: (
535
+ 0 if p.get("expectancy_tier") == "positive_watch" else (1 if p.get("expectancy_tier") != "negative_watch" else 2),
536
+ -int(p.get("hit_count") or 0),
537
+ )
538
+ )
539
+ for pat in pats_list:
540
+ pkey = str(pat.get("pattern") or "")
541
+ dname = str(pat.get("display_name") or pkey)
542
+ exp_tier = str(pat.get("expectancy_tier") or "")
543
+ badge = '<span class="badge active">active</span>' if is_active else (
544
+ '<span class="badge warn">负期望·观察</span>'
545
+ if exp_tier == "negative_watch"
546
+ else '<span class="badge">观察期</span>'
547
+ )
548
+ net_ex = pat.get("replay_t5_net_excess_pct")
549
+ replay_note = (
550
+ f' · T+5净超额 {float(net_ex):+.2f}%'
551
+ if net_ex is not None
552
+ else ""
553
+ )
554
+ sigs = pat.get("signals") or []
555
+ if sigs:
556
+ s_rows = "".join(
557
+ f'<tr><td class="l"><strong>{_esc(s.get("name"))}</strong> <span class="mono dim small">{_esc(s.get("code"))}</span></td>'
558
+ f'<td class="mono">{_fmt_pct(s.get("change_pct"))}</td>'
559
+ f'<td class="dim mono">{_fmt_num(s.get("overhead_supply_10pct"), 0, "%")}</td>'
560
+ f'<td>{_render_mini_kline_svg(s.get("kline"))}</td></tr>'
561
+ for s in sigs[:8]
562
+ )
563
+ body = (
564
+ '<div class="scroll"><table><thead><tr>'
565
+ f'<th class="l" {_i18n("col_stock")}>股票</th>'
566
+ f'<th {_i18n("col_chg")}>涨跌</th>'
567
+ f'<th {_i18n("col_overhead")}>上方套牢</th>'
568
+ f'<th {_i18n("col_kline")}>近20日K线</th></tr></thead><tbody>{s_rows}</tbody></table></div>'
569
+ )
570
+ else:
571
+ body = f'<div class="empty" {_i18n("no_pat_sig")}>今日无触发信号</div>'
572
+ hits_n = int(pat.get("hit_count") or 0)
573
+ pat_cards.append(
574
+ f'<div class="card {"muted-card" if not is_active else ""}"><div class="card-top"><h3><span data-pattern="{_esc(pkey)}">{_esc(dname)}</span>{badge}</h3>'
575
+ f'<div class="sub"><span {_i18n("pat_hits_cnt", n=hits_n)}>命中 {hits_n} 只</span>{replay_note}</div></div>{body}</div>'
576
+ )
577
+ pat_block = f"""
578
+ <section class="panel">
579
+ <div class="sec-head"><h2 {_i18n("sec_patterns")}>无状态形态雷达命中</h2></div>
580
+ <div class="grid">{"".join(pat_cards) if pat_cards else f'<div class="empty" {_i18n("no_pats")}>无形态扫描记录</div>'}</div>
581
+ </section>
582
+ """
583
+
584
+ stale_html = (
585
+ f'<div class="stale-banner" {_i18n("stale_banner", pack=pack_date, exp=str(report.get("expected_trade_date") or "-"), reason=stale_reason)}>⚠️ <b>旧包降级模式</b>:数据包日期 <code>{pack_date}</code> 落后于目标交易日 '
586
+ f'<code>{_esc(report.get("expected_trade_date"))}</code>({_esc(stale_reason)}),数据仅供观察,已自动拦截未强制 IM 推送。</div>'
587
+ if is_stale
588
+ else ""
589
+ )
590
+ deg_html = (
591
+ f'<div class="notice"><span {_i18n("deg_prefix")}>降级说明:</span>{";".join(_esc(d) for d in degradation)}</div>'
592
+ if degradation
593
+ else ""
594
+ )
595
+
596
+ return f"""<!doctype html>
597
+ <html lang="zh-CN">
598
+ <head>
599
+ <meta charset="utf-8">
600
+ <meta name="viewport" content="width=device-width, initial-scale=1">
601
+ <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%23090d16'/%3E%3Cpath d='M6 8h20l-7.5 8.8v6.6l-5 2.4V16.8L6 8z' fill='%233b82f6' fill-opacity='.25' stroke='%2360a5fa' stroke-width='2.2' stroke-linejoin='round'/%3E%3Ccircle cx='23' cy='23' r='2.5' fill='%2334d399'/%3E%3C/svg%3E">
602
+ <title>AlphaSift · A 股盘后投研日报 ({trade_date})</title>
603
+ <style>
604
+ :root {{
605
+ --bg: #09090b; --surface: #111115; --sub: #17171d; --ink: #f4f4f5; --ink-2: #d4d4d8;
606
+ --muted: #8e8e9a; --border: rgba(255,255,255,0.085); --border-strong: rgba(255,255,255,0.16);
607
+ --glass: rgba(9,9,11,0.82); --accent: #3b82f6; --accent-hi: #60a5fa; --accent-soft: rgba(59,130,246,0.14);
608
+ --up: #f87171; --up-soft: rgba(248,113,113,0.12);
609
+ --down: #34d399; --down-soft: rgba(52,211,153,0.12);
610
+ --warn: #fbbf24; --warn-soft: rgba(251,191,36,0.14); --chip: rgba(255,255,255,0.06);
611
+ --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Kaku Gothic ProN", sans-serif;
612
+ --font-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
613
+ }}
614
+ :root[data-theme="light"] {{
615
+ --bg: #fafafa; --surface: #ffffff; --sub: #f4f4f5; --ink: #09090b; --ink-2: #27272a;
616
+ --muted: #52525b; --border: rgba(9,9,11,0.09); --border-strong: rgba(9,9,11,0.18);
617
+ --glass: rgba(250,250,250,0.88); --accent: #1d4ed8; --accent-hi: #2563eb; --accent-soft: rgba(37,99,235,0.1);
618
+ --up: #dc2626; --up-soft: rgba(220,38,38,0.09);
619
+ --down: #059669; --down-soft: rgba(5,150,105,0.1);
620
+ --warn: #b45309; --warn-soft: rgba(180,83,9,0.1); --chip: rgba(9,9,11,0.055);
621
+ }}
622
+ * {{ box-sizing: border-box; }}
623
+ body {{
624
+ margin: 0; background-color: var(--bg); color: var(--ink);
625
+ background-image: radial-gradient(ellipse 75% 340px at 50% -60px, var(--accent-soft), transparent 72%);
626
+ font: 13.5px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased;
627
+ }}
628
+ a {{ color: var(--accent-hi); text-decoration: none; }}
629
+ a:hover {{ text-decoration: underline; }}
630
+ code {{ font-family: var(--font-mono); font-size: 0.9em; background: var(--chip); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border); }}
631
+ .topbar {{
632
+ position: sticky; top: 0; z-index: 40;
633
+ background: var(--glass); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px);
634
+ }}
635
+ .topbar-inner {{
636
+ max-width: 1180px; margin: 0 auto; padding: 10px 20px;
637
+ display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
638
+ }}
639
+ .brand {{ display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; color: var(--ink); }}
640
+ .brand-mark {{
641
+ width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
642
+ background: var(--sub); border: 1px solid var(--border-strong); color: var(--accent-hi);
643
+ }}
644
+ .actions {{ display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }}
645
+ .btn-link, .theme-btn, .github-btn {{
646
+ display: inline-flex; align-items: center; gap: 6px;
647
+ border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
648
+ border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; text-decoration: none;
649
+ }}
650
+ .btn-link:hover, .theme-btn:hover {{ border-color: var(--border-strong); color: var(--ink); text-decoration: none; }}
651
+ .github-btn {{ background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }}
652
+ .github-btn:hover {{ opacity: 0.9; text-decoration: none; color: var(--bg); }}
653
+
654
+ .lang-switch {{
655
+ display: inline-flex; align-items: center;
656
+ border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 2px; gap: 2px;
657
+ }}
658
+ .lang-switch button {{
659
+ border: 0; background: transparent; color: var(--muted);
660
+ padding: 3px 7px; border-radius: 6px; font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
661
+ }}
662
+ .lang-switch button:hover {{ color: var(--ink); background: var(--chip); }}
663
+ .lang-switch button[aria-pressed="true"] {{ background: var(--accent-soft); color: var(--accent-hi); }}
664
+
665
+ main {{ max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }}
666
+ .rpt-header {{
667
+ padding-bottom: 16px; border-bottom: 1px solid var(--border);
668
+ }}
669
+ .rpt-header h1 {{ margin: 4px 0 8px; font-size: clamp(21px, 2.5vw, 27px); letter-spacing: -0.025em; }}
670
+ .eyebrow {{ font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--accent-hi); }}
671
+ .meta-row {{ display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }}
672
+
673
+ .panel {{
674
+ background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
675
+ padding: 16px 18px; margin-top: 18px;
676
+ }}
677
+ .panel.alert-hot {{ border-color: rgba(248,113,113,0.45); }}
678
+ .brief-box {{ border-left: 3px solid var(--accent-hi); }}
679
+ .brief-headline {{ font-size: 16px; font-weight: 700; margin: 4px 0 12px; color: var(--ink); letter-spacing: -0.01em; }}
680
+ .sec-head {{ display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }}
681
+ .sec-head h2 {{ margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }}
682
+ .subhead {{ margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--ink); }}
683
+ .sub-panel {{ background: var(--sub); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; }}
684
+ .grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }}
685
+ .two-col {{ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }}
686
+ .card {{
687
+ background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; break-inside: avoid;
688
+ }}
689
+ .card-top {{ padding: 10px 13px 8px; border-bottom: 1px solid var(--border); background: var(--sub); }}
690
+ .card h3 {{ margin: 0; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }}
691
+ .card .sub {{ font-size: 11.5px; color: var(--muted); margin-top: 2px; font-family: var(--font-mono); }}
692
+ .muted-card {{ opacity: 0.72; }}
693
+
694
+ .kpi-strip {{
695
+ display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px;
696
+ background: var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
697
+ }}
698
+ .kpi-cell {{ background: var(--sub); padding: 11px 13px; }}
699
+ .kpi-cell .lbl {{ font-size: 11px; color: var(--muted); }}
700
+ .kpi-cell .val {{ font-size: 16px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }}
701
+ .kpi-cell .sub {{ font-size: 11px; color: var(--muted); margin-top: 2px; }}
702
+ @media (max-width: 960px) {{ .kpi-strip {{ grid-template-columns: repeat(3, minmax(0, 1fr)); }} }}
703
+ @media (max-width: 600px) {{ .kpi-strip {{ grid-template-columns: repeat(2, minmax(0, 1fr)); }} }}
704
+
705
+ .badge {{
706
+ display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 600;
707
+ background: var(--chip); color: var(--muted); border: 1px solid var(--border); vertical-align: middle;
708
+ }}
709
+ .badge.ai, .badge.accent {{ color: var(--accent-hi); background: var(--accent-soft); border-color: rgba(59,130,246,0.3); }}
710
+ .badge.active, .badge.ok {{ color: var(--down); background: var(--down-soft); border-color: rgba(52,211,153,0.3); }}
711
+ .badge.bad {{ color: var(--up); background: var(--up-soft); border-color: rgba(248,113,113,0.3); }}
712
+ .badge.warn {{ color: var(--warn); background: var(--warn-soft); border-color: rgba(251,191,36,0.3); }}
713
+
714
+ .rank-num {{
715
+ display: inline-flex; align-items: center; justify-content: center;
716
+ min-width: 20px; height: 18px; border-radius: 4px; padding: 0 4px;
717
+ font-family: var(--font-mono); font-size: 11px; font-weight: 600; background: var(--chip); color: var(--muted);
718
+ }}
719
+ .rank-num.top {{ background: var(--accent-soft); color: var(--accent-hi); }}
720
+
721
+ .stale-banner {{
722
+ margin-top: 12px; padding: 10px 14px; border-radius: 9px; background: var(--warn-soft);
723
+ border: 1px solid rgba(251,191,36,0.38); font-size: 12.5px;
724
+ }}
725
+ .notice {{
726
+ margin-top: 12px; padding: 9px 12px; border-radius: 8px; background: var(--surface);
727
+ border: 1px solid var(--border); border-left: 3px solid var(--warn); color: var(--muted); font-size: 12.5px;
728
+ }}
729
+ .alert-card {{
730
+ padding: 10px 12px; border-radius: 8px; background: var(--up-soft); border: 1px solid rgba(248,113,113,0.28); margin-bottom: 8px;
731
+ }}
732
+ .ok-box {{
733
+ padding: 9px 12px; border-radius: 8px; background: var(--down-soft); border: 1px solid rgba(52,211,153,0.25);
734
+ color: var(--down); font-size: 12.5px;
735
+ }}
736
+ .bullet-list {{ margin: 4px 0 0 18px; padding: 0; font-size: 12.5px; color: var(--ink-2); }}
737
+ .bullet-list li {{ margin-bottom: 4px; }}
738
+ .prose {{ margin: 0; font-size: 13px; color: var(--ink-2); }}
739
+ .dist-svg {{ width: 100%; height: 120px; display: block; }}
740
+ .kline {{ width: 96px; height: 28px; display: inline-block; vertical-align: middle; }}
741
+ .ladder-list {{ display: flex; flex-direction: column; gap: 6px; }}
742
+ .ladder-row {{ display: grid; grid-template-columns: 78px 1fr 78px; align-items: center; gap: 8px; font-size: 12px; }}
743
+ .ladder-track {{ background: var(--chip); border-radius: 999px; height: 7px; overflow: hidden; }}
744
+ .ladder-fill {{ height: 100%; border-radius: 999px; background: var(--up); }}
745
+ .accent-bg {{ background: var(--accent-hi); }}
746
+ .ladder-num {{ text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }}
747
+ .scroll {{ overflow-x: auto; }}
748
+ table {{ width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }}
749
+ th, td {{ padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); font-size: 12px; }}
750
+ th {{ color: var(--muted); font-weight: 600; font-size: 11px; background: var(--sub); }}
751
+ th.l, td.l, th:first-child, td:first-child {{ text-align: left; }}
752
+ tr:last-child td {{ border-bottom: 0; }}
753
+ .up {{ color: var(--up); }} .down {{ color: var(--down); }} .dim {{ color: var(--muted); }}
754
+ .small {{ font-size: 11.5px; }} .mono {{ font-family: var(--font-mono); }}
755
+ .ico {{ width: 13.5px; height: 13.5px; display: inline-block; vertical-align: -2px; flex-shrink: 0; }}
756
+ .empty {{ padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }}
757
+ footer {{ margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }}
758
+ @media print {{
759
+ .no-print, .topbar {{ display: none !important; }}
760
+ :root {{ --bg: #ffffff; --surface: #ffffff; --sub: #f8fafc; --ink: #111111; --ink-2: #222222; --muted: #555555; --border: #dddddd; }}
761
+ body {{ background: #ffffff; color: #111111; }}
762
+ main {{ max-width: 100%; padding: 0; }}
763
+ .panel {{ box-shadow: none; break-inside: avoid; border-color: #dddddd; }}
764
+ }}
765
+ </style>
766
+ </head>
767
+ <body>
768
+ <nav class="topbar no-print">
769
+ <div class="topbar-inner">
770
+ <span class="brand">
771
+ <span class="brand-mark" aria-hidden="true">
772
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round">
773
+ <path d="M3 5h18l-7 8v5l-4 2v-7L3 5z"/>
774
+ </svg>
775
+ </span>
776
+ <span {_i18n("brand_title")}>AlphaSift · 盘后研报</span>
777
+ </span>
778
+ <div class="actions">
779
+ <a class="btn-link" id="back-dashboard-link" href="{_esc(detail_url)}">
780
+ <svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
781
+ <span {_i18n("btn_back")}>返回在线看板</span>
782
+ </a>
783
+ <a class="github-btn" href="{_GITHUB_URL}" target="_blank" rel="noopener">
784
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
785
+ <path d="M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.57.11.78-.25.78-.55 0-.27-.01-1.18-.02-2.14-3.2.7-3.87-1.36-3.87-1.36-.52-1.33-1.28-1.68-1.28-1.68-1.05-.72.08-.71.08-.71 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.71 1.26 3.37.96.1-.75.4-1.26.73-1.55-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.09-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.18 1.18a11.06 11.06 0 0 1 5.78 0c2.21-1.49 3.18-1.18 3.18-1.18.63 1.59.23 2.76.11 3.05.74.8 1.19 1.83 1.19 3.09 0 4.42-2.69 5.39-5.26 5.68.41.36.78 1.06.78 2.15 0 1.55-.01 2.8-.01 3.18 0 .31.21.67.79.55C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5z"/>
786
+ </svg>
787
+ <span>GitHub</span>
788
+ </a>
789
+ <button type="button" class="theme-btn" id="print-btn">
790
+ <svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 6 2 18 2 18 9"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="8"/></svg>
791
+ <span {_i18n("btn_print")}>打印 / PDF</span>
792
+ </button>
793
+ <div class="lang-switch" id="lang-switch" role="group" aria-label="Language">
794
+ <button type="button" data-lang="zh" aria-pressed="true">中</button>
795
+ <button type="button" data-lang="en" aria-pressed="false">EN</button>
796
+ <button type="button" data-lang="ja" aria-pressed="false">日</button>
797
+ </div>
798
+ <button type="button" class="theme-btn" id="theme-toggle">亮色</button>
799
+ </div>
800
+ </div>
801
+ </nav>
802
+ <main>
803
+ <header class="rpt-header">
804
+ <div class="eyebrow">OPEN-SOURCE DAILY QUANTITATIVE RESEARCH BRIEF</div>
805
+ <h1 {_i18n("rpt_title")}>AlphaSift · A 股盘后量化投研日报</h1>
806
+ <div class="meta-row">
807
+ <span><span {_i18n("meta_tdate")}>交易日</span> <b>{trade_date}</b></span>
808
+ <span>· <span {_i18n("meta_pdate")}>数据包</span> <code>{pack_date}</code></span>
809
+ <span class="badge {'warn' if is_stale else 'ok'}" {_i18n("badge_stale" if is_stale else "badge_sync")}>{'旧包降级' if is_stale else '数据同步'}</span>
810
+ <span>· <span {_i18n("meta_policy")}>口径:</span><code>{_esc(report.get('usage_policy') or 'cn_only')}</code></span>
811
+ </div>
812
+ </header>
813
+ {stale_html}
814
+ {deg_html}
815
+ {brief_block}
816
+ {panorama_block}
817
+ {news_block}
818
+ {ann_block}
819
+ {synthesis_block}
820
+ {strat_block}
821
+ {pat_block}
822
+ <footer><span {_i18n("disclaimer")}>{_esc(BRIEF_DISCLAIMER)}</span> · <span {_i18n("footer_tag")}>量化形态观测与回测基准</span> · <a href="{_GITHUB_URL}" {_i18n("footer_repo")}>GitHub 开源仓库</a> · Generated {_esc(report.get("generated_at") or "")}</footer>
823
+ </main>
824
+ <script>
825
+ (function () {{
826
+ var TRADE_DATE = {_js_json(str(report.get("trade_date") or "-"))};
827
+ var DETAIL_BASE = {_js_json(detail_url)};
828
+ var I18N = {{
829
+ zh: {{
830
+ page_title: "AlphaSift · A 股盘后投研日报 (" + TRADE_DATE + ")",
831
+ brand_title: "AlphaSift · 盘后研报",
832
+ btn_back: "返回在线看板",
833
+ btn_print: "打印 / PDF",
834
+ theme_light: "亮色",
835
+ theme_dark: "暗色",
836
+ rpt_title: "AlphaSift · A 股盘后量化投研日报",
837
+ meta_tdate: "交易日",
838
+ meta_pdate: "数据包",
839
+ badge_stale: "旧包降级",
840
+ badge_sync: "数据同步",
841
+ meta_policy: "口径:",
842
+ sec_brief: "盘后要点综述",
843
+ brief_badge_rule: "规则统计合成",
844
+ sub_regime: "盘面宽度与情绪",
845
+ sub_consensus: "策略共振与 AI 观察",
846
+ sub_risk: "风险提示",
847
+ sub_watch: "次日观察点",
848
+ empty_warn: "无额外提示",
849
+ empty_watch: "关注开盘量能变化",
850
+ unit_yi: " 亿",
851
+ kpi_adv: "上涨占比",
852
+ kpi_med: "全市场中位数",
853
+ kpi_amt: "两市成交额",
854
+ kpi_luld: "非ST 涨停 / 跌停",
855
+ kpi_streak: "连板最高",
856
+ kpi_prevlu: "昨涨停今日均收益",
857
+ sub_dist: "7 档涨跌幅分布",
858
+ sub_ladder: "连板高度梯队",
859
+ no_dist: "暂无涨跌幅分布统计",
860
+ ladder_empty: "今日无非 ST 连板或首板分布",
861
+ sec_ann: "⚠️ 公告排雷与风险聚焦",
862
+ ann_old: "历史进展",
863
+ ann_skipped: "本期日报跳过公告抽检或无候选股。",
864
+ ann_extra: "候选附加风控标签:",
865
+ sec_news: "📰 市场热点与政策快讯",
866
+ sec_syn: "跨策略共识、行业分布与 AI 归因",
867
+ sub_multi_cons: "多策略共识标的",
868
+ col_stock: "股票",
869
+ col_ind: "行业",
870
+ col_hits: "命中策略数",
871
+ col_strats: "覆盖策略",
872
+ col_score: "均分",
873
+ col_chg: "涨跌",
874
+ col_ann: "公告预警",
875
+ no_consensus: "今日暂无 ≥2 个策略同时选中的共识标的。",
876
+ sub_sector_conc: "候选行业集中度",
877
+ no_sector: "暂无行业分布",
878
+ sub_res: "策略 × 形态共振观察",
879
+ no_resonance: "今日策略候选与扫描形态暂无重叠个股。",
880
+ res_strat: "策略",
881
+ res_pat: "形态",
882
+ sub_ai_today: "今日 AI 调仓对比",
883
+ ai_rebalance: "AI 调仓",
884
+ ai_view: "市场观点:",
885
+ ai_add: "AI 新增:",
886
+ ai_drop: "AI 剔除:",
887
+ none_lbl: "无",
888
+ case_section_title: "历史同日配对 · AI 个股级案例复盘",
889
+ case_badge: "T+5 实盘案例",
890
+ case_adds: "AI 独选高光:",
891
+ case_avoids: "AI 避坑剔除:",
892
+ case_misses: "AI 错杀遗憾:",
893
+ sec_strats: "今日策略精选全览",
894
+ badge_rules: "规则",
895
+ col_total_score: "综合分",
896
+ col_note: "备注/风险",
897
+ no_picks: "无入选股票",
898
+ no_strats: "未附加策略运行结果。",
899
+ sec_patterns: "无状态形态雷达命中",
900
+ col_overhead: "上方套牢",
901
+ col_kline: "近20日K线",
902
+ no_pat_sig: "今日无触发信号",
903
+ no_pats: "无形态扫描记录",
904
+ deg_prefix: "降级说明:",
905
+ footer_tag: "量化形态观测与回测基准",
906
+ footer_repo: "GitHub 开源仓库",
907
+ dist_flat: "平盘",
908
+ }},
909
+ en: {{
910
+ page_title: "AlphaSift · CN Post-Close Research Brief (" + TRADE_DATE + ")",
911
+ brand_title: "AlphaSift · Daily Brief",
912
+ btn_back: "Dashboard",
913
+ btn_print: "Print / PDF",
914
+ theme_light: "Light",
915
+ theme_dark: "Dark",
916
+ rpt_title: "AlphaSift · CN Post-Close Quantitative Research Brief",
917
+ meta_tdate: "Session",
918
+ meta_pdate: "Pack",
919
+ badge_stale: "Stale Fallback",
920
+ badge_sync: "Pack Synced",
921
+ meta_policy: "Policy: ",
922
+ sec_brief: "Executive Post-Close Brief",
923
+ brief_badge_llm: "AI Brief · {{model}}",
924
+ brief_badge_rule: "Rule Synthesis",
925
+ sub_regime: "Market Breadth & Regime",
926
+ sub_consensus: "Consensus & AI Observations",
927
+ sub_risk: "Risk Warnings",
928
+ sub_watch: "Next-Session Watchpoints",
929
+ empty_warn: "No extra warnings",
930
+ empty_watch: "Watch opening auction & volume continuity",
931
+ sec_panorama: "CN Market Panorama ({{d}})",
932
+ unit_yi: "00M",
933
+ kpi_adv: "Advancing Share",
934
+ kpi_adv_sub: "Adv {{adv}} / Dec {{dec}}",
935
+ kpi_med: "Universe Median",
936
+ kpi_med_sub: "{{n}} traded",
937
+ kpi_amt: "Total Turnover",
938
+ kpi_amt_sub: "Seal {{seal}}",
939
+ kpi_luld: "Non-ST Limit-Up / Dn",
940
+ kpi_luld_sub: "Locked {{up}} / {{dn}}",
941
+ kpi_streak: "Max Streak",
942
+ kpi_streak_val: "{{n}}d",
943
+ kpi_streak_sub: "Broken {{n}}",
944
+ kpi_prevlu: "Prev LU Avg Return",
945
+ kpi_prevlu_sub: "Green {{win}}",
946
+ sub_dist: "7-Bucket Return Distribution",
947
+ sub_ladder: "Limit-Up Streak Ladder",
948
+ no_dist: "No return distribution data",
949
+ ladder_empty: "No non-ST consecutive limit-ups today",
950
+ ladder_board: "{{b}}d",
951
+ ladder_cnt: "{{n}}",
952
+ sec_ann: "⚠️ Announcement Risk Screening",
953
+ ann_old: "Earlier Update",
954
+ ann_badge: "{{c}} checked · {{f}} flagged",
955
+ ann_ok: "✓ Screened {{n}} shortlisted candidates — no negative filing keywords detected.",
956
+ ann_skipped: "Announcement screening skipped or no shortlisted candidates.",
957
+ ann_extra: "Additional candidate risk flags:",
958
+ sec_news: "📰 Market Headlines & Catalysts",
959
+ sec_syn: "Cross-Strategy Consensus, Sector Mix & AI Attribution",
960
+ sub_multi_cons: "Multi-Strategy Consensus",
961
+ col_stock: "Security",
962
+ col_ind: "Sector",
963
+ col_hits: "Hits",
964
+ col_strats: "Strategies",
965
+ col_score: "Score",
966
+ col_chg: "Chg%",
967
+ col_ann: "Filings",
968
+ n_strats: "{{n}} strats",
969
+ no_consensus: "No CN stock selected by ≥2 strategies today.",
970
+ sub_sector_conc: "Sector Concentration",
971
+ no_sector: "No sector breakdown available",
972
+ sub_res: "Strategy × Pattern Resonance",
973
+ no_resonance: "No overlap between strategy picks and pattern hits today.",
974
+ res_strat: "Strats",
975
+ res_pat: "Patterns",
976
+ sub_ai_today: "Today's AI Re-Ranking Deltas",
977
+ ai_rebalance: "AI Re-Rank",
978
+ ai_sub: "Overlap {{ov}} · Rules {{r}} / AI {{a}}",
979
+ ai_view: "Market View: ",
980
+ ai_add: "AI Added: ",
981
+ ai_drop: "AI Dropped: ",
982
+ none_lbl: "None",
983
+ case_section_title: "Paired Attribution · T+5 AI Case Studies",
984
+ case_badge: "T+5 Case Study",
985
+ case_adds: "Top AI Adds: ",
986
+ case_avoids: "AI Avoided Losses: ",
987
+ case_misses: "Missed by AI: ",
988
+ sec_strats: "Today's Strategy Picks Overview",
989
+ strat_runs_badge: "{{n}} runs",
990
+ badge_rules: "Rules",
991
+ col_total_score: "Score",
992
+ col_note: "Note / Risk",
993
+ no_picks: "No qualifying picks",
994
+ no_strats: "No strategy runs attached.",
995
+ strat_picks_cnt: "{{n}} picks",
996
+ sec_patterns: "Stateless Pattern Radar Hits",
997
+ col_overhead: "Overhead",
998
+ col_kline: "20D K-Line",
999
+ no_pat_sig: "No signals triggered today",
1000
+ no_pats: "No pattern scan recorded",
1001
+ pat_hits_cnt: "{{n}} hits",
1002
+ stale_banner: "⚠️ <b>Stale Pack Mode</b>: Pack date <code>{{pack}}</code> trails target <code>{{exp}}</code> ({{reason}}). Rendered in observation mode; unforced IM push suppressed.",
1003
+ deg_prefix: "Degradation: ",
1004
+ disclaimer: "Research & observational metrics only — not investment advice or buy/sell instructions.",
1005
+ footer_tag: "Quantitative Discovery & Benchmark",
1006
+ footer_repo: "GitHub Repository",
1007
+ dist_flat: "Flat",
1008
+ }},
1009
+ ja: {{
1010
+ page_title: "AlphaSift · 中国A株 引け後クオンツレポート (" + TRADE_DATE + ")",
1011
+ brand_title: "AlphaSift · 日次レポート",
1012
+ btn_back: "ダッシュボード",
1013
+ btn_print: "印刷 / PDF",
1014
+ theme_light: "ライト",
1015
+ theme_dark: "ダーク",
1016
+ rpt_title: "AlphaSift · 中国A株 引け後クオンツ調査レポート",
1017
+ meta_tdate: "営業日",
1018
+ meta_pdate: "データパック",
1019
+ badge_stale: "旧パック縮退",
1020
+ badge_sync: "同期済み",
1021
+ meta_policy: "方針:",
1022
+ sec_brief: "引け後エグゼクティブ要約",
1023
+ brief_badge_llm: "AI 分析合成 · {{model}}",
1024
+ brief_badge_rule: "統計ルール合成",
1025
+ sub_regime: "市場の幅・センチメント",
1026
+ sub_consensus: "戦略コンセンサス・AI観測",
1027
+ sub_risk: "リスク注意",
1028
+ sub_watch: "翌営業日の注目点",
1029
+ empty_warn: "追加の警戒事項なし",
1030
+ empty_watch: "寄付き出来高の持続性に注目",
1031
+ sec_panorama: "中国A株 市場パノラマ ({{d}})",
1032
+ unit_yi: "億元",
1033
+ kpi_adv: "上昇銘柄比率",
1034
+ kpi_adv_sub: "上昇 {{adv}} / 下落 {{dec}}",
1035
+ kpi_med: "全市場中央値",
1036
+ kpi_med_sub: "出来高 {{n}} 銘柄",
1037
+ kpi_amt: "両市場売買代金",
1038
+ kpi_amt_sub: "維持率 {{seal}}",
1039
+ kpi_luld: "非ST ストップ高 / 安",
1040
+ kpi_luld_sub: "一本値 {{up}}/{{dn}}",
1041
+ kpi_streak: "最高連騰",
1042
+ kpi_streak_val: "{{n}}連騰",
1043
+ kpi_streak_sub: "剥がれ {{n}} 銘柄",
1044
+ kpi_prevlu: "前日S高 本日平均",
1045
+ kpi_prevlu_sub: "陽線率 {{win}}",
1046
+ sub_dist: "7段階 騰落率分布",
1047
+ sub_ladder: "連騰ストップ高ラダー",
1048
+ no_dist: "騰落率分布データなし",
1049
+ ladder_empty: "本日非 ST の連騰ストップ高なし",
1050
+ ladder_board: "{{b}}連続",
1051
+ ladder_cnt: "{{n}} 社",
1052
+ sec_ann: "⚠️ 適時開示リスク検査",
1053
+ ann_old: "過去の続報",
1054
+ ann_badge: "検査 {{c}} · 高リスク {{f}}",
1055
+ ann_ok: "✓ 主要候補 {{n}} 銘柄の適時開示を確認済み(持株売却・調査等の警戒語なし)。",
1056
+ ann_skipped: "開示検査スキップまたは候補銘柄なし。",
1057
+ ann_extra: "追加のリスクタグ:",
1058
+ sec_news: "📰 市場トピックス・ニュース",
1059
+ sec_syn: "複数戦略コンセンサス・業種分布・AI帰属",
1060
+ sub_multi_cons: "複数戦略コンセンサス銘柄",
1061
+ col_stock: "銘柄",
1062
+ col_ind: "業種",
1063
+ col_hits: "戦略数",
1064
+ col_strats: "該当戦略",
1065
+ col_score: "平均スコア",
1066
+ col_chg: "騰落率",
1067
+ col_ann: "開示警戒",
1068
+ n_strats: "{{n}} 戦略",
1069
+ no_consensus: "本日 ≥2 戦略で重複選定された銘柄はありません。",
1070
+ sub_sector_conc: "候補業種集中度",
1071
+ no_sector: "業種データなし",
1072
+ sub_res: "戦略 × パターン共鳴観測",
1073
+ no_resonance: "本日戦略候補とパターン検出の重複はありません。",
1074
+ res_strat: "戦略",
1075
+ res_pat: "パターン",
1076
+ sub_ai_today: "本日の AI 再ランク調整",
1077
+ ai_rebalance: "AI 調整",
1078
+ ai_sub: "重複率 {{ov}} · ルール {{r}} / AI {{a}}",
1079
+ ai_view: "市場見通し:",
1080
+ ai_add: "AI 追加:",
1081
+ ai_drop: "AI 除外:",
1082
+ none_lbl: "なし",
1083
+ case_section_title: "同日ペア帰属 · AI 個別銘柄ケース振り返り",
1084
+ case_badge: "T+5 実測事例",
1085
+ case_adds: "AI 独自選定ハイライト:",
1086
+ case_avoids: "AI 回避成功:",
1087
+ case_misses: "AI 見逃し:",
1088
+ sec_strats: "本日の戦略別選定一覧",
1089
+ strat_runs_badge: "{{n}} 実行",
1090
+ badge_rules: "ルール",
1091
+ col_total_score: "総合点",
1092
+ col_note: "備考 / リスク",
1093
+ no_picks: "該当銘柄なし",
1094
+ no_strats: "戦略実行結果がありません。",
1095
+ strat_picks_cnt: "{{n}} 銘柄",
1096
+ sec_patterns: "ステートレスパターン検出",
1097
+ col_overhead: "上値しこり",
1098
+ col_kline: "直近20日足",
1099
+ no_pat_sig: "本日のシグナルなし",
1100
+ no_pats: "パターン検出記録なし",
1101
+ pat_hits_cnt: "{{n}} 件検出",
1102
+ stale_banner: "⚠️ <b>旧パック縮退モード</b>:パック日付 <code>{{pack}}</code> が目標日 <code>{{exp}}</code> より古い状態です({{reason}})。観測用表示のみとし、強制指定なしの通知は抑制しました。",
1103
+ deg_prefix: "縮退説明:",
1104
+ disclaimer: "本レポートは研究・エンジニアリング観測目的であり、投資助言や売買推奨ではありません。",
1105
+ footer_tag: "クオンツ観測・T+N検証ベンチマーク",
1106
+ footer_repo: "GitHub リポジトリ",
1107
+ dist_flat: "横ばい",
1108
+ }},
1109
+ }};
1110
+ var REGIME_MAP = {{
1111
+ en: {{ freezing: "Freezing", startup: "Startup", main_up: "Main Up", divergence: "Divergence", ebb: "Ebb", neutral: "Choppy" }},
1112
+ ja: {{ freezing: "極寒", startup: "初動", main_up: "主昇波", divergence: "分岐", ebb: "後退", neutral: "レンジ" }},
1113
+ }};
1114
+ var STRAT_MAP = {{
1115
+ en: {{ balanced_alpha: "Balanced Alpha", blue_chip_income: "Blue-Chip Income", capital_heat: "Capital Heat", dual_low: "Dual Low Value", global_value: "Global Value", low_volatility_quality: "Low-Vol Quality", momentum_quality: "Momentum Quality", oversold_reversal: "Oversold Reversal", quality_value: "Quality Value", shrink_pullback: "Shrink Pullback", us_momentum_quality: "US Momentum Quality", volume_breakout: "Volume Breakout" }},
1116
+ ja: {{ balanced_alpha: "バランス・アルファ", blue_chip_income: "優良高配当株", capital_heat: "資金モメンタム", dual_low: "低PER・低PBR", global_value: "グローバル・バリュー", low_volatility_quality: "低ボラ・クオリティ", momentum_quality: "モメンタム・クオリティ", oversold_reversal: "売られ過ぎ反発", quality_value: "クオリティ・バリュー", shrink_pullback: "出来高縮小押し目", us_momentum_quality: "米国モメンタム", volume_breakout: "出来高ブレイク" }},
1117
+ }};
1118
+ var PAT_MAP = {{
1119
+ en: {{ bottom_volume_yang: "Bottom Volume Surge", box_breakout: "Box Breakout", double_bottom_breakout: "Double Bottom Breakout", ma20_shrink_pullback: "MA20 Low-Vol Pullback", shooting_star_confirm: "Upper-Wick Confirm", single_yang_hold: "Single Bullish Hold", steady_trend_breakout: "Steady Trend Breakout", three_white_soldiers: "Three White Soldiers", three_white_soldiers_pullback: "Three Soldiers Pullback" }},
1120
+ ja: {{ bottom_volume_yang: "底値倍増陽線", box_breakout: "ボックス圏ブレイク", double_bottom_breakout: "ダブルボトム突破", ma20_shrink_pullback: "20日線低ボラ押し目", shooting_star_confirm: "上ヒゲ確認", single_yang_hold: "大陽線ホールド", steady_trend_breakout: "低ボラ堅調突破", three_white_soldiers: "赤三兵", three_white_soldiers_pullback: "赤三兵押し目確認" }},
1121
+ }};
1122
+
1123
+ var lang = "zh";
1124
+ var theme = "dark";
1125
+ try {{
1126
+ var qs = new URLSearchParams(window.location.search);
1127
+ var qTheme = qs.get("theme");
1128
+ var qLang = (qs.get("lang") || "").toLowerCase();
1129
+ var savedTheme = localStorage.getItem("alphasift-theme");
1130
+ var savedLang = (localStorage.getItem("alphasift-lang") || "").toLowerCase();
1131
+ if (qTheme === "light" || qTheme === "dark") theme = qTheme;
1132
+ else if (savedTheme === "light" || savedTheme === "dark") theme = savedTheme;
1133
+ var rawLang = qLang || savedLang || (navigator.language || "").toLowerCase();
1134
+ if (rawLang.indexOf("en") === 0) lang = "en";
1135
+ else if (rawLang.indexOf("ja") === 0) lang = "ja";
1136
+ else lang = "zh";
1137
+ }} catch (e) {{}}
1138
+
1139
+ function escHtml(s) {{
1140
+ return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) {{
1141
+ return ({{ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }}[c]);
1142
+ }});
1143
+ }}
1144
+ function formatTpl(tpl, rawVars) {{
1145
+ if (!rawVars) return tpl;
1146
+ try {{
1147
+ var vars = JSON.parse(rawVars);
1148
+ Object.keys(vars).forEach(function (k) {{
1149
+ tpl = tpl.split("{{" + k + "}}").join(escHtml(vars[k]));
1150
+ }});
1151
+ }} catch (e) {{}}
1152
+ return tpl;
1153
+ }}
1154
+
1155
+ var ICO_SUN = '<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41M2 12h2m16 0h2M4.93 19.07l1.41-1.41m11.32-11.32 1.41-1.41"/></svg>';
1156
+ var ICO_MOON = '<svg class="ico" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>';
1157
+ var btn = document.getElementById("theme-toggle");
1158
+ function syncThemeBtn() {{
1159
+ var dict = I18N[lang] || I18N.zh;
1160
+ if (btn) btn.innerHTML = theme === "light" ? ICO_MOON + "<span>" + dict.theme_dark + "</span>" : ICO_SUN + "<span>" + dict.theme_light + "</span>";
1161
+ }}
1162
+ function syncBackLink() {{
1163
+ var link = document.getElementById("back-dashboard-link");
1164
+ if (!link) return;
1165
+ if (DETAIL_BASE.indexOf("http") !== 0 && DETAIL_BASE.indexOf("../index.html") !== 0) return;
1166
+ var p = new URLSearchParams();
1167
+ if (lang !== "zh") p.set("lang", lang);
1168
+ if (theme !== "dark") p.set("theme", theme);
1169
+ var q = p.toString();
1170
+ link.setAttribute("href", q ? DETAIL_BASE.split("?")[0] + "?" + q : DETAIL_BASE);
1171
+ }}
1172
+ function applyLang(nextLang) {{
1173
+ lang = (nextLang === "en" || nextLang === "ja") ? nextLang : "zh";
1174
+ try {{ localStorage.setItem("alphasift-lang", lang); }} catch (e) {{}}
1175
+ document.documentElement.lang = lang === "en" ? "en" : lang === "ja" ? "ja" : "zh-CN";
1176
+ document.documentElement.setAttribute("data-lang", lang);
1177
+ var dict = I18N[lang] || I18N.zh;
1178
+ document.title = dict.page_title;
1179
+ document.querySelectorAll("[data-i18n]").forEach(function (el) {{
1180
+ if (el.dataset.zhHtml === undefined) el.dataset.zhHtml = el.innerHTML;
1181
+ var k = el.getAttribute("data-i18n");
1182
+ if (lang === "zh") {{
1183
+ el.innerHTML = el.dataset.zhHtml;
1184
+ }} else if (dict[k] !== undefined) {{
1185
+ el.innerHTML = formatTpl(dict[k], el.getAttribute("data-i18n-vars"));
1186
+ }}
1187
+ }});
1188
+ document.querySelectorAll("[data-strategy]").forEach(function (el) {{
1189
+ if (el.dataset.zhText === undefined) el.dataset.zhText = el.textContent;
1190
+ var k = el.getAttribute("data-strategy");
1191
+ el.textContent = (lang === "zh" ? el.dataset.zhText : ((STRAT_MAP[lang] && STRAT_MAP[lang][k]) || el.dataset.zhText));
1192
+ }});
1193
+ document.querySelectorAll("[data-pattern]").forEach(function (el) {{
1194
+ if (el.dataset.zhText === undefined) el.dataset.zhText = el.textContent;
1195
+ var k = el.getAttribute("data-pattern");
1196
+ el.textContent = (lang === "zh" ? el.dataset.zhText : ((PAT_MAP[lang] && PAT_MAP[lang][k]) || el.dataset.zhText));
1197
+ }});
1198
+ document.querySelectorAll("[data-regime]").forEach(function (el) {{
1199
+ if (el.dataset.zhText === undefined) el.dataset.zhText = el.textContent;
1200
+ var k = el.getAttribute("data-regime");
1201
+ if (lang === "zh") el.textContent = el.dataset.zhText;
1202
+ else el.textContent = (REGIME_MAP[lang] && REGIME_MAP[lang][k]) || el.getAttribute("data-regime-raw") || k;
1203
+ }});
1204
+ document.querySelectorAll("[data-dist-flat]").forEach(function (el) {{
1205
+ el.textContent = dict.dist_flat || "平盘";
1206
+ }});
1207
+ var sw = document.getElementById("lang-switch");
1208
+ if (sw) sw.querySelectorAll("button").forEach(function (b) {{
1209
+ b.setAttribute("aria-pressed", String(b.getAttribute("data-lang") === lang));
1210
+ }});
1211
+ syncThemeBtn();
1212
+ syncBackLink();
1213
+ }}
1214
+
1215
+ document.documentElement.setAttribute("data-theme", theme);
1216
+ applyLang(lang);
1217
+ var sw = document.getElementById("lang-switch");
1218
+ if (sw) {{
1219
+ sw.addEventListener("click", function (e) {{
1220
+ var b = e.target.closest("button");
1221
+ if (b && b.getAttribute("data-lang")) applyLang(b.getAttribute("data-lang"));
1222
+ }});
1223
+ }}
1224
+ var printBtn = document.getElementById("print-btn");
1225
+ if (printBtn) {{
1226
+ printBtn.addEventListener("click", function () {{ window.print(); }});
1227
+ }}
1228
+ if (btn) {{
1229
+ btn.addEventListener("click", function () {{
1230
+ theme = theme === "light" ? "dark" : "light";
1231
+ document.documentElement.setAttribute("data-theme", theme);
1232
+ syncThemeBtn();
1233
+ syncBackLink();
1234
+ try {{ localStorage.setItem("alphasift-theme", theme); }} catch (e) {{}}
1235
+ }});
1236
+ }}
1237
+ }})();
1238
+ </script>
1239
+ </body>
1240
+ </html>
1241
+ """
1242
+
1243
+
1244
+ def write_daily_report_html(
1245
+ output_path: str | Path,
1246
+ report: dict[str, Any],
1247
+ *,
1248
+ track_summary: dict[str, Any] | None = None,
1249
+ ) -> Path:
1250
+ """Render and write a standalone HTML daily report to disk."""
1251
+ path = Path(output_path)
1252
+ path.parent.mkdir(parents=True, exist_ok=True)
1253
+ path.write_text(
1254
+ render_daily_report_html(report, track_summary=track_summary),
1255
+ encoding="utf-8",
1256
+ )
1257
+ return path