From 049ecb0265607fb268db2bb420e44163dd3a465d Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Sat, 26 Jul 2025 12:30:51 +0200 Subject: [PATCH] Fix presets to match frontend UI exactly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FRONTEND PRESET CORRECTIONS: - Scalp Trading: 5m, 15m, 30m (was 5m, 15m) → 3 timeframes - Day Trading: 1h, 2h (was 1h, 4h) → 2 timeframes - Swing Trading: 4h, 1D (correct) → 2 timeframes UPDATED FILES: - lib/superior-screenshot-service.ts → Correct timeframe definitions - lib/auto-trading-service.ts → TRADING_CONFIGS match frontend - app/api/superior-screenshot/route.js → API presets corrected - Verification and test scripts updated PERFORMANCE ESTIMATES: - Scalp (3 timeframes): ~90s → ~30-40s parallel - Day Trading (2 timeframes): ~60s → ~20-30s parallel - Swing Trading (2 timeframes): ~60s → ~20-30s parallel - Extended (9 timeframes): ~270s → ~70-100s parallel System now matches frontend UI exactly with superior parallel capture! --- app/api/superior-screenshot/route.js | 14 ++++++++------ lib/auto-trading-service.ts | 16 ++++++++-------- lib/superior-screenshot-service.ts | 7 ++++--- test-all-presets-api.js | 6 +++--- verify-integration.js | 13 +++++++------ 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/app/api/superior-screenshot/route.js b/app/api/superior-screenshot/route.js index 6ec06c1..e059d88 100644 --- a/app/api/superior-screenshot/route.js +++ b/app/api/superior-screenshot/route.js @@ -17,15 +17,16 @@ export async function POST(request) { console.log('📋 Superior Config:', config) - // Define trading presets matching the main automation system + // Define trading presets matching the frontend UI const TRADING_PRESETS = { 'scalp': [ { name: '5m', tv: '5' }, - { name: '15m', tv: '15' } + { name: '15m', tv: '15' }, + { name: '30m', tv: '30' } ], 'day-trading': [ { name: '1h', tv: '60' }, - { name: '4h', tv: '240' } + { name: '2h', tv: '120' } ], 'swing-trading': [ { name: '4h', tv: '240' }, @@ -38,6 +39,7 @@ export async function POST(request) { { name: '15m', tv: '15' }, { name: '30m', tv: '30' }, { name: '1h', tv: '60' }, + { name: '2h', tv: '120' }, { name: '4h', tv: '240' }, { name: '1D', tv: '1D' } ] @@ -181,10 +183,10 @@ export async function GET() { POST: '/api/superior-screenshot - Superior parallel analysis' }, presets: { - 'scalp': '2 timeframes (5m, 15m) - Scalping strategy', - 'day-trading': '2 timeframes (1h, 4h) - Day trading strategy', + 'scalp': '3 timeframes (5m, 15m, 30m) - Scalping strategy', + 'day-trading': '2 timeframes (1h, 2h) - Day trading strategy', 'swing-trading': '2 timeframes (4h, 1D) - Swing trading strategy', - 'extended': '8 timeframes (1m-1D) - Comprehensive analysis' + 'extended': '9 timeframes (1m-1D) - Comprehensive analysis' }, features: [ 'Parallel multi-timeframe capture', diff --git a/lib/auto-trading-service.ts b/lib/auto-trading-service.ts index f6eeb08..d24d541 100644 --- a/lib/auto-trading-service.ts +++ b/lib/auto-trading-service.ts @@ -88,15 +88,15 @@ export class AutoTradingService { let preset: 'scalp' | 'day-trading' | 'swing-trading' | 'custom' = 'custom' // Detect strategy based on timeframe patterns - if (timeframeSet.has('5') && timeframeSet.has('15') && config.timeframes.length === 2) { + if (timeframeSet.has('5') && timeframeSet.has('15') && timeframeSet.has('30') && config.timeframes.length === 3) { preset = 'scalp' - console.log('🎯 Detected: SCALP trading strategy') - } else if (timeframeSet.has('60') && timeframeSet.has('240') && config.timeframes.length === 2) { + console.log('🎯 Detected: SCALP trading strategy (5m, 15m, 30m)') + } else if (timeframeSet.has('60') && timeframeSet.has('120') && config.timeframes.length === 2) { preset = 'day-trading' - console.log('🎯 Detected: DAY TRADING strategy') + console.log('🎯 Detected: DAY TRADING strategy (1h, 2h)') } else if (timeframeSet.has('240') && timeframeSet.has('1D') && config.timeframes.length === 2) { preset = 'swing-trading' - console.log('🎯 Detected: SWING TRADING strategy') + console.log('🎯 Detected: SWING TRADING strategy (4h, 1d)') } else { preset = 'custom' console.log('🎯 Using: CUSTOM timeframe configuration') @@ -260,7 +260,7 @@ export const TRADING_CONFIGS = { // Scalping configuration - frequent analysis of short timeframes scalping: { symbol: 'SOLUSD', - timeframes: ['5m', '15m'], + timeframes: ['5m', '15m', '30m'], // Updated to match frontend: 5m, 15m, 30m layouts: ['ai', 'diy'], intervalMs: 5 * 60 * 1000, // Every 5 minutes maxCycles: 100 // Limit for testing @@ -269,7 +269,7 @@ export const TRADING_CONFIGS = { // Day trading configuration - moderate frequency on intraday timeframes dayTrading: { symbol: 'SOLUSD', - timeframes: ['1h', '4h'], + timeframes: ['1h', '2h'], // Updated to match frontend: 1h, 2h layouts: ['ai', 'diy'], intervalMs: 30 * 60 * 1000, // Every 30 minutes maxCycles: 50 // Limit for testing @@ -278,7 +278,7 @@ export const TRADING_CONFIGS = { // Swing trading configuration - less frequent analysis of longer timeframes swingTrading: { symbol: 'SOLUSD', - timeframes: ['4h', '1d'], + timeframes: ['4h', '1d'], // Matches frontend: 4h, 1d layouts: ['ai', 'diy'], intervalMs: 2 * 60 * 60 * 1000, // Every 2 hours maxCycles: 24 // Limit for testing diff --git a/lib/superior-screenshot-service.ts b/lib/superior-screenshot-service.ts index 6357b8b..3774473 100644 --- a/lib/superior-screenshot-service.ts +++ b/lib/superior-screenshot-service.ts @@ -3,15 +3,16 @@ * Uses the proven scalp preset parallel API technique for maximum efficiency */ -// Trading strategy presets matching the main automation system +// Trading strategy presets matching the frontend UI const SCALP_TIMEFRAMES = [ { name: '5m', tv: '5', description: 'Standard scalping' }, - { name: '15m', tv: '15', description: 'Swing scalping' } + { name: '15m', tv: '15', description: 'Swing scalping' }, + { name: '30m', tv: '30', description: 'Extended scalping' } ] const DAY_TRADING_TIMEFRAMES = [ { name: '1h', tv: '60', description: 'Hourly analysis' }, - { name: '4h', tv: '240', description: 'Four-hour trend' } + { name: '2h', tv: '120', description: 'Two-hour trend' } ] const SWING_TRADING_TIMEFRAMES = [ diff --git a/test-all-presets-api.js b/test-all-presets-api.js index 85bc9be..79e00b0 100644 --- a/test-all-presets-api.js +++ b/test-all-presets-api.js @@ -13,10 +13,10 @@ async function testAllPresets() { const baseUrl = 'http://localhost:9001' const presets = [ - { name: 'Scalp Trading', preset: 'scalp', description: '2 timeframes (5m, 15m)' }, - { name: 'Day Trading', preset: 'day-trading', description: '2 timeframes (1h, 4h)' }, + { name: 'Scalp Trading', preset: 'scalp', description: '3 timeframes (5m, 15m, 30m)' }, + { name: 'Day Trading', preset: 'day-trading', description: '2 timeframes (1h, 2h)' }, { name: 'Swing Trading', preset: 'swing-trading', description: '2 timeframes (4h, 1D)' }, - { name: 'Extended Analysis', preset: 'extended', description: '8+ timeframes (1m-1D)' } + { name: 'Extended Analysis', preset: 'extended', description: '9+ timeframes (1m-1D)' } ] console.log('\n📋 Testing Strategy:') diff --git a/verify-integration.js b/verify-integration.js index 1861515..efa8c07 100644 --- a/verify-integration.js +++ b/verify-integration.js @@ -15,11 +15,11 @@ console.log(' 📁 lib/ai-analysis.ts → Updated for compatibility') console.log(' 📁 app/api/enhanced-screenshot/ → Restored with superior backend') console.log(' 📁 app/api/superior-screenshot/ → Updated with all presets') -console.log('\n🎯 CURRENT TRADING PRESETS:') -console.log(' 📊 Scalp Trading: 5m, 15m (2 timeframes) - PARALLEL') -console.log(' 📊 Day Trading: 1h, 4h (2 timeframes) - PARALLEL') +console.log('\n🎯 CURRENT TRADING PRESETS (MATCHING FRONTEND UI):') +console.log(' 📊 Scalp Trading: 5m, 15m, 30m (3 timeframes) - PARALLEL') +console.log(' 📊 Day Trading: 1h, 2h (2 timeframes) - PARALLEL') console.log(' 📊 Swing Trading: 4h, 1D (2 timeframes) - PARALLEL') -console.log(' 📊 Extended: 1m-1D (8 timeframes) - PARALLEL') +console.log(' 📊 Extended: 1m-1D (9 timeframes) - PARALLEL') console.log(' 📊 Custom: Any timeframes - PARALLEL') console.log('\n❌ ELIMINATED ISSUES:') @@ -30,8 +30,9 @@ console.log(' 🚫 No more browser session management complexity') console.log('\n🚀 PERFORMANCE IMPROVEMENTS:') console.log(' ⚡ ALL timeframe selections now use parallel capture') -console.log(' ⚡ 2-timeframe strategies: ~60s → ~20-30s') -console.log(' ⚡ 8-timeframe strategies: ~240s → ~60-90s') +console.log(' ⚡ 3-timeframe scalping: ~90s → ~30-40s') +console.log(' ⚡ 2-timeframe day/swing: ~60s → ~20-30s') +console.log(' ⚡ 9-timeframe extended: ~270s → ~70-100s') console.log(' ⚡ API-managed browser sessions (no cleanup needed)') console.log('\n📋 ANSWERS TO YOUR QUESTION:')