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:
61
docs/architecture/POSITION_SYNC_QUICK_REF.md
Normal file
61
docs/architecture/POSITION_SYNC_QUICK_REF.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Position Sync - Quick Reference
|
||||
|
||||
## 🚨 When to Use
|
||||
- Position open on Drift but Position Manager shows 0 trades
|
||||
- Database says "closed" but Drift shows position still open
|
||||
- After manual Telegram trades with partial fills
|
||||
- Bot restart lost in-memory tracking
|
||||
- Rate limiting (429 errors) disrupted monitoring
|
||||
|
||||
## ✅ Three Ways to Sync
|
||||
|
||||
### 1. Settings UI (Easiest)
|
||||
1. Go to http://localhost:3001/settings
|
||||
2. Click the orange **"🔄 Sync Positions"** button (next to Restart Bot)
|
||||
3. View results in green success message
|
||||
|
||||
### 2. Terminal Script
|
||||
```bash
|
||||
cd /home/icke/traderv4
|
||||
bash scripts/sync-positions.sh
|
||||
```
|
||||
|
||||
### 3. Direct API Call
|
||||
```bash
|
||||
source /home/icke/traderv4/.env
|
||||
curl -X POST http://localhost:3001/api/trading/sync-positions \
|
||||
-H "Authorization: Bearer ${API_SECRET_KEY}"
|
||||
```
|
||||
|
||||
## 📊 What It Does
|
||||
|
||||
**Fetches** all open positions from Drift (SOL-PERP, BTC-PERP, ETH-PERP)
|
||||
|
||||
**Compares** against Position Manager's tracked trades
|
||||
|
||||
**Removes** tracking for positions closed externally
|
||||
|
||||
**Adds** tracking for unmonitored positions with:
|
||||
- Stop loss at configured %
|
||||
- TP1/TP2 at configured %
|
||||
- Emergency stop protection
|
||||
- Trailing stop (if TP2 hit)
|
||||
- MAE/MFE tracking
|
||||
|
||||
**Result**: Dual-layer protection restored ✅
|
||||
|
||||
## 🎯 Your Current Situation
|
||||
|
||||
- **Before Sync:** 4.93 SOL SHORT open, NO software protection
|
||||
- **After Sync:** Position Manager monitors it every 2s with full TP/SL system
|
||||
|
||||
## ⚠️ Limitations
|
||||
|
||||
- Entry time unknown (assumes 1 hour ago - doesn't affect TP/SL)
|
||||
- Signal quality metrics missing (only matters for scaling feature)
|
||||
- Uses current config (not original config from when trade opened)
|
||||
- Synthetic position ID (manual-{timestamp} instead of real TX)
|
||||
|
||||
## 📖 Full Documentation
|
||||
|
||||
See: `docs/guides/POSITION_SYNC_GUIDE.md`
|
||||
Reference in New Issue
Block a user