From 166cb0378268a025492bd84b2013081abab7533c Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 1 Jul 2020 14:40:10 -0400 Subject: [PATCH] Provide account when parsing execution reports. --- .../orderman/actors/ilink3/IL3Dispatcher.h | 14 +++++----- .../ilink3/IL3ExecutionReportParser.cpp | 26 +++++++++++++++---- .../actors/ilink3/IL3ExecutionReportParser.h | 4 ++- src/lib/orderman/actors/ilink3/ILinkGW.cpp | 4 +-- src/lib/orderman/actors/ilink3/ILinkGW.h | 2 +- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/lib/orderman/actors/ilink3/IL3Dispatcher.h b/src/lib/orderman/actors/ilink3/IL3Dispatcher.h index 36c97ae30..167e3f38b 100644 --- a/src/lib/orderman/actors/ilink3/IL3Dispatcher.h +++ b/src/lib/orderman/actors/ilink3/IL3Dispatcher.h @@ -9,13 +9,13 @@ namespace ilink3 { template void handle(Handler& h, const char* data, uint16_t len) { - h.handle( - T { - const_cast(data), - sizeof(FramingHeader) + iLinkBinary::MessageHeader::encodedLength(), - len, - T::sbeBlockLength(), - T::sbeSchemaVersion() }); + T t { + const_cast(data), + sizeof(FramingHeader) + iLinkBinary::MessageHeader::encodedLength(), + len, + T::sbeBlockLength(), + T::sbeSchemaVersion() }; + h.handle(t); } diff --git a/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.cpp b/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.cpp index 6a21a444b..25874e399 100644 --- a/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.cpp +++ b/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.cpp @@ -9,8 +9,10 @@ namespace bts { namespace orderman { namespace ilink3 { -IL3ExecutionReportParser::IL3ExecutionReportParser(md::SecurityOracle* o): oracle(o) { -} +IL3ExecutionReportParser::IL3ExecutionReportParser(md::SecurityOracle* o): + oracle(o), + most_recent_account() +{} void IL3ExecutionReportParser::cache(const api::Security* security) { auto id = SecurityKey { security->id() }; @@ -32,7 +34,8 @@ const api::Security* IL3ExecutionReportParser::get_security(SecurityKey id) { template void IL3ExecutionReportParser::common(const T& msg, ExecutionReport* data) { - // data->account_name ?? + data->account_name = most_recent_account; + static_assert(sizeof(OperatorID) == T::senderIDLength()); memcpy(&data->operator_id.value(), msg.senderID(), msg.senderIDLength()); auto& price = const_cast(msg).price(); @@ -126,6 +129,19 @@ bool IL3ExecutionReportParser::parse(const iLinkBinary::ExecutionReportCancel534 data->order_status = api::orderman::NativeOrderStatus::NATIVE_ORDER_STATUS_CANCELED; return true; } +void IL3ExecutionReportParser::set_account(iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) { + // When using on-demand format the PartyDetailsDefinitionRequestAck519 + // is sent back immediately preceding the execution report on the wire. + auto details = msg.noPartyDetails(); + while(details.hasNext()) { + details.next(); + if (details.partyDetailRole() == iLinkBinary::PartyDetailRole::CustomerAccount) { + const char* p_account = details.partyDetailID(); + strncpy(most_recent_account.value().data(), p_account, most_recent_account.value().size()); + break; + } + } +} struct ParseHandler { @@ -134,10 +150,10 @@ struct ParseHandler { bool success = false; template void handle(const T& t) { success = parser.parse(t, result); } + void handle(iLinkBinary::PartyDetailsDefinitionRequestAck519& t) { parser.set_account(t); } }; -bool parse_report(const std::string& data, md::SecurityOracle& oracle, ExecutionReport* result) { - IL3ExecutionReportParser parser(&oracle); +bool parse_report(const std::string& data, IL3ExecutionReportParser& parser, ExecutionReport* result) { ParseHandler handler { parser, result }; consume_messages(handler, data.c_str(), data.size(), dispatch_execution_reports); return handler.success; diff --git a/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.h b/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.h index 286d86fd0..8ab35f643 100644 --- a/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.h +++ b/src/lib/orderman/actors/ilink3/IL3ExecutionReportParser.h @@ -14,6 +14,7 @@ namespace ilink3 { class IL3ExecutionReportParser { btree::btree_map security_cache; md::SecurityOracle* oracle; + AccountName most_recent_account; const api::Security* get_security(SecurityKey); @@ -30,10 +31,11 @@ public: bool parse(const iLinkBinary::ExecutionReportModify531&, ExecutionReport*); bool parse(const iLinkBinary::ExecutionReportStatus532&, ExecutionReport*); bool parse(const iLinkBinary::ExecutionReportCancel534&, ExecutionReport*); + void set_account(iLinkBinary::PartyDetailsDefinitionRequestAck519&); template void common(const T&, ExecutionReport*); }; -bool parse_report(const std::string&, md::SecurityOracle&, ExecutionReport*); +bool parse_report(const std::string&, IL3ExecutionReportParser&, ExecutionReport*); }}}//namespace diff --git a/src/lib/orderman/actors/ilink3/ILinkGW.cpp b/src/lib/orderman/actors/ilink3/ILinkGW.cpp index d359e1ce1..f20bc79ee 100644 --- a/src/lib/orderman/actors/ilink3/ILinkGW.cpp +++ b/src/lib/orderman/actors/ilink3/ILinkGW.cpp @@ -571,8 +571,8 @@ void ILinkGW::handle(const iLinkBinary::NotApplied513& msg) { log_in(msg); send_sequence(); } -void ILinkGW::handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) { - // Future: store party details id +void ILinkGW::handle(iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) { + _exe_parser.set_account(msg); handle_common(msg); } void ILinkGW::handle(const iLinkBinary::BusinessReject521& msg) { diff --git a/src/lib/orderman/actors/ilink3/ILinkGW.h b/src/lib/orderman/actors/ilink3/ILinkGW.h index 1317cac92..4557a3106 100644 --- a/src/lib/orderman/actors/ilink3/ILinkGW.h +++ b/src/lib/orderman/actors/ilink3/ILinkGW.h @@ -207,7 +207,7 @@ public: void handle(const iLinkBinary::Retransmission509&); void handle(const iLinkBinary::RetransmitReject510&); void handle(const iLinkBinary::NotApplied513&); - void handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519&); + void handle(iLinkBinary::PartyDetailsDefinitionRequestAck519&); void handle(const iLinkBinary::BusinessReject521&); void handle(const iLinkBinary::ExecutionReportNew522&); void handle(const iLinkBinary::ExecutionReportReject523&);