Fix automated trading display calculations
Fixed position size calculation: 00 investment now shows 00 position (was 04.76) Fixed token amount display: Now shows correct tokens (~0.996) for 00 investment (was 2.04) Corrected API route: /api/automation/analysis-details now returns 200 instead of 405 Technical changes: - Updated route calculation logic: tradingAmount / trade.price for correct token amounts - Fixed displayPositionSize to show intended investment amount - Used Docker Compose v2 for container management - Resolved Next.js module export issues The API now correctly displays trade details matching user investment intentions.
This commit is contained in:
@@ -714,21 +714,32 @@ Analyze all provided screenshots comprehensively and return only the JSON respon
|
||||
|
||||
if (sessionId) {
|
||||
progressTracker.updateStep(sessionId, 'analysis', 'completed', 'AI analysis completed successfully!')
|
||||
// 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)
|
||||
}
|
||||
// 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
|
||||
setTimeout(() => progressTracker.deleteSession(sessionId), 1000)
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -739,6 +750,16 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user