160 lines
6.0 KiB
Markdown
160 lines
6.0 KiB
Markdown
# gate_scout_order(onchain_scout)
|
||
|
||
Gate.io **USDT 永续** 量化辅助工具集:包含 **扫描监控端** 与 **下单执行器** 两个独立 Python 服务,可同机或分机部署,通过 HTTP 联动。
|
||
|
||
**Git 仓库:** https://git.bz121.com/dekun/gate_scout_order.git
|
||
|
||
```text
|
||
gate_scout_order/ # git clone 后的根目录(名称可自定)
|
||
├── onchain_scout_gate/ # 扫描端 · 行情监控、企微告警、信号转发(默认 :8088)
|
||
├── gate_order_executor/ # 执行器 · 接信号、Gate 下单、面板风控(默认 :8090+)
|
||
├── 部署说明.md # ★ 完整部署 + 升级前备份清单
|
||
├── 备份恢复说明.md # 手动备份 / 恢复(/opt → /root)
|
||
├── CLONE.md
|
||
└── README.md # 本文件
|
||
```
|
||
|
||
---
|
||
|
||
## 两个子项目
|
||
|
||
| 子目录 | 作用 | 默认端口 | 详细说明 |
|
||
|--------|------|----------|----------|
|
||
| [`onchain_scout_gate/`](onchain_scout_gate/) | 7×24 扫描 Gate 永续;5m 箱体突破;企微推送;可选 Gemma 漏斗;**面板维护多执行器转发列表** | `8088` | [onchain_scout_gate/README.md](onchain_scout_gate/README.md) |
|
||
| [`gate_order_executor/`](gate_order_executor/) | 接收 `POST /v1/signal`;市价开仓 + 计划止盈/止损;盈亏比门槛;移动保本;持仓面板 | `8090`(多账户可 `8091`…) | [gate_order_executor/README.md](gate_order_executor/README.md) |
|
||
|
||
---
|
||
|
||
## 协作关系
|
||
|
||
```mermaid
|
||
flowchart LR
|
||
gate[Gate.io 公共行情 API]
|
||
scout[onchain_scout_gate]
|
||
wecom[企业微信]
|
||
ex1[gate_order_executor 实例 A]
|
||
ex2[gate_order_executor 实例 B]
|
||
gate --> scout
|
||
scout --> wecom
|
||
scout -->|同一 signal 广播| ex1
|
||
scout -->|可选| ex2
|
||
ex1 --> gate2[Gate 私有 API 账户 A]
|
||
ex2 --> gate3[Gate 私有 API 账户 B]
|
||
```
|
||
|
||
1. 扫描端发现 **TRIGGER** 且通过推送门控 → **企业微信** 告警。
|
||
2. 企微成功后 → 向面板中 **已启用** 的执行器 `POST /v1/signal`(方案 A 止盈/止损,同一 `signal_id`)。
|
||
3. 各执行器自行决定是否接单(最低盈亏比等),**规则不在扫描端区分**。
|
||
4. 转发请求 **不走** 扫描端 `proxy`,直连各执行器 `base_url`。
|
||
|
||
设计归档:[onchain_scout_gate/docs/多执行器与信号转发归档.md](onchain_scout_gate/docs/多执行器与信号转发归档.md)
|
||
|
||
---
|
||
|
||
## Git 克隆
|
||
|
||
```bash
|
||
git clone https://git.bz121.com/dekun/gate_scout_order.git gate_scout_order
|
||
cd gate_scout_order
|
||
```
|
||
|
||
- 克隆步骤摘要:[CLONE.md](CLONE.md)
|
||
- **完整部署、升级备份、PM2、多执行器、关代理**:[部署说明.md](部署说明.md)
|
||
- **手动备份与恢复(`/opt/gate_scout_order` → `/root`)**:[备份恢复说明.md](备份恢复说明.md)
|
||
|
||
---
|
||
|
||
## 快速开始(本机)
|
||
|
||
### 1. 扫描端
|
||
|
||
```bash
|
||
cd onchain_scout_gate
|
||
python -m venv .venv
|
||
# Windows: .\.venv\Scripts\Activate.ps1
|
||
# Linux: source .venv/bin/activate
|
||
pip install -r requirements.txt
|
||
cp config.example.yaml config.yaml
|
||
# 编辑 config.yaml:wecom、gate、proxy、auth
|
||
python run.py
|
||
```
|
||
|
||
- 面板:`http://127.0.0.1:8088/dashboard`
|
||
- 部署:[onchain_scout_gate/交易系统部署说明.md](onchain_scout_gate/交易系统部署说明.md)
|
||
- 本地 SOCKS:[onchain_scout_gate/docs/本地部署-SOCKS5代理.md](onchain_scout_gate/docs/本地部署-SOCKS5代理.md)
|
||
|
||
### 2. 执行器(可先 dry_run)
|
||
|
||
```bash
|
||
cd gate_order_executor
|
||
python -m venv .venv
|
||
pip install -r requirements.txt
|
||
cp config.example.yaml config.yaml
|
||
# 编辑 config.yaml:security.webhook_secret、gate(dry_run: true 联调)
|
||
python run.py
|
||
```
|
||
|
||
- 健康检查:`http://127.0.0.1:8090/health`
|
||
- 面板:`http://127.0.0.1:8090/dashboard`
|
||
- 部署:[gate_order_executor/docs/部署说明.md](gate_order_executor/docs/部署说明.md)
|
||
|
||
### 3. 串联
|
||
|
||
1. 执行器 `security.webhook_secret` 与扫描端面板 **「下单执行器」** 里填写的 Webhook 密钥 **一致**。
|
||
2. 扫描端面板添加执行器:`http://127.0.0.1:8090`,打开总开关。
|
||
3. 执行器 `gate.dry_run: false` 并配置子账户 API 后才会实盘下单。
|
||
|
||
---
|
||
|
||
## 多执行器 / 对照实验
|
||
|
||
- 在扫描端 Web **「下单执行器 · 转发链」** 添加多条 Base URL(如 `:8090`、`:8091`)。
|
||
- 每个 URL 对应 **独立进程 + 独立 Gate API**;盈亏比、移动保本在各执行器自己的面板/配置中修改。
|
||
- 列表保存在 `onchain_scout_gate/runtime/order_executors.json`,**仅扫描端维护**。
|
||
|
||
---
|
||
|
||
## 云服务器:关闭代理
|
||
|
||
本机开发若使用 `proxy.enabled: true`(SOCKS),迁到 **可直连** `api.gateio.ws` 的境外云主机后,扫描端与 **每个** 执行器均应设:
|
||
|
||
```yaml
|
||
proxy:
|
||
enabled: false
|
||
```
|
||
|
||
说明见:
|
||
|
||
- [onchain_scout_gate/交易系统部署说明.md §8](onchain_scout_gate/交易系统部署说明.md)
|
||
- [gate_order_executor/docs/部署说明.md §6.1](gate_order_executor/docs/部署说明.md)
|
||
|
||
---
|
||
|
||
## 文档索引
|
||
|
||
| 主题 | 路径 |
|
||
|------|------|
|
||
| **完整部署与备份** | **[部署说明.md](部署说明.md)** |
|
||
| 克隆与分支 | [CLONE.md](CLONE.md) |
|
||
| 多执行器归档 | [onchain_scout_gate/docs/多执行器与信号转发归档.md](onchain_scout_gate/docs/多执行器与信号转发归档.md) |
|
||
| 扫描端安装 | [onchain_scout_gate/安装与说明.md](onchain_scout_gate/安装与说明.md) |
|
||
| 执行器使用 | [gate_order_executor/docs/使用说明.md](gate_order_executor/docs/使用说明.md) |
|
||
|
||
---
|
||
|
||
## 环境要求
|
||
|
||
- Python **3.10+**(推荐 3.11)
|
||
- 访问 Gate.io API(扫描端可用公共行情;执行器需 API Key)
|
||
- 可选:Node.js + PM2(Linux 生产部署)
|
||
- 可选:本地 Ollama(扫描端 Gemma 漏斗)
|
||
- 走 SOCKS 时需 `httpx[socks]` / `socksio`(见各子项目 `requirements.txt`)
|
||
|
||
---
|
||
|
||
## 安全提示
|
||
|
||
- **勿** 将含 `config.yaml`、API 密钥、`runtime/` 数据库的目录提交到公开仓库。
|
||
- 执行器端口(8090 等)建议仅本机或内网访问;公网请 Nginx + HTTPS + 鉴权。
|
||
- `webhook_secret` 修改后须同步到 **所有** 执行器实例。
|