#!/usr/bin/env node /** * Test Stop Loss / Take Profit Implementation in Automation */ const { simpleAutomation } = require('./lib/simple-automation.js'); async function testSLTPImplementation() { console.log('๐Ÿงช Testing SL/TP Implementation in Simple Automation...'); // Mock analysis data with current price const mockAnalysis = { recommendation: 'BUY', confidence: 85, currentPrice: 186.50, reasoning: 'Strong bullish signal' }; // Mock config const mockConfig = { symbol: 'SOLUSD', tradingAmount: 100, leverage: 1, mode: 'SIMULATION' // Keep in simulation for testing }; // Set up automation with mock config simpleAutomation.config = mockConfig; console.log('๐Ÿ“Š Mock Analysis:', mockAnalysis); console.log('โš™๏ธ Mock Config:', mockConfig); try { // Test the executeTrade method console.log('\n๐ŸŽฏ Testing executeTrade with SL/TP calculation...'); // This will show us what payload would be sent const result = await simpleAutomation.executeTrade(mockAnalysis); console.log('โœ… Trade execution test completed'); console.log('๐Ÿ“Š Result:', result); } catch (error) { console.error('โŒ Test failed:', error); } console.log('\n๐Ÿ” Expected behavior:'); console.log(' ๐Ÿ’ฐ Entry: ~$186.50'); console.log(' ๐Ÿ›‘ Stop Loss: ~$177.18 (5% below)'); console.log(' ๐ŸŽฏ Take Profit: ~$205.15 (10% above)'); console.log(' ๐Ÿ“Š Risk/Reward: 2:1 ratio'); } testSLTPImplementation();