Skip to content

fix(gamma): omit legacy non-binary market listings#99

Open
cesarenaldi wants to merge 2 commits into
mainfrom
fix/dev-231-non-binary-markets-python
Open

fix(gamma): omit legacy non-binary market listings#99
cesarenaldi wants to merge 2 commits into
mainfrom
fix/dev-231-non-binary-markets-python

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Align Python SDK market parsing with ts-sdk PR #117 for legacy multi-outcome markets.
  • list_markets omits markets that cannot be represented by the binary Market model while preserving keyset cursors.
  • Direct get_market continues to fail with typed UnexpectedResponseError for legacy multi-outcome markets.
  • Secure split/merge/redeem market lookup paths now surface filtered/unknown markets as UserInputError.

Verification

  • uv run pytest tests/unit/test_gamma_paginated_specs.py tests/unit/test_gamma_models.py
  • uv run pytest tests/integration/test_gamma_paginated.py::test_list_closed_markets_omits_legacy_multi_outcome_markets tests/integration/test_markets.py::test_get_market_rejects_legacy_multi_outcome_market_with_typed_error
  • uv run ruff check src/polymarket/_internal/actions/gamma.py src/polymarket/clients/public.py src/polymarket/clients/async_public.py src/polymarket/clients/secure.py src/polymarket/clients/async_secure.py tests/unit/test_gamma_paginated_specs.py tests/integration/test_gamma_paginated.py tests/integration/test_markets.py
  • uv run ruff format --check src/polymarket/_internal/actions/gamma.py src/polymarket/clients/public.py src/polymarket/clients/async_public.py src/polymarket/clients/secure.py src/polymarket/clients/async_secure.py tests/unit/test_gamma_paginated_specs.py tests/integration/test_gamma_paginated.py tests/integration/test_markets.py
  • uv run pyright
  • live smoke: closed-market listing skips legacy rows and preserves cursor; legacy slug fetch raises UnexpectedResponseError

Note

Medium Risk
Changes public listing semantics and secure split/merge/redeem lookup errors when only legacy multi-outcome markets match; behavior is intentional but can surprise callers relying on full API rows or ambiguous error messages.

Overview
Aligns gamma market listing with the binary Market model by silently dropping legacy multi-outcome rows instead of failing pagination.

list_markets / keyset parsing: _make_keyset_parser now accepts item parsers that return None; those entries are skipped while next_cursor is unchanged. list_markets_spec uses new _parse_list_market, which keeps markets with exactly two string outcomes and skips others; malformed outcomes still raise UnexpectedResponseError.

Direct fetch: get_market behavior is unchanged (still parses via Market.parse_response); public and secure client docstrings now state that non-binary markets raise UnexpectedResponseError, and list_markets docstrings note omissions.

Trading helpers: When split/merge/redeem resolve a market via list_markets and the only match is filtered out, UserInputError ("No market found for …") is raised before the old “expected exactly one” check.

Tests cover parser filtering, integration for closed listings and legacy slug fetch, and updated relayer split-position expectations.

Reviewed by Cursor Bugbot for commit d4841ed. Bugbot is set up for automated code reviews on this repo. Configure here.

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