// Generate a test AI decision to display reasoning panel async function generateTestDecision() { console.log('🧪 Generating Test AI Decision for UI Display...\n'); try { // Create a realistic analysis with detailed reasoning const testAnalysis = { recommendation: 'STRONG BUY', confidence: 89, reasoning: `šŸŽÆ BULLISH CONVERGENCE DETECTED: šŸ“ˆ Technical Analysis: • RSI bounced from oversold (28→54) showing strong recovery momentum • MACD histogram turning positive with bullish crossover confirmed • Price broke above key resistance at $185.40 with 3x normal volume • 20 EMA (184.92) providing strong support, price trending above all major EMAs šŸ“Š Market Structure: • Higher lows pattern intact since yesterday's session • Volume profile shows accumulation at current levels • Order book depth favoring buyers (67% buy-side liquidity) ⚔ Entry Trigger: • Breakout candle closed above $186.00 resistance with conviction • Next resistance target: $189.75 (2.1% upside potential) • Risk/Reward ratio: 1:2.3 (excellent risk management setup) šŸ›”ļø Risk Management: • Stop loss at $184.20 (1.0% below entry) protects against false breakout • Position sizing optimized for 2% account risk tolerance`, summary: 'Multi-timeframe bullish convergence with strong momentum confirmation', stopLoss: 184.20, takeProfit: 189.75, entry: { price: 186.12 }, currentPrice: 186.12, stopLossPercent: '1.0% protective stop' }; // Send test analysis to automation system const response = await fetch('http://localhost:9001/api/automation/test-decision', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'generate_test_decision', analysis: testAnalysis, config: { selectedTimeframes: ['15m', '1h', '4h'], symbol: 'SOLUSD', mode: 'LIVE', enableTrading: true } }) }); if (response.ok) { const result = await response.json(); console.log('āœ… Test decision generated:', result); } else { // Fallback: directly inject into automation if API doesn't exist console.log('šŸ“ Using direct injection method...'); const { simpleAutomation } = require('./lib/simple-automation.js'); // Set up test config simpleAutomation.config = { selectedTimeframes: ['15m', '1h', '4h'], symbol: 'SOLUSD', mode: 'LIVE', enableTrading: true, tradingAmount: 62 }; // Generate decision const shouldExecute = simpleAutomation.shouldExecuteTrade(testAnalysis); if (shouldExecute && simpleAutomation.lastDecision) { // Add execution details simpleAutomation.lastDecision.executed = true; simpleAutomation.lastDecision.executionDetails = { side: 'BUY', amount: 62, leverage: 12.5, currentPrice: 186.12, stopLoss: 184.20, takeProfit: 189.75, aiReasoning: `AI calculated 12.5x leverage based on: • Stop loss distance: 1.0% (tight risk control) • Account balance: $62.08 available • Safety buffer: 8% (liquidation at $171.45 - safe margin) • Risk assessment: MODERATE-LOW • Position value: $775 (12.5x of $62) • Maximum loss if stopped: $119 (1.92% of account)`, txId: `test_${Date.now()}`, aiStopLossPercent: '1.0% protective stop' }; } console.log('āœ… Test decision injected successfully!'); console.log(`šŸ“Š Decision stored: ${!!simpleAutomation.lastDecision}`); console.log(`⚔ Executed: ${simpleAutomation.lastDecision?.executed}`); } console.log('\nšŸŽÆ Test completed! Check the automation-v2 page to see the reasoning panel.'); console.log('šŸ“ The AI reasoning should now be prominently displayed.'); } catch (error) { console.error('āŒ Error generating test decision:', error.message); } } generateTestDecision().catch(console.error);