Files
crypto_monitor/manual_trading_hub/数据看板说明.md
T
dekun 07e8604ea6 feat(hub): dashboard SSE push, light-theme cards, simplify AI coach
Replace dashboard polling with backend SSE and snapshot refresh. Restyle for light/dark theme with soft card glow instead of neon. Remove Today's Summary from AI page; keep trading and general chat only. Update hub documentation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-11 10:53:50 +08:00

51 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 中控数据看板说明
入口:**`/dashboard`**(顶栏「数据看板」)。
## 能力
| 区块 | 说明 |
|------|------|
| **总览 KPI** | 交易日、平仓盈亏、笔数、浮盈亏、资金合计、实盘持仓 |
| **分户明细** | 四户资金/交易账户、今日盈亏、浮盈亏、备注;未启用显示「未监控」 |
| **平仓明细** | 当日平仓流水(合约、方向、结果、盈亏、时间) |
| **风险预警** | 单户单日平仓亏损 ≥ 资金合计 **5%** 时横幅 + 卡片高亮 |
纯数据聚合,**不调用 AI**。交易日口径与实例一致(`TRADING_DAY_RESET_HOUR`,默认 8 点)。
## 刷新机制(SSE
与监控区 board 类似,采用 **后台聚合 + SSE 推送版本号**
1. `hub.py` 启动后 `dashboard_store`**60s**`DASHBOARD_POLL_INTERVAL_SEC`)聚合四户数据到内存快照。
2. 浏览器打开看板页后连接 `GET /api/dashboard/stream``event: dashboard`)。
3. 收到新版本号后拉取 `GET /api/dashboard/daily` 快照并局部渲染,**无整页轮询闪烁**。
4. 监控区触发 board 刷新(全平、撤单等)时,会一并 `request_refresh` 看板,尽量与实盘同步。
5. 「立即刷新」→ `POST /api/dashboard/refresh` 触发下一轮聚合。
可选环境变量:`HUB_DASHBOARD_SSE_HEARTBEAT_SEC`(默认 25SSE 心跳间隔)。
## 主题与样式
- 跟随中控顶栏 **亮/暗主题**`theme.js`),使用 `--panel` / `--border` / `--accent` 等变量。
- 卡片采用 **柔光阴影**(非霓虹渐变背景);亮色主题下为浅灰投影,暗色主题为轻微内高光。
- 盈亏仍用绿/红语义色,与全局一致。
## API
| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `/api/dashboard/daily` | 当前交易日快照(含 `dashboard_version` |
| GET | `/api/dashboard/stream` | SSE 版本推送 |
| POST | `/api/dashboard/refresh` | 请求立即重聚合 |
`GET /api/ping``dashboard_version``dashboard_poll_interval_sec` 等字段。
## 相关文件
- `hub_dashboard.py` — 聚合逻辑
- `hub_dashboard_cache.py` — 后台轮询 + SSE
- `static/dashboard.js` / `dashboard.css` — 前端
部署后 `git pull``pm2 restart manual-trading-hub`