feat(client): support protected market orders#105
Merged
Conversation
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
Verification
Linear: DEV-278
Note
Medium Risk
Changes signed market-order price and amount construction in the trading path; incorrect rounding or validation could affect fill bounds, though behavior is covered by new unit tests.
Overview
Adds protected market orders so callers can cap execution price without relying on book-based estimates.
BUY orders accept optional
max_price; SELL orders accept optionalmin_price. Validation rejects cross-side misuse (e.g.min_priceon BUY). When a protected price is set, draft preparation uses that price (with tick-size bounds and decimal checks) and does not call/bookfor estimation.Amount rounding in
_compute_market_order_amountsgains aprotect_pricepath that rounds up the taker leg when needed, so protected limits are not undercut by downward rounding.create_market_orderandplace_market_orderon async and syncSecureClientpass the new kwargs through typed overloads. Unit tests cover validation, overload signatures, and no-book behavior.Reviewed by Cursor Bugbot for commit 34422bb. Bugbot is set up for automated code reviews on this repo. Configure here.