import { NextResponse } from 'next/server' export async function GET() { try { console.log('🚀 Starting analysis-details API call...') // Return mock data structure that matches what the automation page expects const analysisData = { success: true, data: { // Analysis details for the main display symbol: 'SOLUSD', recommendation: 'HOLD', confidence: 75, reasoning: 'Market conditions are neutral. No clear trend direction detected across timeframes.', // Multi-timeframe analysis timeframes: [ { timeframe: '4h', sessionId: 'session_4h_' + Date.now(), totalTrades: 12, winRate: 66.7, totalPnL: 45.30 }, { timeframe: '1h', sessionId: 'session_1h_' + Date.now(), totalTrades: 8, winRate: 62.5, totalPnL: 23.15 } ], // Recent trades data recentTrades: [ { id: 'trade_' + Date.now(), timestamp: new Date(Date.now() - 3600000).toISOString(), symbol: 'SOLUSD', side: 'BUY', entryPrice: 175.50, exitPrice: 177.25, pnl: 12.50, outcome: 'WIN', confidence: 80, reasoning: 'Strong support bounce with volume confirmation' }, { id: 'trade_' + (Date.now() - 1), timestamp: new Date(Date.now() - 7200000).toISOString(), symbol: 'SOLUSD', side: 'SELL', entryPrice: 178.00, exitPrice: 176.75, pnl: 8.75, outcome: 'WIN', confidence: 75, reasoning: 'Resistance rejection with bearish momentum' } ], // AI Learning status aiLearningStatus: { isActive: false, systemConfidence: 72, totalDecisions: 45, successRate: 64.4, strengths: [ 'Strong momentum detection', 'Good entry timing on reversals', 'Effective risk management' ], weaknesses: [ 'Needs improvement in ranging markets', 'Could better identify false breakouts' ], recentInsights: [ 'Better performance on 4H timeframe', 'High win rate on reversal trades' ] }, // Current trade entry details entry: { price: 176.25, buffer: "±0.25", rationale: "Current market level" }, stopLoss: { price: 174.50, rationale: "Technical support level" }, takeProfits: { tp1: { price: 178.00, description: "First resistance target" }, tp2: { price: 179.50, description: "Extended target" } }, // Metadata layoutsAnalyzed: ["AI Layout", "DIY Layout"], timestamp: new Date().toISOString(), processingTime: "~2.5 minutes", analysisDetails: { screenshotsCaptured: 2, layoutsAnalyzed: 2, timeframesAnalyzed: 2, aiTokensUsed: "~4000 tokens", analysisStartTime: new Date(Date.now() - 150000).toISOString(), analysisEndTime: new Date().toISOString() } } } console.log('✅ Analysis details prepared successfully') return NextResponse.json(analysisData) } catch (error) { console.error('❌ Error in analysis-details API:', error) return NextResponse.json({ success: false, error: 'Failed to fetch analysis details', details: error.message }, { status: 500 }) } }