Skip to content

Fix Position model for Kalshi API schema change#2

Open
ianjamesburke wants to merge 1 commit intoaustron24:mainfrom
ianjamesburke:fix/position-api-schema-change
Open

Fix Position model for Kalshi API schema change#2
ianjamesburke wants to merge 1 commit intoaustron24:mainfrom
ianjamesburke:fix/position-api-schema-change

Conversation

@ianjamesburke
Copy link
Copy Markdown

Summary

  • Kalshi changed the positions API to return string fixed-point values (position_fp, market_exposure_dollars, realized_pnl_dollars, total_traded_dollars, fees_paid_dollars) instead of integer cents (position, market_exposure, realized_pnl, total_traded)
  • This broke all commands that read positions (summary, positions, status) with: Field required for position
  • Updated the Position model to accept both the new and legacy formats, backfilling the legacy integer fields via model_post_init so all existing code continues to work

Test plan

  • kalshi summary — was broken, now works
  • kalshi positions — works, shows correct exposure/P&L
  • kalshi status — works, shows correct position count and exposure

Kalshi changed their positions API to return string fixed-point values
(position_fp, market_exposure_dollars, realized_pnl_dollars, etc.)
instead of integer cents (position, market_exposure, realized_pnl).

This updates the Position model to accept both formats, backfilling
the legacy integer fields from the new string fields via model_post_init
so all existing code continues to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant