Skip to content

refactor: unified execution report stream replacing split putOrder/putTrade callbacks#23

Merged
geseq merged 1 commit into
mainfrom
copilot/update-notification-system-to-stream
May 11, 2026
Merged

refactor: unified execution report stream replacing split putOrder/putTrade callbacks#23
geseq merged 1 commit into
mainfrom
copilot/update-notification-system-to-stream

Conversation

Copilot AI commented May 11, 2026

Copy link
Copy Markdown
Contributor

The notification system had separate putOrder (two overloads) and putTrade callbacks, making it fragmented and hard to consume as a coherent event stream. This replaces them with a single onExecutionReport(const ExecutionReport&) callback modelled after FIX protocol Execution Report (msg type 8).

New types (include/types.hpp)

  • ExecType enum: New | Rejected | Canceled | Trade
  • ExecutionReport flat struct — single message type for all events; fields are conditionally populated based on exec_type:
    • Order events (New, Rejected, Canceled): msg_type, order_id, status, qty, original_qty, error
    • Trade events: maker_order_id, taker_order_id, maker_status, taker_status, last_qty, last_price
  • Removed the now-redundant Trade struct

Interface (include/types.hpp)

NotificationInterface and EmptyNotification now expose a single entry point:

void onExecutionReport(const ExecutionReport& report);

OrderBook (include/orderbook.hpp)

All dispatch sites use C++20 designated initializers for clarity:

notification_.onExecutionReport(ExecutionReport{
    .exec_type     = ExecType::Trade,
    .maker_order_id = mOrderID,
    .taker_order_id = tOrderID,
    .maker_status  = mStatus,
    .taker_status  = tStatus,
    .last_qty      = qty,
    .last_price    = price,
});

Tests (test/util.cpp)

Collapsed the NotificationBase / OrderNotification / Trade polymorphic hierarchy into a plain vector<ExecutionReport>. The to_string rendering preserves the existing assertion format so no test strings change.

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the order book notification API from separate putOrder / putTrade callbacks into a single unified onExecutionReport(const ExecutionReport&) stream, aligning event delivery around a FIX-style execution report model.

Changes:

  • Introduces ExecType and a unified ExecutionReport struct (replacing the old Trade struct) and updates the notification interface to onExecutionReport(...).
  • Updates OrderBook dispatch sites to emit ExecutionReport instances (using C++20 designated initializers).
  • Simplifies test notifications to store a vector<ExecutionReport> and preserves existing assertion string formatting via a renderer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
include/types.hpp Adds ExecType + ExecutionReport and replaces the notification API with onExecutionReport(...).
src/types.cpp Adds stream rendering (operator<<) for ExecType.
include/orderbook.hpp Updates all notification dispatch sites to emit unified ExecutionReport events.
test/util.cpp Refactors test notification capture to store ExecutionReport objects and renders them back to the legacy assertion strings.

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

@geseq geseq marked this pull request as ready for review May 11, 2026 14:45
@geseq geseq merged commit 57714f2 into main May 11, 2026
6 checks passed
@geseq geseq deleted the copilot/update-notification-system-to-stream branch May 11, 2026 15:07
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