diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d7f2ad4..e7ed366 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -3253,7 +3253,80 @@ This section contains the **TOP 10 MOST CRITICAL** pitfalls that every AI agent 📚 **Full Documentation:** `docs/COMMON_PITFALLS.md` (73 pitfalls with code examples, git commits, deployment dates) -79. **CRITICAL: n8n Undefined Field Reference - SHORT Signals Failing (CRITICAL - Dec 12, 2025):** +79. **CRITICAL: Smart Validation Queue Ignores Symbol Enabled Status - Telegram Spam (CRITICAL - Dec 15, 2025):** + - **Symptom:** Receiving Telegram notifications ("SIGNAL QUEUED", "SIGNAL VALIDATED", "ENTERING NOW") for symbols not trading (e.g., FARTCOIN enabled=false) + - **User Report:** "can you please check for the fartcoin data collection. i dont want to receive notifications in telegram as we are not trading it currently" + - **Financial Impact:** Notification spam for data-collection-only symbols, user confusion, unnecessary monitoring + - **Root Cause:** + * File: `app/api/trading/check-risk/route.ts` lines 442-455 + * Smart Validation Queue queues quality 50-89 signals WITHOUT checking if symbol trading enabled + * Code pattern: + ```typescript + if (isInValidationRange) { + const validationQueue = getSmartValidationQueue() + const normalizedSymbol = normalizeTradingViewSymbol(body.symbol) + // BUG: No check for enabled status before queueing + await validationQueue.addSignal({ symbol: normalizedSymbol, ... }) + } + ``` + * Validation queue sends Telegram notifications at multiple stages (queued, validated, entering) + * Execute endpoint checks enabled status (line 290-310) but TOO LATE (after notifications sent) + - **Evidence:** + * Docker logs: "⏰ Smart validation queued: FARTCOIN-PERP SHORT @ $13.21 (quality: 60)" + * Docker logs: "✅ VALIDATED ENTRY BYPASS: Quality 60 accepted" + * Config: `fartcoin: { enabled: false }` at line 147 + * System correctly collecting 1-min data but also sending validation notifications + - **THE FIX (Dec 15, 2025):** + ```typescript + // BEFORE (lines 442-455 - BROKEN): + if (isInValidationRange) { + const validationQueue = getSmartValidationQueue() + const normalizedSymbol = normalizeTradingViewSymbol(body.symbol) + await validationQueue.addSignal({ ... }) // ❌ No enabled check + } + + // AFTER (FIXED): + if (isInValidationRange) { + const validationQueue = getSmartValidationQueue() + const normalizedSymbol = normalizeTradingViewSymbol(body.symbol) + + // Check if symbol trading enabled BEFORE queueing + const { enabled } = getActualPositionSizeForSymbol(normalizedSymbol, config) + + if (!enabled) { + console.log(`⛔ Skipping validation queue: ${normalizedSymbol} trading disabled (data collection only)`) + } else { + await validationQueue.addSignal({ ... }) // ✅ Only queue if enabled + } + } + ``` + - **Why This Matters:** + * **This is a REAL MONEY system** - data collection symbols should be silent + * User only wants notifications for SOL-PERP, BTC-PERP, ETH-PERP (enabled symbols) + * Validation queue designed for marginal quality signals (50-89) to confirm before execution + * But shouldn't send notifications for symbols user isn't trading + * 1-minute data collection continues silently (correct behavior) + - **Prevention Rules:** + 1. ALWAYS check enabled status before adding signals to validation queue + 2. NEVER send Telegram notifications for disabled symbols + 3. Data collection (BlockedSignal database) should continue for analysis + 4. Validation queue is for TRADING validation, not data collection + 5. Execute endpoint enabled check (line 290-310) is backup, not primary + 6. Check-risk endpoint must be first line of defense for symbol filtering + - **Red Flags Indicating This Bug:** + * Telegram notifications for symbols with enabled=false in config + * User asks "why am I receiving notifications for X?" + * Docker logs show "Smart validation queued" for disabled symbols + * System correctly saves to BlockedSignal but also sends Telegram + * Multiple notification types (QUEUED, VALIDATED, ENTERING) for data collection signals + - **Files Changed:** + * app/api/trading/check-risk/route.ts: Lines 442-470 (added enabled check before queueing) + - **Git commit:** [CURRENT] "fix: Smart Validation Queue respects symbol enabled status" (Dec 15, 2025) + - **Deployment:** Pending build + restart + - **Status:** ✅ CODE FIXED - Awaiting deployment verification + - **Expected Result:** No more FARTCOIN Telegram notifications, 1-min data collection continues silently + +80. **CRITICAL: n8n Undefined Field Reference - SHORT Signals Failing (CRITICAL - Dec 12, 2025):** - **Symptom:** SHORT signals stopped at Execute Trade1 node with error "JSON parameter needs to be valid JSON" - **User Report:** "last short signal stopped in n8n at the execute trade 1 with the error JSON parameter needs to be valid JSON" - **Financial Impact:** Part of $1,000+ losses - SHORT trades not executing in production diff --git a/app/api/trading/check-risk/route.ts b/app/api/trading/check-risk/route.ts index 6b61410..40d5ed1 100644 --- a/app/api/trading/check-risk/route.ts +++ b/app/api/trading/check-risk/route.ts @@ -447,23 +447,32 @@ export async function POST(request: NextRequest): Promise