diff --git a/src/server/sparkd/md/MarketDataGateway.cpp b/src/server/sparkd/md/MarketDataGateway.cpp index a6a613711..7d2945467 100644 --- a/src/server/sparkd/md/MarketDataGateway.cpp +++ b/src/server/sparkd/md/MarketDataGateway.cpp @@ -16,6 +16,7 @@ #include "lib/persistence/IDGenerator.h" #include "lib/utils/bts_assert.h" #include "lib/utils/bts_fatal.h" +#include "lib/utils/helper_macros.h" #include "lib/utils/thread_manager.h" #include "server/sparkd/md/MarketDataListenerID.h" #include "server/sparkd/md/MarketDataRegistration.h" @@ -25,6 +26,7 @@ #include "server/sparkd/md/binance/BinanceSubscription.h" #include "server/sparkd/md/binance_us/BinanceUsSubscription.h" #include "server/sparkd/md/binance_usds_futures/BinanceUsdsFuturesSubscription.h" +#include "server/sparkd/md/cboe/CboeMarketDataHandler.h" #include "server/sparkd/md/coinbase/CoinbaseSubscription.h" #include "server/sparkd/md/deribit/DeribitSubscription.h" #include "server/sparkd/md/emumba/EmumbaDeribitData.h" @@ -36,7 +38,9 @@ #include #include +#include #include +#include #include #include #include @@ -279,6 +283,71 @@ void MarketDataGateway::_start_onix_glbx( bts::md::run_onixs(); } +static void run_cboe( + bts::api::md::CboeMarketDataConfig cfg, + persistence::IDGenerator *sec_id_store) { + LOG(md, Info, "MarketDataGateway::run_cboe t_id:{} t_name", + os::get_thread_id(), os::get_thread_name()); + bts::md::GeneralSecurityIndex sec_index; + bts::md::MDProducer md_producer; + std::shared_ptr listener = + std::make_shared( + sec_index, md_producer, bts::api::VENUE_CBOE); + UNUSED(cfg); + UNUSED(sec_id_store); + assert(false); +// bts::md::cboe::CboeMarketDatahandler::run(cfg.read_from_file(), listener,sec_id_store); + // Timers + // auto &disp = utils::Dispatcher::current(); + // utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { + // for (auto &p : platforms) + // p->send_heartbeats(); + // }); + // heartbeat_timer.start(); + // disp.run(); +} +void MarketDataGateway::_start_cboe( + bts::api::md::CboeMarketDataConfig cfg) { + LOG(md, Error, + "MarketDataGateway::_start_cboe starting t_id:{} t_name:{}. " + "cfg:\n{}", + os::get_thread_id(), os::get_thread_name(), cfg.DebugString()); + threading::make_thread("Cboe", [&]() { bts::md::run_cboe(cfg, &me_->sec_id_store);; }).detach(); + +} +static void run_taifex( + bts::api::md::TaifexMarketDataConfig cfg, + persistence::IDGenerator *sec_id_store) { + LOG(md, Info, "MarketDataGateway::run_taifex t_id:{} t_name", + os::get_thread_id(), os::get_thread_name()); + bts::md::GeneralSecurityIndex sec_index; + bts::md::MDProducer md_producer; + std::shared_ptr listener = + std::make_shared( + sec_index, md_producer, bts::api::VENUE_TAIFEX); + bts::md::taifex::TaifexDatahandler::run(cfg.read_from_file(), listener,sec_id_store); + // Timers + // auto &disp = utils::Dispatcher::current(); + // utils::DispatcherTimer heartbeat_timer(disp, 250, [&]() { + // for (auto &p : platforms) + // p->send_heartbeats(); + // }); + // heartbeat_timer.start(); + // disp.run(); +} +void MarketDataGateway::_start_taifex( + bts::api::md::TaifexMarketDataConfig cfg) { + LOG(md, Error, + "MarketDataGateway::_start_taifex starting t_id:{} t_name:{}. " + "cfg:\n{}", + os::get_thread_id(), os::get_thread_name(), cfg.DebugString()); + threading::make_thread("Taifex", [&]() { bts::md::run_taifex(cfg, &me_->sec_id_store);; }).detach(); + LOG(md, Info, "MarketDataGateway::_start_taifez ending t_id:{} t_name:{}", + os::get_thread_id(), os::get_thread_name()); + +} + + // deribit //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/src/server/sparkd/md/taifex/TaifexDataHandler.cpp b/src/server/sparkd/md/taifex/TaifexDataHandler.cpp index ce2dd63e5..3a56b0ce5 100644 --- a/src/server/sparkd/md/taifex/TaifexDataHandler.cpp +++ b/src/server/sparkd/md/taifex/TaifexDataHandler.cpp @@ -3,9 +3,13 @@ #include "lib/config/config.h" #include "lib/domain/Price.h" #include "lib/domain/Security.h" +<<<<<<< Updated upstream #include "lib/md/IMarketDataListener.h" #include "lib/persistence/IDGenerator.h" +======= +#include "lib/logging/logging.h" +>>>>>>> Stashed changes #include #include #include @@ -1030,7 +1034,7 @@ bool readBinaryFile(const std::string &file_name, size_t counter = 0; size_t hits = 0; const size_t hits_limit = 5; - const size_t limit = 1000000; + const size_t limit = 10000; std::unordered_set names; @@ -1061,17 +1065,29 @@ bool readBinaryFile(const std::string &file_name, // std::cout << "we are looking for this!" << std::endl; auto i010_message = I010Data(buffer, position + HEADER_SIZE, Header.Body_Length + FOOTER_SIZE); + const auto remove_spaces= [](const std::string &name){ + std::string removed = ""; + const char space = ' '; + for (auto c:name){ + if(c!=space){ + removed+=c; + } + } + return removed; + }; + const auto id = remove_spaces(i010_message.prod_id); + const auto symbol = id.substr(0,2); bts::domain::SecurityID sec_id{ - sec_id_store->get_or_add(api::domain::VENUE_TAIFEX, i010_message.prod_id)}; + sec_id_store->get_or_add(api::domain::VENUE_TAIFEX, id)}; std::vector complete_security_list; bts::domain::Security &sec = complete_security_list.emplace_back(); sec.security_common.venue = bts::api::domain::VENUE_TAIFEX; sec.security_common.id = sec_id; - sec.security_common.exchange_sec_id = i010_message.prod_id; // Need to fix this - sec.security_common.desc = i010_message.prod_id; - sec.security_common.symbol = i010_message.prod_id; - sec.security_common.asset = i010_message.prod_id; - sec.security_common.group = i010_message.prod_id; + sec.security_common.exchange_sec_id = id; // Need to fix this + sec.security_common.desc = id; + sec.security_common.symbol = symbol; + sec.security_common.asset = id; + sec.security_common.group = id; sec.security_common.min_price_increment = 0.1; sec.security_common.min_quantity = 1; sec.security_common.min_quantity_increment = 0.1; @@ -1081,11 +1097,16 @@ bool readBinaryFile(const std::string &file_name, case I010Data::ProductInfo::ProductType::FUTURES: { auto &t = sec.security.emplace(); //assuming time stamp - std::tm tm = {}; - std::istringstream iss(i010_message.end_date); - iss >> std::get_time(&tm, "%Y%m%d"); - std::time_t time = std::mktime(&tm); - t.expiration = bts::core::TimeStamp(static_cast(time)); + // std::tm tm = {}; + // std::istringstream iss(i010_message.end_date); + // iss >> std::get_time(&tm, "%Y%m%d"); + // std::time_t time = std::mktime(&tm); + LOG(md, Error, "DATE {}",i010_message.end_date); + std::cout<<"hello world "<< i010_message.end_date<on_securities(const_security_list); - hits++; + // hits++; break; //std::cout << i010_message << std::endl; @@ -1194,6 +1215,7 @@ bool readBinaryFile(const std::string &file_name, //const std::string &filename, void bts::md::taifex::TaifexDatahandler::run( +<<<<<<< Updated upstream bool use_file, std::shared_ptr listner, std::shared_ptr sec_id_store) { @@ -1207,3 +1229,17 @@ void bts::md::taifex::TaifexDatahandler::run( } }//namespace bts::md::taifex +======= + const bool &use_file, + std::shared_ptr listner, + persistence::IDGenerator *sec_id_store) { + std::string file_name = "/reference_data_20240806_1"; + if(use_file){ + std::string base_path = config::get().data_path(); + readBinaryFile(base_path+file_name, listner, sec_id_store); + while(1); + } + // bts_assert_msg(false, "inside run taifex"); + } +}//namespace bts::md::taifex +>>>>>>> Stashed changes