'use client' import { useState } from 'react' export function TradingTools() { const [activeTool, setActiveTool] = useState<'calculator' | 'alerts' | 'notes'>('calculator') return (
{/* Tool Navigation */}
{[ { id: 'calculator', label: '🧮 Position Calculator', count: 0 }, { id: 'alerts', label: '🔔 Trade Alerts', count: 0 }, { id: 'notes', label: '📝 Trade Notes', count: 0 }, ].map(tool => ( ))}
{/* Position Calculator */} {activeTool === 'calculator' && } {/* Trade Alerts */} {activeTool === 'alerts' && } {/* Trade Notes */} {activeTool === 'notes' && }
) } function PositionCalculator() { const [form, setForm] = useState({ accountSize: '10000', riskPercent: '2', stopLossPercent: '1', leverage: '1', entryPrice: '', direction: 'long' as 'long' | 'short', }) const calculate = () => { const account = parseFloat(form.accountSize) || 0 const riskPct = parseFloat(form.riskPercent) || 0 const slPct = parseFloat(form.stopLossPercent) || 0 const entry = parseFloat(form.entryPrice) || 0 const lev = parseFloat(form.leverage) || 1 const riskAmount = account * (riskPct / 100) const positionSize = lev * (riskAmount / (slPct / 100)) const margin = positionSize / lev const potentialProfit = positionSize * (slPct / 100) * 2 // 2:1 const potentialLoss = riskAmount return { riskAmount, positionSize, margin, potentialProfit, potentialLoss, rr: '2:1', } } const result = calculate() return (

🧮 Position Size Calculator

setForm({...form, accountSize: e.target.value})} className="w-full bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white" />
setForm({...form, riskPercent: e.target.value})} className="w-full bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white" />
setForm({...form, stopLossPercent: e.target.value})} className="w-full bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white" />
setForm({...form, leverage: e.target.value})} className="w-full bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white" />
setForm({...form, entryPrice: e.target.value})} placeholder="0.00" className="w-full bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white" />
{/* Results */}

Max Risk

${result.riskAmount.toFixed(2)}

Position Size

${result.positionSize.toFixed(2)}

Required Margin

${result.margin.toFixed(2)}

Potential Profit

+${result.potentialProfit.toFixed(2)}

) } function TradeAlerts() { const [alerts, setAlerts] = useState([ { id: '1', pair: 'BTC/USD', type: 'SL Hit', price: 66500, time: '2h ago', triggered: true }, { id: '2', pair: 'ETH/USD', type: 'TP Hit', price: 3200, time: '5h ago', triggered: true }, ]) return (

🔔 Trade Alerts

{alerts.length === 0 ? (

No alerts yet

) : (
{alerts.map(alert => (
{alert.pair} {alert.type}

${alert.price.toLocaleString()}

{alert.time}

))}
)}
) } function TradeNotes() { const [notes, setNotes] = useState<{id: string, date: string, content: string, tradeId?: string}[]>([]) const [newNote, setNewNote] = useState('') const addNote = () => { if (!newNote.trim()) return setNotes([{ id: Date.now().toString(), date: new Date().toISOString(), content: newNote }, ...notes]) setNewNote('') } return (

📝 Trade Notes

{/* Add Note */}