Fix problem with party details
This commit is contained in:
1 parent
fc9e502539
commit
cb07384c9f
1 file changed
+66
-28
@@ -59,12 +59,22 @@ void log_msg(char direction, const T& t) {
|
||||
if (f) {
|
||||
auto time = datetime::simple_date_time_string(datetime::local_now()) + "\n";
|
||||
fwrite(time.c_str(), time.size(), 1, f);
|
||||
auto s = direction + to_string(t) + "\n";
|
||||
auto s = direction + (" " + to_string(t)) + "\n";
|
||||
fwrite(s.c_str(), s.size(), 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
void log_str(const char* str) {
|
||||
if (debug_log) {
|
||||
auto* f = fopen(debug_log_path().c_str(), "ab");
|
||||
if (f) {
|
||||
fwrite(str, strlen(str), 1, f);
|
||||
fwrite("\n", 1, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
template <class T>
|
||||
void log_in(const T& t) { log_msg('<', t); }
|
||||
template <class T>
|
||||
@@ -88,7 +98,7 @@ ILinkGW::ILinkGW(IL3Connection& con, const Session& session, const Config& conf)
|
||||
auto* f = fopen(debug_log_path().c_str(), "ab");
|
||||
if (f) {
|
||||
const char delin[] = "====================\n";
|
||||
fwrite(delin, sizeof(delin), 1, f);
|
||||
fwrite(delin, sizeof(delin)-1, 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
@@ -198,15 +208,15 @@ void ILinkGW::send_retransmit_request(uint64_t uuid, uint32_t from, size_t count
|
||||
|
||||
uint64_t ILinkGW::send_party_details(const api::orderman::RoutingRecord& route) {
|
||||
using namespace iLinkBinary;
|
||||
|
||||
auto msg = _buffer.frame<PartyDetailsDefinitionRequest518>(
|
||||
// 2 repeating group header.
|
||||
// 1 for party details and 1 for trade reg
|
||||
// This seems wildly unsafe but the api doesn't seem to want you to know
|
||||
// how to size buffers ahead of time
|
||||
// This seems unsafe but the api doesn't seem to want you to know how to size buffers ahead of time
|
||||
2 * PartyDetailsDefinitionRequest518::NoPartyDetails::sbeHeaderSize() +
|
||||
// N * size of each block
|
||||
1 * PartyDetailsDefinitionRequest518::NoPartyDetails::sbeBlockLength() +
|
||||
1 * PartyDetailsDefinitionRequest518::NoTrdRegPublications::sbeBlockLength()
|
||||
3 * PartyDetailsDefinitionRequest518::NoPartyDetails::sbeBlockLength() +
|
||||
0 * PartyDetailsDefinitionRequest518::NoTrdRegPublications::sbeBlockLength()
|
||||
);
|
||||
msg.partyDetailsListReqID(++_msg_count);
|
||||
msg.sendingTimeEpoch(_time.now());
|
||||
@@ -232,9 +242,16 @@ uint64_t ILinkGW::send_party_details(const api::orderman::RoutingRecord& route)
|
||||
msg.executor(PartyDetailsDefinitionRequest518::executorNullValue());
|
||||
msg.iDMShortCode(PartyDetailsDefinitionRequest518::iDMShortCodeNullValue());
|
||||
|
||||
auto details = msg.noPartyDetailsCount(1);
|
||||
auto details = msg.noPartyDetailsCount(3);
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::CustomerAccount);
|
||||
details.putPartyDetailID(route.account());
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::ExecutingFirm);
|
||||
details.putPartyDetailID(route.clearing_firm());
|
||||
details.next();
|
||||
details.partyDetailRole(PartyDetailRole::Operator);
|
||||
details.putPartyDetailID(route.operator_id());
|
||||
msg.noTrdRegPublicationsCount(0);
|
||||
// In the future we may check for existing party details definitions and return that id
|
||||
log_out(msg);
|
||||
@@ -388,6 +405,7 @@ void ILinkGW::set_state(State s) {
|
||||
LOG(OrderMan, Info, "ILinkGW {}: {}->{}",
|
||||
_session.uuid, wstate_string(_x_state), wstate_string(s));
|
||||
_x_state = s;
|
||||
log_str(state_string(s));
|
||||
if (_on_state_change) _on_state_change(s);
|
||||
}
|
||||
}
|
||||
@@ -510,31 +528,37 @@ void ILinkGW::handle(const iLinkBinary::Sequence506& s) {
|
||||
}
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Terminate507& msg) {
|
||||
LOG(OrderMan, Error, "Terminated by exchange. Code: {} Reason: {}",
|
||||
LOG(OrderMan, Error, "Terminated by exchange. Code: {} Reason: {}. \n {}",
|
||||
msg.errorCodes(),
|
||||
wrap(msg.reason())
|
||||
wrap(msg.reason()),
|
||||
"https://www.cmegroup.com/confluence/display/EPICSANDBOX/Terminate"
|
||||
);
|
||||
log_in(msg);
|
||||
set_state(State::ERROR);
|
||||
_connection.disconnect();
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Retransmission509& msg) {
|
||||
// Accepted retransmit
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::Retransmission509&) {
|
||||
// Accepted retransmit
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::RetransmitReject510&) {
|
||||
void ILinkGW::handle(const iLinkBinary::RetransmitReject510& msg) {
|
||||
// ?!
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::NotApplied513&) {
|
||||
void ILinkGW::handle(const iLinkBinary::NotApplied513& msg) {
|
||||
// Sequence number problem
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519&) {
|
||||
void ILinkGW::handle(const iLinkBinary::PartyDetailsDefinitionRequestAck519& msg) {
|
||||
// Future: store party details id
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::BusinessReject521& msg) {
|
||||
LOG(OrderMan, Error, "Business Reject: {} '{}'.\nRaw: \"{}\"",
|
||||
msg.businessRejectReason(),
|
||||
wrap(translate_business_reject_reason(msg.businessRejectReason())),
|
||||
to_string(msg));
|
||||
log_in(msg);
|
||||
set_state(State::ERROR);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportNew522& msg) {
|
||||
@@ -548,35 +572,49 @@ void ILinkGW::handle(const iLinkBinary::ExecutionReportNew522& msg) {
|
||||
_on_replay_exe_report(report);
|
||||
}
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportReject523&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportReject523& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportElimination524&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportElimination524& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeOutright525& msg) {
|
||||
log_in(msg);
|
||||
if (msg.uUID() != _session.uuid) {
|
||||
}
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpread526&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpread526& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpreadLeg527&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeSpreadLeg527& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportModify531&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportModify531& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportStatus532&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportStatus532& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportCancel534&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportCancel534& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReject535&) {
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReject535& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReplaceReject536&) {
|
||||
void ILinkGW::handle(const iLinkBinary::OrderCancelReplaceReject536& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionAck539&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionAck539& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumOutright548&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumOutright548& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpread549&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpread549& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpreadLeg550&) {
|
||||
void ILinkGW::handle(const iLinkBinary::ExecutionReportTradeAddendumSpreadLeg550& msg) {
|
||||
log_in(msg);
|
||||
}
|
||||
|
||||
}}} //namespace
|
||||
Reference in new issue
Block a user