Files
crypto_monitor/manual_trading_hub/README.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

107 lines
4.8 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.
# 复盘系统中控(manual_trading_hub
> **完整说明**[使用说明.md](./使用说明.md) · **资金概况**:[资金概况说明.md](./资金概况说明.md) · **数据看板**:[数据看板说明.md](./数据看板说明.md) · **AI 教练**[AI教练说明.md](./AI教练说明.md) · **行情区**:[行情区说明.md](./行情区说明.md) · **部署**[部署文档.md](./部署文档.md) · **云服务器**:[云服务器部署说明.md](./云服务器部署说明.md) · **本地→云端迁移**:[本地数据迁移到云端.md](./本地数据迁移到云端.md) · **局域网/反代**:[局域网与反代部署说明.md](./局域网与反代部署说明.md) · **故障**:[常见问题.md](./常见问题.md)
多账户 **监控聚合 + 紧急全平**;**不在中控网页下单**。人工下单、关键位、**策略交易**(`/strategy`)、复盘请在各 `crypto_monitor_*` 实例网页操作(监控卡片 **「实例」** / **「复盘」**)。**增加子账户**见 [使用说明 §4.3](./使用说明.md#43-增加账户例如再挂一个-gate)。
---
## 当前能力
| 能力 | 说明 |
|------|------|
| 监控区 | 持仓、余额、关键位摘要、趋势计划、机器人单(只读) |
| 资金概况 | 总/分户资金(资金户+交易户)、180 日曲线、最大回撤 |
| **数据看板** | 四户当日总览/分户/平仓明细,SSE 推送(`/dashboard`;见 [数据看板说明.md](./数据看板说明.md) |
| 行情区 | K 线(多周期、本地缓存、技术指标、从监控跳转持仓线) |
| **AI 教练** | 交易教练 + 普通聊天、会话历史(`/ai`;见 [AI教练说明.md](./AI教练说明.md) |
| 紧急全平 | 单户 / 全局市价减仓 |
| 系统设置 | `hub_settings.json` 管理 URL、启用、**监控关键位 / 监控趋势计划**(不控制策略交易页) |
| Web 登录 | `.env``HUB_PASSWORD` 后用户名+密码保护(反代公网**务必**配置) |
| ~~下单区~~ | **已移除**(避免与实例重复、减少故障面) |
---
## 架构
```
浏览器 → hub.py (:5100) 监控 / 资金概况 / **数据看板** / 行情 / **AI 教练** / 设置 / 登录
├→ agent.py × N (:1520015203) 持仓、全平
└→ 各 Flask (:5000/5001/5002/5004) /api/hub/monitor 只读聚合
```
- 账户列表:**系统设置** 或默认 `settings_store.py`(不再使用环境变量 `HUB_AGENTS`)。
- 四实例须注册 **hub_bridge**(仓库根 `hub_bridge.py`);PM2 建议 `PYTHONPATH=..`
---
## 快速启动(Linux / PM2
```bash
cd /opt/crypto_monitor/manual_trading_hub
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
# 编辑 .envHUB_PASSWORD、HUB_BRIDGE_TOKEN、HUB_PUBLIC_ORIGIN 等
pm2 start ecosystem.config.cjs # 4 agent + hub
pm2 save
bash scripts/verify_hub_deploy.sh
curl -s http://127.0.0.1:5100/api/ping
```
浏览器:`http://<本机IP>:5100/monitor`(行情 `/market`;已设密码则先 `/login`)。
---
## 中控 `.env` 要点
| 变量 | 说明 |
|------|------|
| `HUB_PASSWORD` / `HUB_USERNAME` | 非空密码即启用登录 |
| `HUB_BRIDGE_TOKEN` | 与四实例一致 |
| `HUB_DISABLED_IDS` | 默认 `1` 关闭 OKX |
| `HUB_PUBLIC_ORIGIN` | 其它设备打开复盘/实例外链(替换 127.0.0.1 |
| `HUB_COOKIE_SECURE` | HTTPS 反代建议 `true` |
详见 [.env.example](./.env.example)。
---
## 子代理(agent
每所策略目录单独进程,`EXCHANGE` + `PORT`1520015203),密钥来自**该目录 `.env`**。PM2 经 `scripts/run_agent.sh` 启动(自动 `source .env`、去 CRLF)。
| PORT | 目录 |
|------|------|
| 15200 | crypto_monitor_binance |
| 15201 | crypto_monitor_okx |
| 15202 | crypto_monitor_gate |
| 15203 | crypto_monitor_gate_bot |
---
## 运维脚本
| 脚本 | 作用 |
|------|------|
| [scripts/fix_hub_deps.sh](./scripts/fix_hub_deps.sh) | 安装/更新 venv 依赖 |
| [scripts/verify_hub_deploy.sh](./scripts/verify_hub_deploy.sh) | 验收代码版本与 ping |
| [scripts/fix_env_crlf.sh](./scripts/fix_env_crlf.sh) | 修复 .env 的 Windows 换行 |
| [scripts/pm2_hub.sh](./scripts/pm2_hub.sh) | PM2 启停 hub+agent |
| [scripts/后台运行-Ubuntu.md](./scripts/后台运行-Ubuntu.md) | PM2 常驻 |
| [docs/ubuntu-server.md](../docs/ubuntu-server.md) | Ubuntu / Python / Node / PM2 |
---
## 文档索引
| 文档 | 内容 |
|------|------|
| [使用说明.md](./使用说明.md) | 页面、API、环境变量、日常流程 |
| [行情区说明.md](./行情区说明.md) | K 线周期、缓存、快捷键、拉取逻辑 |
| [部署文档.md](./部署文档.md) | Ubuntu、PM2、反代、升级 |
| [常见问题.md](./常见问题.md) | 已遇到问题与处理 |
| [.env.example](./.env.example) | 环境变量模板 |