Files
trading_bot_v3/app/api/automation/stop/route.js
mindesbunister 44968c3bb3 feat: integrate AI learning system with trading automation
- AutomationWithLearning class with decision recording and outcome assessment
- Enhanced API endpoints with learning status visibility
- Singleton automation manager for seamless learning system integration
- EnhancedAILearningPanel component for real-time learning visibility
- Learning-enhanced trade execution with AI adjustments to SL/TP
- Automatic decision tracking and outcome-based learning

 Key Features:
- Records trading decisions before execution
- Enhances analysis with learned patterns
- Tracks trade outcomes for continuous improvement
- Provides full visibility into AI decision-making process
- Integrates SimplifiedStopLossLearner with real trading flow

- Whether learning system is active
- How many decisions are being tracked
- Real-time learning statistics and insights
- AI enhancements applied to trading decisions
2025-07-27 12:11:40 +02:00

47 lines
1.4 KiB
JavaScript

// Import singleton automation manager
async function getAutomationInstance() {
try {
const { getAutomationInstance } = await import('../../../lib/automation-singleton.js');
return await getAutomationInstance();
} catch (error) {
console.error('❌ Could not get automation instance:', error);
return null;
}
}
export async function POST() {
try {
console.log('🛑 AUTOMATION STOP: Request received');
const automation = await getAutomationInstance();
let result = { success: false, message: 'No automation instance available' };
if (automation) {
result = await automation.stop();
// Check if learning system was active
if (typeof automation.getLearningStatus === 'function') {
const learningStatus = await automation.getLearningStatus();
console.log('🧠 LEARNING SYSTEM: Stopped with', learningStatus.activeDecisions, 'active decisions');
}
}
// Additional cleanup
try {
const { execSync } = require('child_process');
execSync('pkill -f "chrome|chromium" 2>/dev/null || true');
console.log('✅ Additional cleanup completed');
} catch (cleanupError) {
console.error('Cleanup error:', cleanupError.message);
}
return Response.json(result);
} catch (error) {
console.error('❌ Stop automation error:', error);
return Response.json({
success: false,
message: error.message
}, { status: 500 });
}
}