docs: Major documentation reorganization + ENV variable reference
**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
This commit is contained in:
82
docs/bugs/CRITICAL_MISSING_TRADES_NOV19.md
Normal file
82
docs/bugs/CRITICAL_MISSING_TRADES_NOV19.md
Normal file
@@ -0,0 +1,82 @@
|
||||
# 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):
|
||||
1. $31.41 profit (6h ago)
|
||||
2. $22.78 profit (6h ago)
|
||||
3. $9.72 profit (12h ago)
|
||||
4. $29.18 profit (12h ago)
|
||||
5. $18.42 profit (14h ago)
|
||||
6. $21.67 profit (15h ago)
|
||||
7. $1.33 profit (19h ago)
|
||||
8. $4.08 profit (19h ago)
|
||||
9. $8.31 profit (19h ago)
|
||||
10. **-$99.93 loss** (19h ago)
|
||||
|
||||
**Total: $46.97**
|
||||
|
||||
### Database (5 trades recorded):
|
||||
1. $54.19 (13:56) - v8, quality 85
|
||||
2. $37.67 (07:47) - v8, quality 110
|
||||
3. $59.35 (05:56) - v8, quality 105
|
||||
4. $19.79 (01:24) - v8, quality 90
|
||||
5. -$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
|
||||
|
||||
1. **Database save failures:** Execute endpoint may be failing to save trades
|
||||
2. **Position Manager not tracking:** Trades executing but PM not adding them
|
||||
3. **External closures:** Some trades closed by on-chain orders without PM detection
|
||||
4. **Container restarts:** Trades executed during downtime not recovered
|
||||
5. **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
|
||||
|
||||
1. Query Drift for complete trade history (last 24 hours)
|
||||
2. Identify which trades are missing from database
|
||||
3. Check logs for database save failures during those times
|
||||
4. Check if trades were manual (Telegram) or automated (TradingView)
|
||||
5. Verify Position Manager was running during those times
|
||||
6. 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
|
||||
Reference in New Issue
Block a user