fix: correct entry prices and position sizing in trading system

- 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
This commit is contained in:
mindesbunister
2025-07-21 09:26:48 +02:00
parent 55cea00e5e
commit 71e1a64b5d
13 changed files with 795 additions and 546 deletions

View File

@@ -33,6 +33,14 @@ export async function GET() {
}
// Get actual trade data to calculate real statistics
// Get ALL trades count for consistency
const totalTradesCount = await prisma.trade.count({
where: {
userId: session.userId,
symbol: session.symbol
}
})
const trades = await prisma.trade.findMany({
where: {
userId: session.userId,
@@ -62,7 +70,7 @@ export async function GET() {
mode: session.mode,
symbol: session.symbol,
timeframe: session.timeframe,
totalTrades: completedTrades.length,
totalTrades: totalTradesCount, // Use actual total count
successfulTrades: successfulTrades.length,
winRate: Math.round(winRate * 10) / 10, // Round to 1 decimal
totalPnL: Math.round(totalPnL * 100) / 100, // Round to 2 decimals