Fixed a bad asser in recovery, a few typos, haderned against bad securities.

This commit is contained in:
Pedro Pinto committed 2020-07-10 10:36:03 -04:00
1 parent 42fa6dfaff
commit 0e75cde409
6 files changed
+75 -47

No files matched your search

+4 -4
View File
@@ -379,8 +379,8 @@ const char *state_string(State s) {
return "INIT";
case State::CONNECTING:
return "CONNECTING";
case State::NEGOTATING:
return "NEGOTATING";
case State::NEGOTIATING:
return "NEGOTIATING";
case State::ESTABLISHING:
return "ESTABLISHING";
case State::RETRANSMITTING:
@@ -412,7 +412,7 @@ void IL3GW::on_connect_success() {
// If we have a 0 cme_seq this is a new session and we need to negotiate
// it
LOG(iLink3, Info, "Negotiating new iLink session. {}", _session.uuid);
set_state(State::NEGOTATING);
set_state(State::NEGOTIATING);
send_negotiate();
} else {
// We only need to establish the current sequence number
@@ -455,7 +455,7 @@ void IL3GW::begin_retransmit() {
LOG(iLink3, Warn,
"Sending retransmit for missing packets: from: {} to: {} count: {}",
working.from, working.to, count);
bts_assert_d(count < Retransmit::MAX_RECOVERY);
bts_assert_d(count <= Retransmit::MAX_RECOVERY);
send_retransmit_request(working.uuid, working.from, count);
}
+1 -1
View File
@@ -47,7 +47,7 @@ struct Config {
enum class State {
INIT,
CONNECTING,
NEGOTATING,
NEGOTIATING,
ESTABLISHING,
RETRANSMITTING,
READY,
+65 -37
View File
@@ -33,7 +33,7 @@ const api::Security *IL3Parser::get_security(ExchangeSecurityKey id) {
}
template <class T>
void IL3Parser::parse_common(const T &msg, ExecutionReport *data) {
bool IL3Parser::parse_common(const T &msg, ExecutionReport *data) {
data->account_name = most_recent_account;
static_assert(sizeof(OperatorID) == T::senderIDLength());
memcpy(&data->operator_id.value(), msg.senderID(), msg.senderIDLength());
@@ -46,7 +46,14 @@ void IL3Parser::parse_common(const T &msg, ExecutionReport *data) {
SecurityKey sk;
decode_clorid(msg.clOrdID(), &data->order_key, &sk);
auto sec = get_security(sk);
bts_assert(sec);
if (!sec) {
LOG(iLink3, Error,
"Cannot resolve security key {} in order {}. Clorid: {} Exchange "
"order id: {}",
sk.value(), data->order_key.value(), std::string(msg.clOrdID()),
msg.orderID());
return false;
}
data->security = sec;
data->order_type = map_order_type(msg.ordType());
auto &price = const_cast<T &>(msg).price();
@@ -62,6 +69,7 @@ void IL3Parser::parse_common(const T &msg, ExecutionReport *data) {
data->ice_cl_ord_id = 0;
data->ice_company_id = 0;
data->cfg = cfg;
return true;
}
template <class T>
@@ -103,19 +111,21 @@ bool IL3Parser::has_account() const {
bool IL3Parser::parse(const iLinkBinary::ExecutionReportNew522 &msg,
ExecutionReport *data) {
parse_common(msg, data);
data->avg_price = Price{0.0};
data->cust_order_handling_inst = "";
data->exchange_fill_id = ExchangeFillID{};
data->exec_type = api::orderman::EXEC_TYPE_NEW;
data->filled_quantity = Quantity{0};
data->last_price = Price{0.0};
data->last_shares = Quantity{0};
data->max_show = Quantity{0};
data->memo = "";
data->msg = "";
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
if (parse_common(msg, data)) {
data->avg_price = Price{0.0};
data->cust_order_handling_inst = "";
data->exchange_fill_id = ExchangeFillID{};
data->exec_type = api::orderman::EXEC_TYPE_NEW;
data->filled_quantity = Quantity{0};
data->last_price = Price{0.0};
data->last_shares = Quantity{0};
data->max_show = Quantity{0};
data->memo = "";
data->msg = "";
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
} else
return false;
}
template <class ER>
@@ -184,28 +194,36 @@ IL3Parser::try_parse_exe_report(std::string_view const &msg) {
bool IL3Parser::parse(const iLinkBinary::ExecutionReportReject523 &msg,
ExecutionReport *data) {
parse_common(msg, data);
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
data->msg = msg.getTextAsStringView();
return true;
if (parse_common(msg, data)) {
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
data->msg = msg.getTextAsStringView();
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportElimination524 &msg,
ExecutionReport *data) {
parse_common(msg, data);
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
if (parse_common(msg, data)) {
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeOutright525 &msg,
ExecutionReport *data) {
parse_common(msg, data);
parse_trade(msg, data);
return true;
if (parse_common(msg, data)) {
parse_trade(msg, data);
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeSpread526 &msg,
ExecutionReport *data) {
parse_common(msg, data);
parse_trade(msg, data);
return true;
if (parse_common(msg, data)) {
parse_trade(msg, data);
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527 &msg,
ExecutionReport *data) {
@@ -221,7 +239,14 @@ bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527 &msg,
SecurityKey sk;
decode_clorid(msg.clOrdID(), &data->order_key, &sk);
auto sec = get_security(sk);
bts_assert(sec);
if (!sec) {
LOG(iLink3, Error,
"Cannot resolve security key {} in order {}. Clorid: {} Exchange "
"order id: {}",
sk.value(), data->order_key.value(), std::string(msg.clOrdID()),
msg.orderID());
return false;
}
data->security = sec;
data->leg_security =
@@ -258,20 +283,23 @@ bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527 &msg,
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportModify531 &msg,
ExecutionReport *data) {
parse_common(msg, data);
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
if (parse_common(msg, data)) {
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportStatus532 &msg,
ExecutionReport *data) {
parse_common(msg, data);
return true;
return parse_common(msg, data);
}
bool IL3Parser::parse(const iLinkBinary::ExecutionReportCancel534 &msg,
ExecutionReport *data) {
parse_common(msg, data);
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
if (parse_common(msg, data)) {
data->order_status = api::orderman::NativeOrderStatus(*msg.ordStatus());
return true;
} else
return false;
}
bool IL3Parser::parse(const iLinkBinary::OrderCancelReject535 &msg,
+1 -1
View File
@@ -37,7 +37,7 @@ public:
bool has_account() const;
std::optional<ExecutionReport> try_parse_exe_report(std::string_view const&bytes);
private:
template <class T> void parse_common(const T&, ExecutionReport*);
template <class T> bool parse_common(const T&, ExecutionReport*);
template <class T> void parse_trade(const T&, ExecutionReport*);
};
+1 -1
View File
@@ -33,7 +33,7 @@ public:
}
private:
md::SecurityOracle &oracle;
md::SecurityOracle oracle;
std::unordered_map<SecurityKey, const api::Security*> security_by_key;
std::unordered_map<ExchangeSecurityKey, const api::Security*> security_by_exchange_key;
};
@@ -35,13 +35,13 @@ static std::string base_store_path(std::string base_path,
static std::string raw_msg_log_path(std::string const &store_path) {
boost::filesystem::path result = store_path;
result /= "raw_msgs";
result /= "log";
return result.string();
}
static std::string session_path(std::string const &store_path) {
boost::filesystem::path result = store_path;
result /= "session";
result /= "seqnum";
return result.string();
}
@@ -66,7 +66,7 @@ load_replay(IL3SecDB &db, config::JetFIX::Connection const *cfg,
f >> j;
if (j["direction"] == "<") {
auto ts = datetime::parse_FIX_timestamp(j["time"]);
if (true || !datetime::is_at_least_secs_old(ts,
if (!datetime::is_at_least_secs_old(ts,
cfg->seconds_to_replay())) {
auto msg_bytes = websocketpp::base64_decode(j["msg_sbe"]);