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

@@ -714,34 +714,23 @@ Analyze all provided screenshots comprehensively and return only the JSON respon
if (sessionId) {
progressTracker.updateStep(sessionId, 'analysis', 'completed', 'AI analysis completed successfully!')
}
// Trigger browser cleanup immediately after analysis completes
try {
console.log('🧹 Triggering browser cleanup after analysis completion...')
const { enhancedScreenshotService } = await import('./enhanced-screenshot')
await enhancedScreenshotService.cleanup()
console.log('✅ Browser cleanup completed')
} catch (cleanupError) {
console.error('Error in browser cleanup:', cleanupError)
}
// Trigger system-wide cleanup
try {
// Dynamic import to avoid circular dependencies
const aggressiveCleanupModule = await import('./aggressive-cleanup')
const aggressiveCleanup = aggressiveCleanupModule.default
// Run cleanup in background, don't block the response
aggressiveCleanup.runPostAnalysisCleanup().catch(console.error)
} catch (cleanupError) {
console.error('Error triggering post-analysis cleanup:', cleanupError)
}
if (sessionId) {
// Mark session as complete after cleanup is initiated
// Mark session as complete
setTimeout(() => progressTracker.deleteSession(sessionId), 1000)
}
// Trigger post-analysis cleanup in development mode
if (process.env.NODE_ENV === 'development') {
try {
// Dynamic import to avoid circular dependencies
const aggressiveCleanupModule = await import('./aggressive-cleanup')
const aggressiveCleanup = aggressiveCleanupModule.default
// Run cleanup in background, don't block the response
aggressiveCleanup.runPostAnalysisCleanup().catch(console.error)
} catch (cleanupError) {
console.error('Error triggering post-analysis cleanup:', cleanupError)
}
}
return {
screenshots,
analysis
@@ -750,16 +739,6 @@ Analyze all provided screenshots comprehensively and return only the JSON respon
} catch (error) {
console.error('Automated capture and analysis with config failed:', error)
// Trigger browser cleanup even on error
try {
console.log('🧹 Triggering browser cleanup after analysis error...')
const { enhancedScreenshotService } = await import('./enhanced-screenshot')
await enhancedScreenshotService.cleanup()
console.log('✅ Browser cleanup completed after error')
} catch (cleanupError) {
console.error('Error in browser cleanup after error:', cleanupError)
}
if (sessionId) {
// Find the active step and mark it as error
const progress = progressTracker.getProgress(sessionId)