fix: Accept market_data_1min action in webhook endpoint

CRITICAL: 1-minute ATR data feed not working - Telegram bot timing out

Root cause:
- TradingView alert sends action: 'market_data_1min'
- Endpoint checked for exact match: 'market_data'
- Result: 400 Bad Request, no data cached

The fix:
- Accept both 'market_data' and 'market_data_1min'
- Prevents rejection of 1-minute TradingView alerts
- Enables fresh ATR data for manual Telegram trades

User symptom: 'long sol' → timeout → fallback to preset ATR 0.43
After fix: 'long sol' → waits for fresh 1min data → uses real ATR

Files changed:
- app/api/trading/market-data/route.ts line 64-71
This commit is contained in:
mindesbunister
2025-12-09 18:42:26 +01:00
parent 57ac0c0400
commit 96683497f4

View File

@@ -61,11 +61,12 @@ export async function POST(request: NextRequest) {
adx: body.adx adx: body.adx
}) })
// Validate it's a market data update // Validate it's a market data update (accept both variations)
if (body.action !== 'market_data') { const validActions = ['market_data', 'market_data_1min']
console.log(`❌ Invalid action: ${body.action} (expected "market_data")`) if (!validActions.includes(body.action)) {
console.log(`❌ Invalid action: ${body.action} (expected ${validActions.join(' or ')})`)
return NextResponse.json( return NextResponse.json(
{ error: 'Invalid action - expected "market_data"' }, { error: `Invalid action - expected ${validActions.join(' or ')}` },
{ status: 400 } { status: 400 }
) )
} }