fix: eliminate excessive P&L calculations and restore CoinGecko price source
- Fixed Prisma table name errors in price-monitor.ts (trades vs trade, automation_sessions vs automationSession) - Commented out excessive P&L calculation logging in analysis-details API that was processing all 69 trades - Restored CoinGecko as primary price source (was falling back to Binance due to DB errors) - Optimized analysis-details to skip P&L calculations for FAILED/EXECUTED trades - Added comprehensive cleanup system for orphaned orders - Performance improvement: eliminated unnecessary processing of old trade data Result: Clean logs, efficient price fetching from CoinGecko, no excessive calculations
This commit is contained in:
61
check-trade-statuses.js
Normal file
61
check-trade-statuses.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
|
||||
async function checkTradeStatuses() {
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
try {
|
||||
console.log('🔍 Checking status of trades mentioned in logs...\n');
|
||||
|
||||
// Check specific trade IDs from the logs
|
||||
const tradeIds = [
|
||||
'cmdhqpakw0007mk1j1ptce70k',
|
||||
'cmdhq2pqf003zn51jx266y5h2',
|
||||
'cmdhpygku003nn51ju1pn43hl',
|
||||
'cmdhpt88e003dn51jzyfdcjti',
|
||||
'cmdhpr3gz0037n51jpxetojtg'
|
||||
];
|
||||
|
||||
for (const tradeId of tradeIds) {
|
||||
const trade = await prisma.trades.findUnique({
|
||||
where: { id: tradeId },
|
||||
select: {
|
||||
id: true,
|
||||
status: true,
|
||||
symbol: true,
|
||||
side: true,
|
||||
createdAt: true,
|
||||
isAutomated: true
|
||||
}
|
||||
});
|
||||
|
||||
if (trade) {
|
||||
console.log(`📊 Trade ${tradeId.substring(0, 8)}...:`);
|
||||
console.log(` Status: ${trade.status}`);
|
||||
console.log(` Symbol: ${trade.symbol}`);
|
||||
console.log(` Side: ${trade.side}`);
|
||||
console.log(` Created: ${trade.createdAt}`);
|
||||
console.log(` Automated: ${trade.isAutomated}`);
|
||||
console.log('');
|
||||
} else {
|
||||
console.log(`❌ Trade ${tradeId} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
// Count current OPEN trades
|
||||
const openTrades = await prisma.trades.count({
|
||||
where: {
|
||||
status: 'OPEN',
|
||||
isAutomated: true
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`🔴 Current OPEN automated trades: ${openTrades}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Error checking trades:', error);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
checkTradeStatuses().catch(console.error);
|
||||
Reference in New Issue
Block a user