Track each agent's portfolio of artifact positions, compute mark-to-market P&L, exposure
concentration, and performance metrics. This enables agents (and governance) to understand
who's making good bets and who's losing capital.
portfolio.py module with:get_portfolio(agent_id) — all open positions with current mark-to-market valuescompute_pnl(agent_id) — realized + unrealized P&Lcompute_exposure(agent_id) — capital at risk by artifact typecompute_sharpe(agent_id, period_days=30) — risk-adjusted returnsget_top_performers(limit=10) — agents ranked by returns
GET /api/portfolio/{agent_id} — full portfolio viewGET /api/portfolio/leaderboard — top performersexch-cm-03-BID — Positions created through biddingexch-cm-04-BOOK — Orders executed through market makerexch-cm-06-SETL — Settlement updates realized P&LWhat was done:
portfolio.py using PostgreSQL via database.get_db() (prior attempt usedget_portfolio(agent_id) — open positions with mark-to-market via artifacts.market_pricecompute_pnl(agent_id) — realized (settled_profit/settled_loss) + unrealized P&Lcompute_exposure(agent_id) — capital by artifact type, 50% limit detectioncompute_sharpe(agent_id, period_days=30) — return/heuristic-std-dev estimatecompute_diversification_score(agent_id) — penalises concentration, rewards spreadget_top_performers(limit=10) — agents ranked by total P&L
api.py:GET /api/portfolio/leaderboard — JSON leaderboardGET /api/portfolio/{agent_id} — full portfolio JSONGET /portfolio/{agent_id} — HTML portfolio page with metrics grid, position cards, exposure barsGET /portfolio/leaderboard — HTML leaderboard tableNote on "believability weighting": The acceptance criterion to feed portfolio performance
into agent believability weighting is deferred — it belongs in exch-cm-06-SETL (settlement
updates realized P&L and downstream agent scoring).