root = Card([header, nav, portfolioSection, riskSection, moversSection, watchSection, ordersSection, marginSection, headlinesSection, econSection, strategySection, drawdownSection, limitSection, rebalanceSection, orderSection, timeframeSection])
header = CardHeader("Trading Desk", "Morning workspace")
nav = Tabs([tabOverview, tabPositions, tabRisk, tabOrders, tabWatch])
tabOverview = TabItem("overview", "Overview", [portfolioSection, riskSection, moversSection])
tabPositions = TabItem("positions", "Positions", [portfolioSection, positionsTable, exposureChart])
tabRisk = TabItem("risk", "Risk", [varSection, marginSection, drawdownSection, limitSection])
tabOrders = TabItem("orders", "Orders", [ordersSection, rebalanceSection, orderSection])
tabWatch = TabItem("watch", "Watch", [watchSection, headlinesSection, econSection])
portfolioSection = Card([portfolioHeading, portfolioValue, pnlText, timeframeSection], "sunk")
portfolioHeading = Heading("Portfolio", "h2")
portfolioValue = TextContent("**$2,847,300**", "large")
pnlText = TextContent("**+$42,180** (+1.51%) today", "small-heavy")
timeframeSection = Card([timeframeLabel, timeframeButtons], "sunk")
timeframeLabel = TextContent("Timeframe")
timeframeButtons = Buttons([tf1d, tf1w, tf1m, tf3m, tf1y])
tf1d = Button("1D", null, "primary", "normal", "small")
tf1w = Button("1W", null, "secondary", "normal", "small")
tf1m = Button("1M", null, "secondary", "normal", "small")
tf3m = Button("3M", null, "secondary", "normal", "small")
tf1y = Button("1Y", null, "secondary", "normal", "small")
positionsTable = Card([positionsHeading, positionsTbl])
positionsHeading = Heading("Positions", "h3")
positionsTbl = Table([posTicker, posSize, posEntry, posCurrent, posPnl])
posTicker = Col("Ticker", ["AAPL", "MSFT", "NVDA", "TSLA", "AMZN"])
posSize = Col("Size", [1200, 800, 500, 900, 1100])
posEntry = Col("Entry", ["$178.20", "$412.50", "$920.30", "$248.10", "$186.40"])
posCurrent = Col("Current", ["$192.40", "$438.70", "$1,045.20", "$235.80", "$201.30"])
posPnl = Col("P/L", ["+$17,040", "+$20,960", "+$62,450", "-$11,070", "+$16,390"])
exposureChart = Card([exposureHeading, exposureBars])
exposureHeading = Heading("Exposure by Sector", "h3")
exposureBars = HorizontalBarChart(["Technology", "Consumer", "Energy", "Finance", "Healthcare"], [exposureSeries])
exposureSeries = Series("Exposure", [42, 18, 15, 14, 11])
riskSection = Card([riskHeading, varCard, marginCard, limitCard])
riskHeading = Heading("Risk Overview", "h2")
varCard = Card([varHeading, varText])
varHeading = Heading("Value at Risk", "h3")
varText = TextContent("**$86,400** (95% 1-day VaR)", "default")
marginCard = Card([marginHeading, marginText])
marginHeading = Heading("Margin in Use", "h3")
marginText = TextContent("**$412,000** / $1,200,000 (34.3%)", "default")
limitCard = Card([limitHeading, limitCallout])
limitHeading = Heading("Limits Near Breach", "h3")
limitCallout = Callout("warning", "NVDA concentration", "NVDA exposure at 28% of portfolio; limit is 30%")
varSection = Card([varHeading2, varText2])
varHeading2 = Heading("Value at Risk", "h2")
varText2 = TextContent("**$86,400** (95% 1-day VaR)", "default")
moversSection = Card([moversHeading, gainersTable, losersTable])
moversHeading = Heading("Today's Biggest Movers", "h2")
gainersTable = Card([gainersHeading, gainersTbl])
gainersHeading = Heading("Gainers", "h3")
gainersTbl = Table([gTicker, gChange])
gTicker = Col("Ticker", ["NVDA", "MSFT", "AMZN"])
gChange = Col("Change", ["+13.6%", "+6.4%", "+8.0%"])
losersTable = Card([losersHeading, losersTbl])
losersHeading = Heading("Losers", "h3")
losersTbl = Table([lTicker, lChange])
lTicker = Col("Ticker", ["TSLA", "JPM", "XOM"])
lChange = Col("Change", ["-4.9%", "-2.1%", "-1.7%"])
watchSection = Card([watchHeading, watchTbl])
watchHeading = Heading("Watchlist", "h2")
watchTbl = Table([wtTicker, wtPrice, wtChange])
wtTicker = Col("Ticker", ["GOOGL", "META", "NFLX", "AMD", "BA"])
wtPrice = Col("Price", ["$174.20", "$512.80", "$612.30", "$158.40", "$228.90"])
wtChange = Col("Change", ["+1.2%", "-0.8%", "+2.4%", "+3.1%", "-1.5%"])
ordersSection = Card([ordersHeading, ordersTbl])
ordersHeading = Heading("Working Orders", "h2")
ordersTbl = Table([ordTicker, ordSide, ordQty, ordPrice, ordStatus])
ordTicker = Col("Ticker", ["AAPL", "TSLA", "NVDA"])
ordSide = Col("Side", ["Buy", "Sell", "Buy"])
ordQty = Col("Qty", [500, 300, 200])
ordPrice = Col("Price", ["$190.00", "$240.00", "$1,020.00"])
ordStatus = Col("Status", ["Working", "Working", "Working"])
marginSection = Card([marginHeading2, marginText2, marginProgress])
marginHeading2 = Heading("Margin in Use", "h2")
marginText2 = TextContent("**$412,000** of $1,200,000 limit", "default")
marginProgress = Progress(34.3, "Utilization")
headlinesSection = Card([headlinesHeading, headlineList])
headlinesHeading = Heading("Market Headlines", "h2")
headlineList = ListBlock([headline1, headline2, headline3])
headline1 = ListItem("Fed signals rate cut in September", "Positive sentiment", null, "Positive")
headline2 = ListItem("Tech earnings beat expectations", "Positive sentiment", null, "Positive")
headline3 = ListItem("Oil prices slide on supply concerns", "Negative sentiment", null, "Negative")
econSection = Card([econHeading, econTbl])
econHeading = Heading("Economic Releases This Week", "h2")
econTbl = Table([econDay, econEvent, econImpact])
econDay = Col("Day", ["Mon", "Tue", "Wed", "Thu", "Fri"])
econEvent = Col("Event", ["CPI", "PPI", "FOMC Minutes", "Jobless Claims", "Retail Sales"])
econImpact = Col("Impact", ["High", "Medium", "High", "Medium", "High"])
strategySection = Card([strategyHeading, strategyChart])
strategyHeading = Heading("Strategy Returns (YTD)", "h2")
strategyChart = BarChart(["Momentum", "Value", "Arbitrage", "Macro"], [strategySeries])
strategySeries = Series("Return %", [18.4, 12.1, 9.8, 15.2])
drawdownSection = Card([drawdownHeading, drawdownChart])
drawdownHeading = Heading("Drawdown (Past Year)", "h2")
drawdownChart = AreaChart(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], [drawdownSeries])
drawdownSeries = Series("Drawdown %", [0, -2, -5, -3, -8, -6, -4, -7, -5, -3, -2, -1])
limitSection = Card([limitHeading2, limitCallout2, limitCallout3])
limitHeading2 = Heading("Risk Limits Near Breach", "h2")
limitCallout2 = Callout("warning", "Concentration limit", "NVDA at 28% vs 30% limit")
limitCallout3 = Callout("info", "Var limit", "VaR at 86% of daily limit")
rebalanceSection = Card([rebalanceHeading, rebalanceText, rebalanceButtons])
rebalanceHeading = Heading("Rebalance", "h2")
rebalanceText = TextContent("Current allocation deviates from target by 4.2%.", "default")
rebalanceButtons = Buttons([rebalanceBtn, rebalancePreviewBtn])
rebalanceBtn = Button("Rebalance Now", null, "primary")
rebalancePreviewBtn = Button("Preview", null, "secondary")
orderSection = Card([orderHeading, orderForm])
orderHeading = Heading("Place Order", "h2")
orderForm = Form("place-order", orderButtons, [orderTickerField, orderSideField, orderQtyField])
orderTickerField = FormControl("Ticker", orderTickerInput)
orderTickerInput = Input("ticker", "e.g. AAPL")
orderSideField = FormControl("Side", orderSideSelect)
orderSideSelect = Select("side", [sideBuy, sideSell], "Choose side")
sideBuy = SelectItem("buy", "Buy")
sideSell = SelectItem("sell", "Sell")
orderQtyField = FormControl("Quantity", orderQtyInput)
orderQtyInput = Input("quantity", "e.g. 500", "number")
orderButtons = Buttons([placeOrderBtn, cancelOrderBtn])
placeOrderBtn = Button("Place Order", null, "primary")
cancelOrderBtn = Button("Cancel", null, "tertiary")