trading skills: 文档同步 (单币上限规则/平仓盈亏字段/静默规则/推送模板)
This commit is contained in:
@@ -74,4 +74,58 @@ If the change in position or price is within a certain threshold (e.g., <2% or <
|
||||
2. **Priority**: A-class (加仓) and C-class (新开) always get full attention.
|
||||
3. **Aggregator logic**: If multiple signals arrive, group them into a single response if possible (e.g., "Summary of last 3 signals").
|
||||
4. **Manual override**: If the user asks for a summary or "what's next", use the current state to provide a consolidated view.
|
||||
5. **No verbose tracking** (User correction 2026-07-02): Do NOT create statistical tables, trend analysis, or verbose summaries for D-class signals. Just process A/B/C signals with the opening skill and push to QQ. For D-class signals, simply note "跳过QQ推送" (skip QQ push) without detailed tracking tables. The user explicitly said: "有信号就用开仓技能就行了,其他不需要你统计" (Just use the opening skill for signals, no need for you to do statistics).
|
||||
### 5. **No verbose tracking** (User correction 2026-07-02): Do NOT create statistical tables, trend analysis, or verbose summaries for D-class signals. Just process A/B/C signals with the opening skill and push to QQ. For D-class signals, simply note "跳过QQ推送" (skip QQ push) without detailed tracking tables. The user explicitly said: "有信号就用开仓技能就行了,其他不需要你统计" (Just use the opening skill for signals, no need for you to do statistics).
|
||||
|
||||
### 6. **"无持仓 + 减仓信号 = 静默跳过" (User correction 2026-09-20) 🔇
|
||||
|
||||
**踩坑现场**: 熬鹰币安实盘**重复发同一减仓信号**(同币种同方向),如果用户**没有对应持仓** → `process_signal.py` line 1131 推 `⏭️ 减仓信号: 你无 ZAMA 持仓, 跳过` 到 QQ → **1 分钟内刷屏 50+ 条相同消息**。User 原话: "这种减仓的,而我没有持仓的就不处理了"。
|
||||
|
||||
**正确行为** (修改 `process_signal.py`):
|
||||
```python
|
||||
if not our_pos:
|
||||
msg = None # None = 不推 QQ
|
||||
outcome = 'silent_no_pos'
|
||||
# ... 后续 record_signal + dedup 正常执行, 但跳过 push_to_qq
|
||||
if msg is None:
|
||||
return f"🔇 静默跳过 | {symbol} {side} {leverage}x"
|
||||
```
|
||||
|
||||
**铁律**:
|
||||
- **静默** "无持仓 + 减仓信号" 路径 = **不推 QQ** 但仍然 record_signal (用于去重)
|
||||
- **不要**给静默留 push 选项 ("要不要 push 一下说明?") — 用户明令"不处理"
|
||||
- **静默指标**: `outcome = 'silent_no_pos'` 写到 `_tracker_record()` 便于事后查询"为什么没动"
|
||||
- **同类 D-class 静默候选**: 平仓信号无持仓、加仓信号总资产超阈值 ($1000)、调杠杆信号无持仓、减仓信号无持仓
|
||||
|
||||
### 7. **process_signal 失败路径仍 mark_done — 信号队列 bug (2026-09-20 实战)
|
||||
|
||||
**踩坑现场**: BTC 平仓信号 (queue 337, 9/21 03:12) → `close_position_raw()` 因 proxy 抽风返 None → `process_signal.py` line 868 `return "❌ 平仓失败: ..."` → **returncode = 0**(正常退出)→ `signal_queue.py` line 110 `if r.returncode == 0: mark_done(row_id, r.stdout[:200])` → **queue 标 done 但仓位没平**。
|
||||
|
||||
**事故代价**: BTC 1.6 张 short 5 小时持仓, 价格波动导致 UPL 从 -X% 到 **-50.5% (-$69)** — 用户手动发现前已扩大亏损 (User 原话: "是啊,为什么标记done了,亏损翻倍了")。
|
||||
|
||||
**根因**:
|
||||
- `signal_queue.py` **只判 returncode**, 不看 result 内容
|
||||
- `process_signal.py` 平仓失败分支只 `return` 字符串, **不抛异常** → returncode = 0
|
||||
- `result` 列被写成 `❌ 平仓失败: ...` 但被标为 done
|
||||
|
||||
**当前修复 (临时)**:
|
||||
1. 平仓失败必须推 QQ (line 864-866 已修, 2026-09-16)
|
||||
2. **用户会看到** ❌ 推送 → 手动补救
|
||||
3. **但 queue 仍然标 done** → 不会 retry → 错过的信号不会再来
|
||||
|
||||
**推荐修复 (TODO)**:
|
||||
- `process_signal.py` 平仓失败时 `sys.exit(1)` 或 raise exception → `signal_queue.py` mark_failed
|
||||
- **OR**: `signal_queue.py` 改判 returncode + 检测 stdout 是否含 `❌`/`失败`/`proxy 抽风`
|
||||
- **OR**: 加 retry 字段 (retries < 3 才 fail)
|
||||
|
||||
**应急检测** (查历史有没有漏掉的失败):
|
||||
```bash
|
||||
sqlite3 ~/.hermes/trading/signal_queue.db \
|
||||
"SELECT id, substr(created_at,1,19), substr(result,1,80) \
|
||||
FROM queue WHERE result LIKE '%❌%' AND status='done' ORDER BY id DESC LIMIT 20"
|
||||
# → 列出来的就是"标 done 但实际失败"的信号, 必须手动补救
|
||||
```
|
||||
|
||||
**铁律**:
|
||||
- `signal_queue.db` 的 `status` **不等于** `实际结果` — 必须看 `result` 列
|
||||
- 任何 `status='done'` + `result` 含 `❌` / `失败` / `proxy 抽风` = **实际失败**, 必须 re-fetch OKX 验证
|
||||
- 不要信任 cron "跑过" 的日志 — 必须 cross-check 实际仓位
|
||||
|
||||
Reference in New Issue
Block a user