Integrate superior parallel screenshot system into main automation
BREAKING CHANGES: - Replace enhancedScreenshotService with superiorScreenshotService throughout system - Update trading presets to match actual strategy definitions: * Scalp: 5m, 15m (was 7 timeframes) * Day Trading: 1h, 4h (NEW) * Swing Trading: 4h, 1D (NEW) * Extended: All timeframes for comprehensive analysis - Auto-trading service now uses intelligent parallel capture - Enhanced-screenshot API restored with superior backend - AI analysis service updated for compatibility - Superior screenshot API supports all presets PERFORMANCE IMPROVEMENTS: - Parallel capture for ALL timeframes regardless of count - Intelligent preset detection based on timeframe patterns - No more hardcoded 7-timeframe limitation - Backwards compatibility maintained The system now uses the superior parallel approach for ANY timeframe selection, whether it's 2 timeframes (scalp/day/swing) or 8+ timeframes (extended). No more sequential delays - everything is parallel!
This commit is contained in:
@@ -17,16 +17,34 @@ export async function POST(request) {
|
||||
|
||||
console.log('📋 Superior Config:', config)
|
||||
|
||||
// Use the proven scalp preset parallel technique
|
||||
const SCALP_TIMEFRAMES = [
|
||||
{ name: '1m', tv: '1' },
|
||||
{ name: '3m', tv: '3' },
|
||||
{ name: '5m', tv: '5' },
|
||||
{ name: '15m', tv: '15' },
|
||||
{ name: '30m', tv: '30' },
|
||||
{ name: '1h', tv: '60' },
|
||||
{ name: '4h', tv: '240' }
|
||||
]
|
||||
// Define trading presets matching the main automation system
|
||||
const TRADING_PRESETS = {
|
||||
'scalp': [
|
||||
{ name: '5m', tv: '5' },
|
||||
{ name: '15m', tv: '15' }
|
||||
],
|
||||
'day-trading': [
|
||||
{ name: '1h', tv: '60' },
|
||||
{ name: '4h', tv: '240' }
|
||||
],
|
||||
'swing-trading': [
|
||||
{ name: '4h', tv: '240' },
|
||||
{ name: '1D', tv: '1D' }
|
||||
],
|
||||
'extended': [
|
||||
{ name: '1m', tv: '1' },
|
||||
{ name: '3m', tv: '3' },
|
||||
{ name: '5m', tv: '5' },
|
||||
{ name: '15m', tv: '15' },
|
||||
{ name: '30m', tv: '30' },
|
||||
{ name: '1h', tv: '60' },
|
||||
{ name: '4h', tv: '240' },
|
||||
{ name: '1D', tv: '1D' }
|
||||
]
|
||||
}
|
||||
|
||||
// Get timeframes for the selected preset
|
||||
const selectedTimeframes = TRADING_PRESETS[config.preset] || TRADING_PRESETS['scalp']
|
||||
|
||||
// For single timeframe compatibility
|
||||
if (body.timeframe) {
|
||||
@@ -69,11 +87,11 @@ export async function POST(request) {
|
||||
|
||||
// Multi-timeframe parallel capture
|
||||
const startTime = Date.now()
|
||||
console.log(`🔄 Starting parallel capture of ${SCALP_TIMEFRAMES.length} timeframes...`)
|
||||
console.log(`🔄 Starting parallel capture of ${selectedTimeframes.length} timeframes for ${config.preset} preset...`)
|
||||
|
||||
const capturePromises = SCALP_TIMEFRAMES.map(async (tf, index) => {
|
||||
const capturePromises = selectedTimeframes.map(async (tf, index) => {
|
||||
try {
|
||||
console.log(`📸 [${index + 1}/${SCALP_TIMEFRAMES.length}] Starting ${tf.name} (${tf.tv})...`)
|
||||
console.log(`📸 [${index + 1}/${selectedTimeframes.length}] Starting ${tf.name} (${tf.tv})...`)
|
||||
|
||||
const response = await fetch('http://localhost:9001/api/enhanced-screenshot', {
|
||||
method: 'POST',
|
||||
@@ -129,8 +147,8 @@ export async function POST(request) {
|
||||
|
||||
console.log('✅ SUPERIOR PARALLEL CAPTURE COMPLETED!')
|
||||
console.log(`⏱️ Duration: ${duration.toFixed(2)}s`)
|
||||
console.log(`📸 Screenshots: ${totalScreenshots}/${SCALP_TIMEFRAMES.length * config.layouts.length}`)
|
||||
console.log(`🎯 Success: ${successful.length}/${SCALP_TIMEFRAMES.length}`)
|
||||
console.log(`📸 Screenshots: ${totalScreenshots}/${selectedTimeframes.length * config.layouts.length}`)
|
||||
console.log(`🎯 Success: ${successful.length}/${selectedTimeframes.length}`)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
@@ -140,10 +158,10 @@ export async function POST(request) {
|
||||
duration: duration,
|
||||
totalScreenshots: totalScreenshots,
|
||||
successfulTimeframes: successful.length,
|
||||
totalTimeframes: SCALP_TIMEFRAMES.length,
|
||||
successRate: ((successful.length / SCALP_TIMEFRAMES.length) * 100).toFixed(1),
|
||||
totalTimeframes: selectedTimeframes.length,
|
||||
successRate: ((successful.length / selectedTimeframes.length) * 100).toFixed(1),
|
||||
results: results,
|
||||
message: `Parallel capture completed: ${successful.length}/${SCALP_TIMEFRAMES.length} timeframes in ${duration.toFixed(2)}s`
|
||||
message: `Parallel capture completed: ${successful.length}/${selectedTimeframes.length} timeframes in ${duration.toFixed(2)}s`
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
@@ -162,12 +180,19 @@ export async function GET() {
|
||||
endpoints: {
|
||||
POST: '/api/superior-screenshot - Superior parallel analysis'
|
||||
},
|
||||
presets: {
|
||||
'scalp': '2 timeframes (5m, 15m) - Scalping strategy',
|
||||
'day-trading': '2 timeframes (1h, 4h) - Day trading strategy',
|
||||
'swing-trading': '2 timeframes (4h, 1D) - Swing trading strategy',
|
||||
'extended': '8 timeframes (1m-1D) - Comprehensive analysis'
|
||||
},
|
||||
features: [
|
||||
'Parallel multi-timeframe capture',
|
||||
'Scalp preset (7 timeframes)',
|
||||
'Intelligent preset detection',
|
||||
'Single timeframe compatibility',
|
||||
'Proven efficiency (100% success rate)',
|
||||
'API-managed browser sessions'
|
||||
'API-managed browser sessions',
|
||||
'No hardcoded 7-timeframe limitation'
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user