const { MandatoryRiskManager } = require('./lib/mandatory-risk-manager.js');

async function testRiskManager() {
  const manager = new MandatoryRiskManager();

  console.log('🧪 Testing LONG position validation...');
  const longResult = manager.validateRiskLevels({
    currentPrice: 245.50,
    stopLoss: 243.00,
    takeProfit: 250.00,
    side: 'BUY',
    amount: 100,
    leverage: 5
  });
  console.log('LONG result:', longResult.isValid ? '✅ VALID' : '❌ INVALID');
  if (!longResult.isValid) console.log('Reason:', longResult.reason);

  console.log('\n🧪 Testing complete enforcement...');
  try {
    const enforcedTrade = await manager.enforceRiskManagement({
      symbol: 'SOLUSD',
      side: 'BUY',
      amount: 100,
      currentPrice: 245.50,
      stopLoss: 243.00,
      takeProfit: 250.00,
      leverage: 5
    });
    console.log('✅ Trade validation passed!');
    console.log('Risk metrics:', {
      stopLoss: enforcedTrade.stopLoss,
      takeProfit: enforcedTrade.takeProfit,
      riskRewardRatio: '1:' + enforcedTrade.riskValidation.riskRewardRatio.toFixed(2)
    });
  } catch (error) {
    console.log('❌ Trade validation failed:', error.message);
  }
}

testRiskManager();
