From e1d8c0c65ac2ad247508d94d8e517418a34ddcdd Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Thu, 24 Jul 2025 14:55:34 +0200 Subject: [PATCH] fix: correct timeframe display in Bot Status for scalping strategies - Add selectedTimeframes to automation status API response to show actual running timeframes - Update Bot Status UI to display selectedTimeframes from API instead of local config state - Fix issue where Bot Status showed '1h' instead of scalping timeframes '5m, 15m, 30m' - Ensure selectedTimeframes are properly stored in database settings and retrieved in status - Bot Status now correctly reflects the actual running automation configuration UI Changes: - Bot Status timeframes now shows: '5m, 15m, 30m' for scalping instead of '1h' - Analysis Timer correctly shows 2-minute intervals for scalping strategies - Status display is now synchronized with actual automation configuration Backend Changes: - Store selectedTimeframes in automation session settings - Include selectedTimeframes in getStatus() API response - Enhanced interval detection to support settings-based timeframes --- app/automation-v2/page.js | 4 ++-- lib/automation-service-simple.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/automation-v2/page.js b/app/automation-v2/page.js index 63001c6..110093c 100644 --- a/app/automation-v2/page.js +++ b/app/automation-v2/page.js @@ -364,7 +364,7 @@ export default function AutomationPageV2() {
Selected: - {config.selectedTimeframes.map(tf => timeframes.find(t => t.value === tf)?.label).filter(Boolean).join(', ')} + {(status.selectedTimeframes || [status.timeframe]).map(tf => timeframes.find(t => t.value === tf)?.label || tf).filter(Boolean).join(', ')}
@@ -499,7 +499,7 @@ export default function AutomationPageV2() {
Timeframes: - {config.selectedTimeframes.map(tf => timeframes.find(t => t.value === tf)?.label).filter(Boolean).join(', ')} + {(status.selectedTimeframes || [status.timeframe]).map(tf => timeframes.find(t => t.value === tf)?.label || tf).filter(Boolean).join(', ')}
diff --git a/lib/automation-service-simple.ts b/lib/automation-service-simple.ts index 7f17214..cde35e9 100644 --- a/lib/automation-service-simple.ts +++ b/lib/automation-service-simple.ts @@ -103,6 +103,7 @@ export class AutomationService { maxLeverage: config.maxLeverage, // stopLossPercent and takeProfitPercent removed - AI calculates these automatically maxDailyTrades: config.maxDailyTrades, + selectedTimeframes: config.selectedTimeframes, riskPercentage: config.riskPercentage }, startBalance: config.tradingAmount, @@ -169,8 +170,8 @@ export class AutomationService { private getIntervalFromTimeframe(timeframe: string): number { // Check if this is a scalping strategy (multiple short timeframes) - if (this.config?.selectedTimeframes) { - const timeframes = this.config.selectedTimeframes + if (this.config?.selectedTimeframes || this.config?.settings?.selectedTimeframes) { + const timeframes = this.config.selectedTimeframes || this.config.settings?.selectedTimeframes const isScalping = timeframes.includes('5') || timeframes.includes('3') || (timeframes.length > 1 && timeframes.every(tf => ['1', '3', '5', '15', '30'].includes(tf))) if (isScalping) { console.log('🎯 Scalping strategy detected - using frequent analysis (2-3 minutes)') @@ -1366,6 +1367,7 @@ ${validResults.map(r => `• ${r.timeframe}: ${r.analysis?.recommendation} (${r. mode: session.mode as 'SIMULATION' | 'LIVE', symbol: session.symbol, timeframe: session.timeframe, + selectedTimeframes: session.settings?.selectedTimeframes, totalTrades: session.totalTrades, successfulTrades: session.successfulTrades, winRate: session.winRate,