From cefa3e646dcd7b3e68aca43e041b424a47cd53e9 Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Thu, 27 Nov 2025 23:17:29 +0100 Subject: [PATCH] critical: MANDATORY quality score check in execute endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ROOT CAUSE: - Execute endpoint calculated quality score but NEVER checked it - After timeframe='5' validation, proceeded directly to execution - TradingView sent signal with all metrics=0 (ADX, ATR, RSI, etc.) - Quality scored as 30, but no threshold check existed - Position opened with 909.77 size at quality 30 (need 90+ for LONG) THE FIX: - Added MANDATORY quality check after timeframe validation - Blocks execution if score < minQualityScore (90 LONG, 95 SHORT) - Returns HTTP 400 with detailed error message - Logs Quality check passed OR ❌ QUALITY TOO LOW: AFFECTED TRADES: - cmihwkjmb0088m407lqd8mmbb: Quality 30 LONG (stopped out) - cmih6ghn20002ql07zxfvna1l: Quality 50 LONG (stopped out) - cmih5vrpu0001ql076mj3nm63: Quality 50 LONG (stopped out) This is a FINANCIAL SAFETY critical fix - prevents low-quality trades. --- app/api/trading/execute/route.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/api/trading/execute/route.ts b/app/api/trading/execute/route.ts index 409932d..7ee6354 100644 --- a/app/api/trading/execute/route.ts +++ b/app/api/trading/execute/route.ts @@ -189,6 +189,25 @@ export async function POST(request: NextRequest): Promise= ${minQualityScore}`) // Initialize Drift service and check account health before sizing const driftService = await initializeDriftService()