Skip to content

Improve validations for LimitIfTouchedOrder #2533

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 1, 2025

Conversation

nicolad
Copy link
Collaborator

@nicolad nicolad commented Apr 19, 2025

Standardized validations for LimitIfTouchedOrder (fixes #2529)

Summary of the changes

  • Implemented new_checked for LimitIfTouchedOrder, bringing it in line with MarketOrder and LimitOrder.
  • Added complete domain‑level validations:
    • positive quantity, price, trigger_price
    • optional display_qty ≤ quantity
    • TimeInForce::Gtd → non‑zero expire_time required
    • side/trigger rule (BUY ⇒ trigger ≥ limit, SELL ⇒ trigger ≤ limit)
  • Legacy new now wraps new_checked, preserving the old panic‑on‑error behaviour for external callers.
  • Added a concise Display implementation.
  • Unit‑tests (4) live in the same module and cover happy‑path plus every validation failure.
  • Inline rust‑doc comments for clarity.

Type of change

  • Bug fix (non‑breaking change which fixes an issue)
  • New feature (non‑breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this change been tested?

  • cargo test -p nautilus-model --lib limit_if_touched --features python – rule set runs 5 dedicated unit-tests:
    • ok
    • quantity_zero
    • gtd_without_expire
    • buy_trigger_lt_price
    • sell_trigger_gt_price

@CLAassistant
Copy link

CLAassistant commented Apr 19, 2025

CLA assistant check
All committers have signed the CLA.

@nicolad nicolad force-pushed the 2529-LimitIfTouched branch from f12df44 to af58734 Compare April 19, 2025 03:20
@nicolad nicolad marked this pull request as draft April 19, 2025 03:27
@cjdsellers cjdsellers changed the title Order validations - LimitIfTouched. Order validations - LimitIfTouched Apr 19, 2025
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

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

Thanks so much for the contribution!

Just a couple of small comments to address, then we can merge this 👌.

@nicolad nicolad force-pushed the 2529-LimitIfTouched branch from 2b5562e to c259229 Compare April 24, 2025 07:04
@nicolad nicolad marked this pull request as ready for review April 24, 2025 07:06
@nicolad nicolad force-pushed the 2529-LimitIfTouched branch from 46f375f to f0eb9d2 Compare April 24, 2025 08:04
@nicolad nicolad marked this pull request as draft April 24, 2025 08:11
@nicolad nicolad marked this pull request as draft April 24, 2025 08:11
@nicolad nicolad marked this pull request as ready for review April 30, 2025 11:09
@nicolad nicolad force-pushed the 2529-LimitIfTouched branch from 8fead81 to 57492cd Compare April 30, 2025 11:11
@cjdsellers cjdsellers changed the title Order validations - LimitIfTouched Improve validations for LimitIfTouched order May 1, 2025
@cjdsellers cjdsellers changed the title Improve validations for LimitIfTouched order Improve validations for LimitIfTouchedOrder May 1, 2025
@cjdsellers cjdsellers merged commit 2f9d8ac into nautechsystems:develop May 1, 2025
17 checks passed
nicolad referenced this pull request in nicolad/vadim.blog May 3, 2025
nicolad referenced this pull request in nicolad/vadim.blog May 3, 2025
@nicolad nicolad deleted the 2529-LimitIfTouched branch May 3, 2025 06:34
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