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
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
import { simpleAutomation } from '@/lib/simple-automation';
|
||||
// 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 result = await simpleAutomation.stop();
|
||||
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 {
|
||||
@@ -17,7 +37,7 @@ export async function POST() {
|
||||
|
||||
return Response.json(result);
|
||||
} catch (error) {
|
||||
console.error('Stop automation error:', error);
|
||||
console.error('❌ Stop automation error:', error);
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: error.message
|
||||
|
||||
Reference in New Issue
Block a user