From 2bbaa072d6c6c901aff241d3b20b18b73087e8bb Mon Sep 17 00:00:00 2001 From: mindesbunister Date: Wed, 23 Jul 2025 13:39:33 +0200 Subject: [PATCH] Fix automation v2 timeframe selection and SELL signal execution - Fixed timeframe selection to use user-selected timeframes instead of hardcoded values - Added selectedTimeframes property to AutomationConfig interface - Added maxDailyTrades property to AutomationConfig interface - Removed Jupiter DEX blocking logic that prevented SELL signals from opening SHORT positions - Fixed SELL signals to properly execute SHORT positions on Drift Protocol - Updated automation test route with missing properties (selectedTimeframes, maxDailyTrades, dexProvider) - Added debug logging to automation v2 page for better troubleshooting - Added test click button for UI interaction debugging - Resolved TypeScript compilation errors in automation service - Ensured automation v2 interface is fully functional and responsive These changes enable: - Multi-timeframe analysis with user-selected timeframes - Proper SHORT position execution on SELL signals - Improved UI reliability and debugging capabilities - Full Drift Protocol perpetual futures trading support --- app/api/automation/test/route.ts | 4 ++- app/automation-v2/page.js | 10 ++++++ lib/automation-service-simple.ts | 59 +++++++------------------------- lib/automation-service.ts | 2 ++ 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/app/api/automation/test/route.ts b/app/api/automation/test/route.ts index 81d7f8c..21dc9a5 100644 --- a/app/api/automation/test/route.ts +++ b/app/api/automation/test/route.ts @@ -11,12 +11,14 @@ export async function GET(request: NextRequest) { mode: 'SIMULATION' as const, symbol: 'SOLUSD', timeframe: '1h', + selectedTimeframes: ['1h'], tradingAmount: 10, // $10 for simulation maxLeverage: 2, stopLossPercent: 2, takeProfitPercent: 6, maxDailyTrades: 5, - riskPercentage: 1 + riskPercentage: 1, + dexProvider: 'DRIFT' as const } console.log('📋 Config:', testConfig) diff --git a/app/automation-v2/page.js b/app/automation-v2/page.js index 9ad1997..895e1dd 100644 --- a/app/automation-v2/page.js +++ b/app/automation-v2/page.js @@ -57,6 +57,7 @@ export default function AutomationPageV2() { try { const response = await fetch('/api/automation/status') const data = await response.json() + console.log('Status fetched:', data) // Debug log if (data.success) { setStatus(data.status) } @@ -90,6 +91,7 @@ export default function AutomationPageV2() { } const handleStart = async () => { + console.log('Start button clicked') // Debug log setLoading(true) try { // Ensure we have selectedTimeframes before starting @@ -126,12 +128,14 @@ export default function AutomationPageV2() { } const handleStop = async () => { + console.log('Stop button clicked') // Debug log setLoading(true) try { const response = await fetch('/api/automation/stop', { method: 'POST' }) const data = await response.json() + console.log('Stop response:', data) // Debug log if (data.success) { fetchStatus() } else { @@ -157,6 +161,12 @@ export default function AutomationPageV2() {

Drift Protocol - Multi-Timeframe Analysis

+ {status?.isActive ? (