From e8405e56388abb962a43fb4b5cf8212c3133ad30 Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Mon, 5 Dec 2022 14:33:04 -0500 Subject: [PATCH] OrderServiceServer starts calling ServiceBridge's do_work only once it gets the ready signal from ServiceBridge --- src/data_files/documents/order_flow.txt | 9 +++++++ src/lib/domain_model/tests/domain_tests.cpp | 30 +++++++++++++++++++++ src/lib/orderman/OrderServiceServer.cpp | 7 +++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/data_files/documents/order_flow.txt b/src/data_files/documents/order_flow.txt index 93ed6a04b..eca416ff5 100644 --- a/src/data_files/documents/order_flow.txt +++ b/src/data_files/documents/order_flow.txt @@ -78,3 +78,12 @@ Misc: ----- To search for a publisher for an event search for make_stream, for example make_stream() + + +ALGO: +---- +// last 3 steps before an algo gets a child order update + +AlgoWrapperOrder::me->services->subscribe_to_child_updates +AlgoWrapperOrder::on_child_order_update +TaskingEyeAlgo::on_child_change \ No newline at end of file diff --git a/src/lib/domain_model/tests/domain_tests.cpp b/src/lib/domain_model/tests/domain_tests.cpp index 3fc8ed772..2c0a9ae2c 100644 --- a/src/lib/domain_model/tests/domain_tests.cpp +++ b/src/lib/domain_model/tests/domain_tests.cpp @@ -10,6 +10,36 @@ namespace bts { namespace test { +TEST_CASE("Quantity", "[Quantity]") { + SECTION("basic") { + double d_orig = 12.76; + auto comp_qq = [](const Quantity &q1, const Quantity &q2) { + return std::abs(q1.full_value() - q2.full_value()) < 0.0000001; + }; + auto comp_qd = [](const Quantity &q1, double d1) { + return std::abs(q1.full_value() - d1) < 0.0000001; + }; + // create_new + Quantity qty_orig = Quantity::create_new(d_orig); + REQUIRE(comp_qd(qty_orig, d_orig)); + // copy cons + Quantity qty_copied = qty_orig; + REQUIRE(comp_qq(qty_orig, qty_copied)); + // operator == + REQUIRE(qty_orig == qty_copied); + REQUIRE(comp_qd(qty_orig, qty_orig.full_value())); + // operator += + double d_inc = 1.13; + Quantity qty_inc = Quantity::create_new(d_inc); + Quantity qty_added = qty_orig; + qty_added += qty_inc; + REQUIRE(comp_qd(qty_added, d_orig + d_inc)); + // const = + Quantity qty_copycons = d_orig; + REQUIRE(!comp_qd(qty_copycons, d_orig)); + } +} + TEST_CASE("rounding_tests", "[md]") { SECTION("test_price_size") { diff --git a/src/lib/orderman/OrderServiceServer.cpp b/src/lib/orderman/OrderServiceServer.cpp index cbd514cfb..f8d1d8721 100644 --- a/src/lib/orderman/OrderServiceServer.cpp +++ b/src/lib/orderman/OrderServiceServer.cpp @@ -260,7 +260,10 @@ OrderServiceServer::OrderServiceServer( thread, "Could not find a configured thread for ServiceBridge. See " "the OrdermanCfg key"); me->service_bridge = new ServiceBridge( - [this]() { me->service_ready = true; }, + [this]() { + me->service_ready = true; + me->context.post([this]() { _do_work(); }, 500); + }, [this, &ctx](auto const &orders) { ctx.post([this, orders] { this->on_orders(orders); }); }, @@ -328,7 +331,7 @@ OrderServiceServer::OrderServiceServer( // we should watch for some signal but right now I am not sure if such a // signal exist. We cant do it too early either or some other problem // happens. We will come to this later and fix it - me->context.post([this]() { _do_work(); }, 300000); + // me->context.post([this]() { _do_work(); }, 300000); } OrderServiceServer::~OrderServiceServer() {