fix: close Gateway API gaps and live-trading correctness bugs - #124
Merged
Conversation
Align the SDK with the current TopstepX Gateway swagger: missing REST methods, correct request field names, and no-retry mutating POSTs. Fix native-bracket double entry, JWT refresh deadlock, empty Level 2 books, and position sizing that ignored tickValue. Also mark unmarked pytest tests as unit so the quality-gate marker collects the suite. Remaining audit items are planned in docs/superpowers/plans/2026-08-30-remaining-audit-items.md.
401 recovery now uses Auth/validate. User-hub UnsubscribeAccounts takes no args; market unsubscribes are per contract, matching subscribe.
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.
Summary
First wave of the 2026-08-30 multi-agent SDK audit. Aligns the client with the current TopstepX Gateway swagger and fixes several live-trading correctness bugs.
Gateway coverage added
POST /Auth/validate(JWT refresh) andPOST /Auth/logoutPOST /Contract/searchByIdforCON.*ids andPOST /Contract/availablePOST /Order/searchByIdandPOST /Order/v2/queryGET /Status/pingget_bars(live=...), 20,000-bar cap, Tick unit7modify_order(trail_price=...)OrderStatus.PENDING_CANCELLATION(7) andSUSPENDED(8)Correctness
size(wascloseSize){entry,stop,target}_orders_connection_lockconnect/disconnectrun via mixin MROvolumetickSize/tickValuewhen an instrument is provided/Order/searchOpenand/Order/searchsend only official fields; extra filters run locallyReadErrorget_all_positionsraises on search failure and drops closed contracts from cacheunitmarker (quality-gate marker previously collected zero tests)Plans:
docs/superpowers/plans/2026-08-30-sdk-audit-hardening.mddocs/superpowers/plans/2026-08-30-remaining-audit-items.mdTest plan
uv run ruff check src/project_x_pyuv run mypy src/uv run pytest -m "unit and not slow"— 2670 passed