'use client' import React, { useState, useEffect } from 'react' import TradeExecutionPanel from '../../components/TradeExecutionPanel.js' import PositionsPanel from '../../components/PositionsPanel.js' import PendingOrdersPanel from '../../components/PendingOrdersPanel.js' import TradesHistoryPanel from '../../components/TradesHistoryPanel.js' export default function TradingPage() { const [selectedSymbol, setSelectedSymbol] = useState('SOL') const [balance, setBalance] = useState(null) const [loading, setLoading] = useState(false) const symbols = [ { name: 'Solana', symbol: 'SOL', icon: '◎', color: 'from-purple-400 to-purple-600' }, { name: 'Bitcoin', symbol: 'BTC', icon: '₿', color: 'from-orange-400 to-orange-600' }, { name: 'Ethereum', symbol: 'ETH', icon: 'Ξ', color: 'from-blue-400 to-blue-600' }, ] useEffect(() => { fetchBalance() }, []) const fetchBalance = async () => { setLoading(true) try { const response = await fetch('/api/trading/balance') const data = await response.json() if (data.success) { setBalance(data.balance) } } catch (error) { console.error('Failed to fetch balance:', error) } finally { setLoading(false) } } return (

Manual Trading

Execute trades using Bitquery integration

{/* Symbol Selection */}

Select Trading Symbol

{symbols.map((coin) => ( ))}
{/* Open Positions */} {/* Pending Orders */} {/* Portfolio Overview */}

Wallet Overview

{balance ? (
Total Value: ${balance.totalValue?.toFixed(2)}
Available Balance: ${balance.availableBalance?.toFixed(2)}
{balance.positions && balance.positions.length > 0 && (

Wallet Holdings

{balance.positions.map((position, index) => (
{position.symbol}
${position.price?.toFixed(4)}
{position.amount}
= 0 ? 'text-green-400' : 'text-red-400' }`}> {position.change24h >= 0 ? '+' : ''}{position.change24h?.toFixed(2)}%
))}
)}
) : (
{loading ? 'Loading wallet...' : 'Failed to load wallet data'}
)}
{/* Recent Trades */}
) }