初始提交:高股息策略研究与回测系统

从 Point-in-Time 股票筛选到统一 Web 前端的完整链路:
筛选 → 画像 → 策略 → 回测 → Walk-forward → 绩效分析 → 报告/前端。

架构
- 数据层与策略层分离;策略代码不写 SQL,只经 data/repo.py 取数
- 所有业务阈值集中在 config/*.yml,代码零硬编码(字段写错直接报错)
- 报告只做「run_id → SQL → 渲染」,不做任何计算,数字可追溯
- 前后端分离:output/ 静态站点 + hdiv web 提供的 REST API

数据安全
- 只增不删:SQL 钩子拦截 DELETE/DROP/TRUNCATE,并有源码扫描测试守护
- qlib 原有表只读,本项目数据写入 hd_ 前缀表
- 回补使用 INSERT IGNORE,保证既有行零改动
- .env 存密钥且已 gitignore;output/、logs/、.venv/ 不入库

交付物
- 30 张 hd_* 表、7 个 YAML 配置、283 项自动化测试
- 统一 Web 前端(hash 路由 SPA)+ nginx 部署配置与 launchd 托管脚本

如实声明的限制
- 策略缺少稳定的样本外超额收益(Walk-forward 7 窗口均值 -0.95%,
  基准 +2.29%);其价值体现在回撤控制,而非超额收益
- 涨跌停/停牌约束仅覆盖 2019 年起;index_weight 尚未填充
- AI Agent 层(plan.md 第四版 P8)未实现

详见 docs/user-guide.md 与 docs/implementation-status.md。
This commit is contained in:
2026-10-03 13:54:56 +08:00
commit fce725e13c
127 changed files with 28001 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="zh-CN" data-theme="{{ theme }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<style>{{ css | safe }}</style>
{{ echarts_tag | safe }}
</head>
<body>
<div class="wrap" style="--max-width: {{ max_width }}px">
<header class="page-head">
<h1>{{ title }}</h1>
{% if subtitle %}<div class="sub">{{ subtitle }}</div>{% endif %}
<div class="sub mono">生成时间 {{ generated_at }}{% if data_asof %} · 数据截止 {{ data_asof }}{% endif %}</div>
</header>
{% block content %}{% endblock %}
{% if show_provenance %}
<footer class="page-foot">
<strong>数据溯源</strong> — 本页所有数值均由下列 SQL 直接查询数据库得到,模板层不做任何计算。
<dl>
{% if source_run_ids %}<dt>来源 run</dt><dd class="mono">{{ source_run_ids }}</dd>{% endif %}
<dt>生成时间</dt><dd class="mono">{{ generated_at }}</dd>
{% if config_hash %}<dt>配置指纹</dt><dd class="mono">{{ config_hash }}</dd>{% endif %}
{% if data_version %}<dt>数据版本</dt><dd class="mono">{{ data_version }}</dd>{% endif %}
</dl>
<details>
<summary>查看数据来源 SQL({{ provenance_count }} 条)</summary>
<pre class="mono small" style="white-space:pre-wrap">{{ provenance_pretty }}</pre>
</details>
</footer>
{% endif %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>