diff --git a/src/server/sparkd/cmds/CMECertCmd.cpp b/src/server/sparkd/cmds/CMECertCmd.cpp index a91977089..91b6d3797 100644 --- a/src/server/sparkd/cmds/CMECertCmd.cpp +++ b/src/server/sparkd/cmds/CMECertCmd.cpp @@ -30,21 +30,21 @@ void beginning_of_week_logon(ILinkGW& gw) { // Submit an Establish message to bind connection // Receive and process a Establishment Acknowledgment message. // Submit a sequence message - // Receive and process a sequence message + // Receive and process a sequence message gw.connect(); } struct SessionSaver { Session current; std::string path; - SessionSaver() : + SessionSaver() : current { Session::none() }, path { os::sparkdata_path("ilink3") + "session.txt" } {} void save() { std::ofstream writer(path, std::ios::binary); - writer + writer << current.uuid << " " << current.to_cme << " " << current.from_cme; @@ -83,16 +83,16 @@ Securities& securities() { api::Security future2; future2.set_id(101); future2.mutable_glbx()->set_security_desc("0WSV0"); - future2.mutable_glbx()->set_exchange_id(997810); + future2.mutable_glbx()->set_exchange_id(998140); api::Security spread; spread.set_id(200); spread.mutable_glbx()->set_security_desc("0WSV0-0WSH1"); spread.mutable_glbx()->set_exchange_id(997800); - static Securities stable = { - future1, + static Securities stable = { + future1, Price { 3674 }, - future2, - Price { 3515 }, + future2, + Price { 0.5 }, spread, Price { -159 } }; @@ -100,10 +100,10 @@ Securities& securities() { } struct TestRunner { - Reactor& reactor; + Reactor& reactor; ILinkGW& gw; - TestRunner(Reactor& reactor, ILinkGW& gw): - reactor(reactor), gw(gw) + TestRunner(Reactor& reactor, ILinkGW& gw): + reactor(reactor), gw(gw) {} private: @@ -126,7 +126,7 @@ private: } return false; } - + void interactive_delay() { // run until a key is pressed std::future res = std::async([]() { @@ -222,10 +222,6 @@ private: run_until([&]() { return gw.state() == State::READY; }); LOG(OrderMan, Info, "HIT KEY"); interactive_delay(); - // for (auto x = 30; x > 0; x-=5) { - // LOG(OrderMan, Info, "Waiting for test to start... {}", x); - // run(5); - // } LOG(OrderMan, Info, "Starting test"); } @@ -235,10 +231,21 @@ private: LOG(OrderMan, Info, "WAIT FOR SEQUENCE MSG"); bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); + // Instructions for running this test + // Set the connection function to connect to the primary gw + // ssh -nNT -L 64530:69.50.112.199:64530 bts@10.3.10.16 + // run msg_failover(1) + // After disconnect + // 1) Go to ILinkGW.cpp:500 and change line 500 to replay from message 4 instead of 1 + // enqueue_retransmit(4, cme_prev_seq, cme_prev_uuid); + // 2) change this file to run msg_failover(2) + // 3) change the tunnel to use the backup segment 99 ip (I just switch the tunnel) + // ssh -nNT -L 64530:69.50.112.205:64530 bts@10.3.10.16 + if (step == 1) { auto order = createOrderDefault(); order.time_in_force = TimeInForce::TIME_IN_FORCE_DAY; @@ -267,14 +274,23 @@ private: } void large_message_gaps() { + // Handles: + // Mid week Connection (Binding without Initialization) for On-Demand Format + // Processing Message Gaps of More than 2500 Messages for On-Demand Format + // Receiving and Processing Multiple Gaps for On-Demand Format + // Bi-Directional Gap Scenario (Sequence Gap Fill) - (Day or FAK/FOK orders) for On-Demand Format + // - Bi-Directional has an issue where it fails if you send the orders "too fast" bootup(); // Send 3 orders qty 425 auto order = createOrderDefault(); - // order.display_quantity = order.quantity = Quantity { 1 }; - order.time_in_force = TimeInForce::TIME_IN_FORCE_IOC; + order.display_quantity = order.quantity = Quantity { 1 }; + // order.time_in_force = TimeInForce::TIME_IN_FORCE_IOC; send_order(order); + // interactive_delay(); send_order(order); + // interactive_delay(); send_order(order); + // interactive_delay(); send_order(order); run(); } @@ -282,7 +298,7 @@ private: void connection_with_gt_orders() { bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); @@ -293,12 +309,12 @@ private: interactive_delay(); } - + void manage_maximum_quantity_display2() { LOG(OrderMan, Info, " Manage Maximum Quantity Display with Cancel-Replace for On-Demand Format "); bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); auto order = createOrderDefault(); @@ -320,7 +336,7 @@ private: LOG(OrderMan, Info, " Cancel Replace with IFM for On-Demand Format "); bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); auto order = createOrderDefault(); @@ -334,7 +350,7 @@ private: LOG(OrderMan, Info, " Cancel Replace with IFM for On-Demand Format "); bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); auto order = createOrderDefault(); @@ -353,7 +369,7 @@ private: void fak_order_test() { bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); auto order = createOrderDefault(); @@ -367,7 +383,7 @@ private: void spread_comlete_order_test() { bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); @@ -396,7 +412,7 @@ private: void process_rejects() { interactive_delay(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); @@ -433,7 +449,7 @@ private: void multiple_cancel_replace_for_on_demand_format() { bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); // send limit day order @@ -467,7 +483,7 @@ private: bootup(); std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); run_until([&]() { return gw.state() == State::READY; }); @@ -488,7 +504,7 @@ private: order.time_in_force = TimeInForce::TIME_IN_FORCE_DATE; send_order(order); - + run(); } @@ -500,7 +516,7 @@ private: using namespace orderman; std::vector reports; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { + gw.subscribe_execution_reports([&](const ExecutionReport* r) { reports.push_back(r); }); @@ -518,7 +534,7 @@ private: // Wait 10 seconds so the cme can breathe run(10); - + LOG(OrderMan, Error, "sending cancel"); auto rr = get_rr(); if (!reports.empty()) { @@ -565,16 +581,10 @@ int CMECert::execute(const std::vector&) { Config config { "NGG", "004", false, {} }; Reactor reactor; auto& connection = reactor.register_connection({ - // local dev + // local dev tunnel TCPEndpoint { "127.0.0.1", 64530 }, TCPEndpoint { "127.0.0.1", 64531 }, - // General NRCERT not AutoCert+ - // {"69.50.112.184", 64530}, - // {"69.50.112.185", 64530}, - // NGF (AutoCert) - // TCPEndpoint { "69.50.112.199", 64529 }, - // TCPEndpoint { "69.50.12.205", 64529 }, - // NGG (AutoCert) + // Direct connection TCPEndpoint { "69.50.112.199", 64530 }, TCPEndpoint { "69.50.12.205", 64530 } }); @@ -586,20 +596,16 @@ int CMECert::execute(const std::vector&) { gw.subscribe_session([&](auto& s) { ss.session_changed(s); }); gw.connect(); - TestRunner run(reactor,gw); + TestRunner run(reactor,gw); /////////////////////////// // - // The test + // The current test // /////////////////////////// - run.msgw_failover(1); + run.msgw_failover(2); - /////////////////////////// - // - // The test - // /////////////////////////// for (auto x =0 ; x< 5; ++x) {