'use client' import React, { useState, useEffect } from 'react' import TradingChart from '../../components/TradingChart' import CompactTradingPanel from '../../components/CompactTradingPanel' export default function ChartTradingPageSimple() { const [currentPrice, setCurrentPrice] = useState(166.21) const [positions, setPositions] = useState([ // Mock position data for demo { id: 'demo_pos_1', symbol: 'SOL/USDC', side: 'BUY' as 'BUY' | 'SELL', amount: 0.5, entryPrice: 165.50, stopLoss: 160.00, takeProfit: 170.00, currentPrice: 166.21, unrealizedPnl: 0.355, } ]) const [selectedSymbol, setSelectedSymbol] = useState('SOL') const handleTrade = async (tradeData: any) => { try { console.log('Trade executed (demo):', tradeData) // Create a mock position for demo const newPosition = { id: `demo_${Date.now()}`, symbol: `${tradeData.symbol}/USDC`, side: tradeData.side, amount: tradeData.amount, entryPrice: tradeData.price, stopLoss: tradeData.stopLoss, takeProfit: tradeData.takeProfit, currentPrice: currentPrice, unrealizedPnl: 0, } setPositions(prev => [...prev, newPosition]) alert(`Demo trade executed: ${tradeData.side} ${tradeData.amount} ${tradeData.symbol}`) } catch (error) { console.error('Trade execution error:', error) } } const handlePriceUpdate = (price: number) => { setCurrentPrice(price) // Update position P&L based on new price setPositions(prev => prev.map(pos => ({ ...pos, currentPrice: price, unrealizedPnl: pos.side === 'BUY' ? (price - pos.entryPrice) * pos.amount : (pos.entryPrice - price) * pos.amount }))) } const handleClosePosition = (positionId: string) => { setPositions(prev => prev.filter(pos => pos.id !== positionId)) alert('Position closed (demo)') } return (
{/* Top Bar */}

Chart Trading Terminal

{/* Symbol Selector */}
{['SOL', 'BTC', 'ETH'].map(symbol => ( ))}
{/* Market Status */}
Demo Mode
{new Date().toLocaleTimeString()}
{/* Main Trading Interface */}
{/* Chart Area (70% width) */}
{/* Trading Panel (30% width) */}
{/* Bottom Panel - Positions */}
{positions.length > 0 && (
Total P&L: sum + (pos.unrealizedPnl || 0), 0) >= 0 ? 'text-green-400' : 'text-red-400' }`}> {positions.reduce((sum, pos) => sum + (pos.unrealizedPnl || 0), 0) >= 0 ? '+' : ''}$ {positions.reduce((sum, pos) => sum + (pos.unrealizedPnl || 0), 0).toFixed(2)}
)}
{/* Positions Table */}
{positions.length === 0 ? (
No open positions
) : (
{positions.map((position: any) => (
{position.symbol} • {position.side}
Size: {position.amount} • Entry: ${position.entryPrice?.toFixed(2)}
{position.stopLoss && (
SL: ${position.stopLoss.toFixed(2)}
)} {position.takeProfit && (
TP: ${position.takeProfit.toFixed(2)}
)}
${(position.amount * position.currentPrice).toFixed(2)}
= 0 ? 'text-green-400' : 'text-red-400' }`}> {(position.unrealizedPnl || 0) >= 0 ? '+' : ''}${(position.unrealizedPnl || 0).toFixed(2)}
))}
)}
) }