Skip to content

fix: close Gateway API gaps and live-trading correctness bugs - #124

Merged
TexasCoding merged 2 commits into
mainfrom
fix/sdk-audit-hardening
Aug 30, 2026
Merged

fix: close Gateway API gaps and live-trading correctness bugs#124
TexasCoding merged 2 commits into
mainfrom
fix/sdk-audit-hardening

Conversation

@TexasCoding

Copy link
Copy Markdown
Owner

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) and POST /Auth/logout
  • POST /Contract/searchById for CON.* ids and POST /Contract/available
  • POST /Order/searchById and POST /Order/v2/query
  • GET /Status/ping
  • get_bars(live=...), 20,000-bar cap, Tick unit 7
  • modify_order(trail_price=...)
  • OrderStatus.PENDING_CANCELLATION (7) and SUSPENDED (8)

Correctness

  • Partial close sends size (was closeSize)
  • Native bracket success no longer places a second entry
  • Position-order cancel/resize honors nested {entry,stop,target}_orders
  • JWT refresh no longer deadlocks on _connection_lock
  • Health monitoring connect/disconnect run via mixin MRO
  • OrderBook accepts a single GatewayDepth object and volume
  • Position sizing uses tickSize / tickValue when an instrument is provided
  • Trailing stops only ratchet in the favorable direction
  • /Order/searchOpen and /Order/search send only official fields; extra filters run locally
  • Mutating POSTs are not retried after 401/429/ReadError
  • get_all_positions raises on search failure and drops closed contracts from cache
  • Unmarked pytest tests default to the unit marker (quality-gate marker previously collected zero tests)

Plans:

  • What this PR did: docs/superpowers/plans/2026-08-30-sdk-audit-hardening.md
  • Remaining audit items (risk OCO, realtime watchdog, docs/shims): docs/superpowers/plans/2026-08-30-remaining-audit-items.md

Test plan

  • uv run ruff check src/project_x_py
  • uv run mypy src/
  • uv run pytest -m "unit and not slow" — 2670 passed

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.
@TexasCoding
TexasCoding merged commit d70db8b into main Aug 30, 2026
7 checks passed
@TexasCoding
TexasCoding deleted the fix/sdk-audit-hardening branch August 30, 2026 13:44
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