Files
Kalshi_Polymarket/arb
Casey Judice ba533980e4 Positions History: include sold-out / round-tripped markets
Kalshi /portfolio/settlements only lists matured-and-held markets. Anything
the user bought and sold before expiry was invisible. Added a follow-up
query on /portfolio/positions?count_filter=total_traded filtered to
position_fp=0 — captures every round-trip. realized comes straight from
Kalshi's realized_pnl_dollars (exact).

Polymarket history was skipping any conditionId where the CLOB still
reports closed=false. But if the user sold all their shares before the
market resolves, that's still a history row with realized = sell - buy.
Result tag is 'SOLD' to distinguish from resolved-and-won/-lost rows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 20:44:52 -04:00
..