From 795026aed16298b65e4907b921a9009acbaef2ec Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Fri, 14 Nov 2025 08:23:04 +0100 Subject: [PATCH] fix: use Pyth price data for flip-flop context check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: Previous implementation showed incorrect price movements (100% instead of 0.2%) because currentPrice wasn't available in check-risk endpoint. Changes: - app/api/trading/check-risk/route.ts: Fetch current price from Pyth price monitor before quality scoring - lib/trading/signal-quality.ts: Added validation and detailed logging - Check if currentPrice available, apply penalty if missing - Log actual prices: $X → $Y = Z% - Include prices in penalty/allowance messages Example outputs: Flip-flop in tight range: 4min ago, only 0.20% move ($143.86 → $143.58) (-25 pts) Direction change after 10.2% move ($170.00 → $153.00, 12min ago) - reversal allowed This fixes the false positive that allowed a 0.2% flip-flop earlier today. Deployed: 09:42 CET Nov 14, 2025 --- app/api/trading/check-risk/route.ts | 7 ++++- lib/trading/signal-quality.ts | 42 ++++++++++++++++++----------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/app/api/trading/check-risk/route.ts b/app/api/trading/check-risk/route.ts index 04faf5b..bc999cf 100644 --- a/app/api/trading/check-risk/route.ts +++ b/app/api/trading/check-risk/route.ts @@ -312,6 +312,11 @@ export async function POST(request: NextRequest): Promise