Core Features: - True 24/7 automation runs without browser dependency - Server-side process in Docker container - Auto-executes paper trades with ≥60% confidence - Integrates with existing AI learning system - Safe paper trading mode only (zero real money risk) - working-24x7.js: Main automation process (currently running) - check-automation.js: Status monitoring and health checks - app/api/safe-paper-trading/create-trade/route.js: Paper trade API - app/api/automation-24x7/route.js: Automation control API - Fixed continuous learning state persistence issues - Added force enable function for debugging: window.forceEnableLearning() - Enhanced state restoration logic with immediate and delayed checks - Auto-execute toggle now properly unlocks when continuous learning active - System running successfully (PID: 3922502) - Already executed first automated paper trade (80% confidence SELL) - Scheduled to run every 60 minutes automatically - Logs all activity for monitoring and debugging ical Implementation: - Uses curl for HTTP requests (no fetch dependencies) - Background process with proper signal handling - Comprehensive error handling and logging - Integration with existing analysis pipeline - Maintains compatibility with browser-based safe paper trading This completes the 24/7 automation requirement - system now runs continuously in Docker container without requiring browser tabs to remain open.
91 lines
3.0 KiB
JavaScript
91 lines
3.0 KiB
JavaScript
#!/usr/bin/env node
|
||
|
||
// Quick automation status checker
|
||
|
||
const { exec } = require('child_process');
|
||
const { promisify } = require('util');
|
||
const execAsync = promisify(exec);
|
||
|
||
async function checkStatus() {
|
||
console.log('🤖 24/7 AUTOMATION STATUS CHECK\n');
|
||
|
||
try {
|
||
// Check if process is running
|
||
const { stdout } = await execAsync('ps aux | grep "working-24x7" | grep -v grep');
|
||
if (stdout.trim()) {
|
||
console.log('✅ AUTOMATION STATUS: RUNNING');
|
||
console.log(`📊 Process: ${stdout.trim().split(/\s+/).slice(0, 11).join(' ')}`);
|
||
} else {
|
||
console.log('❌ AUTOMATION STATUS: NOT RUNNING');
|
||
return;
|
||
}
|
||
} catch (error) {
|
||
console.log('❌ AUTOMATION STATUS: NOT RUNNING');
|
||
return;
|
||
}
|
||
|
||
try {
|
||
// Check recent logs
|
||
const { stdout: logs } = await execAsync('tail -5 nohup.out');
|
||
console.log('\n📝 RECENT LOGS:');
|
||
console.log(logs);
|
||
} catch (error) {
|
||
console.log('\n⚠️ No logs available');
|
||
}
|
||
|
||
try {
|
||
// Check current analysis
|
||
const { stdout } = await execAsync('curl -s "http://localhost:9001/api/ai-analysis/latest?symbol=SOLUSD&timeframe=60"');
|
||
const data = JSON.parse(stdout);
|
||
|
||
if (data.success && data.data && data.data.analysis) {
|
||
const analysis = data.data.analysis;
|
||
console.log('\n📊 CURRENT ANALYSIS:');
|
||
console.log(` Signal: ${analysis.recommendation}`);
|
||
console.log(` Confidence: ${analysis.confidence}%`);
|
||
console.log(` Entry: $${analysis.entry}`);
|
||
console.log(` Status: ${analysis.confidence >= 60 ? '🎯 WILL AUTO-EXECUTE' : '⏸️ Below threshold'}`);
|
||
} else {
|
||
console.log('\n❌ No analysis data available');
|
||
}
|
||
} catch (error) {
|
||
console.log('\n❌ Analysis check failed:', error.message);
|
||
}
|
||
|
||
try {
|
||
// Check recent paper trades
|
||
const { stdout } = await execAsync('curl -s "http://localhost:9001/api/safe-paper-trading/create-trade"');
|
||
const data = JSON.parse(stdout);
|
||
|
||
if (data.success && data.trades) {
|
||
console.log('\n📄 PAPER TRADES:');
|
||
console.log(` Total: ${data.summary.total}`);
|
||
console.log(` Open: ${data.summary.open}`);
|
||
console.log(` Closed: ${data.summary.closed}`);
|
||
console.log(` P&L: $${data.summary.totalPnL}`);
|
||
|
||
// Show recent trades
|
||
const recentTrades = data.trades.slice(-3);
|
||
if (recentTrades.length > 0) {
|
||
console.log('\n📈 RECENT TRADES:');
|
||
recentTrades.forEach(trade => {
|
||
console.log(` ${trade.id}: ${trade.side} ${trade.symbol} @ $${trade.entry} (${trade.confidence}%)`);
|
||
});
|
||
}
|
||
}
|
||
} catch (error) {
|
||
console.log('\n⚠️ Could not check paper trades');
|
||
}
|
||
|
||
console.log('\n🎯 AUTOMATION CONFIGURATION:');
|
||
console.log(' Symbol: SOLUSD');
|
||
console.log(' Timeframe: 1 hour');
|
||
console.log(' Interval: Every 60 minutes');
|
||
console.log(' Auto-execute: ≥60% confidence');
|
||
console.log(' Mode: Safe paper trading only');
|
||
|
||
console.log('\n✨ System is running 24/7 in your Docker container!');
|
||
}
|
||
|
||
checkStatus();
|