- 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
57 lines
1.6 KiB
JavaScript
57 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);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export async function GET() {
|
|
try {
|
|
const automation = await getAutomationInstance();
|
|
|
|
if (!automation) {
|
|
return NextResponse.json({
|
|
error: 'No automation instance available',
|
|
isRunning: false,
|
|
learningSystem: { enabled: false }
|
|
}, { status: 503 });
|
|
}
|
|
|
|
const status = automation.getStatus();
|
|
|
|
// Add learning system status if available
|
|
if (typeof automation.getLearningStatus === 'function') {
|
|
try {
|
|
const learningStatus = await automation.getLearningStatus();
|
|
status.learningSystem = learningStatus;
|
|
} catch (learningError) {
|
|
status.learningSystem = {
|
|
enabled: false,
|
|
error: learningError.message
|
|
};
|
|
}
|
|
} else {
|
|
status.learningSystem = {
|
|
enabled: false,
|
|
message: 'Basic automation - learning not integrated'
|
|
};
|
|
}
|
|
|
|
return NextResponse.json(status);
|
|
} catch (error) {
|
|
console.error('❌ Status error:', error);
|
|
return NextResponse.json({
|
|
error: 'Failed to get status',
|
|
message: error.message,
|
|
isRunning: false,
|
|
learningSystem: { enabled: false, error: 'Status check failed' }
|
|
}, { status: 500 });
|
|
}
|
|
}
|