#include "BinanceDepthStreamSite.h" #include "lib/collections/UnorderedSetMap.h" #include "lib/api/md/binance/BinanceMarketDataSubscriptionParams.pb.h" #include "lib/domain/SecurityID.h" #include "lib/domain/SecurityResolver.h" #include "lib/domain/Venue.h" #include "lib/io/URL.h" #include "lib/io/websocket/WebsocketClient.h" #include "lib/md/IMarketDataListener.h" #include "lib/md/MarketDataListenerData.h" #include "lib/md/MarketDataListenerID.h" #include "lib/md/binance/BinanceDepthStreamSiteKey.h" #include "lib/md/binance/BinanceDiffDepthSubscription.h" #include "lib/md/binance/BinanceDiffDepthUpdate.h" #include "lib/utils/ContainsKey.h" #include "lib/utils/bts_assert.h" #include #include namespace bts::md::binance { BinanceDepthStreamSite::BinanceDepthStreamSite( BinanceDepthStreamSiteKey site_key, collections::UnorderedSetMap *sec_listeners_ptr, std::unordered_map *listeners_ptr) : site_key_(std::move(site_key)), sec_listeners_ptr_(sec_listeners_ptr), listeners_ptr_(listeners_ptr) {} collections::UnorderedSetMap & BinanceDepthStreamSite::sec_listeners_() { return *sec_listeners_ptr_; } const collections::UnorderedSetMap & BinanceDepthStreamSite::sec_listeners_() const { return *sec_listeners_ptr_; } std::unordered_map & BinanceDepthStreamSite::listeners_() { return *listeners_ptr_; } const std::unordered_map & BinanceDepthStreamSite::listeners_() const { return *listeners_ptr_; } void BinanceDepthStreamSite::connect() { auto &b = binance_.emplace(site_key_.params()); // (re)bind the callback b.on_depth_changed().bind<&BinanceDepthStreamSite::fwd_on_depth_changed_>( *this); b.connect(); } void BinanceDepthStreamSite::ensure_connect_() { if (!binance_) { connect(); } } BinanceDiffDepthSubscription::OnDepthChanged & BinanceDepthStreamSite::on_depth_changed() { return on_depth_changed_proxy_; } void BinanceDepthStreamSite::fwd_on_depth_changed_( const std::string &symbol, bts::md::binance::BinanceDiffDepthUpdate update) { on_depth_changed_proxy_(symbol, update); } } // namespace bts::md::binance