Skip to content

fix: added order cancellation based on its deviation from current price#26

Merged
L-u-v merged 6 commits into
prodfrom
fix/order-book-bloat
Apr 3, 2026
Merged

fix: added order cancellation based on its deviation from current price#26
L-u-v merged 6 commits into
prodfrom
fix/order-book-bloat

Conversation

@AdityaRaj212
Copy link
Copy Markdown
Contributor

@AdityaRaj212 AdityaRaj212 commented Apr 2, 2026

Note

Medium Risk
Changes order-lifecycle behavior in the synthetic market generator by tracking and cancelling live limit orders, which can materially affect book liquidity and performance under load. Risk is moderate because it touches the hot path that interacts with the matching engine each tick.

Overview
Adds active limit-order tracking to the market Generator and introduces automatic cancellations for orders whose placement price drifts beyond a configurable % deviation from the current GBM mid.

Extends Config with MaxActiveOrders and MaxDeviationPct (with new defaults), enforces a hard cap on tracked orders as a secondary safeguard, and updates stock presets to set MaxDeviationPct based on per-symbol volatility (Sigma).

Written by Cursor Bugbot for commit b6d83d9. Configure here.

Copilot AI review requested due to automatic review settings April 2, 2026 16:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds lifecycle management for the synthetic market maker’s limit orders by tracking submitted limit orders and canceling them when they drift too far from the current GBM mid price, with per-symbol deviation thresholds derived from volatility presets.

Changes:

  • Extend market.Config with MaxActiveOrders and MaxDeviationPct, and track active limit orders in the generator.
  • Cancel tracked limit orders whose anchored price deviates beyond a configured percentage from the current mid, plus enforce a hard cap on tracked orders.
  • Set MaxDeviationPct slabs in IndianStockPresets() based on Sigma.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
internal/market/presets.go Adds MaxActiveOrders and derives MaxDeviationPct from volatility (sigma) in stock presets.
internal/market/generator.go Adds active order tracking and implements deviation-based and max-count cancellation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/market/generator.go
Comment thread internal/market/generator.go Outdated
Comment thread internal/market/generator.go Outdated
Comment thread internal/market/generator.go Outdated
Comment thread internal/market/generator.go
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Comment thread internal/market/generator.go Outdated
AdityaRaj212 and others added 3 commits April 2, 2026 22:09
@L-u-v L-u-v merged commit 812ed46 into prod Apr 3, 2026
1 check passed
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