从 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。
106 lines
4.0 KiB
Plaintext
106 lines
4.0 KiB
Plaintext
# ============================================================
|
||
# nginx 配置示例 · 高股息回测系统
|
||
#
|
||
# 架构:前后端分离
|
||
# - 前端(静态)由 nginx 直接提供:output/ 目录
|
||
# - 后端(API)由 hdiv web 进程提供,nginx 反代 /api
|
||
#
|
||
# 使用方式:
|
||
# 1. 把 output/ 同步到服务器,例如 /srv/hddiv/site/
|
||
# 2. 在服务器上启动后端:
|
||
# cd <项目目录> && PYTHONPATH=src nohup .venv/bin/python -m hdiv web \
|
||
# --host 127.0.0.1 --port 8099 --api-only > logs/web.log 2>&1 &
|
||
# 3. 把本文件按需修改后放到 /etc/nginx/conf.d/ 或 sites-available/
|
||
# 4. nginx -t && nginx -s reload
|
||
# ============================================================
|
||
|
||
server {
|
||
listen 8080;
|
||
server_name 192.168.1.166; # ← 改成你的服务器地址或域名
|
||
|
||
charset utf-8;
|
||
access_log /var/log/nginx/hddiv.access.log;
|
||
error_log /var/log/nginx/hddiv.error.log;
|
||
|
||
# ------------------------------------------------------------
|
||
# 站点根:output/ 已同步到服务器的这个目录
|
||
# ------------------------------------------------------------
|
||
root /srv/hddiv/site; # ← 改成实际路径
|
||
index index.html;
|
||
|
||
# ------------------------------------------------------------
|
||
# 后端 API(关键:必须放在静态规则之前)
|
||
#
|
||
# 前端从页面相对路径请求 api/xxx。页面在 /ggx/ 下,
|
||
# 因此请求会落到 /ggx/api/xxx —— 这里把它转发到后端 /api/xxx。
|
||
# ------------------------------------------------------------
|
||
location /ggx/api/ {
|
||
proxy_pass http://127.0.0.1:8099/api/;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_read_timeout 120s;
|
||
proxy_buffering off; # 接口数据量小,关闭缓冲更及时
|
||
|
||
# 接口不做缓存,避免 PATCH 后看到旧数据
|
||
add_header Cache-Control "no-store" always;
|
||
}
|
||
|
||
# ------------------------------------------------------------
|
||
# 前端静态资源
|
||
# ------------------------------------------------------------
|
||
location /ggx/ {
|
||
alias /srv/hddiv/site/; # ← 与上面 root 保持一致(注意结尾斜杠)
|
||
|
||
# 前端是 hash 路由(#/...),无需服务端 rewrite;
|
||
# 未知路径回落到 index.html,保证深链接也能打开
|
||
try_files $uri $uri/ /ggx/index.html;
|
||
|
||
# 图表库较大,允许缓存;app.js/app.css 不缓存便于更新
|
||
location ~* /ggx/assets/.*\.js$ {
|
||
expires 7d;
|
||
add_header Cache-Control "public";
|
||
}
|
||
location ~* /ggx/app/.*\.(js|css)$ {
|
||
add_header Cache-Control "no-cache";
|
||
}
|
||
}
|
||
|
||
# 根路径跳到应用
|
||
location = / {
|
||
return 302 /ggx/;
|
||
}
|
||
}
|
||
|
||
# ============================================================
|
||
# 备选:不挂子路径,直接把前端放在站点根
|
||
#
|
||
# 若你希望用 http://<host>:8080/ 直接打开,用下面这段替换上面的 server 块。
|
||
# 注意此时 API 前缀是 /api/,与前端相对路径解析一致,无需改前端。
|
||
# ============================================================
|
||
#
|
||
# server {
|
||
# listen 8080;
|
||
# server_name 192.168.1.166;
|
||
# charset utf-8;
|
||
#
|
||
# root /srv/hddiv/site;
|
||
# index index.html;
|
||
#
|
||
# location /api/ {
|
||
# proxy_pass http://127.0.0.1:8099/api/;
|
||
# proxy_http_version 1.1;
|
||
# proxy_set_header Host $host;
|
||
# proxy_set_header X-Real-IP $remote_addr;
|
||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
# proxy_read_timeout 120s;
|
||
# add_header Cache-Control "no-store" always;
|
||
# }
|
||
#
|
||
# location / {
|
||
# try_files $uri $uri/ /index.html;
|
||
# }
|
||
# }
|