Skip to content

Improve validations for MarketToLimitOrder #2584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged

Conversation

nicolad
Copy link
Collaborator

@nicolad nicolad commented May 2, 2025

  • Adds new_checked (returns anyhow::Result<Self>) with full validation.

  • Updates the existing new constructor to delegate to new_checked, preserving the old panic-on-failure behaviour for backwards-compatibility.

  • Enforces:

    • quantity > 0
    • display_qty > 0 and display_qty ≤ quantity
    • expire_time is supplied when time_in_force == GTD
  • Fills out the market_to_limit.rs doc-comment and removes outdated TODOs.

  • Adds a dedicated test-suite (crates/model/src/orders/market_to_limit.rs) covering the happy path plus each new validation branch.

Rationale

Issue #2529 highlighted that MarketToLimitOrder lacked the strict invariants now applied to all order types.
Bringing these checks in-line:

  • Eliminates a class of runtime panics only observed after order submission.
  • Makes the validation surface symmetrical across Market-To-Limit, Limit-If-Touched, and Market-If-Touched orders, simplifying future maintenance.
  • Ensures the builder-based test harnesses catch bad inputs early in CI.

Type of change

  • Bug fix – strengthens existing validation without breaking the public API.

How has this change been tested?

Fixes #2529

@CLAassistant
Copy link

CLAassistant commented May 2, 2025

CLA assistant check
All committers have signed the CLA.

@nicolad nicolad force-pushed the 2529-market_to_limit branch from 8742856 to 38638c3 Compare May 2, 2025 10:52
@cjdsellers cjdsellers merged commit df5f6b1 into develop May 2, 2025
16 checks passed
@cjdsellers cjdsellers deleted the 2529-market_to_limit branch May 2, 2025 22:44
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.

3 participants