From b53d9d7d4c81fc5e51347b3d8e5b544e99b205e6 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Wed, 17 Jan 2024 01:00:58 -0500 Subject: [PATCH] refactor: Remove 'Platform' (md source) config Good riddance. Improper 'PlatformMap' config was often the reason market data mysteriously wouldn't show up in the client. Especially with new exchanges. We should keep all md source/connection configuration in one place (one proto message), to avoid any confusion. --- .../DataStreamCore/BlueData/MetaDataField.cs | 18 +-- .../spark_api/MarketData/MDConsumerHandle.cs | 1 - src/client/spark_test/Co2/Co2Tests.cs | 1 - .../config/profiles/default/market_data.conf | 17 +-- src/lib/config/protos/market_data.proto | 7 - src/lib/md/MDConsumer.cpp | 58 +++----- src/lib/md/MDConsumer.h | 4 +- src/lib/md/MDProducer.cpp | 25 ++-- src/lib/md/MDProducer.h | 5 +- src/lib/md/MarketDataGateway.cpp | 25 ++-- src/lib/md/SecurityIndex.h | 2 +- src/lib/md/SettlementRecorder.cpp | 6 +- src/lib/md/SettlementRecorder.h | 2 +- src/lib/md/Shm/MDStructure.h | 14 +- src/lib/md/ShmSegmentName.h | 40 ++---- src/lib/md/SymbolLoader.h | 24 +--- src/lib/md/common.cpp | 18 --- src/lib/md/common.h | 17 +-- src/lib/md/protos/co2.proto | 11 -- src/lib/md/readme.md | 9 +- src/lib/md/relay/QueryServer.cpp | 6 +- src/lib/md/relay/RelayClient.cpp | 56 ++++---- src/lib/md/test/Co2ManagedTestHelper.cpp | 17 +-- src/lib/md/test/md2_tests.cpp | 134 +++++++----------- src/lib/md/vendor/emumba/EmumbaDeribitData.h | 3 +- src/server/sparkd/cmds/md/cmds/Dump.cpp | 7 +- src/server/sparkd/cmds/md/cmds/Tail.cpp | 19 +-- .../sparkd/cmds/md/common/PlatformOption.cpp | 32 ----- .../sparkd/cmds/md/common/PlatformOption.h | 14 -- .../exchange_sim/ExchangeSimApplication.cpp | 33 ++--- .../sparkd/md/platforms/emumba/EmumbaMain.cpp | 3 +- .../sparkd/md/platforms/ice_onixs/ICEMain.cpp | 6 +- .../md/platforms/mdp3_onixs/MDP3Main.cpp | 27 ++-- 33 files changed, 202 insertions(+), 459 deletions(-) delete mode 100644 src/server/sparkd/cmds/md/common/PlatformOption.cpp delete mode 100644 src/server/sparkd/cmds/md/common/PlatformOption.h diff --git a/src/DataStreamSuite/DataStreamCore/BlueData/MetaDataField.cs b/src/DataStreamSuite/DataStreamCore/BlueData/MetaDataField.cs index 9b0f80302..ea2f3130a 100644 --- a/src/DataStreamSuite/DataStreamCore/BlueData/MetaDataField.cs +++ b/src/DataStreamSuite/DataStreamCore/BlueData/MetaDataField.cs @@ -3,8 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace BCG -{ +namespace BCG { /* These fields are first going to be used by BlueRay to help it determine what differnet tags mean, but eventually * the goal is that they will be used for all services in this system. @@ -12,11 +11,12 @@ namespace BCG * not all metadata fields are present in all metadata; it depends upon the class. For example, a bluepages service * probably won't have a 'symbol' or 'exchange' field populated, but it'll probably have the 'type' of service populated */ - public enum MetaDataField { Protocol, //is this a bluepages service, a pubsub tag, a blueray tag, a 29 west thing, or what - Type, //if it's a multicast, is it option, fireprice, whatever. If it's bluepages, is it persistence, pubsub, whatever - Symbol, - Exchange, - Platform, - MarketDataType, // BAM (bid, ask, mid), last, etc - RealName }; //does this thing have a better name we could call it + public enum MetaDataField { + Protocol, // is this a bluepages service, a pubsub tag, a blueray tag, a 29 west thing, or what + Type, // if it's a multicast, is it option, fireprice, whatever. If it's bluepages, is it persistence, pubsub, whatever + Symbol, + Exchange, + MarketDataType, // BAM (bid, ask, mid), last, etc + RealName + }; //does this thing have a better name we could call it } diff --git a/src/client/spark_api/MarketData/MDConsumerHandle.cs b/src/client/spark_api/MarketData/MDConsumerHandle.cs index 7dbe0b7a7..4a9ccd404 100644 --- a/src/client/spark_api/MarketData/MDConsumerHandle.cs +++ b/src/client/spark_api/MarketData/MDConsumerHandle.cs @@ -320,7 +320,6 @@ internal uint security_count; internal bool has_depth; - internal Platform platform; internal ulong trade_count; // atomic internal ulong coconut_status_count; // atomic internal ulong exchange_status_count; // atomic diff --git a/src/client/spark_test/Co2/Co2Tests.cs b/src/client/spark_test/Co2/Co2Tests.cs index af5edc856..bcb598da4 100644 --- a/src/client/spark_test/Co2/Co2Tests.cs +++ b/src/client/spark_test/Co2/Co2Tests.cs @@ -155,7 +155,6 @@ namespace mbts.co2.tests Assert.IsTrue(header.heartbeat.time > 0); Assert.IsTrue(header.security_count == 77000); Assert.IsTrue(header.has_depth == true); - Assert.IsTrue(header.platform == Platform.Sim); Assert.IsTrue(header.trade_count == 100); Assert.IsTrue(header.coconut_status_count == 101); Assert.IsTrue(header.exchange_status_count == 102); diff --git a/src/lib/config/profiles/default/market_data.conf b/src/lib/config/profiles/default/market_data.conf index e98e1cfd5..a4fb421ac 100644 --- a/src/lib/config/profiles/default/market_data.conf +++ b/src/lib/config/profiles/default/market_data.conf @@ -7,13 +7,6 @@ HistoricMarketDataConfig { } } -PlatformMap { - value { - glbx_platform: "PLATFORM_MDP3ONIXS" - ice_platform: "PLATFORM_ICEONIXS" - } -} - PublisherOptions { value { network_interface: "0.0.0.0" @@ -209,14 +202,6 @@ HistoricMarketDataConfig { } } -PlatformMap { - rule: "DeploymentType.type == 'prod'" - value { - glbx_platform: "PLATFORM_MDP3ONIXS" - ice_platform: "PLATFORM_ICEONIXS" - } -} - MarketDataConfig { value { emumba_deribit { @@ -237,4 +222,4 @@ MarketDataConfig { value{ onixs_license: "{default}" } -} \ No newline at end of file +} diff --git a/src/lib/config/protos/market_data.proto b/src/lib/config/protos/market_data.proto index 23b018ddd..2fd1fd15f 100644 --- a/src/lib/config/protos/market_data.proto +++ b/src/lib/config/protos/market_data.proto @@ -12,13 +12,6 @@ message HistoricMarketDataConfig { bool use_sim = 4; } -message PlatformMap { - // PLATFORM_MDP3ONIXS - string glbx_platform = 1; - // PLATFORM_ICEONIXS - string ice_platform = 2; -} - // LOCAL TIME message MDBootDelayWindow { uint32 delay_seconds = 1; diff --git a/src/lib/md/MDConsumer.cpp b/src/lib/md/MDConsumer.cpp index 5e3fce7f7..ab5525720 100644 --- a/src/lib/md/MDConsumer.cpp +++ b/src/lib/md/MDConsumer.cpp @@ -78,33 +78,20 @@ bool is_heart_beat_ok(const ColdHeader &); class MDConsumerInst { public: MDConsumerInst( - const string &symbol, - SecurityType type, - Venue exchange, - bool shared, - co2::Platform platform) - : _symbol(symbol), _type(type), _exchange(exchange), - _platform( - platform == co2::PLATFORM_UNSET ? platform_for_exchange(exchange) - : platform), - _security_count(0), _found_keys(), _hot(), _hot_depth(), - _cold( - ShmSegmentName::cold_name(symbol, type, exchange, _platform), - shared), + const string &symbol, SecurityType type, Venue exchange, bool shared) + : _symbol(symbol), _type(type), _exchange(exchange), _security_count(0), + _found_keys(), _hot(), _hot_depth(), + _cold(ShmSegmentName::cold_name(symbol, type, exchange), shared), _queues() { LOG(md, Diag, - "MDConsumerInst::MDConsumerInst symbol: {} venue: {} type: {} " - "platform: {}", - symbol, static_cast(exchange), static_cast(type), - static_cast(platform)); + "MDConsumerInst::MDConsumerInst symbol: {} venue: {} type: {}", + symbol, static_cast(exchange), static_cast(type)); if (enable_depth(symbol, type)) { _hot_depth.reset(new utils::SharedListReader( - ShmSegmentName::hot_name(symbol, type, exchange, _platform), - shared)); + ShmSegmentName::hot_name(symbol, type, exchange), shared)); } else { _hot.reset(new utils::SharedListReader( - ShmSegmentName::hot_name(symbol, type, exchange, _platform), - shared)); + ShmSegmentName::hot_name(symbol, type, exchange), shared)); } } ~MDConsumerInst() { @@ -265,7 +252,6 @@ class MDConsumerInst { const string &symbol() const { return _symbol; } SecurityType type() const { return _type; } Venue exchange() const { return _exchange; } - co2::Platform platform() const { return _platform; } // // Queued data @@ -341,7 +327,6 @@ class MDConsumerInst { string _symbol; SecurityType _type; Venue _exchange; - co2::Platform _platform; size_t _security_count; set _found_keys; unique_ptr> _hot; @@ -592,7 +577,6 @@ class MDConsumerImpl { map> _deferred_handles; vector _callbacks; mutable SecurityCache _cache; - // co2::Platform _platform; public: MDConsumerImpl( @@ -600,8 +584,7 @@ class MDConsumerImpl { SecurityCache &cache, api::ISyntheticSecurityService *ss, MBOReader *mbo, - bool shared, - co2::Platform platform) + bool shared) : _workmutex(), _instances(), _sci(), _mbo(mbo), _deferred_handles(), _callbacks(), _cache(cache) { std::ostringstream msg; @@ -612,15 +595,14 @@ class MDConsumerImpl { msg << symbol.symbol() << "-" << SecurityType_Name(symbol.type()) << " " << Venue_Name(symbol.exchange()); } - LOG(md, Info, "Created MDConsumerImpl for securities: {} on {}", - msg.str(), co2::Platform_Name(platform)); + LOG(md, Info, "Created MDConsumerImpl for securities: {}", msg.str()); for (auto &s : symbols) { if (s.type() == SECURITYTYPE_FUTURE || s.type() == SECURITYTYPE_OPTION || s.type() == api::SECURITYTYPE_SPOT) { _instances.push_back(make_shared( - s.symbol(), s.type(), s.exchange(), shared, platform)); + s.symbol(), s.type(), s.exchange(), shared)); } // TODO, add options here } @@ -632,13 +614,12 @@ class MDConsumerImpl { // ISyntheticSecurityService? if (has_synthetic_instance == false) { _instances.push_back(make_shared( - SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared, - platform)); + SYNTHETIC_SYMBOL, s.type(), api::VENUE_BTS, shared)); } has_synthetic_instance = true; } else { _instances.push_back(make_shared( - s.symbol(), s.type(), s.exchange(), shared, platform)); + s.symbol(), s.type(), s.exchange(), shared)); } } } @@ -1022,7 +1003,7 @@ class MDConsumerImpl { // MDConsumer public interface, forwards to pimple /////////////////////////////////////////////////////////////////////////////////////////////////// -void log_cons(const std::set *symbols, co2::Platform platform) { +void log_cons(const std::set *symbols) { std::string log_str = ""; if (symbols != nullptr) { for (const auto &s : *symbols) { @@ -1030,8 +1011,7 @@ void log_cons(const std::set *symbols, co2::Platform platform) { Venue_Name(s.exchange()) + ","; } } - LOG(md, Info, "MDConsumer::MDConsumer symbols: {} platform: {} ", log_str, - static_cast(platform)); + LOG(md, Info, "MDConsumer::MDConsumer symbols: {}", log_str); } MDConsumer::MDConsumer( @@ -1039,17 +1019,16 @@ MDConsumer::MDConsumer( api::ISyntheticSecurityService *ss, MBOReader *mbo, const std::set *symbols, - bool shared, - co2::Platform platform) + bool shared) : _pimpl() { - log_cons(symbols, platform); + log_cons(symbols); set all_symbols; if (symbols == nullptr || symbols->empty()) { all_symbols = SymbolLoader::load(); symbols = &all_symbols; } - _pimpl.reset(new MDConsumerImpl(*symbols, cache, ss, mbo, shared, platform)); + _pimpl.reset(new MDConsumerImpl(*symbols, cache, ss, mbo, shared)); } MDConsumer::~MDConsumer() {} @@ -1114,7 +1093,6 @@ const std::string &MDConsumerChannel::symbol() const { } SecurityType MDConsumerChannel::type() const { return _pimpl->type(); } Venue MDConsumerChannel::exchange() const { return _pimpl->exchange(); } -Platform MDConsumerChannel::platform() const { return _pimpl->platform(); } bool MDConsumerChannel::is_heart_beating() const { return _pimpl->is_heart_beating(); diff --git a/src/lib/md/MDConsumer.h b/src/lib/md/MDConsumer.h index 951d8d11e..e16944e47 100644 --- a/src/lib/md/MDConsumer.h +++ b/src/lib/md/MDConsumer.h @@ -36,8 +36,7 @@ class MDConsumer { api::ISyntheticSecurityService *ss, MBOReader *mbo = nullptr, const std::set *sym = nullptr, - bool shared = true, - co2::Platform platform = co2::PLATFORM_UNSET); + bool shared = true); ~MDConsumer(); bool all_heartbeats_ok() const; @@ -89,7 +88,6 @@ class BTS_EXPORT MDConsumerChannel { const std::string &symbol() const; SecurityType type() const; Venue exchange() const; - Platform platform() const; bool is_initialized() const; utils::TimeStamp create_time() const; diff --git a/src/lib/md/MDProducer.cpp b/src/lib/md/MDProducer.cpp index 569d6be30..805f387d8 100644 --- a/src/lib/md/MDProducer.cpp +++ b/src/lib/md/MDProducer.cpp @@ -24,16 +24,15 @@ class MDProducerImpl { const string &symbol, SecurityType type, Venue exchange, - Platform platform, MDProducerFlags flags) : _symbol(symbol), _type(type), _exchange(exchange), _hot( - ShmSegmentName::hot_name(symbol, type, exchange, platform), + ShmSegmentName::hot_name(symbol, type, exchange), config::get().hot_initial(), config::get().hot_growth(), flags & MDProducerFlags::Shared), _cold( - ShmSegmentName::cold_name(symbol, type, exchange, platform), + ShmSegmentName::cold_name(symbol, type, exchange), config::get().cold_initial(), config::get().cold_growth(), flags & MDProducerFlags::Shared), @@ -49,7 +48,6 @@ class MDProducerImpl { // We should monitor and adjust based on production use for optimal // performance _cold.header().has_depth = enable_depth(symbol, type); - _cold.header().platform = platform; // static_assert(sizeof(HotEntry) <= 32,"HotEntry should be less than 32 // bytes"); @@ -130,22 +128,19 @@ class MDProducerImpl { // MDProducer // -MDProducer::MDProducer(Platform platform, MDProducerFlags flags) - : _mutex(new std::mutex()), _producers(), _id_recorder(), - _platform(platform), _flags(flags), +MDProducer::MDProducer(MDProducerFlags flags) + : _mutex(new std::mutex()), _producers(), _id_recorder(), _flags(flags), _smapper(flags & MDProducerFlags::SecurityMapper) {} #ifndef _WIN32 -MDProducer::MDProducer( - Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags) +MDProducer::MDProducer(SecurityIDRecorder recorder, MDProducerFlags flags) : _mutex(new std::mutex()), _producers(), _id_recorder(std::make_unique(recorder)), - _platform(platform), _flags(flags), - _smapper(flags & MDProducerFlags::SecurityMapper) {} + _flags(flags), _smapper(flags & MDProducerFlags::SecurityMapper) {} #endif MDProducer::MDProducer(MDProducer &&other) : _mutex(std::move(other._mutex)), _producers(std::move(other._producers)), - _platform(other._platform), _flags(other._flags), - _smapper(_flags & MDProducerFlags::SecurityMapper) {} + _flags(other._flags), _smapper(_flags & MDProducerFlags::SecurityMapper) { +} MDProducer::~MDProducer() {} @@ -169,9 +164,9 @@ MDProducerImpl &MDProducer::get_producer( // for each one so we put them all in one newp.reset(new MDProducerImpl( SYNTHETIC_SYMBOL, api::SECURITYTYPE_SYNTHETIC, Venue::VENUE_BTS, - _platform, _flags)); + _flags)); } else { - newp.reset(new MDProducerImpl(symbol, type, exchange, _platform, _flags)); + newp.reset(new MDProducerImpl(symbol, type, exchange, _flags)); } _producers.push_back(std::move(newp)); return *_producers.back(); diff --git a/src/lib/md/MDProducer.h b/src/lib/md/MDProducer.h index 99b3bb23b..ab6c0344b 100644 --- a/src/lib/md/MDProducer.h +++ b/src/lib/md/MDProducer.h @@ -42,10 +42,8 @@ constexpr MDProducerFlags DefaultMDProducerFlags = // the same for he other venue)) class BTS_EXPORT MDProducer { public: + MDProducer(MDProducerFlags flags = DefaultMDProducerFlags); MDProducer( - Platform platform, MDProducerFlags flags = DefaultMDProducerFlags); - MDProducer( - Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags = DefaultMDProducerFlags); MDProducer(MDProducer &&other); @@ -72,7 +70,6 @@ class BTS_EXPORT MDProducer { std::unique_ptr _mutex; std::vector> _producers; std::unique_ptr _id_recorder; - Platform _platform; MDProducerFlags _flags; SecurityMapper _smapper; }; diff --git a/src/lib/md/MarketDataGateway.cpp b/src/lib/md/MarketDataGateway.cpp index 630461248..26c76bfe3 100644 --- a/src/lib/md/MarketDataGateway.cpp +++ b/src/lib/md/MarketDataGateway.cpp @@ -1,5 +1,4 @@ #if !defined(_WIN32) && defined(SPARK_ENABLE_CCAPI) -#include "server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h" #include "MarketDataGateway.h" #include "lib/api/md/EmumbaDeribitMarketDataConfig.pb.h" #include "lib/api/md/MarketDataConfig.pb.h" @@ -40,6 +39,7 @@ #include "lib/utils/bts_fatal.h" #include "lib/utils/thread_manager.h" #include "server/sparkd/md/platforms/emumba/EmumbaMain.h" +#include "server/sparkd/md/platforms/mdp3_onixs/MDP3Main.h" #include #include @@ -97,7 +97,6 @@ struct MDReplayData { MDReplayData(const bts::api::md::MarketDataReplayConfig &replay_conf) : replay_conf(replay_conf), venue(replay_conf.venue()), sec_index(), - md_producer(bts::co2::PLATFORM_SIM), md_replayer(replay_conf.venue(), sec_index, md_producer) {} }; @@ -107,8 +106,7 @@ struct CCMDSourceData { bts::md::GeneralMarketDataListener listener; CCMDSourceData(bts::api::Venue venue) - : sec_index(), md_producer(bts::co2::PLATFORM_SIM), - listener(sec_index, md_producer, venue) {} + : sec_index(), listener(sec_index, md_producer, venue) {} }; struct MarketDataGateway::PImpl { @@ -142,7 +140,7 @@ void MarketDataGateway::run() { bts_assert(me_->md_config.emumba_deribit().size() == 1); _start_emumba_deribit(me_->md_config.emumba_deribit().at(0)); } - if(!me_->md_config.glbx().empty()){ + if (!me_->md_config.glbx().empty()) { bts_assert(me_->md_config.glbx().size() == 1); _start_onix_glbx(me_->md_config.glbx().at(0)); } @@ -244,18 +242,17 @@ void MarketDataGateway::unsubscribe(MarketDataListenerID id) { /// glbx ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// static void run_onixs() { - LOG(md, Info, "MarketDataGateway::run_onixs t_id:{} t_name", os::get_thread_id(), - os::get_thread_name()); + LOG(md, Info, "MarketDataGateway::run_onixs t_id:{} t_name", + os::get_thread_id(), os::get_thread_name()); bts::md::MBOWriter *mbo = nullptr; bts::md::TradeSummarySignalDispatcher *tssd = nullptr; std::vector> platforms; // get all glbx symbols - auto cme_symbols = - SymbolLoader::load(bts::domain::SecurityCriteria::create({api::domain::VENUE_GLBX})); + auto cme_symbols = SymbolLoader::load( + bts::domain::SecurityCriteria::create({api::domain::VENUE_GLBX})); if (!cme_symbols.empty()) { auto *main = new bts::md::MDP3Main(); - main->start( - {cme_symbols.begin(), cme_symbols.end()}, mbo, tssd); + main->start({cme_symbols.begin(), cme_symbols.end()}, mbo, tssd); platforms.emplace_back(main); } // deribit @@ -271,9 +268,8 @@ static void run_onixs() { disp.run(); } - - -void MarketDataGateway::_start_onix_glbx( bts::api::md::GlbxMarketDataConfig cfg){ +void MarketDataGateway::_start_onix_glbx( + bts::api::md::GlbxMarketDataConfig cfg) { LOG(md, Info, "MarketDataGateway::_start_onix_glbx starting t_id:{} t_name:{}. " "cfg:\n{}", @@ -281,7 +277,6 @@ void MarketDataGateway::_start_onix_glbx( bts::api::md::GlbxMarketDataConfig cfg bts::md::run_onixs(); } - // deribit //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib/md/SecurityIndex.h b/src/lib/md/SecurityIndex.h index 704a2aae1..878a9c646 100644 --- a/src/lib/md/SecurityIndex.h +++ b/src/lib/md/SecurityIndex.h @@ -65,7 +65,7 @@ class SimpleSecurityIndex { auto result = _map.insert(std::make_pair(key, std::unique_ptr())); if (!result.second) { - LOG(md, Error, "Found duplicate entry for platform id '{} - ", key); + LOG(md, Error, "Exchange key '{}' has already been added.", key); bts_assert(result.second); } result.first->second = std::move(entry); diff --git a/src/lib/md/SettlementRecorder.cpp b/src/lib/md/SettlementRecorder.cpp index 84db56ad7..4b3bb9f89 100644 --- a/src/lib/md/SettlementRecorder.cpp +++ b/src/lib/md/SettlementRecorder.cpp @@ -83,12 +83,10 @@ void apply_work(SettlementRecorderImpl &me, Work work) { } } -SettlementRecorder::SettlementRecorder(Platform platform) - : _self(new SettlementRecorderImpl()) { +SettlementRecorder::SettlementRecorder() : _self(new SettlementRecorderImpl()) { string db_dir = config::get().data_path() + "databases/md/"; - string db_path = - db_dir + "/settlements_" + Platform_Name(platform) + ".sqlite"; + string db_path = db_dir + "/settlements.sqlite"; if (!boost::filesystem::exists(db_dir)) { boost::filesystem::create_directories(db_dir); } diff --git a/src/lib/md/SettlementRecorder.h b/src/lib/md/SettlementRecorder.h index 4e5d6b35c..f027f5080 100644 --- a/src/lib/md/SettlementRecorder.h +++ b/src/lib/md/SettlementRecorder.h @@ -11,7 +11,7 @@ using namespace md; struct SettlementRecorderImpl; class SettlementRecorder { public: - SettlementRecorder(Platform platform); + SettlementRecorder(); ~SettlementRecorder(); // Put settlement update in a queue diff --git a/src/lib/md/Shm/MDStructure.h b/src/lib/md/Shm/MDStructure.h index 1e9e7abad..45a4e1f80 100644 --- a/src/lib/md/Shm/MDStructure.h +++ b/src/lib/md/Shm/MDStructure.h @@ -93,8 +93,8 @@ class HotDepthEntry { *bid = implied[depth].bid(); *ask = implied[depth].ask(); } - bool - write_direct(uint32_t depth, const PriceSize &bid, const PriceSize &ask) { + bool write_direct( + uint32_t depth, const PriceSize &bid, const PriceSize &ask) { bts_assert_d(depth < direct.size()); auto temp = PriceLevel(bid, ask); if (direct[depth] != temp) { @@ -103,8 +103,8 @@ class HotDepthEntry { } return false; } - bool - write_implied(uint32_t depth, const PriceSize &bid, const PriceSize &ask) { + bool write_implied( + uint32_t depth, const PriceSize &bid, const PriceSize &ask) { bts_assert_d(depth < implied.size()); auto temp = PriceLevel(bid, ask); if (implied[depth] != temp) { @@ -137,9 +137,8 @@ struct ALIGNED_(CACHE_LINE) ColdHeader { heartbeat_ms(config::get().heartbeat_ms()), heartbeat_boot_seconds( config::get().heartbeat_boot_seconds()), - security_count(0), has_depth(false), platform(co2::PLATFORM_UNSET), - trade_count(0), coconut_status_count(0), exchange_status_count(0), - rfq_count(0) {} + security_count(0), has_depth(false), trade_count(0), + coconut_status_count(0), exchange_status_count(0), rfq_count(0) {} uint32_t version; size_t count; @@ -152,7 +151,6 @@ struct ALIGNED_(CACHE_LINE) ColdHeader { uint32_t security_count; // incremented when a security is made public bool has_depth; - Platform platform; std::atomic trade_count; std::atomic coconut_status_count; diff --git a/src/lib/md/ShmSegmentName.h b/src/lib/md/ShmSegmentName.h index 6c48af06d..e7680fb8c 100644 --- a/src/lib/md/ShmSegmentName.h +++ b/src/lib/md/ShmSegmentName.h @@ -13,29 +13,19 @@ class ShmSegmentName { static std::string prefix(); static std::string prefix( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform); + const std::string &symbol, api::SecurityType type, api::Venue exchange); static std::string hot_name( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform); + const std::string &symbol, api::SecurityType type, api::Venue exchange); static std::string cold_name( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform); + const std::string &symbol, api::SecurityType type, api::Venue exchange); private: static std::string name_( const std::string &symbol, api::SecurityType type, api::Venue exchange, - co2::Platform platform, const std::string &suffix); }; @@ -49,37 +39,27 @@ inline std::string ShmSegmentName::prefix() { } inline std::string ShmSegmentName::prefix( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform) { + const std::string &symbol, api::SecurityType type, api::Venue exchange) { return prefix() + "_" + symbol + "_" + api::SecurityType_Name(type) + "_" + - Venue_Name(exchange) + "_" + Platform_Name(platform); + Venue_Name(exchange); } inline std::string ShmSegmentName::name_( const std::string &symbol, api::SecurityType type, api::Venue exchange, - co2::Platform platform, const std::string &suffix) { - return prefix(symbol, type, exchange, platform) + "_" + suffix; + return prefix(symbol, type, exchange) + "_" + suffix; } inline std::string ShmSegmentName::hot_name( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform) { - return name_(symbol, type, exchange, platform, "hot"); + const std::string &symbol, api::SecurityType type, api::Venue exchange) { + return name_(symbol, type, exchange, "hot"); } inline std::string ShmSegmentName::cold_name( - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - co2::Platform platform) { - return name_(symbol, type, exchange, platform, "cold"); + const std::string &symbol, api::SecurityType type, api::Venue exchange) { + return name_(symbol, type, exchange, "cold"); } } // namespace bts::md diff --git a/src/lib/md/SymbolLoader.h b/src/lib/md/SymbolLoader.h index 44c7b00e8..cbaf7502f 100644 --- a/src/lib/md/SymbolLoader.h +++ b/src/lib/md/SymbolLoader.h @@ -1,6 +1,7 @@ #pragma once #include "UserSymbol.h" #include "common.h" +#include "lib/api/md/MarketDataConfig.pb.h" #include "lib/collections/Contains.h" #include "lib/config/config.h" #include "lib/config/protos/market_data.pb.h" @@ -8,7 +9,6 @@ #include "lib/core/FMT.h" #include "lib/domain/DomainSecurityUtils.h" #include "lib/domain/SecurityCriteria.h" -#include "lib/api/md/MarketDataConfig.pb.h" #include "lib/domain_model/Security.pb.h" #include @@ -18,7 +18,6 @@ namespace bts::md { // Macro aliases for verbose types/fns. Be sure to undef at end of file. -#define PLATFORM(p) bts::co2::PLATFORM_##p #define SEC_TYPE(t) bts::api::SECURITYTYPE_##t #define VENUE(v) bts::api::VENUE_##v @@ -36,8 +35,6 @@ class SymbolLoader { const bts::domain::SecurityCriteria &filter = {}); private: - // Some linux assemblies don't have a proper SONAME so we preload them by - // path to satisfy imports void preload(Platform); SymbolLoader(const SymbolLoader &); SymbolLoader &operator=(const SymbolLoader &); @@ -130,24 +127,6 @@ inline std::size_t SymbolLoader::load( return n_loaded; } -inline Platform platform_for_exchange(Venue v) { - const auto &pmap = config::get(); - co2::Platform platform; - if (v == VENUE(SIM)) { - return PLATFORM(SIM); - } - if (v == VENUE(ICE) && co2::Platform_Parse(pmap.ice_platform(), &platform)) { - return platform; - } - - // md2_tests.cpp depends on this fall through to yield SIM as the GLBX - // platform - if (co2::Platform_Parse(pmap.glbx_platform(), &platform)) { - return platform; - } - return PLATFORM(UNSET); -} - inline bool SymbolLoader::parse_venue( const std::string &str, bts::md::Venue *venue) { if (Venue_Parse(str, venue)) { @@ -161,7 +140,6 @@ inline bool SymbolLoader::parse_venue( return false; } -#undef PLATFORM #undef SEC_TYPE #undef VENUE diff --git a/src/lib/md/common.cpp b/src/lib/md/common.cpp index b0403c5c1..852f09bc0 100644 --- a/src/lib/md/common.cpp +++ b/src/lib/md/common.cpp @@ -17,23 +17,5 @@ const double NO_PRICE = std::numeric_limits().quiet_NaN(); const char *SYNTHETIC_SYMBOL = "SYNTHETIC"; } // namespace md - -namespace co2 { -using namespace std; -using namespace md; -string topic( - const char *data_type, - const string &symbol, - SecurityType type, - Venue exchange, - Platform platform) { - std::ostringstream topic; - topic << "/md/" << config::get().channel_prefix() - << Platform_Name(platform) << "/" << Venue_Name(exchange) << "/" - << symbol << "/" << api::SecurityType_Name(type) << "/" << data_type; - return topic.str(); -} -} // namespace co2 - } // namespace bts #endif diff --git a/src/lib/md/common.h b/src/lib/md/common.h index 067467b39..ca34dd6ba 100644 --- a/src/lib/md/common.h +++ b/src/lib/md/common.h @@ -11,8 +11,8 @@ #include -namespace bts { -namespace md { +namespace bts::md { + const extern char *SYNTHETIC_SYMBOL; typedef uint32_t security_key; @@ -24,19 +24,8 @@ using api::SecurityType; using api::Venue; using bts::api::Side; using bts::co2::CoconutSecurityStatus; -using bts::co2::Platform; using bts::co2::TradingStatus; SecurityType securitytype_of(const Security &); -} // namespace md -namespace co2 { -std::string topic( - const char *data_type, - const std::string &symbol, - api::SecurityType type, - api::Venue exchange, - Platform platform); -} - -} // namespace bts +} // namespace bts::md diff --git a/src/lib/md/protos/co2.proto b/src/lib/md/protos/co2.proto index fe424b4c8..8aada7d6e 100644 --- a/src/lib/md/protos/co2.proto +++ b/src/lib/md/protos/co2.proto @@ -3,16 +3,6 @@ package bts.co2; option csharp_namespace="bts.co2"; import "lib/domain_model/Security.proto"; -enum Platform { - PLATFORM_UNSET = 0; - PLATFORM_SIM = 1; - PLATFORM_MDP3ONIXS = 10; - PLATFORM_CELOXICA = 13; - PLATFORM_MDP3EMUMBA = 14; - PLATFORM_ICEONIXS = 15; - PLATFORM_DERIBIT = 16; -} - enum TradingStatus { TRADINGSTATUS_UNKNOWN = 0; TRADINGSTATUS_NORMAL = 2; @@ -79,7 +69,6 @@ message ChannelUpdate { message ChannelReply { SecurityChannel channel = 1; - Platform platform = 2; repeated ChannelUpdate updates = 3; repeated TradeMessage trade_log = 4; repeated QuoteRequestMessage rfq_log = 5; diff --git a/src/lib/md/readme.md b/src/lib/md/readme.md index 94e101bd5..cb2789c06 100644 --- a/src/lib/md/readme.md +++ b/src/lib/md/readme.md @@ -20,7 +20,6 @@ The MDConsumer is the dual of the MDProducer. It provides an on_security() call * MDConsumerHandle * MDProducer * MDProducerHandle -* PlatformLoader * PriceSize/IntPrice * SecurityCache* * SecurityOracle* @@ -63,8 +62,6 @@ Internally MDConsumer is a collection of MDConsumerInst which each handle a sing On Linux MDConsumer maps the shared memory as read-only pages. On Windows it cannot do this because std::atomic uses a different instruction which is considered a write by the CPU so we map it read/write. -If we have multiple platforms that can produce md for an exchange (i.e. onixs vs emumba) the MDConsumer consults the PlatformMap config key to determine which to read from. The md replayer impersonates the producer it was recorded from. - ### MDConsumerChannel read_trades() and read_rfqs() read from a ring buffer stored in the header section of the shared memory. They read directly into a google::protobuf::RepeatedPtrField to avoid extra copies in the QueryServer but can just as easily read into a std::vector. They expose a 'cursor' representing the position in the ring buffer and this cursor is sent all the way to the client so it can request updates. @@ -82,16 +79,12 @@ Reading from a BBO/DEPTH handle is done with an optimistic copy. If you inrease ## MDProducer -Handle to writeable shared memory. Each market data producer "platform" (onixs_cme, onixs_ice, emumba, etc) constructs one. +Handle to writeable shared memory. ## MDProducerHandle All updates to a single security go through here. Assumes a single writer thread. -## PlatformLoader - -In Edge this was the entry point to the run() for the market data producer process. It loaded the bts_md_*.so so each producer process only loaded the third party objects for a particular producer. In spark this is all in process so this is defunct. It looks like it still exists because it has some utility functions that probably belong in another file. - ## PriceSize/IntPrice Market data uses integer prices to avoid double problems. diff --git a/src/lib/md/relay/QueryServer.cpp b/src/lib/md/relay/QueryServer.cpp index 23c098f80..6c440f12d 100644 --- a/src/lib/md/relay/QueryServer.cpp +++ b/src/lib/md/relay/QueryServer.cpp @@ -83,8 +83,8 @@ struct MDConsumerGroup { const UserSymbol &symbol, const MDConsumer &consumer, metrics::MetricsContainer &stats) - : symbol(symbol), platform(platform_for_exchange(symbol.exchange())), - channel(consumer.get_channel(symbol)), handles(), mic() { + : symbol(symbol), channel(consumer.get_channel(symbol)), handles(), + mic() { set_consumer(consumer); // create and publish a stat for this group @@ -199,7 +199,6 @@ struct MDConsumerGroup { } UserSymbol symbol; - Platform platform; MDConsumerChannel channel; // Can add to handles without invalidating readers (no lock needed) @@ -320,7 +319,6 @@ class QueryServerImpl : public IQueryServer { bts_assert(reply); reply->mutable_channel()->CopyFrom(chan); - reply->set_platform(group.platform); reply->mutable_channel()->set_time(TimeStamp::now().to_uint64()); bool entitled = bypass_entitlement || chan.exchange() == api::VENUE_BTS; diff --git a/src/lib/md/relay/RelayClient.cpp b/src/lib/md/relay/RelayClient.cpp index 844b6d2ca..2a66782f6 100644 --- a/src/lib/md/relay/RelayClient.cpp +++ b/src/lib/md/relay/RelayClient.cpp @@ -60,7 +60,7 @@ IntPrice convert(const PriceMessage &price) { class RelayProducer : public IRelayWriter { bool _shared; - std::map _producers; + std::optional _producer; unordered_map _handles; void record_update(MDProducerHandle &handle, const ChannelUpdate &update) { @@ -109,24 +109,20 @@ class RelayProducer : public IRelayWriter { } public: - RelayProducer(bool shared) : _shared(shared), _producers(), _handles() {} + RelayProducer(bool shared) : _shared(shared), _handles() {} - MDProducer &ensure_producer(Platform platform) { - auto find_result = _producers.find(platform); - if (find_result == _producers.end()) { + MDProducer &ensure_producer() { + if (!_producer) { // relay never wants to enable SecurityMapper. Securities should always // match the relay source. - auto flags = _shared ? MDProducerFlags::Shared : MDProducerFlags::None; - auto result = _producers.insert( - make_pair(platform, MDProducer(platform, flags))); - if (result.second) { - return result.first->second; - } + _producer.emplace( + _shared ? MDProducerFlags::Shared : MDProducerFlags::None); } - return find_result->second; + return *_producer; } void write(const co2::MDReply &data, bool *phas_new_securities) override { + auto &producer = ensure_producer(); for (const auto &ch : data.channels()) { // Per-security data int added_security_count = 0; @@ -136,7 +132,7 @@ class RelayProducer : public IRelayWriter { if (phas_new_securities) *phas_new_securities = true; added_security_count++; - MDProducer &producer = ensure_producer(ch.platform()); + MDProducer &producer = ensure_producer(); with_security_like(update.security(), [&](FixedSecurity &fs) { convert_security(update.security(), fs, true); MDProducerHandle handle = producer.add_security(fs); @@ -149,28 +145,24 @@ class RelayProducer : public IRelayWriter { } } // Heartbeat - auto iter = _producers.find(ch.platform()); - if (iter != _producers.end()) { - auto &producer = iter->second; - auto channel = producer.get_channel( - ch.channel().symbol().c_str(), ch.channel().type(), - ch.channel().exchange()); - channel.heartbeat(); + auto channel = producer.get_channel( + ch.channel().symbol().c_str(), ch.channel().type(), + ch.channel().exchange()); + channel.heartbeat(); - // RFQ and TRADE LOG - if (ch.trade_log_size() > 0 || ch.rfq_log_size() > 0) { - if (ch.trade_log_size() > 0) { - LOG(md, Diag, "Added {} trades", ch.trade_log_size()); - } - for (const auto &trade : ch.trade_log()) { - if (trade.key()) { - channel.add_trade(trade); - } - } - for (const auto &rfq : ch.rfq_log()) { - channel.add_rfq(rfq); + // RFQ and TRADE LOG + if (ch.trade_log_size() > 0 || ch.rfq_log_size() > 0) { + if (ch.trade_log_size() > 0) { + LOG(md, Diag, "Added {} trades", ch.trade_log_size()); + } + for (const auto &trade : ch.trade_log()) { + if (trade.key()) { + channel.add_trade(trade); } } + for (const auto &rfq : ch.rfq_log()) { + channel.add_rfq(rfq); + } } if (added_security_count > 0) { LOG(md, Diag, "Added {} {} - {}", added_security_count, diff --git a/src/lib/md/test/Co2ManagedTestHelper.cpp b/src/lib/md/test/Co2ManagedTestHelper.cpp index 683801099..c1296ffe7 100644 --- a/src/lib/md/test/Co2ManagedTestHelper.cpp +++ b/src/lib/md/test/Co2ManagedTestHelper.cpp @@ -13,8 +13,8 @@ namespace test { using namespace co2; -std::vector -create_test_securities(MDProducer &producer, const char *postfix = "M"); +std::vector create_test_securities( + MDProducer &producer, const char *postfix = "M"); void assign_ids( std::vector::iterator begin, @@ -53,8 +53,8 @@ extern "C" BTS_EXPORT void co2_get_sample_hot(size_t &size, HotEntry &entry) { entry.set_time(utils::TimeStamp::now()); } -extern "C" BTS_EXPORT void -co2_get_sample_depth(size_t &size, HotDepthEntry &entry) { +extern "C" BTS_EXPORT void co2_get_sample_depth( + size_t &size, HotDepthEntry &entry) { size = sizeof(HotDepthEntry); entry.key = 1234; for (size_t x = 0; x < COCONUT_MAX_DEPTH; ++x) { @@ -107,7 +107,6 @@ extern "C" BTS_EXPORT void co2_get_sample_cold_header(ColdHeader &header) { header.security_count = 77000; header.has_depth = true; - header.platform = PLATFORM_SIM; header.trade_count = 100; header.coconut_status_count = 101; header.exchange_status_count = 102; @@ -123,13 +122,9 @@ struct TestProducer { }; extern "C" BTS_EXPORT TestProducer *co2_produce_test_md() { - config::internal::initialize_for_test("PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); + config::internal::initialize_for_test(""); auto *tp = new TestProducer(); - tp->md = std::make_shared(PLATFORM_SIM, MDProducerFlags::None); + tp->md = std::make_shared(MDProducerFlags::None); tp->handles = create_test_securities(*(tp->md)); auto &producers = tp->handles; assign_ids(producers.begin(), producers.end()); diff --git a/src/lib/md/test/md2_tests.cpp b/src/lib/md/test/md2_tests.cpp index 3b2b6b881..13cdbb323 100644 --- a/src/lib/md/test/md2_tests.cpp +++ b/src/lib/md/test/md2_tests.cpp @@ -10,10 +10,10 @@ #include "lib/metrics/metrics.h" #include "lib/os/os.h" #include "lib/utils/Dispatcher.h" +#include "lib/utils/Shuffle.h" #include "lib/utils/bts_chrono.h" #include "lib/utils/defer.h" #include "lib/utils/warn_ctrl.h" -#include "lib/utils/Shuffle.h" #include "lib/config/protos/market_data.pb.h" #include "lib/utils/Sqlite_utils.h" @@ -55,14 +55,12 @@ namespace test { using namespace api; using namespace co2; -Platform TEST_PLATFORM = PLATFORM_SIM; - // // Helper functions for Producer/Consumer tests // -std::vector -create_test_securities(MDProducer &producer, const char *postfix = ""); +std::vector create_test_securities( + MDProducer &producer, const char *postfix = ""); set get_test_symbols(const char *postfix = "") { set symbols; @@ -75,8 +73,8 @@ set get_test_symbols(const char *postfix = "") { return symbols; } -Security -mkfuture(string symbol, security_key key, int year, int month, int day) { +Security mkfuture( + string symbol, security_key key, int year, int month, int day) { Security result; result.set_symbol(symbol); result.set_exchange(VENUE_BTS); @@ -104,8 +102,8 @@ Security mkoption( result.mutable_option()->set_call_put(PUTORCALL_PUT); return result; } -unique_ptr -mkfixedfuture(string symbol, security_key key, int year, int month, int day) { +unique_ptr mkfixedfuture( + string symbol, security_key key, int year, int month, int day) { unique_ptr ffs(new FixedFutureSecurity()); ffs->type = SECURITYTYPE_FUTURE; ffs->exchange = VENUE_BTS; @@ -116,8 +114,8 @@ mkfixedfuture(string symbol, security_key key, int year, int month, int day) { ffs->symbol(symbol); return ffs; } -Security -mkspread(string symbol, security_key key, const vector &legs) { +Security mkspread( + string symbol, security_key key, const vector &legs) { Security result; result.set_symbol(symbol); result.set_exchange(VENUE_BTS); @@ -128,8 +126,8 @@ mkspread(string symbol, security_key key, const vector &legs) { } return result; } -Security -mkspread(string symbol, security_key key, Security leg1, Security leg2) { +Security mkspread( + string symbol, security_key key, Security leg1, Security leg2) { vector vlegs; vlegs.push_back(leg1); vlegs.push_back(leg2); @@ -151,18 +149,12 @@ Security mkspread( class Co2Tests { public: void setup() { - config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}" - "PublisherOptions {" - " value {" - " heartbeat_ms: 100" - " heartbeat_boot_seconds: 1" - " }" - "}"); + config::internal::initialize_for_test("PublisherOptions {" + " value {" + " heartbeat_ms: 100" + " heartbeat_boot_seconds: 1" + " }" + "}"); } #ifndef _WIN32 @@ -354,7 +346,7 @@ class Co2Tests { } void test_producer_consumer() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); // Add bbo data for those expirations @@ -372,8 +364,7 @@ class Co2Tests { UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); vector consumer_securities; // Poll for security list - none visible until they have keys @@ -448,7 +439,7 @@ class Co2Tests { // When a security is added the consumer should provide callback void test_consumer_callback_on_security_added() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); // Symbol list for the consumer @@ -458,8 +449,7 @@ class Co2Tests { UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); // Add the on_security callback vector securities; @@ -494,7 +484,7 @@ class Co2Tests { // been discovered // * Case 2 - The producer has never been created void test_consumer_defer_handle1() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); set symbols; @@ -503,8 +493,7 @@ class Co2Tests { UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); // Get a handle to 24 consumers which haven't been created yet vector consumers; @@ -571,8 +560,7 @@ class Co2Tests { UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); // Get a handle to 24 consumers which haven't been created yet vector consumers; @@ -600,7 +588,7 @@ class Co2Tests { } // Only NOW create the producers (and the shared memory) - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); // Set bbo on the producers - still not public TimeStamp write_time = TimeStamp::now(); @@ -634,7 +622,7 @@ class Co2Tests { } void test_no_double_security_callback() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); // Assign ids so securities are already public in the producer assign_ids(producers.begin(), producers.end()); @@ -642,8 +630,7 @@ class Co2Tests { // Symbol list for the consumer auto symbols = get_test_symbols(); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); // Add the on_security callback - callback fires for existing securities vector securities; @@ -662,7 +649,7 @@ class Co2Tests { } void test_recovery() { - auto producer1 = make_shared(TEST_PLATFORM); + auto producer1 = make_shared(); vector producers = create_test_securities(*producer1); assign_ids(producers.begin(), producers.end()); producer1->get_channel("FOO", SECURITYTYPE_FUTURE, VENUE_BTS).heartbeat(); @@ -727,7 +714,7 @@ class Co2Tests { // Create a new producer and attempt to recover shared_ptr producer2; try { - producer2 = make_shared(TEST_PLATFORM); + producer2 = make_shared(); } catch (std::exception &) { LOG(md, Error, "Failed to create new producer"); REQUIRE(false); @@ -803,7 +790,7 @@ class Co2Tests { } void test_get_handles() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); // Add entries to the shared memory that we aren't looking for vector p2_no_id = create_test_securities(producer, "2"); @@ -824,8 +811,7 @@ class Co2Tests { UserSymbol option_symbol("FOOX", VENUE_BTS, SECURITYTYPE_OPTION); symbols.insert(option_symbol); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &symbols, true); set keys; consumer.walk_security_list( @@ -854,7 +840,7 @@ class Co2Tests { Security s1 = mkspread("S1", ++key, f1, s2); Security all_secs_array[] = {f1, o1, o2, o3, s1, s2, s3, s4}; - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers; for (auto &sec : all_secs_array) { with_security_like(sec, [&](FixedSecurity &fsec) { @@ -873,8 +859,7 @@ class Co2Tests { csymbols.insert(UserSymbol("S3", VENUE_BTS, SECURITYTYPE_SPREAD)); csymbols.insert(UserSymbol("S4", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &csymbols, true); auto check_sec = [&](const SecurityPtr &security, MDConsumerHandle handle) { @@ -913,7 +898,7 @@ class Co2Tests { Security s1 = mkspread("SS", ++key, f1, s2); Security all_secs_array[] = {f1, o1, o2, o3, s1, s2, s3, s4}; - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers; for (auto &sec : all_secs_array) { with_security_like(sec, [&](FixedSecurity &fsec) { @@ -927,8 +912,7 @@ class Co2Tests { csymbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); csymbols.insert(UserSymbol("SS", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &csymbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &csymbols, true); auto check_sec = [&](const SecurityPtr &security, MDConsumerHandle handle) { @@ -966,7 +950,7 @@ class Co2Tests { Security s1 = mkspread("SS", 500, o1, o2); Security s2 = mkspread("SS", 501, o2, o3); - MDProducer producer(TEST_PLATFORM); + MDProducer producer; map handles; auto add_security = [&](const Security &sec) { with_security_like(sec, [&](FixedSecurity &fsec) { @@ -986,8 +970,7 @@ class Co2Tests { consumer_symbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); consumer_symbols.insert(UserSymbol("SS", VENUE_BTS, SECURITYTYPE_SPREAD)); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &consumer_symbols, true); size_t security_count = 0; // Indirection for check function @@ -1043,7 +1026,7 @@ class Co2Tests { security_key k1 = 401, k2 = 402; Security o1 = mkoption("OO", k1, 2016, 5, 1, 100); Security o2 = mkoption("OO", k2, 2016, 5, 2, 200); - MDProducer producer(TEST_PLATFORM); + MDProducer producer; auto add_security = [&](const Security &sec) { unique_ptr phandle; with_security_like(sec, [&](FixedSecurity &fsec) { @@ -1057,8 +1040,7 @@ class Co2Tests { set consumer_symbols; consumer_symbols.insert(UserSymbol("OO", VENUE_BTS, SECURITYTYPE_OPTION)); SecurityCache cache; - MDConsumer consumer( - cache, nullptr, nullptr, &consumer_symbols, true, TEST_PLATFORM); + MDConsumer consumer(cache, nullptr, nullptr, &consumer_symbols, true); auto h1 = consumer.get_handle(k1); REQUIRE(h1.is_initialized()); auto h2 = consumer.get_handle(k2); @@ -1069,7 +1051,7 @@ class Co2Tests { auto yesterday = datetime::add_days(today, -1); { - co2::SettlementRecorder recorder(PLATFORM_UNSET); + co2::SettlementRecorder recorder; recorder.add_settlement(ph1, {101, 0}, yesterday); recorder.add_settlement(ph1, {102, 0}, today); recorder.add_settlement(ph2, {199, 0}, yesterday); @@ -1109,7 +1091,7 @@ class Co2Tests { // Restore persisted state { - co2::SettlementRecorder recorder(PLATFORM_UNSET); + co2::SettlementRecorder recorder; recorder.restore_settlement(ph1); recorder.restore_settlement(ph2); recorder.do_work(); @@ -1226,7 +1208,8 @@ struct Co2IndexTests { Handle handle; }; - template void gen_securities(Index &index) { + template + void gen_securities(Index &index) { unique_ptr temp; uint32_t count = 0; for (auto &id : used_ids) { @@ -1242,7 +1225,8 @@ struct Co2IndexTests { } } - template void test_random_search(Index &index) { + template + void test_random_search(Index &index) { vector temp(random_ids); utils::Shuffle::shuffle(temp.begin(), temp.end()); for (auto &id : temp) { @@ -1254,7 +1238,8 @@ struct Co2IndexTests { } } - template void test_walk(Index &index) { + template + void test_walk(Index &index) { int count = 0; index.walk_security_list([&count](const SecurityData &) { ++count; }); REQUIRE(count == (int)used_ids.size()); @@ -1304,14 +1289,7 @@ struct Co2IndexTests { struct Co2RelayTests { SecurityCache cache; Co2RelayTests() : _stats() {} - void setup() { - config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); - } + void setup() { config::internal::initialize_for_test(""); } void teardown() {} MDConsumer create_consumer() { @@ -1325,7 +1303,8 @@ struct Co2RelayTests { return consumer; } - template T simulate_wire_transfer(const T &request) { + template + T simulate_wire_transfer(const T &request) { T temp; std::string buffer; request.SerializeToString(&buffer); @@ -1373,7 +1352,7 @@ struct Co2RelayTests { } void relay_nans() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; Entitlements entitlements; @@ -1523,7 +1502,7 @@ struct Co2RelayTests { } void relay_implied() { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; // initialize data vector producers; @@ -1693,7 +1672,7 @@ void test_merge( const std::array &direct_ask, const std::array &implied_ask, const std::function &)> &validate) { - MDProducer producer(TEST_PLATFORM); + MDProducer producer; vector producers = create_test_securities(producer); auto write_time = TimeStamp::now(); @@ -1737,12 +1716,7 @@ void test_merge( } // namespace ImpliedTests TEST_CASE("MergeImpliedTests", "[md]") { - config::internal::initialize_for_test( - "PlatformMap {" - " value {" - " glbx_platform: 'PLATFORM_SIM'" - " }" - "}"); + config::internal::initialize_for_test(""); // create a handle with implied and direct std::array direct_bid, direct_ask; std::array implied_bid, implied_ask; diff --git a/src/lib/md/vendor/emumba/EmumbaDeribitData.h b/src/lib/md/vendor/emumba/EmumbaDeribitData.h index 96c469dd1..81295af80 100644 --- a/src/lib/md/vendor/emumba/EmumbaDeribitData.h +++ b/src/lib/md/vendor/emumba/EmumbaDeribitData.h @@ -22,7 +22,6 @@ struct EmumbaDeribitData { [=, this](ExchangeKey k) { return SecurityKey(sec_index.get_key(k.value())); }}), - md_producer(bts::co2::PLATFORM_SIM, recorder), - listener(sec_index, md_producer) {} + md_producer(recorder), listener(sec_index, md_producer) {} }; } // namespace bts::md diff --git a/src/server/sparkd/cmds/md/cmds/Dump.cpp b/src/server/sparkd/cmds/md/cmds/Dump.cpp index a8d71cfd3..0be9687c1 100644 --- a/src/server/sparkd/cmds/md/cmds/Dump.cpp +++ b/src/server/sparkd/cmds/md/cmds/Dump.cpp @@ -1,5 +1,4 @@ #include "Dump.h" -#include "../common/PlatformOption.h" #include "../common/SecurityTypeOption.h" #include "../common/VenueOption.h" #include "lib/config/config.h" @@ -23,7 +22,6 @@ struct Dump::Args { std::string symbol; bts::api::SecurityType security_type; bts::api::Venue venue; - bts::co2::Platform platform; bool hot; }; @@ -40,15 +38,12 @@ Dump::Dump() add_option("venue,--venue", _args->venue, "Venue") ->transform( CLI::CheckedTransformer(VenueOption::names(), CLI::ignore_case)); - add_option("platform,--platform", _args->platform, "Platform") - ->transform( - CLI::CheckedTransformer(PlatformOption::names(), CLI::ignore_case)); // flags add_flag("--hot", _args->hot); callback([&] { const auto prefix = bts::md::ShmSegmentName::prefix( - _args->symbol, _args->security_type, _args->venue, _args->platform); + _args->symbol, _args->security_type, _args->venue); bts::md::ShmDumper dumper(prefix); if (_args->hot) dumper.dump_hot(); diff --git a/src/server/sparkd/cmds/md/cmds/Tail.cpp b/src/server/sparkd/cmds/md/cmds/Tail.cpp index e95184763..b6c820940 100644 --- a/src/server/sparkd/cmds/md/cmds/Tail.cpp +++ b/src/server/sparkd/cmds/md/cmds/Tail.cpp @@ -15,28 +15,19 @@ using bts::domain::SecurityCriteria; using bts::md::SymbolLoader; struct Tail::Args { - bts::co2::Platform platform; bts::md::PrintFormat format; long mod; bool all; std::string qualifier; }; -Tail::Tail() : - CLI::App("Print out books when sequence%count==0", "tail"), - _args(new Tail::Args()) { +Tail::Tail() + : CLI::App("Print out books when sequence%count==0", "tail"), + _args(new Tail::Args()) { add_option( "--mod,--modulus", _args->mod, - "Sequence count modulus (i.e., inverse print frequency with respect to sequence count)"); - // platform - std::map platform_names{ - {"celoxica", bts::co2::PLATFORM_CELOXICA}, - {"iceonixs", bts::co2::PLATFORM_ICEONIXS}, - {"mdp3emumba", bts::co2::PLATFORM_MDP3EMUMBA}, - {"mdp3onixs", bts::co2::PLATFORM_MDP3ONIXS}, - {"sim", bts::co2::PLATFORM_SIM}}; - add_option("--platform", _args->platform, "Platform to monitor") - ->transform(CLI::CheckedTransformer(platform_names, CLI::ignore_case)); + "Sequence count modulus (i.e., inverse print frequency with respect to " + "sequence count)"); // format std::map format_names{ {"csv", bts::md::PrintFormat::CSV}, diff --git a/src/server/sparkd/cmds/md/common/PlatformOption.cpp b/src/server/sparkd/cmds/md/common/PlatformOption.cpp deleted file mode 100644 index 589c35949..000000000 --- a/src/server/sparkd/cmds/md/common/PlatformOption.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "PlatformOption.h" - -namespace bts::cmds::md { - -#define NAME_PAIR(val) \ - { name(val), val } - -EnumOptionNames PlatformOption::names() { - return { - NAME_PAIR(co2::PLATFORM_CELOXICA), NAME_PAIR(co2::PLATFORM_ICEONIXS), - NAME_PAIR(co2::PLATFORM_MDP3EMUMBA), NAME_PAIR(co2::PLATFORM_MDP3ONIXS), - NAME_PAIR(co2::PLATFORM_SIM)}; -} - -std::string PlatformOption::name(bts::co2::Platform platform) { - switch (platform) { - case co2::PLATFORM_CELOXICA: - return "celoxica"; - case co2::PLATFORM_ICEONIXS: - return "iceonixs"; - case co2::PLATFORM_MDP3EMUMBA: - return "mdp3emumba"; - case co2::PLATFORM_MDP3ONIXS: - return "mdp3onixs"; - case co2::PLATFORM_SIM: - return "sim"; - default: - return std::to_string(static_cast(platform)); - } -} - -} // namespace bts::cmds::md diff --git a/src/server/sparkd/cmds/md/common/PlatformOption.h b/src/server/sparkd/cmds/md/common/PlatformOption.h deleted file mode 100644 index 6a3b0c698..000000000 --- a/src/server/sparkd/cmds/md/common/PlatformOption.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "../../common/EnumOptionNames.h" -#include "lib/md/protos/co2.pb.h" -#include -#include - -namespace bts::cmds::md { - -struct PlatformOption { - static EnumOptionNames names(); - static std::string name(co2::Platform); -}; - -} // namespace bts::cmds::md diff --git a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp index 514bc9ffe..055e718b4 100644 --- a/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp +++ b/src/server/sparkd/exchange_sim/ExchangeSimApplication.cpp @@ -78,8 +78,8 @@ FIX::OrdType convert(api::orderman::NativeOrderType type) { } } -FIX::ManualOrderIndicator -convert(const api::orderman::ManualOrderIndicator &moi) { +FIX::ManualOrderIndicator convert( + const api::orderman::ManualOrderIndicator &moi) { switch (moi) { case api::orderman::MANUAL_ORDER_INDICATOR_YES: return FIX::ManualOrderIndicator(true); @@ -88,8 +88,8 @@ convert(const api::orderman::ManualOrderIndicator &moi) { } } -api::orderman::ManualOrderIndicator -convert(const FIX::ManualOrderIndicator &moi) { +api::orderman::ManualOrderIndicator convert( + const FIX::ManualOrderIndicator &moi) { if (moi.getValue()) return api::orderman::MANUAL_ORDER_INDICATOR_YES; else @@ -107,11 +107,10 @@ inline FIX::OrderID exchange_key(const std::string &clOrdID) { struct ExchangeSimApplication::PImpl { PImpl(bts::api::Venue venue, md::MBOWriter *mbo) - : venue(venue), producer(co2::PLATFORM_SIM), md_sn(1), - timer( - utils::Dispatcher::background(), - 200, - [=]() { producer.heartbeat(); }), + : venue(venue), md_sn(1), timer( + utils::Dispatcher::background(), + 200, + [=]() { producer.heartbeat(); }), do_merge_with_md(config::get().merge_with_md()), store(new persistence::SqliteStore( "ex_sim_orders_" + boost::to_lower_copy(api::Venue_Name(venue)))), @@ -119,7 +118,7 @@ struct ExchangeSimApplication::PImpl { IDGenerator m_generator; bts::api::Venue venue; - md::MDProducer producer; + md::MDProducer producer{}; std::map md_consumer_recs; std::map md_producer_handles; uint32_t md_sn; @@ -158,17 +157,19 @@ void ExchangeSimApplication::onCreate(const FIX::SessionID &) {} void ExchangeSimApplication::onLogon(const FIX::SessionID &) {} void ExchangeSimApplication::onLogout(const FIX::SessionID &) {} void ExchangeSimApplication::toAdmin(FIX::Message &, const FIX::SessionID &) {} -void ExchangeSimApplication::toApp( - FIX::Message &, const FIX::SessionID &) EXCEPT(FIX::DoNotSend) {} -void ExchangeSimApplication:: - fromAdmin(const FIX::Message &, const FIX::SessionID &) EXCEPT( +void ExchangeSimApplication::toApp(FIX::Message &, const FIX::SessionID &) + EXCEPT(FIX::DoNotSend) {} +void ExchangeSimApplication::fromAdmin( + const FIX::Message &, const FIX::SessionID &) + EXCEPT( FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon) {} -void ExchangeSimApplication:: - fromApp(const FIX::Message &message, const FIX::SessionID &sessionID) EXCEPT( +void ExchangeSimApplication::fromApp( + const FIX::Message &message, const FIX::SessionID &sessionID) + EXCEPT( FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, diff --git a/src/server/sparkd/md/platforms/emumba/EmumbaMain.cpp b/src/server/sparkd/md/platforms/emumba/EmumbaMain.cpp index c26d6fbe9..748a89251 100644 --- a/src/server/sparkd/md/platforms/emumba/EmumbaMain.cpp +++ b/src/server/sparkd/md/platforms/emumba/EmumbaMain.cpp @@ -47,8 +47,7 @@ struct EmumbaMain::PImpl { [=, this](ExchangeKey k) { return SecurityKey(sec_index.get_key(k.value())); }}), - producer(bts::co2::PLATFORM_SIM, recorder), - listener(sec_index, producer) { + producer(recorder), listener(sec_index, producer) { const auto config_path = Path{config::get().config_path()} / "deribit_demo_config.json"; diff --git a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp index e388a3388..4bcd0c9d4 100644 --- a/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp +++ b/src/server/sparkd/md/platforms/ice_onixs/ICEMain.cpp @@ -52,7 +52,7 @@ ICEMain::ICEMain() [=, this](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); }}), - _producer(PLATFORM_ICEONIXS, _recorder), _handlers(), _listeners() {} + _producer(_recorder), _handlers(), _listeners() {} ICEMain::~ICEMain() {} @@ -65,8 +65,8 @@ const IceChannelConfig channel_settings_for(const ICEChannel &channel) { return {}; } -onixs_ice::MarketSubscriptions -market_subcription_for_channel(const ICEChannel &chan) { +onixs_ice::MarketSubscriptions market_subcription_for_channel( + const ICEChannel &chan) { onixs_ice::MarketSubscriptions subs; for (const auto &x : chan.market_types) { onixs_ice::MarketSubscription futures( diff --git a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp index be73e62f4..9ad5c53ba 100644 --- a/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp +++ b/src/server/sparkd/md/platforms/mdp3_onixs/MDP3Main.cpp @@ -35,9 +35,8 @@ MDP3Main::MDP3Main() [=, this](ExchangeKey k) { return SecurityKey(_index.get_key(k.value())); }}), - _producer(PLATFORM_MDP3ONIXS, _recorder), - // _settlement_recorder(PLATFORM_MDP3ONIXS), - _engines(), _handlers(), _listeners(), _recovery() {} + _producer(_recorder), _engines(), _handlers(), _listeners(), _recovery() { +} MDP3Main::~MDP3Main() {} @@ -86,23 +85,23 @@ const onixs::FeedEngineSettings feed_engine_settings_from_config( if (settings.num_threads() != 0) { result.threadCount(settings.num_threads()); } else { - bts_assert(settings.channels_per_thread()>0); + bts_assert(settings.channels_per_thread() > 0); // If num_threads is absent determine thread count based on #channels result.threadCount((feed_count / settings.channels_per_thread()) + 1); } return result; } -size_t -count_engine_uses(const vector &channels, const string &feed_name) { +size_t count_engine_uses( + const vector &channels, const string &feed_name) { return count_if(channels.begin(), channels.end(), [&](const CMEChannel &ch) { const auto &settings = channel_settings_for(ch.id); return settings.feed_engine() == feed_name; }); } -map -create_feed_engine_settings(const std::vector &channels) { +map create_feed_engine_settings( + const std::vector &channels) { map settings; const auto &config = config::get(); @@ -120,8 +119,8 @@ create_feed_engine_settings(const std::vector &channels) { return settings; } -map> -create_feed_engines(const vector &channels) { +map> create_feed_engines( + const vector &channels) { map> result; auto settings = create_feed_engine_settings(channels); // Loop through settings and instantiate feed engines @@ -133,8 +132,8 @@ create_feed_engines(const vector &channels) { return result; } -onixs::SessionSettings -session_settings_for_channel(const string &channel_id, MBOWriter *mbo) { +onixs::SessionSettings session_settings_for_channel( + const string &channel_id, MBOWriter *mbo) { const auto &options = channel_settings_for(channel_id); onixs::SessionSettings settings; @@ -211,8 +210,8 @@ void MDP3Main::initialize(const std::string &license_store) { // // // Initialize HandlerSettings and allocate the channel Handler -unique_ptr -MDP3Main::prepare_handler(const string &channel_id, MBOWriter *mbo) { +unique_ptr MDP3Main::prepare_handler( + const string &channel_id, MBOWriter *mbo) { const auto &pub_options = config::get(); const auto &options = channel_settings_for(channel_id); LOG(md, Info, "Loaded channel options for channel {}:\n{}", channel_id,