Files
trading_bot_v3/lib/automation-singleton.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

// Singleton automation instance manager with learning integration
let automationInstance = null;
async function createAutomationInstance() {
try {
// Try to import the learning-enhanced automation first
const AutomationWithLearning = require('./automation-with-learning-v2.js');
console.log('✅ Creating automation instance with AI learning system');
return new AutomationWithLearning();
} catch (error) {
console.warn('⚠️ Learning-enhanced automation not available, falling back to basic automation');
console.warn('Error:', error.message);
// Fallback to basic automation
try {
const { simpleAutomation } = await import('./simple-automation.js');
console.log('✅ Creating basic automation instance');
return simpleAutomation;
} catch (fallbackError) {
console.error('❌ Could not create any automation instance:', fallbackError);
throw new Error('No automation system available');
}
}
}
function getAutomationInstance() {
if (!automationInstance) {
automationInstance = createAutomationInstance();
}
return automationInstance;
}
function resetAutomationInstance() {
if (automationInstance) {
console.log('🔄 Resetting automation instance');
if (typeof automationInstance.stop === 'function') {
automationInstance.stop();
}
}
automationInstance = null;
}
module.exports = {
getAutomationInstance,
resetAutomationInstance
};