root = Card([header, controlsCard, portfolioCard, marketCard, exposureCard, varCard, positionsCard, gainersLosersCard, watchlistCard, ordersCard, econCard, strategiesCard, drawdownCard, riskAlertCard, rebalanceCard, orderCard], "card", "column", "2xl")
header = CardHeader("Trading Desk — Morning Workspace", "Friday, May 16, 2025")
controlsCard = Card([controlsHeader, timeframeButtons], "sunk")
controlsHeader = CardHeader("Timeframe")
timeframeButtons = Buttons([tf1d, tf1w, tf1m], "row")
tf1d = Button("1D", null, "secondary", null, "small")
tf1w = Button("1W", null, "secondary", null, "small")
tf1m = Button("1M", null, "primary", null, "small")
portfolioCard = Card([portfolioHeader, portfolioStats], "sunk")
portfolioHeader = CardHeader("Portfolio")
portfolioStats = Table([statMetric, statValue])
statMetric = Col("Metric", ["Portfolio Value", "P&L Today"])
statValue = Col("Value", ["$12,847,350", "+$214,200 (+1.7%)"])
marketCard = Card([marketHeader, headlinesTable], "sunk")
marketHeader = CardHeader("Market headlines", "Sentiment")
headlinesTable = Table([headlineCol, sourceCol, sentimentCol])
headlineCol = Col("Headline", ["Fed signals patience on rate cuts", "Oil slides as inventories build", "Tech earnings beat estimates", "Eurozone GDP revised higher"])
sourceCol = Col("Source", ["Reuters", "Bloomberg", "CNBC", "FT"])
sentimentCol = Col("Sentiment", ["Neutral", "Negative", "Positive", "Positive"])
exposureCard = Card([exposureHeader, exposureChart], "sunk")
exposureHeader = CardHeader("Exposure by sector")
exposureChart = PieChart(sectorLabels, sectorValues, "donut", "circular")
sectorLabels = ["Technology", "Financials", "Energy", "Healthcare", "Consumer"]
sectorValues = [38, 22, 15, 13, 12]
varCard = Card([varHeader, varCallout, marginProgress], "sunk")
varHeader = CardHeader("Value at Risk & Margin")
varCallout = TextCallout("info", "Value at Risk", "$1.42M (95% 1-day)")
marginProgress = Progress(68, "Margin in use: 68%")
positionsCard = Card([positionsHeader, positionsTable], "sunk")
positionsHeader = CardHeader("Positions", "Current holdings")
positionsTable = Table([tickerCol, sizeCol, entryCol, priceCol])
tickerCol = Col("Ticker", ["AAPL", "MSFT", "NVDA", "TSLA", "JPM", "XOM"])
sizeCol = Col("Size", ["1,200", "850", "420", "1,100", "900", "2,000"])
entryCol = Col("Entry", ["$189.42", "$332.10", "$742.30", "$251.20", "$172.30", "$116.40"])
priceCol = Col("Current", ["$212.40", "$364.80", "$1,024.50", "$235.10", "$183.20", "$120.75"])
gainersLosersCard = Card([glHeader, glTable], "sunk")
glHeader = CardHeader("Today's biggest movers")
glTable = Table([gainerCol, loserCol])
gainerCol = Col("Top Gainers", ["NVDA +2.8%", "AAPL +3.2%", "MSFT +1.9%"])
loserCol = Col("Top Losers", ["TSLA -2.1%", "XOM -1.4%", "JPM -0.8%"])
watchlistCard = Card([watchlistHeader, watchlistTable], "sunk")
watchlistHeader = CardHeader("Watchlist", "Instruments being watched")
watchlistTable = Table([watchTicker, watchPrice, watchChange])
watchTicker = Col("Ticker", ["AMD", "GOOG", "AMZN", "META", "NFLX"])
watchPrice = Col("Price", ["$175.20", "$1,823.40", "$188.30", "$512.80", "$680.90"])
watchChange = Col("Chg %", ["+1.2%", "-0.4%", "+0.8%", "+2.1%", "-1.5%"])
ordersCard = Card([ordersHeader, ordersTable], "sunk")
ordersHeader = CardHeader("Working orders")
ordersTable = Table([orderTicker, orderSide, orderQty, orderType, orderStatus])
orderTicker = Col("Ticker", ["AAPL", "NVDA", "TSLA"])
orderSide = Col("Side", ["Buy", "Sell", "Buy"])
orderQty = Col("Qty", ["500", "200", "300"])
orderType = Col("Type", ["Limit", "Market", "Stop"])
orderStatus = Col("Status", ["Working", "Working", "Filled"])
econCard = Card([econHeader, econTable], "sunk")
econHeader = CardHeader("Economic releases this week")
econTable = Table([econDate, econEvent, econPrev, econForecast])
econDate = Col("Date", ["Mon", "Tue", "Wed", "Thu"])
econEvent = Col("Event", ["Core CPI", "PPI", "Retail Sales", "Jobless Claims"])
econPrev = Col("Prev", ["3.1%", "2.2%", "0.4%", "212K"])
econForecast = Col("Forecast", ["3.0%", "2.4%", "0.3%", "220K"])
strategiesCard = Card([strategiesHeader, strategiesChart], "sunk")
strategiesHeader = CardHeader("Strategy returns YTD", "Year-to-date")
strategiesChart = BarChart(strategyLabels, [strategySeries], "grouped", "Strategy", "Return %")
strategyLabels = ["Momentum", "Mean Rev", "Carry", "Arbitrage", "Macro"]
strategySeries = Series("Return %", [18.2, 12.4, 8.9, 15.3, -2.1])
drawdownCard = Card([drawdownHeader, drawdownChart], "sunk")
drawdownHeader = CardHeader("Drawdown — past year")
drawdownChart = AreaChart(ddLabels, [ddSeries], "natural", "Month", "Drawdown %")
ddLabels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
ddSeries = Series("Drawdown", [-4.2, -6.8, -9.5, -7.1, -3.9, -5.4, -11.2, -8.6, -6.1, -4.8, -3.2, -4.5])
riskAlertCard = Card([riskAlertHeader, riskAlerts], "sunk")
riskAlertHeader = CardHeader("Risk limits near breach")
riskAlerts = Callout("warning", "Two limits close to breach", "Volatility VaR at 92% of limit; Tech sector concentration at 88%. Consider rebalancing.")
rebalanceCard = Card([rebalancePrompt, rebalanceButtons], "sunk")
rebalancePrompt = TextContent("Portfolio drift detected. Rebalance to restore target weights.")
rebalanceButtons = Buttons([rebalanceBtn, dryRunBtn], "row")
rebalanceBtn = Button("Rebalance now", null, "primary")
dryRunBtn = Button("Preview rebalance", null, "secondary")
orderCard = Card([orderHeader, orderForm], "sunk")
orderHeader = CardHeader("Place order")
orderForm = Form("place-order", orderButtons, [tickerField, sideField, qtyField])
tickerField = FormControl("Ticker", tickerSelect, "Select instrument")
tickerSelect = Select("ticker", [tickerAAPL, tickerNVDA, tickerTSLA], "Choose ticker")
tickerAAPL = SelectItem("AAPL", "AAPL")
tickerNVDA = SelectItem("NVDA", "NVDA")
tickerTSLA = SelectItem("TSLA", "TSLA")
sideField = FormControl("Side", sideRadio)
sideRadio = RadioGroup("side", [sideBuy, sideSell], "buy")
sideBuy = RadioItem("Buy", "Go long", "buy")
sideSell = RadioItem("Sell", "Go short", "sell")
qtyField = FormControl("Quantity", qtyInput, "Number of shares")
qtyInput = Input("quantity", "e.g. 100", "number")
orderButtons = Buttons([submitOrder, cancelOrder])
submitOrder = Button("Place order", null, "primary")
cancelOrder = Button("Cancel", null, "tertiary")