LEARNING INTEGRATION: - Enhanced AI analysis service feeds historical data into OpenAI prompts - Symbol/timeframe specific learning optimization - Pattern recognition from past trade outcomes - Confidence adjustment based on success rates HTTP COMPATIBILITY SYSTEM: - HttpUtil with automatic curl/no-curl detection - Node.js fallback for Docker environments without curl - Updated all automation systems to use HttpUtil - Production-ready error handling AUTONOMOUS RISK MANAGEMENT: - Enhanced risk manager with learning integration - Simplified learners using existing AILearningData schema - Real-time position monitoring every 30 seconds - Smart stop-loss decisions with AI learning INFRASTRUCTURE: - Database utility for shared Prisma connections - Beach mode status display system - Complete error handling and recovery - Docker container compatibility tested Historical performance flows into OpenAI prompts before every trade.
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test HTTP Utility
|
|
*
|
|
* Tests the HTTP utility for compatibility in environments with/without curl
|
|
*/
|
|
|
|
const HttpUtil = require('./lib/http-util');
|
|
|
|
async function testHttpUtil() {
|
|
console.log('🔧 TESTING HTTP UTILITY');
|
|
console.log('='.repeat(50));
|
|
|
|
// Test curl availability
|
|
const isCurlAvailable = await HttpUtil.checkCurlAvailability();
|
|
console.log(`📋 curl available: ${isCurlAvailable ? '✅ YES' : '❌ NO'}`);
|
|
|
|
if (isCurlAvailable) {
|
|
console.log(' Will use curl for HTTP requests');
|
|
} else {
|
|
console.log(' Will use built-in Node.js http module');
|
|
}
|
|
|
|
console.log('\n🌐 Testing position monitor endpoint...');
|
|
|
|
try {
|
|
const data = await HttpUtil.get('http://localhost:9001/api/automation/position-monitor');
|
|
|
|
console.log('✅ HTTP request successful!');
|
|
console.log(`📊 Response: ${JSON.stringify(data, null, 2).substring(0, 200)}...`);
|
|
|
|
if (data.success) {
|
|
console.log('🎯 Position monitor API responding correctly');
|
|
|
|
if (data.monitor?.hasPosition) {
|
|
console.log(`📈 Active position: ${data.monitor.position?.symbol || 'Unknown'}`);
|
|
console.log(`💰 P&L: $${data.monitor.position?.unrealizedPnl || 0}`);
|
|
console.log(`⚠️ Distance to SL: ${data.monitor.stopLossProximity?.distancePercent || 'N/A'}%`);
|
|
} else {
|
|
console.log('📊 No active positions');
|
|
}
|
|
} else {
|
|
console.log('⚠️ API responded but with success: false');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.log(`❌ HTTP request failed: ${error.message}`);
|
|
|
|
if (error.message.includes('ECONNREFUSED')) {
|
|
console.log('💡 Server not running on localhost:9001');
|
|
} else if (error.message.includes('timeout')) {
|
|
console.log('💡 Request timed out - server may be slow');
|
|
} else {
|
|
console.log('💡 Other error - check server status');
|
|
}
|
|
}
|
|
|
|
console.log('\n🔧 HTTP Utility Test Complete');
|
|
console.log(`✅ Fallback system ${isCurlAvailable ? 'not needed' : 'working'}`);
|
|
}
|
|
|
|
// Run the test
|
|
if (require.main === module) {
|
|
testHttpUtil().catch(console.error);
|
|
}
|
|
|
|
module.exports = { testHttpUtil };
|