// Test the corrected trade calculation
async function testCorrectedTrade() {
  console.log('=== CORRECTED TRADE CALCULATION TEST ===')
  
  // Simulate current SOL price
  const currentPrice = 189.50
  
  // Simulate config
  const config = {
    tradingAmount: 100,  // $100 USD investment
    riskPercentage: 100, // 100% of trading amount
    symbol: 'SOLUSD'
  }
  
  // Simulate analysis
  const analysis = {
    confidence: 75, // 75% confidence
    recommendation: 'BUY'
  }
  
  // Calculate position size (this is what should happen)
  const baseAmount = config.tradingAmount
  const riskAdjustment = config.riskPercentage / 100
  const confidenceAdjustment = analysis.confidence / 100
  
  const usdAmount = baseAmount * riskAdjustment * confidenceAdjustment
  const tokenAmount = usdAmount / currentPrice
  
  console.log(`💰 Trading Amount: $${config.tradingAmount}`)
  console.log(`📊 Risk Adjustment: ${(riskAdjustment * 100)}%`)
  console.log(`🎯 Confidence Adjustment: ${(confidenceAdjustment * 100)}%`)
  console.log(`💵 USD Amount to Invest: $${usdAmount}`)
  console.log(`📈 Current SOL Price: $${currentPrice}`)
  console.log(`🪙 Token Amount: ${tokenAmount.toFixed(4)} SOL`)
  
  console.log('\n=== COMPARISON ===')
  console.log(`❌ Old (Wrong): 2.04 SOL at $100 = $204 position size`)
  console.log(`✅ New (Correct): ${tokenAmount.toFixed(4)} SOL at $${currentPrice} = $${(tokenAmount * currentPrice).toFixed(2)} position size`)
  
  // Simulate slippage and execution
  const slippage = 0.002 // 0.2%
  const executionPrice = currentPrice * (1 + slippage)
  
  console.log('\n=== EXECUTION ===')
  console.log(`🎲 Slippage: ${(slippage * 100).toFixed(2)}%`)
  console.log(`💱 Execution Price: $${executionPrice.toFixed(2)}`)
  console.log(`📝 Trade Record:`)
  console.log(`   - Side: BUY`)
  console.log(`   - Amount: ${tokenAmount.toFixed(4)} SOL`)
  console.log(`   - Price: $${executionPrice.toFixed(2)}`)
  console.log(`   - Total Value: $${(tokenAmount * executionPrice).toFixed(2)}`)
}

testCorrectedTrade()
