import React, { useState } from 'react' interface TradingViewCredentials { email: string password: string } interface AutomatedAnalysisResult { screenshots: string[] analysis: any symbol: string timeframe: string timestamp: string } export function AutomatedTradingPanel() { const [credentials, setCredentials] = useState({ email: '', password: '' }) const [symbol, setSymbol] = useState('SOLUSD') const [timeframe, setTimeframe] = useState('5') const [isLoading, setIsLoading] = useState(false) const [result, setResult] = useState(null) const [error, setError] = useState('') const [healthStatus, setHealthStatus] = useState<'unknown' | 'ok' | 'error'>('unknown') const checkHealth = async () => { try { const response = await fetch('/api/trading/automated-analysis') const data = await response.json() if (data.status === 'ok') { setHealthStatus('ok') } else { setHealthStatus('error') setError(data.message || 'Health check failed') } } catch (err: any) { setHealthStatus('error') setError(err.message || 'Failed to check health') } } const runAutomatedAnalysis = async () => { if (!credentials.email || !credentials.password) { setError('Please enter your TradingView credentials') return } setIsLoading(true) setError('') setResult(null) try { const response = await fetch('/api/trading/automated-analysis', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ symbol, timeframe, credentials }) }) const data = await response.json() if (!response.ok) { throw new Error(data.error || data.details || 'Analysis failed') } setResult(data.data) } catch (err: any) { setError(err.message || 'Failed to run automated analysis') } finally { setIsLoading(false) } } return (

Automated TradingView Analysis (Docker)

{/* Health Check */}

System Health

{healthStatus !== 'unknown' && (
Status: {healthStatus === 'ok' ? '✅ System Ready' : '❌ System Error'}
)}
{/* Configuration */}
setSymbol(e.target.value)} className="w-full p-2 border rounded" placeholder="e.g., SOLUSD, BTCUSD" />
setCredentials(prev => ({ ...prev, email: e.target.value }))} className="w-full p-2 border rounded" placeholder="your-email@example.com" />
setCredentials(prev => ({ ...prev, password: e.target.value }))} className="w-full p-2 border rounded" placeholder="your-password" />
{/* Action Button */} {/* Error Display */} {error && (
Error: {error}
)} {/* Results */} {result && (

Analysis Results

{/* Screenshots */}

Screenshots Captured:

{result.screenshots.map((screenshot, index) => (
📸 {screenshot}
))}
{/* Analysis Summary */}

AI Analysis Summary

Symbol: {result.symbol}
Timeframe: {result.timeframe}
Sentiment: {result.analysis.marketSentiment}
Recommendation: {result.analysis.recommendation}
Confidence: {result.analysis.confidence}%
Summary: {result.analysis.summary}
Reasoning: {result.analysis.reasoning}
{/* Trading Details */} {result.analysis.entry && (

Trading Setup

Entry: ${result.analysis.entry.price}
{result.analysis.stopLoss && (
Stop Loss: ${result.analysis.stopLoss.price}
)} {result.analysis.takeProfits?.tp1 && (
Take Profit 1: ${result.analysis.takeProfits.tp1.price}
)} {result.analysis.riskToReward && (
Risk/Reward: {result.analysis.riskToReward}
)}
)}
)}
) } export default AutomatedTradingPanel