**Documentation Structure:** - Created docs/ subdirectory organization (analysis/, architecture/, bugs/, cluster/, deployments/, roadmaps/, setup/, archived/) - Moved 68 root markdown files to appropriate categories - Root directory now clean (only README.md remains) - Total: 83 markdown files now organized by purpose **New Content:** - Added comprehensive Environment Variable Reference to copilot-instructions.md - 100+ ENV variables documented with types, defaults, purpose, notes - Organized by category: Required (Drift/RPC/Pyth), Trading Config (quality/ leverage/sizing), ATR System, Runner System, Risk Limits, Notifications, etc. - Includes usage examples (correct vs wrong patterns) **File Distribution:** - docs/analysis/ - Performance analyses, blocked signals, profit projections - docs/architecture/ - Adaptive leverage, ATR trailing, indicator tracking - docs/bugs/ - CRITICAL_*.md, FIXES_*.md bug reports (7 files) - docs/cluster/ - EPYC setup, distributed computing docs (3 files) - docs/deployments/ - *_COMPLETE.md, DEPLOYMENT_*.md status (12 files) - docs/roadmaps/ - All *ROADMAP*.md strategic planning files (7 files) - docs/setup/ - TradingView guides, signal quality, n8n setup (8 files) - docs/archived/2025_pre_nov/ - Obsolete verification checklist (1 file) **Key Improvements:** - ENV variable reference: Single source of truth for all configuration - Common Pitfalls #68-71: Already complete, verified during audit - Better findability: Category-based navigation vs 68 files in root - Preserves history: All files git mv (rename), not copy/delete - Zero broken functionality: Only documentation moved, no code changes **Verification:** - 83 markdown files now in docs/ subdirectories - Root directory cleaned: 68 files → 0 files (except README.md) - Git history preserved for all moved files - Container running: trading-bot-v4 (no restart needed) **Next Steps:** - Create README.md files in each docs subdirectory - Add navigation index - Update main README.md with new structure - Consolidate duplicate deployment docs - Archive truly obsolete files (old SQL backups) See: docs/analysis/CLEANUP_PLAN.md for complete reorganization strategy
2.7 KiB
2.7 KiB
CRITICAL: Missing Trades in Database (Nov 19, 2025)
Issue
Database shows 5 v8 trades with $71.07 P&L, but Drift UI shows 10 trades with $46.97 P&L.
5 trades are MISSING from the database despite being executed on Drift.
Evidence
Drift UI (TRUTH - 10 trades in last 19 hours):
- $31.41 profit (6h ago)
- $22.78 profit (6h ago)
- $9.72 profit (12h ago)
- $29.18 profit (12h ago)
- $18.42 profit (14h ago)
- $21.67 profit (15h ago)
- $1.33 profit (19h ago)
- $4.08 profit (19h ago)
- $8.31 profit (19h ago)
- -$99.93 loss (19h ago)
Total: $46.97
Database (5 trades recorded):
- $54.19 (13:56) - v8, quality 85
- $37.67 (07:47) - v8, quality 110
- $59.35 (05:56) - v8, quality 105
- $19.79 (01:24) - v8, quality 90
- -$99.93 (00:45) - v8, quality 80
Total: $71.07
Analysis
Missing trades (not in database but in Drift):
- Approximately 5 trades with smaller P&L values
- Likely the 9.72, 29.18, 18.42, 21.67, 1.33, 4.08, 8.31 trades
- All appear to be profitable small trades
Database P&L values don't match Drift:
- Trade showing $54.19 in DB might be $31.41 in Drift
- Trade showing $37.67 in DB might be $22.78 in Drift
- Discrepancies suggest BOTH missing trades AND incorrect P&L recording
Root Causes to Investigate
- Database save failures: Execute endpoint may be failing to save trades
- Position Manager not tracking: Trades executing but PM not adding them
- External closures: Some trades closed by on-chain orders without PM detection
- Container restarts: Trades executed during downtime not recovered
- n8n workflow failures: Some signals reaching Drift but not saving to DB
Impact
- Data integrity compromised: Can't trust database for analytics
- Performance metrics wrong: Showing $71 when actual is $47
- Missing trade history: Can't analyze what trades were executed
- Withdrawal calculations affected: Total P&L used for withdrawal decisions
Immediate Actions Required
- Query Drift for complete trade history (last 24 hours)
- Identify which trades are missing from database
- Check logs for database save failures during those times
- Check if trades were manual (Telegram) or automated (TradingView)
- Verify Position Manager was running during those times
- Check for container restarts that might explain gaps
Long-term Fix
Need to implement trade reconciliation system:
- Periodic job queries Drift for all trades
- Compares with database records
- Alerts if trades found on Drift but not in DB
- Backfills missing trades automatically
- Added to Common Pitfalls in copilot instructions
Date
November 19, 2025 - 15:00 CET
Status
🔴 CRITICAL - Investigating root cause