Skip to content

feat(client): add Perps cancel-all orders#144

Merged
cesarenaldi merged 2 commits into
feat/perps-supportfrom
feat/perps-cancel-all-orders
Jul 7, 2026
Merged

feat(client): add Perps cancel-all orders#144
cesarenaldi merged 2 commits into
feat/perps-supportfrom
feat/perps-cancel-all-orders

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add PerpsSession.cancel_all_orders(...) for proxy-signed cancel-all REST calls
  • Serialize cancelAll as scoped or unscoped signed ops and validate the accepted response
  • Add focused unit coverage and opt-in metered live coverage

Verification

  • uv run pytest tests/unit/test_perps_trading_commands.py tests/unit/test_perps_session.py
  • uv run ruff check
  • uv run pyright
  • uv run pytest tests/integration/test_perps.py::test_places_and_cancels_all_perps_orders_for_one_instrument skipped by default
  • uv run pytest tests/unit
  • uv run ruff format --check
  • git diff --check

Note

Medium Risk
Introduces a broad trading action (account-wide cancel when unscoped) over signed REST; behavior is covered by tests but mistakes could cancel more orders than intended.

Overview
Adds PerpsSession.cancel_all_orders so callers can clear open Perps orders with an optional instrument_id scope, or across all instruments when omitted. The call is a proxy-signed DELETE /v1/trade/orders/all (not the WebSocket cancel path) and accepts an optional expires_at like other signed commands.

Command plumbing adds cancel_all_orders_op and cancelAll serialization (empty args vs {"iid": …}), plus PerpsCancelAllOrdersResponse for the accepted status: ok payload. Signed-command building is refactored into _create_signed_command so REST cancel-all and WebSocket commands share salt/signature/expiry logic.

_ORDER_PLACEMENT_UPDATE_TIMEOUT_S is raised from 1s to 2s. Unit tests cover op/body validation and REST request shape; an opt-in metered integration test places two resting orders and verifies instrument-scoped cancel-all clears them.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c52720b. Configure here.

"op": to_command_body_op(op),
},
)
PerpsCancelAllOrdersResponse.parse_response(response)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancel-all ignores err body

Medium Severity

When the cancel-all REST call returns HTTP 200 with status: "err", PerpsCancelAllOrdersResponse.parse_response raises UnexpectedResponseError instead of RequestRejectedError with the API error text, unlike other Perps signed REST commands in this codebase.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c52720b. Configure here.

@cesarenaldi cesarenaldi merged commit 55adc5a into feat/perps-support Jul 7, 2026
5 checks passed
@cesarenaldi cesarenaldi deleted the feat/perps-cancel-all-orders branch July 7, 2026 18:40
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