Repository navigation
fix: correct private position and balance callbacks - #12
Merged
Merged
Conversation
BREAKING CHANGE: private position and balance types now describe the gateway payloads and nullable fields. Preserve legacy dispatch aliases and document the 2.0.0 migration.
poly-william
approved these changes
Sep 28, 2026
watashi
pushed a commit
to watashi/polymarket-us-python
that referenced
this pull request
Oct 12, 2026
feat(streams): clob market websocket stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Dispatch
positionSubscriptionandaccountBalancesUpdateto the advertised position and balance callbacks, preserving existing aliases and the original message object. Ignore empty error strings while retaining nonempty errors.Correct the payload types and examples for before/after changes and balance snapshots. Include exact decimal quantities, nullable cost fields, combo legs, complete nested team/market metadata and optional balance reservation/display fields. Mark position snapshots as legacy; current position subscriptions send updates only.
BREAKING CHANGE: typed consumers must use the corrected envelope keys and handle nullable values. The README includes migration examples. Set the reviewed package version to 2.0.0 for the existing publish workflow.
Part of ISVBE-936; RFQ callbacks remain outside this PR.
Testing
Checklist
pytest)ruff check .)mypy polymarket_us)Note
Medium Risk
Breaking change for apps reading old envelope keys; incorrect migration would mis-parse live position and balance streams, though dispatch behavior is heavily tested.
Overview
Ships 2.0.0 so private WebSocket handling matches the current gateway wire format for positions and account balances.
The private dispatcher now routes
positionSubscriptionandaccountBalancesUpdateframes to the existing position/balance callbacks (legacy key aliases still work), passes through the raw message unchanged, and treats only non-emptyerrorstrings as failures—emptyerrorno longer blocks data callbacks.Typed payloads are updated: position changes use
positionSubscription.beforePosition/afterPositioninstead ofpositionSubscriptionUpdate.position; balance snapshot/update useaccountBalancesSnapshot.balancesandaccountBalancesUpdate.balanceChangewith fullUserBalanceobjects. Related models add decimal quantity fields, nullable cost/metadata, combo leg types, and optional balance reservation/display fields. README and the WebSocket example document migration; position snapshots are documented as legacy (initial positions via REST).Tests add gateway fixtures, socket regressions, alias preservation, and typed consumer coverage.
Reviewed by Cursor Bugbot for commit 713b680. Bugbot is set up for automated code reviews on this repo. Configure here.