Fixed life cycle of exe reports and config during replay.
This commit is contained in:
1 parent
e915945880
commit
42fa6dfaff
7 files changed
+29
-23
No files matched your search
@@ -31,7 +31,8 @@ struct GLBXiLink3ExecutionGateway::PImpl {
|
||||
: state(), cfg(cfg), reactor(), start_of_pause(), on_exe_report(),
|
||||
on_gw_status_change(), on_cancel_reject(), perf_log(log), db(o),
|
||||
gw_name(cfg.name()), session_store(), gw(), connection(nullptr),
|
||||
connection_failures(0), started(false), has_replayed(false) {
|
||||
connection_failures(0), started(false), replay_messages(),
|
||||
has_replayed(false) {
|
||||
TCPEndpoint endpoint{cfg.socket_connect_host_ip(),
|
||||
(ushort)cfg.socket_connect_port()};
|
||||
connection = &reactor.register_connection({endpoint});
|
||||
@@ -54,6 +55,11 @@ struct GLBXiLink3ExecutionGateway::PImpl {
|
||||
IL3Connection *connection;
|
||||
size_t connection_failures;
|
||||
bool started;
|
||||
|
||||
// We need to keep this collection alive for the duration of the
|
||||
// program because we will be passing pointers to ExecutionReport
|
||||
// to other threads
|
||||
std::vector<ExecutionReport> replay_messages;
|
||||
bool has_replayed;
|
||||
};
|
||||
|
||||
@@ -131,11 +137,11 @@ void GLBXiLink3ExecutionGateway::connect(jetfix::SessionName const &sn) {
|
||||
c.firm = me->cfg.sender_compid().substr(3);
|
||||
c.failover_on_disconnect = false;
|
||||
|
||||
me->session_store.emplace(me->db, sn, me->cfg);
|
||||
me->session_store.emplace(me->db, sn, &me->cfg);
|
||||
if (!me->has_replayed) {
|
||||
me->has_replayed = true;
|
||||
auto &replay = me->session_store.value().replay();
|
||||
for (auto const &er : replay)
|
||||
me->replay_messages = me->session_store.value().replay();
|
||||
for (auto const &er : me->replay_messages)
|
||||
me->on_exe_report(er, {});
|
||||
}
|
||||
|
||||
@@ -145,7 +151,8 @@ void GLBXiLink3ExecutionGateway::connect(jetfix::SessionName const &sn) {
|
||||
};
|
||||
|
||||
me->gw.emplace(*me->connection, me->framer, &me->db,
|
||||
me->session_store->starting_session_descriptor(), c, me->cfg);
|
||||
me->session_store->starting_session_descriptor(), c,
|
||||
&me->cfg);
|
||||
|
||||
me->gw->subscribe_cancel_reject([this](auto &cr) {
|
||||
bts_assert(me->state == State::READY || me->state == State::CONNECTING);
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace ilink3 {
|
||||
log::CharPtrWrapper wrap(const char *str) { return log::CharPtrWrapper{str}; }
|
||||
|
||||
IL3GW::IL3GW(IL3Connection &con, IL3MessageFramer &buffer, IL3SecDB *db,
|
||||
const Session &session, const Config &conf,
|
||||
config::JetFIX::Connection const &cfg)
|
||||
const Session &session, const Config &conf,
|
||||
config::JetFIX::Connection const *cfg)
|
||||
: _config(conf), _x_state(State::INIT), _buffer(buffer),
|
||||
_on_state_change([](auto) {}), _on_exe_report([](auto *) {}),
|
||||
_on_session_change([](auto) {}), _connection(con), _session(session),
|
||||
@@ -142,7 +142,7 @@ void IL3GW::send_sequence(bool lapsed) {
|
||||
}
|
||||
|
||||
void IL3GW::send_retransmit_request(uint64_t uuid, uint32_t from,
|
||||
size_t count) {
|
||||
size_t count) {
|
||||
bts_assert(from > 0);
|
||||
using namespace iLinkBinary;
|
||||
auto msg = _buffer.frame<RetransmitRequest508>();
|
||||
@@ -154,8 +154,7 @@ void IL3GW::send_retransmit_request(uint64_t uuid, uint32_t from,
|
||||
log_out(msg, 0);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
IL3GW::send_party_details(const api::orderman::RoutingRecord &route) {
|
||||
uint64_t IL3GW::send_party_details(const api::orderman::RoutingRecord &route) {
|
||||
using namespace iLinkBinary;
|
||||
|
||||
auto msg = _buffer.frame<PartyDetailsDefinitionRequest518>(
|
||||
|
||||
@@ -88,7 +88,7 @@ class IL3GW : IL3ConnectionHandler {
|
||||
|
||||
public:
|
||||
IL3GW(IL3Connection &, IL3MessageFramer &, IL3SecDB *, const Session &,
|
||||
const Config &, config::JetFIX::Connection const &);
|
||||
const Config &, config::JetFIX::Connection const *);
|
||||
|
||||
void connect();
|
||||
void send_order(const CreateOrderMsg &);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace bts {
|
||||
namespace orderman {
|
||||
namespace ilink3 {
|
||||
|
||||
IL3Parser::IL3Parser(config::JetFIX::Connection const &cfg, IL3SecDB *db)
|
||||
IL3Parser::IL3Parser(config::JetFIX::Connection const *cfg, IL3SecDB *db)
|
||||
: most_recent_account(), cfg(cfg), db(db) {}
|
||||
|
||||
const api::Security *IL3Parser::get_security(SecurityKey id) {
|
||||
@@ -61,7 +61,7 @@ void IL3Parser::parse_common(const T &msg, ExecutionReport *data) {
|
||||
data->transact_time = ExchangeTimeStamp64{msg.transactTime()};
|
||||
data->ice_cl_ord_id = 0;
|
||||
data->ice_company_id = 0;
|
||||
data->cfg = &cfg;
|
||||
data->cfg = cfg;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -252,7 +252,7 @@ bool IL3Parser::parse(const iLinkBinary::ExecutionReportTradeSpreadLeg527 &msg,
|
||||
data->transact_time = ExchangeTimeStamp64{msg.transactTime()};
|
||||
data->ice_cl_ord_id = 0;
|
||||
data->ice_company_id = 0;
|
||||
data->cfg = &cfg;
|
||||
data->cfg = cfg;
|
||||
parse_trade(msg, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ class IL3SecDB;
|
||||
|
||||
class IL3Parser {
|
||||
AccountName most_recent_account;
|
||||
config::JetFIX::Connection const cfg;
|
||||
config::JetFIX::Connection const *cfg;
|
||||
IL3SecDB *db;
|
||||
const api::Security* get_security(SecurityKey);
|
||||
const api::Security* get_security(ExchangeSecurityKey);
|
||||
|
||||
public:
|
||||
IL3Parser(config::JetFIX::Connection const &, IL3SecDB *sec_db);
|
||||
IL3Parser(config::JetFIX::Connection const *, IL3SecDB *sec_db);
|
||||
bool parse(const iLinkBinary::ExecutionReportNew522&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportReject523&, ExecutionReport*);
|
||||
bool parse(const iLinkBinary::ExecutionReportElimination524&, ExecutionReport*);
|
||||
|
||||
@@ -46,7 +46,7 @@ static std::string session_path(std::string const &store_path) {
|
||||
}
|
||||
|
||||
static std::vector<ExecutionReport>
|
||||
load_replay(IL3SecDB &db, config::JetFIX::Connection const &cfg,
|
||||
load_replay(IL3SecDB &db, config::JetFIX::Connection const *cfg,
|
||||
std::string const &path) {
|
||||
|
||||
IL3Parser parser(cfg, &db);
|
||||
@@ -67,7 +67,7 @@ load_replay(IL3SecDB &db, config::JetFIX::Connection const &cfg,
|
||||
if (j["direction"] == "<") {
|
||||
auto ts = datetime::parse_FIX_timestamp(j["time"]);
|
||||
if (true || !datetime::is_at_least_secs_old(ts,
|
||||
cfg.seconds_to_replay())) {
|
||||
cfg->seconds_to_replay())) {
|
||||
|
||||
auto msg_bytes = websocketpp::base64_decode(j["msg_sbe"]);
|
||||
if (msg_bytes.size()) {
|
||||
@@ -120,8 +120,8 @@ Session load_session(jetfix::SessionName const &sn, std::string const &path) {
|
||||
|
||||
struct SessionStore::PImpl {
|
||||
PImpl(IL3SecDB &db, jetfix::SessionName const &session_name,
|
||||
config::JetFIX::Connection const &cfg, std::string const &base_path)
|
||||
: cfg(cfg), store_path(base_store_path(base_path, cfg.name(),
|
||||
config::JetFIX::Connection const *cfg, std::string const &base_path)
|
||||
: cfg(cfg), store_path(base_store_path(base_path, cfg->name(),
|
||||
session_name.as_string)),
|
||||
replay_messages(load_replay(db, cfg, raw_msg_log_path(store_path))),
|
||||
starting_session_descriptor(
|
||||
@@ -130,7 +130,7 @@ struct SessionStore::PImpl {
|
||||
raw_msg_store.open(raw_msg_log_path(store_path), std::ofstream::app);
|
||||
}
|
||||
|
||||
const config::JetFIX::Connection cfg;
|
||||
const config::JetFIX::Connection *cfg;
|
||||
const std::string store_path;
|
||||
const std::vector<ExecutionReport> replay_messages;
|
||||
const Session starting_session_descriptor;
|
||||
@@ -142,7 +142,7 @@ struct SessionStore::PImpl {
|
||||
|
||||
SessionStore::SessionStore(IL3SecDB &db,
|
||||
jetfix::SessionName const &session_name,
|
||||
config::JetFIX::Connection const &cfg,
|
||||
config::JetFIX::Connection const *cfg,
|
||||
std::string base_path)
|
||||
: me(new PImpl(db, session_name, cfg, base_path)) {
|
||||
me->storage_thread = threading::make_thread_from_function(
|
||||
|
||||
@@ -23,7 +23,7 @@ class SessionStore {
|
||||
public:
|
||||
SessionStore(IL3SecDB &,
|
||||
jetfix::SessionName const&session_name,
|
||||
config::JetFIX::Connection const&,
|
||||
config::JetFIX::Connection const*,
|
||||
std::string base_path="");
|
||||
~SessionStore() ;
|
||||
|
||||
|
||||
Reference in new issue
Block a user