Skip to content

fix(client): tighten Perps request typing#139

Merged
cesarenaldi merged 1 commit into
feat/perps-supportfrom
feat/perps-public-surface-docs
Jul 6, 2026
Merged

fix(client): tighten Perps request typing#139
cesarenaldi merged 1 commit into
feat/perps-supportfrom
feat/perps-public-surface-docs

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add overloads for PerpsOrderRequest so GTC price and IOC/FOK post-only constraints are visible to pyright
  • add overloads for Perps session cancel methods so order id and client order id inputs are mutually exclusive at type-check time
  • align Perps async client and session docstrings with the TypeScript SDK public-surface wording
  • add pyright typing examples for Perps request/session usage

Verification

  • uv run ruff check .
  • uv run ruff format --check .
  • uv run pyright
  • uv run pytest -m "not integration"

Stacked on #133.


Note

Low Risk
Mostly type hints and documentation; the only behavioral tweak is rejecting post_only on non-gtc place_order paths, which matches documented constraints.

Overview
Tightens static typing and docs for the Perps async surface without changing wire behavior for valid callers.

PerpsOrderRequest now uses constructor overloads so pyright requires price for gtc and disallows post_only on ioc/fok. PerpsSession.cancel_order and cancel_orders get the same pattern so order_id vs client_order_id (and list variants) are mutually exclusive at type-check time.

place_order builds the request in a gtc vs non-gtc branch and raises UserInputError if post_only is used outside gtc (runtime guard aligned with types).

Docstrings on PerpsSession, AsyncPublicClient, and AsyncSecureClient Perps helpers are expanded (pagination, depth, session Args, deposit metadata, etc.) to match the TypeScript SDK wording.

Adds tests/unit/test_perps_typing.py (pyright assert_type examples) and adjusts test_perps_trading_commands for the new PerpsOrderRequest constructor.

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

@cesarenaldi cesarenaldi merged commit 62840dc into feat/perps-support Jul 6, 2026
5 checks passed
@cesarenaldi cesarenaldi deleted the feat/perps-public-surface-docs branch July 6, 2026 12:34
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