import type { Position } from "../lib/alpaca"; import { money, num, pct } from "../lib/format"; export function PositionsTable({ positions }: { positions: Position[] }) { if (!positions.length) { return (
No open positions.
); } return (
Positions
{positions.length}
{positions.map((p) => { const pl = Number(p.unrealized_pl); const plpc = Number(p.unrealized_plpc); const tone = pl > 0 ? "text-up" : pl < 0 ? "text-down" : "text-mute"; const isOpt = p.asset_class?.toLowerCase().includes("option"); return ( ); })}
Symbol Class Qty Entry Mark Market value P&L %
{p.symbol} {isOpt ? "opt" : "eq"} ยท {p.side || "long"} {num(p.qty, 0)} {money(p.avg_entry_price)} {money(p.current_price)} {money(p.market_value)} {money(pl, { sign: true })} {pct(plpc)}
); }