feat(client): add Perps cancel-all orders#144
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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) |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit c52720b. Configure here.
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
PerpsSession.cancel_all_orders(...)for proxy-signed cancel-all REST callscancelAllas scoped or unscoped signed ops and validate the accepted responseVerification
uv run pytest tests/unit/test_perps_trading_commands.py tests/unit/test_perps_session.pyuv run ruff checkuv run pyrightuv run pytest tests/integration/test_perps.py::test_places_and_cancels_all_perps_orders_for_one_instrumentskipped by defaultuv run pytest tests/unituv run ruff format --checkgit diff --checkNote
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_ordersso callers can clear open Perps orders with an optionalinstrument_idscope, or across all instruments when omitted. The call is a proxy-signedDELETE /v1/trade/orders/all(not the WebSocket cancel path) and accepts an optionalexpires_atlike other signed commands.Command plumbing adds
cancel_all_orders_opandcancelAllserialization (emptyargsvs{"iid": …}), plusPerpsCancelAllOrdersResponsefor the acceptedstatus: okpayload. Signed-command building is refactored into_create_signed_commandso REST cancel-all and WebSocket commands share salt/signature/expiry logic._ORDER_PLACEMENT_UPDATE_TIMEOUT_Sis 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.