// Test the new timeframe-aware interval system import { simpleAutomation } from './lib/simple-automation.js'; async function testTimeframeIntervals() { try { const automation = simpleAutomation; console.log('=== Testing Timeframe-Aware Interval System ===\n'); // Test different timeframe scenarios const testScenarios = [ { description: "Scalping Configuration (5m, 15m)", selectedTimeframes: ['5m', '15m'], riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE'] }, { description: "Day Trading Configuration (1h, 4h)", selectedTimeframes: ['1h', '4h'], riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE'] }, { description: "Swing Trading Configuration (4h, 1d)", selectedTimeframes: ['4h', '1d'], riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE'] }, { description: "No Timeframes Selected (Default)", selectedTimeframes: [], riskLevels: ['MEDIUM'] } ]; for (const scenario of testScenarios) { console.log(`📋 ${scenario.description}`); console.log(` Timeframes: ${scenario.selectedTimeframes.join(', ') || 'default'}`); // Mock the selected timeframes (in real app this comes from UI) automation.selectedTimeframes = scenario.selectedTimeframes; console.log(` Strategy: ${automation.detectStrategy()}`); console.log(` Base Interval: ${automation.getTimeframeBasedIntervals() / (60 * 1000)} minutes`); for (const riskLevel of scenario.riskLevels) { const interval = automation.getNextInterval(riskLevel); const minutes = Math.round(interval / (60 * 1000)); console.log(` ${riskLevel.padEnd(8)}: ${minutes} minutes`); } console.log(''); } // Test specific scalping scenario user asked about console.log('🎯 SPECIFIC TEST: 5-minute scalping compatibility'); automation.selectedTimeframes = ['5m', '15m']; const scalping = automation.detectStrategy(); const baseInterval = automation.getTimeframeBasedIntervals(); const criticalInterval = automation.getNextInterval('CRITICAL'); const normalInterval = automation.getNextInterval('MEDIUM'); console.log(`Strategy Detected: ${scalping}`); console.log(`Base Interval: ${baseInterval / (60 * 1000)} minutes`); console.log(`Critical Risk: ${criticalInterval / (60 * 1000)} minutes (fastest for urgent situations)`); console.log(`Normal Risk: ${normalInterval / (60 * 1000)} minutes (standard scalping frequency)`); if (criticalInterval / (60 * 1000) <= 10 && normalInterval / (60 * 1000) <= 15) { console.log('✅ SUCCESS: Fast enough for 5-minute scalping!'); } else { console.log('❌ WARNING: Might be too slow for effective 5-minute scalping'); } console.log('\n=== Test Complete ==='); } catch (error) { console.error('❌ Test failed:', error.message); console.error(error.stack); } } // Run the test testTimeframeIntervals();