Files
trading_bot_v3/app/api/automation/start/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

53 lines
1.6 KiB
JavaScript

import { NextResponse } from 'next/server';
// 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);
throw error;
}
}
export async function POST(request) {
try {
const config = await request.json();
console.log('🚀 AUTOMATION START: Received config:', JSON.stringify(config, null, 2));
console.log('🧠 LEARNING SYSTEM: Attempting to start with AI learning integration');
const automation = await getAutomationInstance();
const result = await automation.start(config);
// Add learning system status to response
const response = {
...result,
learningSystem: {
integrated: typeof automation.getLearningStatus === 'function',
type: automation.constructor.name
}
};
if (result.success) {
console.log('✅ AUTOMATION STARTED:', response.learningSystem.integrated ? 'With AI Learning' : 'Basic Mode');
return NextResponse.json(response);
} else {
return NextResponse.json(response, { status: 400 });
}
} catch (error) {
console.error('❌ Start automation error:', error);
return NextResponse.json({
success: false,
error: 'Internal server error',
message: error.message,
learningSystem: {
integrated: false,
error: 'Failed to initialize'
}
}, { status: 500 });
}
}