fix: TradeFollowUpPanel property mismatch causing position loading error

- Fix property names: size → amount, pnl → unrealizedPnl
- Update TradePosition interface to match actual API response
- Add missing properties: pnlPercentage, totalValue, timestamp, status, leverage, txId
- Resolves 'Error Loading Positions' issue when accessing marked trades
- Follow-up assistant now properly displays position information
This commit is contained in:
mindesbunister
2025-07-17 16:28:17 +02:00
parent 55f85a10e4
commit 7c4e9d0122

View File

@@ -7,11 +7,16 @@ interface TradePosition {
side: 'LONG' | 'SHORT'
entryPrice: number
currentPrice: number
size: number
pnl: number
amount: number
unrealizedPnl: number
pnlPercentage: number
totalValue: number
stopLoss?: number
takeProfit?: number
entryTime: string
timestamp: number
status: string
leverage: number
txId: string
entryAnalysis?: string
}
@@ -60,7 +65,7 @@ export default function TradeFollowUpPanel({ onClose }: TradeFollowUpPanelProps)
setChatMessages([{
id: Date.now().toString(),
type: 'system',
content: `🎯 **Trade Follow-up Assistant**\n\nI'm here to help you manage your active ${data.positions[0].symbol} ${data.positions[0].side} position.\n\n**Current Position:**\n• Entry: $${data.positions[0].entryPrice}\n• Size: ${data.positions[0].size}\n• Current P&L: ${data.positions[0].pnl > 0 ? '+' : ''}$${data.positions[0].pnl.toFixed(2)}\n\nAsk me anything about your trade!`,
content: `🎯 **Trade Follow-up Assistant**\n\nI'm here to help you manage your active ${data.positions[0].symbol} ${data.positions[0].side} position.\n\n**Current Position:**\n• Entry: $${data.positions[0].entryPrice}\n• Size: ${data.positions[0].amount}\n• Current P&L: ${data.positions[0].unrealizedPnl > 0 ? '+' : ''}$${data.positions[0].unrealizedPnl.toFixed(2)}\n\nAsk me anything about your trade!`,
timestamp: new Date().toISOString()
}])
} else {