'use client' import React, { useState, useEffect } from 'react' export default function AutomationPage() { const [config, setConfig] = useState({ mode: 'SIMULATION', dexProvider: 'DRIFT', symbol: 'SOLUSD', timeframe: '1h', tradingAmount: 100, maxLeverage: 5, stopLossPercent: 2, takeProfitPercent: 6, maxDailyTrades: 5, riskPercentage: 2 }) const [status, setStatus] = useState(null) const [isLoading, setIsLoading] = useState(false) useEffect(() => { fetchStatus() const interval = setInterval(fetchStatus, 30000) return () => clearInterval(interval) }, []) 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 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) } } return (
{/* Header */}

Automated Trading

Drift Protocol

{status?.isActive ? ( ) : ( )}
{/* Main Grid */}
{/* Configuration */}

Configuration

{/* Trading Mode */}
{/* Leverage */}
{/* Parameters */}
setConfig({...config, tradingAmount: parseFloat(e.target.value)})} className="w-full p-3 bg-gray-700 border border-gray-600 rounded-lg text-white focus:border-blue-500" disabled={status?.isActive} min="10" step="10" />
{/* Risk Management */}
setConfig({...config, stopLossPercent: parseFloat(e.target.value)})} className="w-full p-3 bg-gray-700 border border-gray-600 rounded-lg text-white focus:border-blue-500" disabled={status?.isActive} min="0.5" max="20" step="0.5" />
setConfig({...config, takeProfitPercent: parseFloat(e.target.value)})} className="w-full p-3 bg-gray-700 border border-gray-600 rounded-lg text-white focus:border-blue-500" disabled={status?.isActive} min="1" max="50" step="1" />
setConfig({...config, maxDailyTrades: parseInt(e.target.value)})} className="w-full p-3 bg-gray-700 border border-gray-600 rounded-lg text-white focus:border-blue-500" disabled={status?.isActive} min="1" max="50" />
{/* Status */}

Status

{status ? (
Status: {status.isActive ? 'ACTIVE' : 'STOPPED'}
Mode: {status.mode}
Protocol: DRIFT
Symbol: {config.symbol}
Leverage: {config.maxLeverage}x
Position Size: ${config.tradingAmount}
) : (

Loading...

)}

Performance

0
Trades
0%
Win Rate
$0.00
P&L
0
Active
) }