From 9fd0df2a13e8143d9c71894e507405f0addfc55d Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Mon, 27 Feb 2023 15:44:58 -0500 Subject: [PATCH] SimExecution can be turned on from config now --- src/lib/config/protos/jetfix.proto | 9 +++++++++ .../gateways/ExecutionGatewayFactory.cpp | 13 ++++++------- .../sim/SimExecutionGatewayFactory.cpp | 19 +++++++++++++++++-- .../gateways/sim/SimExecutionGatewayFactory.h | 1 + 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/lib/config/protos/jetfix.proto b/src/lib/config/protos/jetfix.proto index 31b93fe9b..79e1e3f90 100644 --- a/src/lib/config/protos/jetfix.proto +++ b/src/lib/config/protos/jetfix.proto @@ -139,3 +139,12 @@ message CMECannedSecureLogon { "tbb3it0rUQSSTa0TC9QcRwkrHEMDLWhaJH4VQ0FqGB4 2018-04-05 " " 2019-04-05 NEWRELEASE \n" ]; } + + +message SimExecution{ + message SimExecutionEntry { + required bts.api.Venue venue = 100; + required bool incorporate_crosses_into_book = 200; + } + repeated SimExecutionEntry entries = 100; +} diff --git a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp index b9e61753e..a72c410c5 100644 --- a/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp +++ b/src/lib/orderman/gateways/ExecutionGatewayFactory.cpp @@ -7,6 +7,7 @@ #include "lib/orderman/gateways/GLBXExecutionGateway.h" #include "lib/orderman/gateways/GLBXiLink3ExecutionGateway.h" #include "lib/orderman/gateways/ICEExecutionGateway.h" +#include "lib/orderman/gateways/sim/SimExecutionGatewayFactory.h" #include "lib/orderman/gateways/sim/SimExecutionGatewayUniqueWrapper.h" #include "lib/tracing/PerfLog.h" #include "lib/utils/PBUtils.h" @@ -20,7 +21,9 @@ std::unique_ptr ExecutionGatewayFactory::create_gateway( const config::JetFIX::Connection &conn, trace::PerfLog &pl, md::SecurityOracle o) { - // check which exchanges are set to Sim + if (SimExecutionGatewayFactory::is_sim_execution_on(conn.venue())) { + return std::make_unique(conn.venue()); + } LOG(OrderMan, Info, "ExecutionGatewayFactory::create_gateway conn: {}", utils::pb::to_string(conn)); if (conn.venue() == bts::api::VENUE_ICE || @@ -32,12 +35,8 @@ std::unique_ptr ExecutionGatewayFactory::create_gateway( conn, pl, o); return std::make_unique(conn, pl, o); } else if (conn.venue() == bts::api::VENUE_DERIBIT) - return std::make_unique(conn.venue()); - //return std::make_unique(o); - return std::make_unique(conn.venue()); - //return std::make_unique(o); - // return std::make_unique(o); - // return std::make_unique(conn, pl, o); + return std::make_unique(o); + return std::make_unique(o); } } // namespace bts::orderman diff --git a/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.cpp b/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.cpp index 1684574e5..71bc624d7 100644 --- a/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.cpp +++ b/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.cpp @@ -23,8 +23,13 @@ std::shared_ptr SimExecutionGatewayFactory::get_getayeway( api::Venue venue) { LOG(OrderMan, Info, "SimExecutionGatewayFactory::get_getayeway venue: {}", bts::api::Venue_Name(venue)); - // This needs to look at config, to check if an exchange is set to sim or - // not. If it is not to set to sim, it should return a nullptr + if (!is_sim_execution_on(venue)) { + LOG(OrderMan, Info, + "SimExecutionGatewayFactory::get_getayeway venue: {}, sim is turned " + "off", + bts::api::Venue_Name(venue)); + return nullptr; + } std::shared_ptr rv = nullptr; gateway_map.lock( [&, venue](std::map> @@ -55,4 +60,14 @@ SimExecutionGatewayFactory *SimExecutionGatewayFactory::get() { return instance; } +bool SimExecutionGatewayFactory::is_sim_execution_on(api::Venue venue) { + const auto &sim_exec = config::get(); + for (const auto &e : sim_exec.entries()) { + if (e.has_venue() && e.venue() == venue) { + return true; + } + } + return false; +} + } // namespace bts::orderman \ No newline at end of file diff --git a/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.h b/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.h index d32bcfe1a..8fd6e00ec 100644 --- a/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.h +++ b/src/lib/orderman/gateways/sim/SimExecutionGatewayFactory.h @@ -32,6 +32,7 @@ class SimExecutionGatewayFactory { public: // this has to be called once before all usages static SimExecutionGatewayFactory *get(); + static bool is_sim_execution_on(api::Venue); }; } // namespace bts::orderman