# 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`