Skip to content

Fix sandbox IOC cancel after local accept#4113

Closed
Jonah-Chan wants to merge 1 commit into
nautechsystems:developfrom
Jonah-Chan:codex/fix-ioc-full-fill-cancel
Closed

Fix sandbox IOC cancel after local accept#4113
Jonah-Chan wants to merge 1 commit into
nautechsystems:developfrom
Jonah-Chan:codex/fix-ioc-full-fill-cancel

Conversation

@Jonah-Chan

@Jonah-Chan Jonah-Chan commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Apply OrderAccepted to the local sandbox order before continuing same-call-stack matching-engine handling.
  • Add a regression test for a freshly initialized IOC limit order that is accepted but not immediately marketable, expecting OrderAccepted followed by OrderCanceled.

Fixes #4112.

Why

accept_order previously dispatched the accepted event without updating the mutable local OrderAny. In the IOC/FOK no-immediate-match branch, process_limit_order could then call cancel_order with an order still in INITIALIZED, which logs Cannot cancel an order with INITIALIZED from the matching engine and drops the cancel event.

Tests

cargo test -p nautilus-execution --test matching_engine test_process_ioc_limit_order_without_immediate_match_emits_cancel
cargo test -p nautilus-execution --test matching_engine test_process_limit_order_matched_immediate_fill
cargo test -p nautilus-execution --test matching_engine test_ioc_order_canceled_when_liquidity_consumption_exhausts_fills
cargo fmt --check --package nautilus-execution
git diff --check

@CLAassistant

CLAassistant commented May 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Jonah-Chan Jonah-Chan force-pushed the codex/fix-ioc-full-fill-cancel branch from 090b9c5 to b66414b Compare May 22, 2026 08:37
Constraint: Sandbox matching can accept an IOC limit order and immediately evaluate the no-match cancel path in the same call stack.

Rejected: Canceling from the pre-accept local order state | initialized orders are local-only and cancel_order intentionally refuses them.

Confidence: high

Scope-risk: narrow

Directive: Matching-engine paths that emit an order state event and then continue processing must use state that has observed the emitted event.

Tested: cargo test -p nautilus-execution --test matching_engine test_process_ioc_limit_order_without_immediate_match_emits_cancel

Tested: cargo test -p nautilus-execution --test matching_engine test_process_limit_order_matched_immediate_fill

Tested: cargo test -p nautilus-execution --test matching_engine test_ioc_order_canceled_when_liquidity_consumption_exhausts_fills

Tested: cargo fmt --check --package nautilus-execution

Tested: git diff --check

Not-tested: full workspace test suite

Co-authored-by: OmX <omx@oh-my-codex.dev>
@Jonah-Chan Jonah-Chan force-pushed the codex/fix-ioc-full-fill-cancel branch from b66414b to 1f0909b Compare May 22, 2026 09:01
@cjdsellers

Copy link
Copy Markdown
Member

Thanks @Jonah-Chan, closed per b69bade.

@cjdsellers cjdsellers closed this May 23, 2026
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.

Sandbox matching engine cannot cancel freshly accepted IOC limit orders

3 participants