root = Card([portfolioHeader, summaryRow, positionsSection, exposureSection, watchlistOrdersSection, headlinesEconomicSection, strategyDrawdownSection, riskLimitsSection, actionsSection], "card", "column", "l")
portfolioHeader = CardHeader("Trading Desk — Morning Workspace", "As of 09:30 ET | Portfolio: MAIN-ALPHA")
summaryRow = Card([valueCard, pnlCard, varCard, marginCard], "clear", "row", "m", "stretch", "between", true)
valueCard = Card([valueLabel, valueAmount], "sunk", "column", "s", "center")
valueLabel = TextContent("Portfolio Value", "small-heavy")
valueAmount = TextContent("$12,847,320", "large-heavy")
pnlCard = Card([pnlLabel, pnlAmount], "sunk", "column", "s", "center")
pnlLabel = TextContent("P&L Today", "small-heavy")
pnlAmount = TextContent("+$84,210 (+0.66%)", "large-heavy")
varCard = Card([varLabel, varAmount], "sunk", "column", "s", "center")
varLabel = TextContent("Value at Risk (1D, 95%)", "small-heavy")
varAmount = TextContent("$312,400", "large-heavy")
marginCard = Card([marginLabel, marginAmount, marginProgress], "sunk", "column", "s", "center")
marginLabel = TextContent("Margin In Use", "small-heavy")
marginAmount = TextContent("$4.2M / $8.0M (52.5%)", "large-heavy")
marginProgress = Progress(52.5, "52.5% utilized")
positionsSection = Card([positionsHeader, positionsTable], "card", "column", "m")
positionsHeader = Heading("Current Positions", "h3")
positionsTable = Table([posTicker, posSize, posEntry, posCurrent, posUnrealized, posPnlPct])
posTicker = Col("Ticker", ["AAPL", "MSFT", "NVDA", "GOOGL", "TSLA", "JPM", "XOM", "SPY", "QQQ", "IWM"])
posSize = Col("Size", [12500, 8200, 3400, 4100, -2800, 6500, 9200, 15000, 8500, 11000])
posEntry = Col("Entry", [172.45, 398.20, 845.60, 142.30, 248.90, 189.50, 112.75, 432.10, 398.50, 198.20])
posCurrent = Col("Current", [178.92, 405.10, 872.30, 145.80, 241.50, 192.80, 115.20, 438.50, 402.10, 201.40])
posUnrealized = Col("Unrealized P&L", [80875, 56580, 90780, 14350, -20720, 21450, 22540, 96000, 30600, 35200])
posPnlPct = Col("P&L %", [3.75, 1.73, 3.16, 2.46, -2.97, 1.74, 2.17, 1.48, 0.90, 1.61])
exposureSection = Card([exposureHeader, exposureChart], "card", "column", "m")
exposureHeader = Heading("Exposure by Sector", "h3")
exposureChart = HorizontalBarChart(["Technology", "Financials", "Energy", "Healthcare", "Consumer Disc", "Industrials", "Communications", "Utilities", "Materials", "Real Estate"], [exposureLong, exposureShort], "grouped", "Net Exposure ($M)", "Sector")
exposureLong = Series("Long", [4.2, 1.8, 1.1, 0.9, 0.7, 0.5, 0.4, 0.2, 0.3, 0.1])
exposureShort = Series("Short", [-0.3, -0.1, 0, -0.2, -0.4, 0, -0.1, 0, 0, 0])
watchlistOrdersSection = Card([watchlistCard, ordersCard], "clear", "row", "m", "stretch", "between", true)
watchlistCard = Card([watchlistHeader, watchlistTable], "card", "column", "m")
watchlistHeader = Heading("Watchlist", "h3")
watchlistTable = Table([watchTicker, watchPrice, watchChange, watchSignal])
watchTicker = Col("Ticker", ["AMD", "META", "AVGO", "CRM", "NFLX", "PLTR", "COIN", "MSTR"])
watchPrice = Col("Price", [158.40, 485.20, 1342.80, 267.50, 634.10, 28.90, 215.60, 1420.30])
watchChange = Col("Change %", [+1.2, -0.8, +2.1, +0.5, -1.3, +3.4, -2.2, +4.1])
watchSignal = Col("Signal", ["Buy", "Hold", "Buy", "Hold", "Sell", "Buy", "Sell", "Buy"])
ordersCard = Card([ordersHeader, ordersTable], "card", "column", "m")
ordersHeader = Heading("Working Orders", "h3")
ordersTable = Table([orderTicker, orderSide, orderType, orderQty, orderLimit, orderStatus, orderTime])
orderTicker = Col("Ticker", ["NVDA", "TSLA", "SPY", "QQQ", "AAPL"])
orderSide = Col("Side", ["Buy", "Sell", "Buy", "Sell", "Buy"])
orderType = Col("Type", ["Limit", "Stop", "Limit", "Stop-Limit", "Limit"])
orderQty = Col("Qty", [500, 300, 2000, 1200, 800])
orderLimit = Col("Limit/Stop", [865.00, 235.00, 436.00, 399.50, 177.50])
orderStatus = Col("Status", ["Working", "Working", "Working", "Working", "Working"])
orderTime = Col("Time", ["08:42", "08:55", "09:01", "09:12", "09:25"])
headlinesEconomicSection = Card([headlinesCard, economicCard], "clear", "row", "m", "stretch", "between", true)
headlinesCard = Card([headlinesHeader, headlinesList], "card", "column", "m")
headlinesHeader = Heading("Market Headlines", "h3")
headlinesList = ListBlock([hl1, hl2, hl3, hl4, hl5], "number")
hl1 = ListItem("Fed holds rates steady; Powell signals patience on cuts", "Reuters • 06:45 ET • Sentiment: Neutral", null, null)
hl2 = ListItem("Tech earnings beat estimates; AI capex guidance raised", "Bloomberg • 07:12 ET • Sentiment: Positive", null, null)
hl3 = ListItem("Oil drops 3% on demand concerns; OPEC+ meeting eyed", "WSJ • 07:30 ET • Sentiment: Negative", null, null)
hl4 = ListItem("Yield curve steepens as 10Y hits 4.45%; inflation data ahead", "FT • 08:05 ET • Sentiment: Neutral", null, null)
hl5 = ListItem("China stimulus hopes lift EM equities; HK up 2.1%", "CNBC • 08:20 ET • Sentiment: Positive", null, null)
economicCard = Card([economicHeader, economicList], "card", "column", "m")
economicHeader = Heading("Economic Releases This Week", "h3")
economicList = ListBlock([eco1, eco2, eco3, eco4, eco5], "number")
eco1 = ListItem("Mon 08:30 ET — Core PCE Price Index MoM (Nov)", "Consensus: +0.2% | Prior: +0.2%", null, null)
eco2 = ListItem("Tue 10:00 ET — ISM Manufacturing PMI (Dec)", "Consensus: 48.5 | Prior: 48.4", null, null)
eco3 = ListItem("Wed 08:30 ET — ADP Employment Change (Dec)", "Consensus: 140K | Prior: 146K", null, null)
eco4 = ListItem("Thu 08:30 ET — Initial Jobless Claims", "Consensus: 218K | Prior: 219K", null, null)
eco5 = ListItem("Fri 08:30 ET — Nonfarm Payrolls (Dec)", "Consensus: 170K | Prior: 199K", null, null)
strategyDrawdownSection = Card([strategyCard, drawdownCard], "clear", "row", "m", "stretch", "between", true)
strategyCard = Card([strategyHeader, strategyChart], "card", "column", "m")
strategyHeader = Heading("Strategy Returns YTD", "h3")
strategyChart = BarChart(["Long/Short Equity", "Global Macro", "Stat Arb", "Event Driven", "Credit", "Quant Equity", "Commodity", "Volatility"], [stratReturns], "grouped", "Strategy", "Return %")
stratReturns = Series("YTD %", [18.4, 12.7, 8.9, 15.2, 6.3, 11.8, 4.1, -2.3])
drawdownCard = Card([drawdownHeader, drawdownChart], "card", "column", "m")
drawdownHeader = Heading("Portfolio Drawdown (Past Year)", "h3")
drawdownChart = AreaChart(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], [ddSeries], "natural", "Month", "Drawdown %")
ddSeries = Series("Drawdown", [-2.1, -3.4, -5.8, -4.2, -6.1, -3.8, -2.9, -4.5, -7.2, -5.1, -3.3, -2.8])
riskLimitsSection = Card([riskHeader, riskAlerts], "card", "column", "m")
riskHeader = Heading("Risk Limits — Near Breach", "h3")
riskAlerts = Card([alert1, alert2, alert3], "clear", "column", "s")
alert1 = Callout("warning", "Gross Leverage", "Current: 2.85x | Limit: 3.0x (95% utilized)")
alert2 = Callout("warning", "Single Name Concentration (NVDA)", "Current: 9.2% | Limit: 10% (92% utilized)")
alert3 = Callout("info", "Sector Concentration (Technology)", "Current: 38.5% | Limit: 40% (96% utilized)")
actionsSection = Card([rebalanceBtn, orderForm, timeframeSelector], "clear", "column", "l")
rebalanceBtn = Buttons([rebalanceButton], "row")
rebalanceButton = Button("Rebalance Portfolio", ["rebalance"], "primary")
orderForm = Form("place-order", orderButtons, [tickerField, sideField, qtyField, typeField, priceField])
tickerField = FormControl("Ticker", tickerInput, "Enter symbol (e.g., AAPL)")
tickerInput = Input("ticker", "AAPL", "text", null, "")
sideField = FormControl("Side", sideSelect)
sideSelect = Select("side", [sideBuy, sideSell], "Select side")
sideBuy = SelectItem("buy", "Buy")
sideSell = SelectItem("sell", "Sell")
qtyField = FormControl("Quantity", qtyInput, "Number of shares/contracts")
qtyInput = Input("quantity", "100", "number", null, "")
typeField = FormControl("Order Type", typeSelect)
typeSelect = Select("order_type", [typeMarket, typeLimit, typeStop, typeStopLimit], "Select type")
typeMarket = SelectItem("market", "Market")
typeLimit = SelectItem("limit", "Limit")
typeStop = SelectItem("stop", "Stop")
typeStopLimit = SelectItem("stop_limit", "Stop-Limit")
priceField = FormControl("Limit/Stop Price", priceInput, "Required for limit/stop orders")
priceInput = Input("price", "178.50", "number", null, "")
orderButtons = Buttons([submitOrder, cancelOrder], "row")
submitOrder = Button("Place Order", ["submit_order"], "primary")
cancelOrder = Button("Cancel", null, "tertiary")
timeframeSelector = Card([tfLabel, tfButtons], "clear", "column", "s")
tfLabel = TextContent("Chart Timeframe", "small-heavy")
tfButtons = Buttons([tf1d, tf1w, tf1m, tf3m, tf1y, tfYtd], "row")
tf1d = Button("1D", ["tf_1d"], "tertiary")
tf1w = Button("1W", ["tf_1w"], "tertiary")
tf1m = Button("1M", ["tf_1m"], "tertiary")
tf3m = Button("3M", ["tf_3m"], "tertiary")
tfYtd = Button("YTD", ["tf_ytd"], "tertiary")
tf1y = Button("1Y", ["tf_1y"], "secondary")