Skip to content

fix: handle position display fields#88

Open
rupurt wants to merge 1 commit into
TexasCoding:mainfrom
rupurt:fix/filter-position-response-fields
Open

fix: handle position display fields#88
rupurt wants to merge 1 commit into
TexasCoding:mainfrom
rupurt:fix/filter-position-response-fields

Conversation

@rupurt

@rupurt rupurt commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Adds support for ProjectX Gateway position payloads that include contractDisplayName and other additive fields.

Root Cause

search_open_positions() passed raw Gateway position payloads directly to Position(**pos). Gateway responses can include contractDisplayName, which was not modeled by the SDK and caused construction to fail when present.

Changes

  • Adds contractDisplayName to the Position model.
  • Adds contractDisplayName to the PositionResponse TypedDict.
  • Parses position responses through the modeled Position fields so unknown future Gateway fields do not crash the SDK.
  • Adds regression coverage for preserving contractDisplayName while ignoring an unknown Gateway field.

Scope

This PR is intentionally independent from the trade endpoint and trade response normalization PRs. It contains one commit on top of main and only touches position response handling.

Validation

  • uv run pytest tests/client/test_trading.py tests/client/test_trading_legacy.py tests/types/test_models.py tests/types/test_api_responses.py -q
  • uv run ruff check src/project_x_py/client/trading.py src/project_x_py/models.py src/project_x_py/types/api_responses.py tests/client/test_trading_legacy.py tests/types/test_models.py tests/types/test_api_responses.py
  • uv run ruff format --check src/project_x_py/client/trading.py src/project_x_py/models.py src/project_x_py/types/api_responses.py tests/client/test_trading_legacy.py tests/types/test_models.py tests/types/test_api_responses.py
  • uv run mypy src/project_x_py/client/trading.py src/project_x_py/models.py src/project_x_py/types/api_responses.py

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