feat: bidirectional daily auto-transfer with position skip

Rebalance swap to AUTO_TRANSFER_AMOUNT at Beijing hour: top up from funding or sweep excess back. Skip and WeChat notify when active positions exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 09:57:25 +08:00
parent 0456d5fa2c
commit 29b0634c6d
16 changed files with 241 additions and 270 deletions
+33
View File
@@ -0,0 +1,33 @@
# 每日自动划转(四所统一)
## 行为
`.env` 开启 `AUTO_TRANSFER_ENABLED=true` 后,监控轮询在**北京时间 `AUTO_TRANSFER_BJ_HOUR` 整点所在小时**内(默认 8:00–8:59)执行一次(按 **UTC 自然日** 去重):
| 交易账户 (`AUTO_TRANSFER_TO`,默认 swap) | 动作 |
|------------------------------------------|------|
| 余额 **低于** `AUTO_TRANSFER_AMOUNT` | 从 `AUTO_TRANSFER_FROM`(默认 funding)划入差额 |
| 余额 **高于** `AUTO_TRANSFER_AMOUNT` | 将多余划回 `AUTO_TRANSFER_FROM` |
| 与目标相差 &lt; 0.01U | 跳过,不写划转 |
| 存在 **active** 持仓(`order_monitors` | **不划转**,写账簿 `skipped`,并**企业微信**说明「持仓中,本次资金无划转」 |
## 配置示例(目标 50U
```env
AUTO_TRANSFER_ENABLED=true
AUTO_TRANSFER_AMOUNT=50
AUTO_TRANSFER_FROM=funding
AUTO_TRANSFER_TO=swap
AUTO_TRANSFER_BJ_HOUR=8
```
API Key 须具备万向划转权限(与手动划转相同)。
## 部署
```bash
git pull
python scripts/sync_four_exchange_transfer_env.py # 仅补全缺项
# 编辑各所 .envAUTO_TRANSFER_ENABLED=true、AUTO_TRANSFER_AMOUNT=50
pm2 restart crypto-monitor-binance crypto-monitor-okx crypto-monitor-gate crypto-monitor-gate-bot
```