refactor: unified execution report stream replacing split putOrder/putTrade callbacks#23
Merged
Merged
Conversation
…ream Agent-Logs-Url: https://github.com/geseq/cpp-orderbook/sessions/c6dfee74-fd68-44a8-b15e-09a20354cdaa Co-authored-by: geseq <5458743+geseq@users.noreply.github.com>
There was a problem hiding this comment.
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
ExecTypeand a unifiedExecutionReportstruct (replacing the oldTradestruct) and updates the notification interface toonExecutionReport(...). - Updates
OrderBookdispatch sites to emitExecutionReportinstances (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
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The notification system had separate
putOrder(two overloads) andputTradecallbacks, making it fragmented and hard to consume as a coherent event stream. This replaces them with a singleonExecutionReport(const ExecutionReport&)callback modelled after FIX protocol Execution Report (msg type 8).New types (
include/types.hpp)ExecTypeenum:New|Rejected|Canceled|TradeExecutionReportflat struct — single message type for all events; fields are conditionally populated based onexec_type:New,Rejected,Canceled):msg_type,order_id,status,qty,original_qty,errormaker_order_id,taker_order_id,maker_status,taker_status,last_qty,last_priceTradestructInterface (
include/types.hpp)NotificationInterfaceandEmptyNotificationnow expose a single entry point: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/Tradepolymorphic hierarchy into a plainvector<ExecutionReport>. Theto_stringrendering preserves the existing assertion format so no test strings change.