Skip to content

fix: take liquidity when an L3 order is modified to a marketable price - #322

Open
23f3001135 wants to merge 1 commit into
nkaz001:masterfrom
23f3001135:fix/l3-modify-marketable-takes
Open

fix: take liquidity when an L3 order is modified to a marketable price#322
23f3001135 wants to merge 1 commit into
nkaz001:masterfrom
23f3001135:fix/l3-modify-marketable-takes

Conversation

@23f3001135

Copy link
Copy Markdown

Summary

When a resting L3 order is modified to a price that crosses the book, such as a buy order with a price greater than or equal to the best ask, or a sell order with a price less than or equal to the best bid, it must take liquidity rather than remain at a crossed price in the queue.

L3NoPartialFillExchange::ack_modify now detects a marketable modification and cancels and resubmits the order, resetting leaves_qty to the new qty.

This mirrors the behavior of the L2 NoPartialFillExchange, where an order modification is handled as a cancellation followed by a new order.

When the original order no longer exists because it was filled, expired, or has an unknown ID, the modification is rejected using the existing OrderNotFound path.

Tests

Added unit tests covering:

  • A buy order modified to or through the best ask takes liquidity and fills.
  • A sell order modified to or through the best bid takes liquidity and fills.
  • A non-marketable modification continues to rest and is repositioned using the queue model.

Test command:

cargo test -p hftbacktest --no-default-features --features backtest

All 25 tests pass.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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