Opus finding
`resolve_market` does not zero out positions after payout — winning shares stay queryable as positions
mediumdata-losshigh
- backend/wonderwall/simulations/polymarket/platform.py:295-314
After resolution, winning positions still have `shares > 0` in the position table. `view_portfolio` joins position with market and renders these as still-held positions with `current_price` derived from final reserves. Furthermore, `view_portfolio` does not filter out resolved markets — so the agent will see phantom positions that already paid out. Losing positions are also never zeroed. This is misleading and a likely source of double-counting in downstream analytics.
Recommendation
In resolve_market, after paying out, DELETE FROM position WHERE market_id = ? (or set shares = 0). Also filter view_portfolio's join by `m.resolved = 0` if you want only active positions.