#!/usr/bin/env node /** * Superior Screenshot Command - Direct Implementation * Uses the proven parallel technique without API dependencies * Ready for integration into the main system */ const SCALP_TIMEFRAMES = [ { name: '1m', tv: '1', description: 'Ultra-short scalping' }, { name: '3m', tv: '3', description: 'Short scalping' }, { name: '5m', tv: '5', description: 'Standard scalping' }, { name: '15m', tv: '15', description: 'Swing scalping' }, { name: '30m', tv: '30', description: 'Longer scalping' }, { name: '1h', tv: '60', description: 'Context timeframe' }, { name: '4h', tv: '240', description: 'Trend context' } ] class SuperiorScreenshotCommand { constructor() { this.apiUrl = 'http://localhost:9001' } async captureScalpPreset(symbol = 'SOLUSD', layouts = ['ai', 'diy']) { console.log('šŸš€ SUPERIOR SCREENSHOT: Scalp Preset Capture') console.log(`šŸ“Š Symbol: ${symbol}`) console.log(`šŸŽØ Layouts: ${layouts.join(', ')}`) console.log(`ā±ļø Timeframes: ${SCALP_TIMEFRAMES.length}`) console.log(`šŸ“ø Total Screenshots: ${SCALP_TIMEFRAMES.length * layouts.length}`) const startTime = Date.now() try { // Use the proven parallel approach - each timeframe in parallel const capturePromises = SCALP_TIMEFRAMES.map(async (tf, index) => { try { console.log(`šŸ“ø [${index + 1}/${SCALP_TIMEFRAMES.length}] ${tf.name} (${tf.tv})...`) // Direct API call to the working enhanced-screenshot endpoint const response = await fetch(`${this.apiUrl}/api/enhanced-screenshot`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol: symbol, timeframe: tf.tv, layouts: layouts, analyze: false }) }) if (!response.ok) { throw new Error(`HTTP ${response.status}`) } const result = await response.json() if (result.success && result.screenshots) { console.log(`āœ… ${tf.name}: ${result.screenshots.length} screenshots`) return { timeframe: tf.tv, name: tf.name, success: true, screenshots: result.screenshots, count: result.screenshots.length } } else { throw new Error(result.error || 'API returned no screenshots') } } catch (error) { console.error(`āŒ ${tf.name}: ${error.message}`) return { timeframe: tf.tv, name: tf.name, success: false, error: error.message } } }) console.log('\nā³ Waiting for all parallel captures...') const results = await Promise.all(capturePromises) const endTime = Date.now() const duration = (endTime - startTime) / 1000 // Analyze results const successful = results.filter(r => r.success) const failed = results.filter(r => !r.success) const totalScreenshots = successful.reduce((sum, r) => sum + (r.count || 0), 0) console.log('\nāœ… SCALP PRESET COMPLETED!') console.log(`ā±ļø Duration: ${duration.toFixed(2)} seconds`) console.log(`šŸ“ø Screenshots: ${totalScreenshots}/${SCALP_TIMEFRAMES.length * layouts.length}`) console.log(`šŸŽÆ Success Rate: ${((successful.length / SCALP_TIMEFRAMES.length) * 100).toFixed(1)}%`) console.log(`šŸš€ Speed: ${(totalScreenshots / duration).toFixed(1)} screenshots/second`) // Show detailed results console.log('\nšŸ“Š TIMEFRAME RESULTS:') SCALP_TIMEFRAMES.forEach(tf => { const result = results.find(r => r.name === tf.name) if (result) { if (result.success) { console.log(` āœ… ${tf.name.padEnd(4)}: ${result.count} screenshots`) } else { console.log(` āŒ ${tf.name.padEnd(4)}: ${result.error}`) } } }) if (successful.length === SCALP_TIMEFRAMES.length) { console.log('\nšŸŽ‰ PERFECT SUCCESS: All scalping timeframes captured!') } else if (successful.length > 0) { console.log(`\nāš ļø PARTIAL SUCCESS: ${successful.length}/${SCALP_TIMEFRAMES.length} timeframes`) } else { console.log('\nāŒ COMPLETE FAILURE: No timeframes captured') } return { success: successful.length > 0, duration, totalScreenshots, successfulTimeframes: successful.length, totalTimeframes: SCALP_TIMEFRAMES.length, successRate: (successful.length / SCALP_TIMEFRAMES.length) * 100, results } } catch (error) { console.error('āŒ Scalp preset failed:', error.message) throw error } } async captureQuick(symbol = 'SOLUSD', timeframe = '60', layouts = ['ai']) { console.log(`šŸš€ QUICK CAPTURE: ${symbol} ${timeframe}`) try { const response = await fetch(`${this.apiUrl}/api/enhanced-screenshot`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol: symbol, timeframe: timeframe, layouts: layouts, analyze: false }) }) if (!response.ok) { throw new Error(`HTTP ${response.status}`) } const result = await response.json() if (result.success && result.screenshots) { console.log(`āœ… Quick capture: ${result.screenshots.length} screenshots`) return result.screenshots } else { throw new Error(result.error || 'No screenshots returned') } } catch (error) { console.error('āŒ Quick capture failed:', error.message) throw error } } } // CLI interface async function main() { const command = new SuperiorScreenshotCommand() const args = process.argv.slice(2) const mode = args[0] || 'scalp' const symbol = args[1] || 'SOLUSD' try { if (mode === 'quick') { const timeframe = args[2] || '60' await command.captureQuick(symbol, timeframe) } else { // Default to scalp preset await command.captureScalpPreset(symbol) } console.log('\nšŸŽÆ SUPERIOR SCREENSHOT COMMAND COMPLETED!') } catch (error) { console.error('\nāŒ Command failed:', error.message) process.exit(1) } } // Export for integration module.exports = { SuperiorScreenshotCommand, SCALP_TIMEFRAMES } // Run if called directly if (require.main === module) { main() }