'use client'
import React, { useState, useEffect } from 'react'
import TradeExecutionPanel from '../../components/TradeExecutionPanel.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) => (
))}
{/* Portfolio Overview */}
Portfolio Overview
{balance ? (
Total Value:
${balance.totalValue?.toFixed(2)}
Available Balance:
${balance.availableBalance?.toFixed(2)}
{balance.positions && balance.positions.length > 0 && (
Current Positions
{balance.positions.map((position, index) => (
{position.symbol}
${position.price?.toFixed(4)}
= 0 ? 'text-green-400' : 'text-red-400'
}`}>
{position.change24h >= 0 ? '+' : ''}{position.change24h?.toFixed(2)}%
))}
)}
) : (
{loading ? 'Loading portfolio...' : 'Failed to load portfolio data'}
)}
{/* Trading History Placeholder */}
Recent Trades
Trade history will appear here after executing trades.
)
}