feat: Revenge system enhancements #4 and #10 - IMPLEMENTED

Enhancement #4: Failed Revenge Tracking
- Added 3 database fields: revengeOutcome, revengePnL, revengeFailedReason
- Added updateRevengeOutcome() method in stop-hunt-tracker.ts
- Position Manager hooks revenge trade closes, records outcome
- Enables data-driven analysis of revenge success rate

Enhancement #10: Metadata Persistence
- Added 4 database fields: firstCrossTime, lowestInZone, highestInZone, zoneResetCount
- Migrated 90-second zone tracking from in-memory to database
- Rewrote shouldExecuteRevenge() with database persistence
- Container restarts now preserve exact zone tracking state

Technical Details:
- Prisma schema updated with 7 new StopHunt fields
- Added signalSource field to ActiveTrade interface
- All zone metadata persisted in real-time to database
- Build verified successful (no TypeScript errors)

Files Changed:
- prisma/schema.prisma (StopHunt model + index)
- lib/trading/stop-hunt-tracker.ts (DB persistence + outcome tracking)
- lib/trading/position-manager.ts (revenge hook + interface)
- docs/REVENGE_ENHANCEMENTS_EXPLAINED.md (comprehensive guide)

Pending User Decision:
- Enhancement #1: ADX confirmation (3 options explained in docs)
- Enhancement #6: SL distance validation (2× ATR recommended)

Status: Ready for deployment after Prisma migration
Date: Nov 27, 2025
This commit is contained in:
mindesbunister
2025-11-27 08:08:37 +01:00
parent 2238261dfe
commit ceb84c3bc1
6 changed files with 586 additions and 33 deletions

View File

@@ -10,6 +10,9 @@ MANDATORY FIRST STEPS:
- This is 4,400+ lines of critical context
- Every section matters - shortcuts cause financial losses
- Pay special attention to Common Pitfalls (60+ documented bugs)
- Clean up after yourself in code and documentation
- keep user data secure and private
- keep a clean structure for future developers
2. UNDERSTAND THE VERIFICATION ETHOS
- NEVER say "done", "fixed", "working" without 100% verification