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:
@@ -259,8 +259,10 @@ export class AutomationService {
|
||||
return
|
||||
}
|
||||
|
||||
// Step 2: Store analysis in database for learning
|
||||
await this.storeAnalysisForLearning(config, result, sessionId)
|
||||
// Step 2: Store analysis in database for learning (only if analysis exists)
|
||||
if (result.analysis) {
|
||||
await this.storeAnalysisForLearning(config, { ...result, analysis: result.analysis }, sessionId)
|
||||
}
|
||||
|
||||
// Step 3: Check if we should execute trade
|
||||
const shouldTrade = await this.shouldExecuteTrade(result.analysis, config)
|
||||
@@ -306,7 +308,7 @@ export class AutomationService {
|
||||
data: {
|
||||
userId: config.userId,
|
||||
sessionId: sessionId,
|
||||
analysisData: result.analysis,
|
||||
analysisData: result.analysis as any,
|
||||
marketConditions: {
|
||||
timeframe: config.timeframe,
|
||||
symbol: config.symbol,
|
||||
@@ -626,11 +628,11 @@ export class AutomationService {
|
||||
successfulTrades: session.successfulTrades,
|
||||
winRate: session.winRate,
|
||||
totalPnL: session.totalPnL,
|
||||
lastAnalysis: session.lastAnalysis,
|
||||
lastTrade: session.lastTrade,
|
||||
nextScheduled: session.nextScheduled,
|
||||
lastAnalysis: session.lastAnalysis || undefined,
|
||||
lastTrade: session.lastTrade || undefined,
|
||||
nextScheduled: session.nextScheduled || undefined,
|
||||
errorCount: session.errorCount,
|
||||
lastError: session.lastError
|
||||
lastError: session.lastError || undefined
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to get automation status:', error)
|
||||
|
||||
Reference in New Issue
Block a user