Skip to content

FIX: [xmaker] filter unowned order and trade updates in HedgeMarket - #2710

Merged
dboyliao merged 3 commits into
mainfrom
dboy/xmaker/shared-fiat-market
Oct 21, 2026
Merged

dboyliao merged 3 commits into
mainfrom
dboy/xmaker/shared-fiat-market

Conversation

@dboyliao

Copy link
Copy Markdown
Collaborator

Summary

Prevents cross-instance order and trade update collisions in xmaker.HedgeMarket when multiple strategy instances share the same session and trading pair (such as fiat hedge sessions or split-source streams).

Key Changes

  • Order & Trade Isolation in HedgeMarket:
    • Replaced stream auto-binding (BindStream) on orderStore, tradeCollector, and activeMakerOrders with dedicated stream listeners in NewHedgeMarket.
    • Filter incoming updates by symbol and ensure ownership via orderStore.Exists(orderID). Updates for orders not submitted by the local HedgeMarket instance are ignored, preventing sibling instances from polluting local positions and order tracking.
  • Exported ActiveOrderBook.OrderUpdateHandler:
    • Exported ActiveOrderBook.OrderUpdateHandler so callers can dispatch filtered order updates directly to an active order book.
  • Tests:
    • Updated activeorderbook_test.go to call the exported OrderUpdateHandler.
    • Added synchronization with assert.Eventually in synthetichedge_test.go to wait for async hedge order registration in orderStore before emitting test trade updates.

@dboyliao
dboyliao requested a review from c9s October 21, 2026 01:41
@dboyliao
dboyliao requested a balanced review from Copilot and removed request for Copilot October 21, 2026 03:03
@dboyliao
dboyliao merged commit 405de48 into main Oct 21, 2026
3 of 4 checks passed
@dboyliao
dboyliao deleted the dboy/xmaker/shared-fiat-market branch October 21, 2026 04:18
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.

2 participants