fix: Remove all hardcoded timeframe references in automation service
- Replace hardcoded timeframes array ['15', '1h', '2h', '4h'] with dynamic selectedTimeframes - Fix hardcoded '1h' references in primary timeframe selection - Update recommendation messages to use dynamic primaryTimeframe - Ensure scalping selection (5,15,30m) is properly respected by automation service - All timeframe logic now uses selectedTimeframes from UI configuration
This commit is contained in:
@@ -15,6 +15,7 @@ export interface AutomationConfig {
|
|||||||
mode: 'SIMULATION' | 'LIVE'
|
mode: 'SIMULATION' | 'LIVE'
|
||||||
symbol: string
|
symbol: string
|
||||||
timeframe: string
|
timeframe: string
|
||||||
|
selectedTimeframes?: string[] // Multi-timeframe support from UI
|
||||||
tradingAmount: number
|
tradingAmount: number
|
||||||
maxLeverage: number
|
maxLeverage: number
|
||||||
// stopLossPercent and takeProfitPercent removed - AI calculates these automatically
|
// stopLossPercent and takeProfitPercent removed - AI calculates these automatically
|
||||||
@@ -271,8 +272,8 @@ export class AutomationService {
|
|||||||
progressTracker.createSession(sessionId, progressSteps)
|
progressTracker.createSession(sessionId, progressSteps)
|
||||||
progressTracker.updateStep(sessionId, 'init', 'active', 'Starting multi-timeframe analysis...')
|
progressTracker.updateStep(sessionId, 'init', 'active', 'Starting multi-timeframe analysis...')
|
||||||
|
|
||||||
// Multi-timeframe analysis: 15m, 1h, 2h, 4h
|
// Use selected timeframes from UI, fallback to default if not provided
|
||||||
const timeframes = ['15', '1h', '2h', '4h']
|
const timeframes = this.config!.selectedTimeframes || ['1h']
|
||||||
const symbol = this.config!.symbol
|
const symbol = this.config!.symbol
|
||||||
|
|
||||||
console.log(`🔍 Analyzing ${symbol} across timeframes: ${timeframes.join(', ')} with AI + DIY layouts`)
|
console.log(`🔍 Analyzing ${symbol} across timeframes: ${timeframes.join(', ')} with AI + DIY layouts`)
|
||||||
@@ -404,8 +405,10 @@ export class AutomationService {
|
|||||||
return { screenshots: [], analysis: null }
|
return { screenshots: [], analysis: null }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the primary timeframe (1h) as base
|
// Get the primary timeframe (first selected or default) as base
|
||||||
const primaryResult = validResults.find(r => r.timeframe === '1h') || validResults[0]
|
const selectedTimeframes = this.config!.selectedTimeframes || ['1h']
|
||||||
|
const primaryTimeframe = selectedTimeframes[0] || '1h'
|
||||||
|
const primaryResult = validResults.find(r => r.timeframe === primaryTimeframe) || validResults[0]
|
||||||
const screenshots = validResults.length > 0 ? [primaryResult.timeframe] : []
|
const screenshots = validResults.length > 0 ? [primaryResult.timeframe] : []
|
||||||
|
|
||||||
// Calculate weighted confidence based on timeframe alignment
|
// Calculate weighted confidence based on timeframe alignment
|
||||||
@@ -478,8 +481,10 @@ ${validResults.map(r => `• ${r.timeframe}: ${r.analysis?.recommendation} (${r.
|
|||||||
const allLevels = results.map(r => r.analysis?.keyLevels).filter(Boolean)
|
const allLevels = results.map(r => r.analysis?.keyLevels).filter(Boolean)
|
||||||
if (allLevels.length === 0) return {}
|
if (allLevels.length === 0) return {}
|
||||||
|
|
||||||
// Use the 1h timeframe levels as primary, or first available
|
// Use the primary timeframe levels (first selected) as primary, or first available
|
||||||
const primaryLevels = results.find(r => r.timeframe === '1h')?.analysis?.keyLevels || allLevels[0]
|
const selectedTimeframes = this.config!.selectedTimeframes || ['1h']
|
||||||
|
const primaryTimeframe = selectedTimeframes[0] || '1h'
|
||||||
|
const primaryLevels = results.find(r => r.timeframe === primaryTimeframe)?.analysis?.keyLevels || allLevels[0]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...primaryLevels,
|
...primaryLevels,
|
||||||
@@ -491,8 +496,10 @@ ${validResults.map(r => `• ${r.timeframe}: ${r.analysis?.recommendation} (${r.
|
|||||||
const sentiments = results.map(r => r.analysis?.marketSentiment).filter(Boolean)
|
const sentiments = results.map(r => r.analysis?.marketSentiment).filter(Boolean)
|
||||||
if (sentiments.length === 0) return 'NEUTRAL'
|
if (sentiments.length === 0) return 'NEUTRAL'
|
||||||
|
|
||||||
// Use the 1h timeframe sentiment as primary, or first available
|
// Use the primary timeframe sentiment (first selected) as primary, or first available
|
||||||
const primarySentiment = results.find(r => r.timeframe === '1h')?.analysis?.marketSentiment || sentiments[0]
|
const selectedTimeframes = this.config!.selectedTimeframes || ['1h']
|
||||||
|
const primaryTimeframe = selectedTimeframes[0] || '1h'
|
||||||
|
const primarySentiment = results.find(r => r.timeframe === primaryTimeframe)?.analysis?.marketSentiment || sentiments[0]
|
||||||
|
|
||||||
return primarySentiment || 'NEUTRAL'
|
return primarySentiment || 'NEUTRAL'
|
||||||
}
|
}
|
||||||
@@ -1191,11 +1198,14 @@ ${validResults.map(r => `• ${r.timeframe}: ${r.analysis?.recommendation} (${r.
|
|||||||
recommendations: string[]
|
recommendations: string[]
|
||||||
}> {
|
}> {
|
||||||
try {
|
try {
|
||||||
// For now, return mock data
|
// For now, return mock data with dynamic timeframe
|
||||||
|
const selectedTimeframes = this.config?.selectedTimeframes || ['1h']
|
||||||
|
const primaryTimeframe = selectedTimeframes[0] || '1h'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalAnalyses: 150,
|
totalAnalyses: 150,
|
||||||
avgAccuracy: 0.72,
|
avgAccuracy: 0.72,
|
||||||
bestTimeframe: '1h',
|
bestTimeframe: primaryTimeframe,
|
||||||
worstTimeframe: '15m',
|
worstTimeframe: '15m',
|
||||||
commonFailures: [
|
commonFailures: [
|
||||||
'Low confidence predictions',
|
'Low confidence predictions',
|
||||||
@@ -1203,7 +1213,7 @@ ${validResults.map(r => `• ${r.timeframe}: ${r.analysis?.recommendation} (${r.
|
|||||||
'Timeframe misalignment'
|
'Timeframe misalignment'
|
||||||
],
|
],
|
||||||
recommendations: [
|
recommendations: [
|
||||||
'Focus on 1h timeframe for better accuracy',
|
`Focus on ${primaryTimeframe} timeframe for better accuracy`,
|
||||||
'Wait for higher confidence signals (>75%)',
|
'Wait for higher confidence signals (>75%)',
|
||||||
'Use multiple timeframe confirmation'
|
'Use multiple timeframe confirmation'
|
||||||
]
|
]
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user