fix: Disable ccapi md provider if venue has empty symbols config
Previously, ccapi exchanges (e.g., binance) would subscribe to EVERYTHING if symbols config was empty. There are way too many symbols for that.
This commit is contained in:
1 parent
7b933026bb
commit
eccfd1ee30
1 file changed
+65
-38
@@ -1,5 +1,5 @@
|
||||
#include "CCApiMarketDataProvider.h"
|
||||
#include "spark/api/domain/Venue.pb.h"
|
||||
#include "spark/api/domain/Venue.h"
|
||||
#include "spark/api/md/MarketDataConfig.pb.h"
|
||||
#include "spark/config/config.h"
|
||||
#include "spark/io/ProtoPrinter.h"
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "spark/md/GeneralMarketDataListener.h"
|
||||
#include "spark/md/GeneralSecurityIndex.h"
|
||||
#include "spark/md/MDProducer.h"
|
||||
#include "spark/md/SymbolLoader.h"
|
||||
#include "spark/md/UserSymbol.h"
|
||||
#include "spark/persistence/IDGenerator.h"
|
||||
#include "sparkd/md/binance/BinanceSubscription.h"
|
||||
#include "sparkd/md/binance_us/BinanceUsSubscription.h"
|
||||
@@ -82,56 +84,81 @@ CCApiMarketDataProvider::get_sources() {
|
||||
"CCApiMarketDataProvider::get_sources failed. Invalid config: {}",
|
||||
fmt::to_string(fmt::join(cfg_errs, "\n")));
|
||||
}
|
||||
|
||||
std::set<UserSymbol> syms;
|
||||
auto is_venue_enabled = [&syms](api::domain::Venue venue) {
|
||||
syms.clear();
|
||||
SymbolLoader::load(syms, domain::SecurityCriteria::create({venue}));
|
||||
if (syms.empty()) {
|
||||
LOG(md, Warn,
|
||||
R"([ccapi_md_pro_disabled.json]{{ "venue": "{}", "rsn": "No symbols config", "ts": {} }})",
|
||||
venue, core::TimeStamp::now_ns());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
// Binance
|
||||
for (const auto &binance : cfg.binance()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE,
|
||||
std::make_shared<binance::BinanceSubscription>(
|
||||
&me_->dispatcher, binance, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_BINANCE)) {
|
||||
for (const auto &binance : cfg.binance()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE,
|
||||
std::make_shared<binance::BinanceSubscription>(
|
||||
&me_->dispatcher, binance, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// Binance US
|
||||
for (const auto &binance_us : cfg.binance_us()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE_US,
|
||||
std::make_shared<binance_us::BinanceUsSubscription>(
|
||||
&me_->dispatcher, binance_us, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_BINANCE_US)) {
|
||||
for (const auto &binance_us : cfg.binance_us()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE_US,
|
||||
std::make_shared<binance_us::BinanceUsSubscription>(
|
||||
&me_->dispatcher, binance_us, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// Binance USDS Futures
|
||||
for (const auto &binance_ufs : cfg.binance_usds_futures()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE_USDS_FUTURES,
|
||||
std::make_shared<
|
||||
binance_usds_futures::BinanceUsdsFuturesSubscription>(
|
||||
&me_->dispatcher, binance_ufs, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_BINANCE_USDS_FUTURES)) {
|
||||
for (const auto &binance_ufs : cfg.binance_usds_futures()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_BINANCE_USDS_FUTURES,
|
||||
std::make_shared<
|
||||
binance_usds_futures::BinanceUsdsFuturesSubscription>(
|
||||
&me_->dispatcher, binance_ufs, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// Coinbase
|
||||
for (const auto &coinbase : cfg.coinbase()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_COINBASE,
|
||||
std::make_shared<coinbase::CoinbaseSubscription>(
|
||||
&me_->dispatcher, coinbase, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_COINBASE)) {
|
||||
for (const auto &coinbase : cfg.coinbase()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_COINBASE,
|
||||
std::make_shared<coinbase::CoinbaseSubscription>(
|
||||
&me_->dispatcher, coinbase, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// Deribit
|
||||
for (const auto &deribit : cfg.deribit()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_DERIBIT,
|
||||
std::make_shared<deribit::DeribitSubscription>(
|
||||
&me_->dispatcher, deribit, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_DERIBIT)) {
|
||||
for (const auto &deribit : cfg.deribit()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_DERIBIT,
|
||||
std::make_shared<deribit::DeribitSubscription>(
|
||||
&me_->dispatcher, deribit, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// FTX
|
||||
for (const auto &ftx : cfg.ftx()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_FTX,
|
||||
std::make_shared<ftx::FTXSubscription>(
|
||||
&me_->dispatcher, ftx, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_FTX)) {
|
||||
for (const auto &ftx : cfg.ftx()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_FTX,
|
||||
std::make_shared<ftx::FTXSubscription>(
|
||||
&me_->dispatcher, ftx, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
// Okx
|
||||
for (const auto &okx : cfg.okx()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_OKX,
|
||||
std::make_shared<okx::OkxSubscription>(
|
||||
&me_->dispatcher, okx, me_->sec_id_store.get()));
|
||||
if (is_venue_enabled(api::domain::VENUE_OKX)) {
|
||||
for (const auto &okx : cfg.okx()) {
|
||||
me_->sources.emplace_back(
|
||||
api::domain::VENUE_OKX,
|
||||
std::make_shared<okx::OkxSubscription>(
|
||||
&me_->dispatcher, okx, me_->sec_id_store.get()));
|
||||
}
|
||||
}
|
||||
return me_->sources;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user