diff --git a/frontend/src/pages/Positions.tsx b/frontend/src/pages/Positions.tsx
index c1102c6..53a314b 100644
--- a/frontend/src/pages/Positions.tsx
+++ b/frontend/src/pages/Positions.tsx
@@ -28,14 +28,44 @@ export function PositionsPage() {
if (isLoading) return ;
+ const positions = data ?? [];
+
+ const totals = positions.reduce(
+ (acc, p) => ({
+ quantity: acc.quantity + p.quantity,
+ unrealized_pnl: acc.unrealized_pnl + (p.unrealized_pnl ?? 0),
+ realized_pnl: acc.realized_pnl + (p.realized_pnl ?? 0),
+ market_value: acc.market_value + p.quantity * (p.current_price ?? 0),
+ cost_basis: acc.cost_basis + p.quantity * p.avg_entry_price,
+ }),
+ { quantity: 0, unrealized_pnl: 0, realized_pnl: 0, market_value: 0, cost_basis: 0 },
+ );
+
return (
Positions
- data={data ?? []}
+ data={positions}
columns={columns}
keyField="id"
/>
+ {positions.length > 0 && (
+
+
+
+
+ | Totals |
+ {totals.quantity} |
+ {fmtUsd(totals.cost_basis)} |
+ {fmtUsd(totals.market_value)} |
+ {fmtUsd(totals.unrealized_pnl)} |
+ {fmtUsd(totals.realized_pnl)} |
+ |
+
+
+
+
+ )}
);
}