docs: MANDATORY - Always verify Drift API before position operations

CRITICAL incident (Dec 9, 2025):
- Agent closed position based on stale bot data
- User explicitly said NOT to close
- Bot logs showed 'closed' but Drift still had open position
- Catastrophic if user wants to keep position open

NEW IRON-CLAD RULE:
- NEVER trust bot logs, API responses, or database alone
- ALWAYS query Drift API first: curl sync-positions
- Verify actual position.size, entry, P&L from Drift
- Only AFTER Drift verification: proceed with any operation

This is NON-NEGOTIABLE for financial system integrity.
This commit is contained in:
mindesbunister
2025-12-09 20:19:56 +01:00
parent f2e4156c8a
commit 64d520ad09

View File

@@ -1263,12 +1263,22 @@ docker logs -f trading-bot-v4 | grep "expected log message from fix"
### Critical Path Verification Requirements
**MANDATORY: ALWAYS VERIFY DRIFT STATE BEFORE ANY POSITION OPERATIONS (Dec 9, 2025)**
- **NEVER trust bot logs, API responses, or database state alone**
- **ALWAYS query Drift API first:** `curl -X POST /api/trading/sync-positions -H "Authorization: Bearer $API_SECRET_KEY"`
- **Verify actual position.size, entry price, current P&L from Drift response**
- **Only AFTER Drift verification:** proceed with close, modify orders, or state changes
- **Incident:** Agent closed position based on stale bot data when user explicitly said NOT to close
- **Why:** Bot logs showed "closed" but Drift still had open position - catastrophic if user wants to keep position open
- **This is NON-NEGOTIABLE** - verify Drift state before ANY position operation
**Position Manager Changes:**
- [ ] Execute test trade with DRY_RUN=false (small size)
- [ ] Watch docker logs for full TP1 → TP2 → exit cycle
- [ ] SQL query: verify `tp1Hit`, `slMovedToBreakeven`, `currentSize` match Position Manager logs
- [ ] Compare Position Manager tracked size to actual Drift position size
- [ ] Check exit reason matches actual trigger (TP1/TP2/SL/trailing)
- [ ] **VERIFY VIA DRIFT API** before declaring anything "working" or "closed"
**Exit Logic Changes (TP/SL/Trailing):**
- [ ] Log EXPECTED values (TP1 price, SL price after breakeven, trailing stop distance)