// Test the specific values that should be displayed
const testDisplayValues = async () => {
  try {
    console.log('🔍 Testing display values for missing data fields...\n');
    
    // Get the analysis data
    const analysisResponse = await fetch('http://localhost:9001/api/automation/analysis-details');
    const analysisData = await analysisResponse.json();
    
    if (analysisData.success) {
      const analysis = analysisData.data.analysis;
      const recentTrade = analysisData.data.recentTrades?.[0];
      
      console.log('📊 Analysis Data:');
      console.log('- Decision:', analysis.decision);
      console.log('- Confidence:', analysis.confidence + '%');
      console.log('- Entry Price:', '$' + (analysis.entry?.price || 'N/A'));
      console.log('- Stop Loss:', '$' + (analysis.stopLoss?.price || 'N/A'));
      console.log('- Take Profit:', '$' + (analysis.takeProfits?.tp1?.price || 'N/A'));
      
      console.log('\n💰 Recent Trade Data:');
      if (recentTrade) {
        console.log('- Entry Price:', '$' + (recentTrade.entryPrice || recentTrade.price || 'N/A'));
        console.log('- Position Size:', '$' + (recentTrade.positionSize || recentTrade.amount || 'N/A'));
        console.log('- Trading Amount:', '$' + (recentTrade.realTradingAmount || recentTrade.tradingAmount || 'N/A'));
        console.log('- Side:', recentTrade.side || 'N/A');
        console.log('- Leverage:', (recentTrade.leverage || 'N/A') + 'x');
        console.log('- Status:', recentTrade.status || 'N/A');
      } else {
        console.log('No recent trade found');
      }
      
      // Simulate the execution details object
      console.log('\n🎯 Execution Details Object (as component would create):');
      if (recentTrade) {
        const executionDetails = {
          leverage: recentTrade.leverage || 3,
          entryPrice: recentTrade.entryPrice || recentTrade.price,
          stopLoss: analysis.stopLoss?.price || 185.50,
          takeProfit: analysis.takeProfits?.tp1?.price || 193.00,
          positionSize: recentTrade.positionSize || recentTrade.amount || 15.2,
          side: recentTrade.side || 'BUY',
          amount: recentTrade.realTradingAmount || recentTrade.tradingAmount || recentTrade.actualInvestment
        };
        
        console.log('Execution Details:', JSON.stringify(executionDetails, null, 2));
        
        console.log('\n📋 Display Values:');
        console.log('- Entry Price Display:', '$' + (executionDetails.entryPrice?.toFixed(4) || 'N/A'));
        console.log('- Position Size Display:', '$' + (executionDetails.amount || 'N/A'));
        console.log('- Direction Display:', executionDetails.side || 'N/A');
        console.log('- Leverage Display:', (executionDetails.leverage || 'N/A') + 'x');
        console.log('- Stop Loss Display:', '$' + (executionDetails.stopLoss?.toFixed(4) || 'N/A'));
        console.log('- Take Profit Display:', '$' + (executionDetails.takeProfit?.toFixed(4) || 'N/A'));
      }
    }
    
  } catch (error) {
    console.error('❌ Error testing display values:', error);
  }
};

testDisplayValues();
