From e75d15146c510f081988e4bb8d6319dab24ecf43 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Tue, 26 May 2020 23:55:27 -0400 Subject: [PATCH] cme cert test update --- src/server/sparkd/cmds/CMECertCmd.cpp | 51 +++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/server/sparkd/cmds/CMECertCmd.cpp b/src/server/sparkd/cmds/CMECertCmd.cpp index 4553b9adf..58dfd923f 100644 --- a/src/server/sparkd/cmds/CMECertCmd.cpp +++ b/src/server/sparkd/cmds/CMECertCmd.cpp @@ -117,39 +117,62 @@ struct TestRunner { gw.flush(); } - void send_market_limit_order() { + void send_order(api::Security& security) { using namespace orderman; - const ExecutionReport* last_report; - gw.subscribe_execution_reports([&](const ExecutionReport* r) { last_report = r; }, [](auto*) {}); - - // send a market order - auto sec = securities(); api::orderman::RoutingRecord r; + r.set_account("CustAccount"); + r.set_clearing_firm("001"); r.set_operator_id("NGG"); // SenderID : 48 r.set_customer_or_firm(api::orderman::CUSTOMER_OR_FIRM_CUSTOMER); r.set_smp_id("12345678"); - r.set_smp_instruction(api::orderman::SelfMatchPreventionInstruction::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_AGRESSING); + r.set_smp_instruction(api::orderman::SELF_MATCH_PREVENTION_INSTRUCTION_CANCEL_AGRESSING); + r.set_location("US"); + CreateOrderMsg order { OrderKey { 99 }, Price { 1.5 }, Quantity { 2 }, - &sec.future1, + &security, api::SIDE_SELL, Price { 0.0 }, Quantity { 2 }, api::orderman::NativeOrderType::NATIVE_ORDER_TYPE_MARKET, api::orderman::TIME_IN_FORCE_DAY, - api::orderman::ManualOrderIndicator::MANUAL_ORDER_INDICATOR_YES, - nullptr // &r + api::orderman::ManualOrderIndicator::MANUAL_ORDER_INDICATOR_NO, + &r }; gw.send_order(order); - run_until([&]() { return last_report != nullptr; }); + gw.flush(); + } + + void send_market_limit_order() { + using namespace orderman; + const ExecutionReport* last_report; + gw.subscribe_execution_reports([&](const ExecutionReport* r) { last_report = r; }, [](auto*) {}); + run(3); + + // send a market order + auto sec = securities(); + send_order(sec.future1); + run(300); // get a confirm + auto ok = run_until([&]() { return last_report != nullptr; }); + if (!ok) { + std::cout << "Error waiting for ack" << std::endl; + } + last_report = nullptr; // get a fill + ok = run_until([&]() { return last_report != nullptr; }); + if (!ok) { + std::cout << "Error waiting for fill" << std::endl; + } + // send a cancel } + void primary_gateway_enforcement() { + // success! run(30); run(30); gw.send_terminate(); @@ -164,7 +187,7 @@ int CMECert::execute(const std::vector&) { // Typically a timestamp SessionSaver ss; ss.load(); - Config config { Session::none(), "NGG", "004", true }; + Config config { Session::none(), "NGG", "004", false }; Reactor reactor; auto& connection = reactor.register_connection({ // local dev @@ -189,11 +212,9 @@ int CMECert::execute(const std::vector&) { gw.connect(); TestRunner run(reactor,gw); - run.primary_gateway_enforcement(); + run.send_market_limit_order(); // run.run(); - // send_market_limit_order(reactor, gw); - std::cout << std::endl << "We're done here."; // sleep(100); return 0;