@@ -395,7 +396,7 @@ Based on comprehensive technical analysis across multiple timeframes:
) : (
š
- STOP
+ {status?.isActive ? 'STOP' : 'DISABLE'}
)}
@@ -403,7 +404,7 @@ Based on comprehensive technical analysis across multiple timeframes:
onClick={handleEmergencyStop}
disabled={loading}
className="px-6 py-4 bg-gradient-to-r from-red-800 to-red-900 text-white rounded-xl hover:from-red-900 hover:to-red-950 transition-all duration-200 disabled:opacity-50 font-semibold border-2 border-red-600/50 shadow-lg shadow-red-900/50 transform hover:scale-105"
- title="Emergency Stop - Closes all positions immediately"
+ title={status?.isActive ? "Emergency Stop - Closes all positions immediately" : "Emergency disable - Prevents any automation triggers"}
>
šØ
diff --git a/immediate-stop.js b/immediate-stop.js
new file mode 100644
index 0000000..e28d2ff
--- /dev/null
+++ b/immediate-stop.js
@@ -0,0 +1,67 @@
+#!/usr/bin/env node
+
+/**
+ * Immediate Stop Script - Disable automation to prevent triggers on position close
+ */
+
+const baseUrl = 'http://localhost:9001';
+
+async function immediateStop() {
+ console.log('šØ IMMEDIATE AUTOMATION STOP\n');
+
+ try {
+ // 1. Check current position
+ console.log('š Checking Active Position:');
+ const positionsResponse = await fetch(`${baseUrl}/api/drift/positions`);
+ const positionsData = await positionsResponse.json();
+
+ if (positionsData.success && positionsData.positions?.length > 0) {
+ console.log(` ā ļø ACTIVE POSITION DETECTED: ${positionsData.positions.length} position(s)`);
+ positionsData.positions.forEach((pos, i) => {
+ console.log(` - Position ${i+1}: ${pos.symbol} ${pos.side.toUpperCase()}`);
+ console.log(` Size: ${pos.size}, PnL: $${pos.unrealizedPnl?.toFixed(2)}`);
+ });
+ console.log(' šØ Position close could trigger automation - STOPPING NOW!\n');
+ }
+
+ // 2. Stop automation immediately
+ console.log('š Stopping Automation:');
+ const stopResponse = await fetch(`${baseUrl}/api/automation/stop`, {
+ method: 'POST'
+ });
+ const stopResult = await stopResponse.json();
+ console.log(` - Regular Stop: ${stopResult.success ? 'ā
SUCCESS' : 'ā FAILED'}`);
+ console.log(` - Message: ${stopResult.message}`);
+
+ // 3. Emergency stop for extra safety
+ console.log('\nšØ Emergency Stop (Extra Safety):');
+ const emergencyResponse = await fetch(`${baseUrl}/api/automation/emergency-stop`, {
+ method: 'POST'
+ });
+ const emergencyResult = await emergencyResponse.json();
+ console.log(` - Emergency Stop: ${emergencyResult.success ? 'ā
SUCCESS' : 'ā FAILED'}`);
+
+ // 4. Verify automation is stopped
+ console.log('\nā
Verification:');
+ const statusResponse = await fetch(`${baseUrl}/api/automation/status`);
+ const statusData = await statusResponse.json();
+ console.log(` - Automation Active: ${statusData.isActive ? 'ā ļø STILL ACTIVE' : 'ā
STOPPED'}`);
+
+ console.log('\nšÆ RESULT:');
+ if (!statusData.isActive) {
+ console.log(' ā
AUTOMATION DISABLED - Safe to close position manually');
+ console.log(' ā
No automation will trigger when position closes');
+ console.log(' š” You can now close your position safely in Drift');
+ } else {
+ console.log(' ā ļø AUTOMATION STILL ACTIVE - May need manual intervention');
+ }
+
+ } catch (error) {
+ console.error('ā Stop script failed:', error.message);
+ console.log('\nš MANUAL STOP COMMANDS:');
+ console.log(' curl -X POST http://localhost:9001/api/automation/stop');
+ console.log(' curl -X POST http://localhost:9001/api/automation/emergency-stop');
+ }
+}
+
+immediateStop().catch(console.error);
diff --git a/live-component-test.js b/live-component-test.js
new file mode 100644
index 0000000..b03cc32
--- /dev/null
+++ b/live-component-test.js
@@ -0,0 +1,83 @@
+#!/usr/bin/env node
+
+/**
+ * Live Component Data Test - Check what the frontend component is actually receiving
+ */
+
+const baseUrl = 'http://localhost:9001';
+
+async function testComponentData() {
+ console.log('š Testing what the EnhancedAILearningPanel component receives...\n');
+
+ try {
+ // Test the three API endpoints the component calls
+ console.log('1ļøā£ Testing /api/automation/learning-status:');
+ const learningResponse = await fetch(`${baseUrl}/api/automation/learning-status`);
+ const learningData = await learningResponse.json();
+ console.log(` - Success: ${learningData.success}`);
+ console.log(` - Learning Enabled: ${learningData.learningSystem?.enabled}`);
+ console.log(` - Message: ${learningData.learningSystem?.message}`);
+
+ console.log('\n2ļøā£ Testing /api/automation/status:');
+ const statusResponse = await fetch(`${baseUrl}/api/automation/status`);
+ const statusData = await statusResponse.json();
+ console.log(` - Is Active: ${statusData.isActive}`);
+ console.log(` - Mode: ${statusData.mode}`);
+ console.log(` - Symbol: ${statusData.symbol}`);
+
+ console.log('\n3ļøā£ Testing /api/ai-learning-status:');
+ const aiLearningResponse = await fetch(`${baseUrl}/api/ai-learning-status`);
+ const aiLearningData = await aiLearningResponse.json();
+ console.log(` - Success: ${aiLearningData.success}`);
+ console.log(` - Total Analyses: ${aiLearningData.data?.totalAnalyses}`);
+ console.log(` - Phase: ${aiLearningData.data?.phase}`);
+ console.log(` - Statistics Object:`, JSON.stringify(aiLearningData.data?.statistics, null, 2));
+
+ // Check what the component logic would do
+ console.log('\nš§ Component Logic Analysis:');
+ const aiData = aiLearningData.success ? aiLearningData.data : {
+ totalAnalyses: 0,
+ totalDecisions: 0,
+ // ... fallback data
+ };
+
+ console.log(` - Component would use: ${aiLearningData.success ? 'REAL API DATA' : 'FALLBACK DATA'}`);
+ console.log(` - Total Analyses: ${aiData.totalAnalyses}`);
+ console.log(` - Has Learning Data: ${(aiData.totalAnalyses || 0) > 0}`);
+ console.log(` - Should Show Active: ${(aiData.totalAnalyses || 0) > 0 || (aiData.totalDecisions || 0) > 0}`);
+
+ // Check browser cache issues
+ console.log('\nš Browser Cache Check:');
+ const headers = {
+ 'Cache-Control': 'no-cache',
+ 'Pragma': 'no-cache'
+ };
+ const pageResponse = await fetch(`${baseUrl}/automation-v2`, { headers });
+ console.log(` - Page loads: ${pageResponse.ok ? 'YES' : 'NO'}`);
+ console.log(` - Content-Type: ${pageResponse.headers.get('content-type')}`);
+
+ // Check if it's a Next.js page
+ const pageText = await pageResponse.text();
+ const hasLearningComponent = pageText.includes('AI Learning System');
+ const hasReactHydration = pageText.includes('__NEXT_DATA__');
+
+ console.log(` - Has AI Learning Component: ${hasLearningComponent ? 'YES' : 'NO'}`);
+ console.log(` - Has React Hydration: ${hasReactHydration ? 'YES' : 'NO'}`);
+
+ console.log('\nšÆ Diagnosis:');
+ if (!statusData.isActive) {
+ console.log(' ā ļø STOP BUTTON: Hidden because automation is not active');
+ console.log(' š” To see stop button: Start automation first');
+ }
+
+ if (aiLearningData.success && aiData.totalAnalyses > 9000) {
+ console.log(' ā
AI DATA: Component should show real learning data');
+ console.log(' š” If still showing old data: Clear browser cache (Ctrl+F5)');
+ }
+
+ } catch (error) {
+ console.error('ā Test failed:', error.message);
+ }
+}
+
+testComponentData().catch(console.error);