- Add comprehensive setup guide (VIRTUAL_TRADING_SETUP_GUIDE.md) - Improve UI to clearly show required steps for AI learning - Make auto-execute toggle always visible with clear instructions - Add blue info panel explaining the learning setup process - User can now easily enable: Continuous Learning + Auto-Execute - Virtual trades will execute automatically and AI will learn from outcomes Resolves issue: AI analyzing without learning due to missing virtual trade execution
74 lines
2.1 KiB
JavaScript
74 lines
2.1 KiB
JavaScript
import { NextResponse } from 'next/server';
|
|
|
|
export async function GET(request) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const symbol = searchParams.get('symbol') || 'SOLUSD';
|
|
const timeframe = searchParams.get('timeframe') || '60'; // 1h default
|
|
|
|
console.log(`🔍 Getting latest AI analysis for ${symbol} on ${timeframe} timeframe...`);
|
|
|
|
// Get fresh screenshot and analysis
|
|
console.log('🔥 Fetching real screenshot analysis...')
|
|
const screenshotResponse = await fetch('http://localhost:3000/api/enhanced-screenshot', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
symbol,
|
|
timeframe,
|
|
layouts: ['ai', 'diy'],
|
|
analyze: true
|
|
})
|
|
})
|
|
|
|
if (!screenshotResponse.ok) {
|
|
throw new Error(`Screenshot API failed: ${screenshotResponse.status}`)
|
|
}
|
|
|
|
const screenshotData = await screenshotResponse.json()
|
|
console.log('📸 Screenshot response received:', {
|
|
success: screenshotData.success,
|
|
hasAnalysis: !!screenshotData.analysis,
|
|
analysisType: typeof screenshotData.analysis,
|
|
timestamp: screenshotData.timestamp
|
|
})
|
|
|
|
if (!screenshotData.success) {
|
|
throw new Error('Screenshot system returned failure status')
|
|
}
|
|
|
|
if (!screenshotData.analysis) {
|
|
throw new Error('No analysis data from screenshot system')
|
|
}
|
|
|
|
// Handle case where analysis might have an error property
|
|
if (screenshotData.analysis.error) {
|
|
throw new Error(`Analysis failed: ${screenshotData.analysis.error}`)
|
|
}
|
|
|
|
// Extract real analysis data
|
|
const analysis = screenshotData.analysis;
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: {
|
|
symbol,
|
|
timeframe,
|
|
timestamp: new Date().toISOString(),
|
|
analysis: analysis,
|
|
screenshots: screenshotData.screenshots,
|
|
source: 'REAL_SCREENSHOT_ANALYSIS'
|
|
}
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('Error getting latest AI analysis:', error);
|
|
return NextResponse.json({
|
|
success: false,
|
|
error: error.message
|
|
}, { status: 500 });
|
|
}
|
|
}
|