- Fixed automation service to use real SOL price (~89) instead of hardcoded 00 - Updated position size calculation to properly convert USD investment to token amount - Enhanced trade display to show separate entry/exit prices with price difference - Added data quality warnings for trades with missing exit data - Updated API to use current SOL price (189.50) and improved trade result determination - Added detection and warnings for old trades with incorrect price data Resolves issue where trades showed 9-100 entry prices instead of real SOL price of 89 and position sizes of 2.04 SOL instead of correct ~0.53 SOL for 00 investment
92 lines
2.2 KiB
JavaScript
92 lines
2.2 KiB
JavaScript
const { PrismaClient } = require('@prisma/client')
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
async function checkTradeCounts() {
|
|
try {
|
|
console.log('🔍 Checking trade counts in database...')
|
|
|
|
// Total trades
|
|
const totalTrades = await prisma.trade.count({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD'
|
|
}
|
|
})
|
|
|
|
// Completed trades
|
|
const completedTrades = await prisma.trade.count({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD',
|
|
status: 'COMPLETED'
|
|
}
|
|
})
|
|
|
|
// Open/Active trades
|
|
const activeTrades = await prisma.trade.count({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD',
|
|
status: 'OPEN'
|
|
}
|
|
})
|
|
|
|
// Pending trades
|
|
const pendingTrades = await prisma.trade.count({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD',
|
|
status: 'PENDING'
|
|
}
|
|
})
|
|
|
|
console.log('\n📊 TRADE COUNTS:')
|
|
console.log(`Total Trades: ${totalTrades}`)
|
|
console.log(`Completed Trades: ${completedTrades}`)
|
|
console.log(`Active Trades: ${activeTrades}`)
|
|
console.log(`Pending Trades: ${pendingTrades}`)
|
|
|
|
// Get all trades with details
|
|
const allTrades = await prisma.trade.findMany({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD'
|
|
},
|
|
orderBy: { createdAt: 'desc' },
|
|
select: {
|
|
id: true,
|
|
side: true,
|
|
amount: true,
|
|
price: true,
|
|
status: true,
|
|
createdAt: true,
|
|
leverage: true,
|
|
profit: true
|
|
}
|
|
})
|
|
|
|
console.log('\n📋 ALL TRADES:')
|
|
allTrades.forEach((trade, index) => {
|
|
console.log(`${index + 1}. ${trade.side} ${trade.amount} tokens @ $${trade.price} - ${trade.status} (${new Date(trade.createdAt).toLocaleString()})`)
|
|
})
|
|
|
|
// Check automation sessions
|
|
const sessions = await prisma.automationSession.count({
|
|
where: {
|
|
userId: 'default-user',
|
|
symbol: 'SOLUSD'
|
|
}
|
|
})
|
|
|
|
console.log(`\n🤖 Automation Sessions: ${sessions}`)
|
|
|
|
} catch (error) {
|
|
console.error('Error checking trade counts:', error)
|
|
} finally {
|
|
await prisma.$disconnect()
|
|
}
|
|
}
|
|
|
|
checkTradeCounts()
|