Files
crypto_monitor/docs/position-sizing-mode.md
T
dekun 02bc3c14bc docs: document four-exchange env sync script usage
Add docs/env-sync-scripts.md; cross-link from deploy README, feature docs, README, and script headers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 10:02:08 +08:00

56 lines
2.1 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.
# 计仓模式(四所统一)
## 配置
在各实例 `.env` 中设置(**仅能通过 env 切换,修改后须重启进程**):
```env
# risk(默认)= 以损定仓
# full_margin = 全仓杠杆(合约可用保证金 × 比例)
POSITION_SIZING_MODE=risk
FULL_MARGIN_BUFFER_RATIO=0.98
```
切换为全仓杠杆前:**交易所须无持仓**(`MAX_ACTIVE_POSITIONS` 默认 1,全仓模式会强制单仓)。
## 模式说明
| 模式 | 保证金计算 | 杠杆 | 允许入口 |
|------|------------|------|----------|
| `risk` | `RISK_PERCENT` × 交易资金,按止损距离反推 | 表单可选 / 同步交易所 | 实盘人工、关键位自动、趋势回调、顺势加仓 |
| `full_margin` | **合约账户可用 USDT × `FULL_MARGIN_BUFFER_RATIO`**(保留 2 位小数) | BTC/ETH **10x**,其它 **5x**(与 `BTC_LEVERAGE`/`ALT_LEVERAGE` 一致) | **仅** 实盘人工下单;阻力/支撑仅提醒 |
全仓模式下:
- 仍校验 **计划盈亏比**`MANUAL_MIN_PLANNED_RR`)。
- 下单张数由 `prepare_order_amount` + 交易所 `amount_to_precision` 决定。
- `order_monitors.initial_stop_loss` 仍记录**开仓时**止损快照;交易记录复盘以该快照为准。
- 已存在的 **箱体突破 / 收敛突破 / 斐波** 监控:进程启动时**自动撤销**并企业微信通知。
## 不允许(全仓模式)
- 关键位:箱体突破、收敛突破、斐波自动单(添加时拒绝;已存在则启动时撤销)。
- 趋势回调、顺势加仓(策略入口返回明确错误)。
## 用脚本更新四所 `.env`
详见 **[env-sync-scripts.md](./env-sync-scripts.md)**。常用命令:
```bash
git pull
# 仅补全计仓相关项(缺省 risk、缓冲 0.98)
python scripts/sync_four_exchange_position_sizing_env.py
# 无仓后切换全仓
python scripts/sync_four_exchange_position_sizing_env.py --set-mode full_margin
# 无仓后切回以损定仓
python scripts/sync_four_exchange_position_sizing_env.py --set-mode risk
# 计仓 + 划转一并补全
python scripts/sync_four_exchange_env.py
pm2 restart crypto-monitor-binance crypto-monitor-okx crypto-monitor-gate crypto-monitor-gate-bot
```