'use client' import React, { useState, useEffect } from 'react' export default function AutomationPage() { const [config, setConfig] = useState({ mode: 'SIMULATION', symbol: 'SOLUSD', timeframe: '1h', tradingAmount: 100, maxLeverage: 3, stopLossPercent: 2, takeProfitPercent: 6, maxDailyTrades: 5, riskPercentage: 2 }) const [status, setStatus] = useState(null) const [isLoading, setIsLoading] = useState(false) const [learningInsights, setLearningInsights] = useState(null) const [recentTrades, setRecentTrades] = useState([]) useEffect(() => { fetchStatus() fetchLearningInsights() fetchRecentTrades() }, []) const fetchStatus = async () => { try { const response = await fetch('/api/automation/status') const data = await response.json() if (data.success) { setStatus(data.status) } } catch (error) { console.error('Failed to fetch status:', error) } } const fetchLearningInsights = async () => { try { const response = await fetch('/api/automation/learning-insights') const data = await response.json() if (data.success) { setLearningInsights(data.insights) } } catch (error) { console.error('Failed to fetch learning insights:', error) } } const fetchRecentTrades = async () => { try { const response = await fetch('/api/automation/recent-trades') const data = await response.json() if (data.success) { setRecentTrades(data.trades) } } catch (error) { console.error('Failed to fetch recent trades:', error) } } const handleStart = async () => { setIsLoading(true) try { const response = await fetch('/api/automation/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(config) }) const data = await response.json() if (data.success) { fetchStatus() } else { alert('Failed to start automation: ' + data.error) } } catch (error) { console.error('Failed to start automation:', error) alert('Failed to start automation') } finally { setIsLoading(false) } } const handleStop = async () => { setIsLoading(true) try { const response = await fetch('/api/automation/stop', { method: 'POST' }) const data = await response.json() if (data.success) { fetchStatus() } else { alert('Failed to stop automation: ' + data.error) } } catch (error) { console.error('Failed to stop automation:', error) alert('Failed to stop automation') } finally { setIsLoading(false) } } const handlePause = async () => { setIsLoading(true) try { const response = await fetch('/api/automation/pause', { method: 'POST' }) const data = await response.json() if (data.success) { fetchStatus() } else { alert('Failed to pause automation: ' + data.error) } } catch (error) { console.error('Failed to pause automation:', error) alert('Failed to pause automation') } finally { setIsLoading(false) } } const handleResume = async () => { setIsLoading(true) try { const response = await fetch('/api/automation/resume', { method: 'POST' }) const data = await response.json() if (data.success) { fetchStatus() } else { alert('Failed to resume automation: ' + data.error) } } catch (error) { console.error('Failed to resume automation:', error) alert('Failed to resume automation') } finally { setIsLoading(false) } } return (
AI-powered automated trading on 1H timeframe with learning capabilities
No active automation session
)}No recent trades
)}