"use client" import React, { useEffect, useState } from 'react' import AutoTradingPanel from './AutoTradingPanel' import TradingHistory from './TradingHistory' import DeveloperSettings from './DeveloperSettings' import AIAnalysisPanel from './AIAnalysisPanel' import SessionStatus from './SessionStatus' export default function Dashboard() { const [positions, setPositions] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [stats, setStats] = useState({ totalPnL: 0, dailyPnL: 0, winRate: 0, totalTrades: 0 }) useEffect(() => { async function fetchPositions() { try { const res = await fetch('/api/trading') if (res.ok) { const data = await res.json() setPositions(data.positions || []) // Calculate some mock stats for demo setStats({ totalPnL: 1247.50, dailyPnL: 67.25, winRate: 73.2, totalTrades: 156 }) } else { setError('Failed to load positions') } } catch (e) { setError('Error loading positions') } setLoading(false) } fetchPositions() }, []) return (
{/* Stats Cards */}

Total P&L

= 0 ? 'text-green-400' : 'text-red-400'}`}> {stats.totalPnL >= 0 ? '+' : ''}${stats.totalPnL.toFixed(2)}

📈

Daily P&L

= 0 ? 'text-green-400' : 'text-red-400'}`}> {stats.dailyPnL >= 0 ? '+' : ''}${stats.dailyPnL.toFixed(2)}

💰

Win Rate

{stats.winRate}%

🎯

Total Trades

{stats.totalTrades}

🔄
{/* Main Content Grid */}
{/* Left Column - Controls */}
{/* Right Column - Analysis & Positions */}
{/* Open Positions */}

Open Positions

{loading ? (
Loading positions...
) : error ? (
⚠️

{error}

Please check your connection and try again

) : positions.length === 0 ? (
📊

No open positions

Start trading to see your positions here

) : (
{positions.map((pos, i) => ( ))}
Asset Side Size Entry PnL
{pos.symbol?.slice(0, 2) || 'BT'}
{pos.symbol || 'BTC/USD'}
{pos.side || 'Long'} {pos.size || '0.1 BTC'} ${pos.entryPrice || '45,230.00'} = 0 ? 'text-green-400' : 'text-red-400' }`}> {(pos.unrealizedPnl || 125.50) >= 0 ? '+' : ''}${(pos.unrealizedPnl || 125.50).toFixed(2)}
)}
) }