文档修改

This commit is contained in:
2026-05-21 16:51:27 +08:00
parent 7dbc5542de
commit ab854b2c3c
14 changed files with 116 additions and 102 deletions
@@ -22,9 +22,9 @@ chmod +x manual_trading_hub/scripts/stop_hub_screen.sh
./manual_trading_hub/scripts/stop_agents_3screen.sh
```
脚本默认认为:`manual_trading_hub` 的**上一级目录**里并列放着三个 `crypto_monitor_*`。若你把 hub 单独放在 `/opt/crypto_monitor/manual_trading_hub`,而策略项目在例如 `/opt/crypto_monitor/` 下的其他位置,请先执行
`export MANUAL_TRADING_REPO_ROOT=/opt/crypto_monitor` 再运行 `start_agents_3screen.sh`
启动后若 `screen -ls` 里没有 `mt-agent-*`,看日志:`tail -80 /opt/crypto_monitor/manual_trading_hub/logs/mt-agent-bn.log`
脚本默认认为:`manual_trading_hub` 的**上一级目录**里并列放着三个 `crypto_monitor_*`。若你把 hub 单独放在 `/opt/crypto_monitor_user/manual_trading_hub`,而策略项目在例如 `/opt/crypto_monitor_user/` 下的其他位置,请先执行
`export MANUAL_TRADING_REPO_ROOT=/opt/crypto_monitor_user` 再运行 `start_agents_3screen.sh`
启动后若 `screen -ls` 里没有 `mt-agent-*`,看日志:`tail -80 /opt/crypto_monitor_user/manual_trading_hub/logs/mt-agent-bn.log`
### 局域网内其他电脑访问中控
@@ -39,14 +39,14 @@ chmod +x manual_trading_hub/scripts/stop_hub_screen.sh
```bash
# 新建会话,在里面照常启动 agent 或 hub,然后按键 Ctrl+B 再按 D 脱离
tmux new -s hub
cd /opt/crypto_monitor/manual_trading_hub && source .venv/bin/activate && python hub.py
cd /opt/crypto_monitor_user/manual_trading_hub && source .venv/bin/activate && python hub.py
# Ctrl+B, D
tmux new -s agent-bn
cd /opt/crypto_monitor/crypto_monitor_binance && set -a && source .env && set +a
cd /opt/crypto_monitor_user/crypto_monitor_binance && set -a && source .env && set +a
export EXCHANGE=binance PORT=15200 HOST=127.0.0.1
source /opt/crypto_monitor/manual_trading_hub/.venv/bin/activate
python /opt/crypto_monitor/manual_trading_hub/agent.py
source /opt/crypto_monitor_user/manual_trading_hub/.venv/bin/activate
python /opt/crypto_monitor_user/manual_trading_hub/agent.py
# Ctrl+B, D
```
@@ -57,7 +57,7 @@ python /opt/crypto_monitor/manual_trading_hub/agent.py
## 二、nohup(快速、无守护重启)
```bash
cd /opt/crypto_monitor/manual_trading_hub
cd /opt/crypto_monitor_user/manual_trading_hub
source .venv/bin/activate
nohup python hub.py > /tmp/manual-hub.log 2>&1 &
```
@@ -70,7 +70,7 @@ nohup python hub.py > /tmp/manual-hub.log 2>&1 &
## 三、systemd(推荐:开机自启、崩溃自动拉起)
1. 把下面两个示例里的 **`YOUR_REPO`** 改成 **`/opt/crypto_monitor`**(或你本机实际仓库根目录),`YOUR_USER` 改成 Linux 用户名。
1. 把下面两个示例里的 **`YOUR_REPO`** 改成 **`/opt/crypto_monitor_user`**(或你本机实际仓库根目录),`YOUR_USER` 改成 Linux 用户名。
2. 复制到 `/etc/systemd/system/`(需 sudo),文件名例如 `manual-hub.service``manual-agent-binance.service`
3. 执行:
@@ -150,7 +150,7 @@ ExecStart=/bin/bash -lc 'set -a; source YOUR_REPO/crypto_monitor_binance/.env; s
## 四、常见问题(子代理 / screen / 依赖)
1. **`curl http://127.0.0.1:15202/status`(或其它端口)返回 `ok:false`,错误里提到 pysocks / SOCKS**
策略目录 `.env` 里配置了 `GATE_SOCKS_PROXY`(或 `BINANCE_SOCKS_PROXY``OKX_SOCKS_PROXY`)时,ccxt 需要 **PySocks**。在 **`/opt/crypto_monitor/manual_trading_hub/.venv`**(或你本机的 `manual_trading_hub/.venv`)中执行:
策略目录 `.env` 里配置了 `GATE_SOCKS_PROXY`(或 `BINANCE_SOCKS_PROXY``OKX_SOCKS_PROXY`)时,ccxt 需要 **PySocks**。在 **`/opt/crypto_monitor_user/manual_trading_hub/.venv`**(或你本机的 `manual_trading_hub/.venv`)中执行:
`pip install PySocks``pip install -r requirements.txt`
2. **已经 `pip install PySocks`,错误文案完全不变**
+2 -2
View File
@@ -17,7 +17,7 @@
1. 已安装 **Python 3.10+**,且 `pip` 可用。
2. 各策略目录下已配置好交易所 API:在对应 `crypto_monitor_*` 目录执行过 **`cp .env.example .env`** 并填好密钥(与平时运行 Flask 时同一份 **`.env`**,或等价环境变量)。各项目 `app.py` 会读取同目录 `.env` 中的 **`APP_HOST` / `APP_PORT`** 用于 **Flask**;子代理使用环境变量 **`PORT`**,二者不能占用同一端口。策略目录的 **`.env` 不在 Git 中**`git pull` 不会覆盖;升级前建议在各策略目录 `cp .env .env.backup.$(date +%Y%m%d)`
3. 本机端口 **`15200``15203`、5100**(及你各策略 `.env` 里的 `APP_PORT`)无冲突;若被占用,须改子代理 `PORT` 并同步修改 `HUB_AGENTS`
4. **Linux 路径约定(可选)**:若部署在 Ubuntu 等环境,建议将整个代码树放在 **`/opt/crypto_monitor/`** 下(与 `scripts/后台运行-Ubuntu.md` 示例一致),例如策略目录为 `/opt/crypto_monitor/crypto_monitor_binance`、中控为 `/opt/crypto_monitor/manual_trading_hub`
4. **Linux 路径约定(可选)**:若部署在 Ubuntu 等环境,建议将整个代码树放在 **`/opt/crypto_monitor_user/`** 下(与 `scripts/后台运行-Ubuntu.md` 示例一致),例如策略目录为 `/opt/crypto_monitor_user/crypto_monitor_binance`、中控为 `/opt/crypto_monitor_user/manual_trading_hub`
---
@@ -192,7 +192,7 @@ Windows 可将 `hub.py` 与各 `agent.py` 写入「启动」文件夹,或使
| `/status``ok:false`,文案含 **pysocks** / **SOCKS** | 使用 SOCKS 代理但未装 **PySocks** | 在 **`manual_trading_hub/.venv`** 执行 `pip install PySocks``pip install -r requirements.txt` |
| **已安装 PySocks**`/status` 仍报同样 pysocks 文案 | 子代理进程未重启 | 子代理是常驻进程,**仅 pip 不会替换已运行进程**;退出对应 screen / systemd 单元后重新拉起(Ubuntu 见 `scripts/后台运行-Ubuntu.md` §四) |
| 跑 `start_agents_3screen.sh` 无新会话 | screen 会话已存在被脚本跳过 | 先 `stop_agents_3screen.sh`,或 `screen -S mt-agent-xxx -X quit` 后再启动 |
| 子代理行为异常、依赖已装仍报错 | 实际用的不是 hub 的 venv | `ps aux` 查看命令行,应为 **`/opt/crypto_monitor/manual_trading_hub/.venv/bin/python`** `…/manual_trading_hub/agent.py`(路径按你机器实际根目录调整);否则在**当前使用的解释器**对应环境中装依赖,或改用官方脚本启动 |
| 子代理行为异常、依赖已装仍报错 | 实际用的不是 hub 的 venv | `ps aux` 查看命令行,应为 **`/opt/crypto_monitor_user/manual_trading_hub/.venv/bin/python`** `…/manual_trading_hub/agent.py`(路径按你机器实际根目录调整);否则在**当前使用的解释器**对应环境中装依赖,或改用官方脚本启动 |
| 子代理端口与 Flask 抢端口 | `PORT` 与策略目录 `.env``APP_PORT` 相同 | 子代理用 **1520015203**(或自改),Flask 继续用 `APP_PORT`,二者勿重复 |
| 全平失败 | 持仓模式、精度、交易所维护 | 看返回 JSON 中 `errors` 字段;对照交易所 App |