Skip to content

feat(client): support protected market orders#105

Merged
cesarenaldi merged 1 commit into
mainfrom
feature/dev-278-protected-market-orders
Jun 16, 2026
Merged

feat(client): support protected market orders#105
cesarenaldi merged 1 commit into
mainfrom
feature/dev-278-protected-market-orders

Conversation

@cesarenaldi

@cesarenaldi cesarenaldi commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add BUY max_price and SELL min_price protection to Python market orders
  • skip book-derived price estimation when a protected price is provided
  • expose protected prices on sync and async SecureClient overloads

Verification

  • uv run pytest tests/unit
  • uv run ruff check .
  • uv run ruff format --check .
  • uv run pyright

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 optional min_price. Validation rejects cross-side misuse (e.g. min_price on BUY). When a protected price is set, draft preparation uses that price (with tick-size bounds and decimal checks) and does not call /book for estimation.

Amount rounding in _compute_market_order_amounts gains a protect_price path that rounds up the taker leg when needed, so protected limits are not undercut by downward rounding.

create_market_order and place_market_order on async and sync SecureClient pass 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.

@cesarenaldi cesarenaldi merged commit f68cd62 into main Jun 16, 2026
7 checks passed
@cesarenaldi cesarenaldi deleted the feature/dev-278-protected-market-orders branch June 16, 2026 14:48
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