From 57f0457f958e903b9cbaac80cd70ef717f40a9bd Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Mon, 3 Nov 2025 14:34:26 +0100 Subject: [PATCH] fix: Require signal quality check for position flips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem:** - Signal flips (SHORT→LONG or LONG→SHORT) were auto-approved - Bypassed signal quality scoring, cooldown, drawdown checks - User wanted flips ONLY if new signal has strong quality (score ≥60) **Solution:** - Removed early return for opposite-direction signals in check-risk - Flips now go through FULL validation: quality score, cooldown, limits - Execute endpoint still handles flip logic (close opposite + open new) **New Flow:** 1. n8n sends flip signal → check-risk endpoint 2. Detects potential flip, logs 'checking quality score' 3. Continues to quality checks (not early return) 4. If score ≥60 AND all checks pass → execute handles flip 5. If score <60 → BLOCKS flip with 'Signal quality too low' **Result:** Flips now require signal strength, not just direction change --- app/api/trading/check-risk/route.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/api/trading/check-risk/route.ts b/app/api/trading/check-risk/route.ts index 4c497e1..f4c22ca 100644 --- a/app/api/trading/check-risk/route.ts +++ b/app/api/trading/check-risk/route.ts @@ -73,19 +73,16 @@ export async function POST(request: NextRequest): Promise