feat: fix Safe Paper Trading display formatting and API sync
- Fixed field mapping between API and frontend (amount→positionSize, entry→entryPrice, createdAt→timestamp) - Updated API sync function to properly convert API trade format to frontend format - Resolved display issues: 'Invalid Date', missing entry price, missing trade size - Added trade monitoring system and automation improvements - Enhanced automation with simple-automation.js for reliable 24/7 operation - Working automation now detecting 85% confidence BUY signals and executing trades
This commit is contained in:
41
trade-monitor.js
Normal file
41
trade-monitor.js
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Trade Monitor - Track trade creation and persistence
|
||||
const fs = require('fs');
|
||||
|
||||
async function checkTrades() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:9001/api/safe-paper-trading/trades');
|
||||
const data = await response.json();
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
const logEntry = {
|
||||
timestamp,
|
||||
totalTrades: data.totalTrades,
|
||||
trades: data.trades.map(t => ({
|
||||
id: t.id,
|
||||
side: t.side,
|
||||
source: t.source,
|
||||
createdAt: t.createdAt
|
||||
}))
|
||||
};
|
||||
|
||||
// Log to file
|
||||
fs.appendFileSync('trade-monitor.log', JSON.stringify(logEntry) + '\n');
|
||||
|
||||
console.log(`[${timestamp}] Trades: ${data.totalTrades}`);
|
||||
if (data.totalTrades > 0) {
|
||||
data.trades.forEach(trade => {
|
||||
console.log(` - ${trade.id}: ${trade.side} (${trade.source})`);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`[${new Date().toISOString()}] Error checking trades:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Check every 30 seconds
|
||||
console.log('🔍 Trade Monitor Started - Checking every 30 seconds');
|
||||
setInterval(checkTrades, 30000);
|
||||
checkTrades(); // Initial check
|
||||
Reference in New Issue
Block a user