feat: add price movement context to flip-flop detection
Improved flip-flop penalty logic to distinguish between: - Chop (bad): <2% price move from opposite signal → -25 penalty - Reversal (good): ≥2% price move from opposite signal → allowed Changes: - lib/database/trades.ts: getRecentSignals() now returns oppositeDirectionPrice - lib/trading/signal-quality.ts: Added currentPrice parameter, price movement check - app/api/trading/check-risk/route.ts: Added currentPrice to RiskCheckRequest interface - app/api/trading/execute/route.ts: Pass openResult.fillPrice as currentPrice - app/api/analytics/reentry-check/route.ts: Pass currentPrice from metrics Example scenarios: - ETH $170 SHORT → $153 LONG (10% move) = reversal allowed ✅ - ETH $154.50 SHORT → $154.30 LONG (0.13% move) = chop blocked ⚠️ Deployed: 09:18 CET Nov 14, 2025 Container: trading-bot-v4
This commit is contained in:
@@ -365,6 +365,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
|
||||
pricePosition: body.pricePosition || 0,
|
||||
direction: body.direction,
|
||||
symbol: driftSymbol,
|
||||
currentPrice: openResult.fillPrice,
|
||||
timeframe: body.timeframe,
|
||||
})
|
||||
|
||||
@@ -596,6 +597,7 @@ export async function POST(request: NextRequest): Promise<NextResponse<ExecuteTr
|
||||
pricePosition: body.pricePosition || 0,
|
||||
direction: body.direction,
|
||||
symbol: driftSymbol,
|
||||
currentPrice: openResult.fillPrice,
|
||||
timeframe: body.timeframe,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user