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.
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
// Analysis completion flag manager
|
|
// This ensures cleanup only happens after the entire analysis cycle is complete
|
|
|
|
class AnalysisCompletionFlag {
|
|
private static instance: AnalysisCompletionFlag
|
|
private isAnalysisComplete = false
|
|
private currentSessionId: string | null = null
|
|
|
|
private constructor() {}
|
|
|
|
static getInstance(): AnalysisCompletionFlag {
|
|
if (!AnalysisCompletionFlag.instance) {
|
|
AnalysisCompletionFlag.instance = new AnalysisCompletionFlag()
|
|
}
|
|
return AnalysisCompletionFlag.instance
|
|
}
|
|
|
|
// Called at the start of each analysis cycle
|
|
startAnalysisCycle(sessionId: string) {
|
|
console.log(`🚀 Starting analysis cycle: ${sessionId}`)
|
|
this.isAnalysisComplete = false
|
|
this.currentSessionId = sessionId
|
|
}
|
|
|
|
// Called at the end of each analysis cycle
|
|
markAnalysisComplete(sessionId: string) {
|
|
if (sessionId === this.currentSessionId) {
|
|
console.log(`✅ Analysis cycle complete: ${sessionId}`)
|
|
this.isAnalysisComplete = true
|
|
} else {
|
|
console.log(`⚠️ Session ID mismatch: expected ${this.currentSessionId}, got ${sessionId}`)
|
|
}
|
|
}
|
|
|
|
// Check if analysis is complete and cleanup can proceed
|
|
canCleanup(): boolean {
|
|
return this.isAnalysisComplete
|
|
}
|
|
|
|
// Get current session info
|
|
getCurrentSession(): { sessionId: string | null; isComplete: boolean } {
|
|
return {
|
|
sessionId: this.currentSessionId,
|
|
isComplete: this.isAnalysisComplete
|
|
}
|
|
}
|
|
|
|
// Reset flag (for manual cleanup or new cycles)
|
|
reset() {
|
|
console.log(`🔄 Resetting analysis completion flag`)
|
|
this.isAnalysisComplete = false
|
|
this.currentSessionId = null
|
|
}
|
|
}
|
|
|
|
export const analysisCompletionFlag = AnalysisCompletionFlag.getInstance()
|