cme cert test update

This commit is contained in:
Eric Harding committed 2020-05-26 23:55:27 -04:00
1 parent cb07384c9f
commit e75d15146c
1 file changed
+36 -15
+36 -15
View File
@@ -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<std::string>&) {
// 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<std::string>&) {
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;