#!/usr/bin/env node /** * Parallel Screenshot Batch Test for Scalping Timeframes * Uses the most efficient batch capture system for all relevant timeframes */ const { BatchScreenshotService } = require('./lib/enhanced-screenshot-batch.ts') // Scalping-focused timeframes (from seconds to hours) const SCALP_TIMEFRAMES = [ '1m', // 1 minute - ultra-short scalping '3m', // 3 minutes - short scalping '5m', // 5 minutes - standard scalping '15m', // 15 minutes - swing scalping '30m', // 30 minutes - longer scalping '1h', // 1 hour - context timeframe '4h' // 4 hours - trend context ] // TradingView timeframe mappings const TIMEFRAME_MAP = { '1m': '1', '3m': '3', '5m': '5', '15m': '15', '30m': '30', '1h': '60', '4h': '240' } async function testScalpBatchScreenshots() { console.log('๐Ÿš€ SCALP PRESET: Parallel Batch Screenshot Test') console.log('โšก Capturing ALL scalping timeframes in parallel sessions') try { // Convert to TradingView format const timeframes = SCALP_TIMEFRAMES.map(tf => TIMEFRAME_MAP[tf]) const config = { symbol: 'SOLUSD', timeframes: timeframes, layouts: ['ai', 'diy'], // Both AI and DIY layouts credentials: { email: process.env.TRADINGVIEW_EMAIL || '', password: process.env.TRADINGVIEW_PASSWORD || '' } } console.log('๐Ÿ“‹ Batch Configuration:') console.log(` ๐Ÿ“Š Symbol: ${config.symbol}`) console.log(` โฑ๏ธ Timeframes: ${SCALP_TIMEFRAMES.join(', ')} (${timeframes.length} total)`) console.log(` ๐ŸŽจ Layouts: ${config.layouts.join(', ')} (${config.layouts.length} total)`) console.log(` ๐Ÿ“ธ Total Screenshots: ${timeframes.length * config.layouts.length}`) // Initialize batch service const batchService = new BatchScreenshotService(`scalp_test_${Date.now()}`) console.log('\n๐Ÿ”„ Starting parallel batch capture...') const startTime = Date.now() // Execute the batch capture const batches = await batchService.captureMultipleTimeframes(config) const endTime = Date.now() const duration = (endTime - startTime) / 1000 // Results analysis console.log('\nโœ… BATCH CAPTURE COMPLETED!') console.log(`โฑ๏ธ Total Duration: ${duration.toFixed(2)} seconds`) console.log(`๐Ÿ“ธ Screenshots Captured: ${batches.length}/${timeframes.length * config.layouts.length}`) console.log(`๐Ÿš€ Efficiency: ${(batches.length / duration).toFixed(1)} screenshots/second`) // Group results by layout and timeframe const aiScreenshots = batches.filter(b => b.layout === 'ai') const diyScreenshots = batches.filter(b => b.layout === 'diy') console.log('\n๐Ÿ“Š RESULTS BREAKDOWN:') console.log(`๐Ÿค– AI Layout: ${aiScreenshots.length}/${timeframes.length} screenshots`) console.log(`๐Ÿ”ง DIY Layout: ${diyScreenshots.length}/${timeframes.length} screenshots`) // Display captured files by timeframe console.log('\n๐Ÿ“ CAPTURED FILES:') SCALP_TIMEFRAMES.forEach((tf, index) => { const tvTimeframe = timeframes[index] const aiBatch = batches.find(b => b.timeframe === tvTimeframe && b.layout === 'ai') const diyBatch = batches.find(b => b.timeframe === tvTimeframe && b.layout === 'diy') console.log(` ${tf.padEnd(4)} (${tvTimeframe}):`) if (aiBatch) { console.log(` ๐Ÿค– AI: ${aiBatch.filepath}`) } else { console.log(` ๐Ÿค– AI: โŒ Failed`) } if (diyBatch) { console.log(` ๐Ÿ”ง DIY: ${diyBatch.filepath}`) } else { console.log(` ๐Ÿ”ง DIY: โŒ Failed`) } }) // Success rate analysis const successRate = (batches.length / (timeframes.length * config.layouts.length) * 100).toFixed(1) console.log(`\n๐Ÿ“ˆ SUCCESS RATE: ${successRate}%`) if (batches.length === timeframes.length * config.layouts.length) { console.log('๐ŸŽ‰ PERFECT SUCCESS: All timeframes captured successfully!') } else { console.log('โš ๏ธ Some screenshots failed - check logs above') } // Performance benchmark const avgTimePerScreenshot = duration / batches.length console.log(`\nโšก PERFORMANCE METRICS:`) console.log(` โ€ข Average time per screenshot: ${avgTimePerScreenshot.toFixed(2)}s`) console.log(` โ€ข Parallel efficiency gain: ~${Math.round(100 - (duration / (batches.length * 10)) * 100)}%`) console.log(` โ€ข Total time saved vs sequential: ~${((batches.length * 10) - duration).toFixed(0)}s`) // Cleanup console.log('\n๐Ÿงน Cleaning up browser sessions...') await batchService.cleanup() console.log('โœ… Cleanup completed') } catch (error) { console.error('\nโŒ Batch test failed:', error.message) console.error('Stack trace:', error.stack) process.exit(1) } } // Run the test testScalpBatchScreenshots()