Files
trading_bot_v3/remove-demo-trades.js
mindesbunister d7a1b96a80 fix: Resolve win rate and P&L discrepancies between Status and AI Learning sections
- Fixed analysis-details API to use stored profit field as fallback when exit prices missing
- Updated UI to use Status API data instead of calculating from limited recent trades
- Modified AI Learning Status to use real database trade data instead of demo numbers
- Enhanced price monitor with automatic trade closing logic for TP/SL hits
- Modified automation service to create trades with OPEN status for proper monitoring
- Added test scripts for creating OPEN trades and validating monitoring system

Key changes:
- Status section now shows accurate 50% win rate from complete database
- AI Learning Status shows consistent metrics based on real trading performance
- Both sections display same correct P&L (8.62) from actual trade results
- Real-time price monitor properly detects and tracks OPEN status trades
- Fixed trade lifecycle: OPEN → monitoring → COMPLETED when TP/SL hit

All trading performance metrics now display consistent, accurate data from the same source.
2025-07-21 12:56:14 +02:00

48 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
async function removeDemoTrades() {
try {
console.log('🧹 Removing demo trades...')
// Remove demo trades
const deletedTrades = await prisma.trade.deleteMany({
where: {
userId: 'demo-user',
tradingMode: 'SIMULATION',
isAutomated: true
}
})
console.log(`✅ Removed ${deletedTrades.count} demo trades`)
// Optionally remove demo user if no other data
const remainingUserData = await prisma.trade.count({
where: { userId: 'demo-user' }
})
if (remainingUserData === 0) {
await prisma.user.delete({
where: { id: 'demo-user' }
})
console.log('✅ Removed demo user (no remaining data)')
} else {
console.log(` Demo user kept (has ${remainingUserData} other records)`)
}
console.log('🎉 Demo data cleanup completed!')
} catch (error) {
console.error('❌ Error removing demo trades:', error)
} finally {
await prisma.$disconnect()
}
}
if (require.main === module) {
removeDemoTrades()
}
module.exports = { removeDemoTrades }