diff --git a/src/Spark.Admin.WebApp/src/Spark.Admin.WebApp.fsproj b/src/Spark.Admin.WebApp/src/Spark.Admin.WebApp.fsproj index b1786e5c0..cd6637db9 100644 --- a/src/Spark.Admin.WebApp/src/Spark.Admin.WebApp.fsproj +++ b/src/Spark.Admin.WebApp/src/Spark.Admin.WebApp.fsproj @@ -33,6 +33,7 @@ + diff --git a/src/app_sparkd/sparkd/exchange_sim/ExchangeSimApplication.cpp b/src/app_sparkd/sparkd/exchange_sim/ExchangeSimApplication.cpp index 0abc5bbf2..a44b93fe9 100644 --- a/src/app_sparkd/sparkd/exchange_sim/ExchangeSimApplication.cpp +++ b/src/app_sparkd/sparkd/exchange_sim/ExchangeSimApplication.cpp @@ -34,6 +34,8 @@ namespace ex_sim { GCC_DIAG_OFF("-Wdeprecated") GCC_DIAG_OFF("-Wignored-qualifiers") +#define AGGRESSOR_SIDE(x) bts::domain::protobufs::AGGRESSOR_SIDE_##x + api::Side convert(const FIX::Side &side) { switch (side) { case FIX::Side_BUY: @@ -539,9 +541,9 @@ void ExchangeSimApplication::update_md(std::string const &sec_desc) { md::PriceSize_from_double( t.price.value() * price_factor, t.quantity.value()), datetime::ll_now(), - t.bid_aggressor ? co2::AGGRESSOR_SIDE_BUY - : (t.ask_aggressor ? co2::AGGRESSOR_SIDE_SELL - : co2::AGGRESSOR_SIDE_NONE)); + t.bid_aggressor ? AGGRESSOR_SIDE(BUY) + : (t.ask_aggressor ? AGGRESSOR_SIDE(SELL) + : AGGRESSOR_SIDE(NONE))); } // publish mbo diff --git a/src/app_sparkd/sparkd/md/ChannelVolume.cpp b/src/app_sparkd/sparkd/md/ChannelVolume.cpp index 3344b2d5f..e9984f71b 100644 --- a/src/app_sparkd/sparkd/md/ChannelVolume.cpp +++ b/src/app_sparkd/sparkd/md/ChannelVolume.cpp @@ -9,10 +9,12 @@ namespace auxiliary { using namespace bts::co2; using namespace bts::api::md::auxiliary; +#define AGGRESSOR_SIDE(x) bts::domain::protobufs::AGGRESSOR_SIDE_##x + ChannelVolume::ChannelVolume(SecurityChannel *channel) : _channel(channel) {} -const VolumeAtPriceLevel & -ChannelVolume::add_trade(const TradeMessage &m, int &record_id) { +const VolumeAtPriceLevel &ChannelVolume::add_trade( + const TradeMessage &m, int &record_id) { auto price_map_it = _sec_map.find(m.key()); if (price_map_it == _sec_map.end()) { _sec_map[m.key()] = std::unordered_map(); @@ -31,12 +33,13 @@ ChannelVolume::add_trade(const TradeMessage &m, int &record_id) { } VolumeAtPriceLevel &vol = price_it->second; vol.set_volume(vol.volume() + m.size()); - if (m.aggressor_side() == AggressorSide::AGGRESSOR_SIDE_BUY) + if (m.aggressor_side() == AGGRESSOR_SIDE(BUY)) { vol.set_buy_volume(vol.buy_volume() + m.size()); - else if (m.aggressor_side() == AggressorSide::AGGRESSOR_SIDE_SELL) + } else if (m.aggressor_side() == AGGRESSOR_SIDE(SELL)) { vol.set_sell_volume(vol.sell_volume() + m.size()); - else if (m.aggressor_side() == AggressorSide::AGGRESSOR_SIDE_NONE) + } else if (m.aggressor_side() == AGGRESSOR_SIDE(NONE)) { vol.set_passive_volume(vol.passive_volume() + m.size()); + } return vol; } @@ -52,4 +55,4 @@ bool ChannelVolume::match_update(const SecurityChannel &channel) { } // namespace auxiliary } // namespace md -} // namespace bts \ No newline at end of file +} // namespace bts diff --git a/src/app_sparkd/sparkd/md/PyMarketDataSubscription.cpp b/src/app_sparkd/sparkd/md/PyMarketDataSubscription.cpp index eab7179ab..c662e660f 100644 --- a/src/app_sparkd/sparkd/md/PyMarketDataSubscription.cpp +++ b/src/app_sparkd/sparkd/md/PyMarketDataSubscription.cpp @@ -1,6 +1,6 @@ #include "PyMarketDataSubscription.h" -#include "domain/aggressor_side.h" #include "domain/future_security.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "domain/protobufs/call_put.pb.h" #include "domain/protobufs/venue.h" #include "domain/security.h" @@ -30,6 +30,8 @@ namespace bts::md { +#define AGGRESSOR_SIDE(x) bts::domain::protobufs::AGGRESSOR_SIDE_##x + using bts::api::md::PyMarketDataProviderConfig; using bts::domain::SecurityID; using bts::md::py_interop::PyBook; @@ -208,8 +210,8 @@ struct PyMarketDataSubscription::PImpl : private py_interop::MdSink { dest.time_stamp = core::TimeStamp::from_nanos(source.timestamp()); dest.agg_side = source.aggressor_side().starts_with('B') || source.aggressor_side().starts_with('b') - ? domain::AggressorSide::Buy - : domain::AggressorSide::Sell; + ? AGGRESSOR_SIDE(BUY) + : AGGRESSOR_SIDE(SELL); dest.trade_price = domain::Price::from_double(source.price()); *dest.trade_quantity = source.quantity(); } diff --git a/src/app_sparkd/sparkd/md/ccapi/CCApiTradeRecord.cpp b/src/app_sparkd/sparkd/md/ccapi/CCApiTradeRecord.cpp index f66e6f0a4..5477bd8dd 100644 --- a/src/app_sparkd/sparkd/md/ccapi/CCApiTradeRecord.cpp +++ b/src/app_sparkd/sparkd/md/ccapi/CCApiTradeRecord.cpp @@ -1,6 +1,6 @@ #include "CCApiTradeRecord.h" -#include "domain/aggressor_side.h" #include "domain/price.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "domain/quantity.h" #include "domain/trade_record.h" #include "spark/io/JsonDumper.h" @@ -18,6 +18,8 @@ namespace bts::md { +#define AGGRESSOR_SIDE(x) bts::domain::protobufs::AGGRESSOR_SIDE_##x + using bts::domain::TradeRecord; using bts::io::JsonDumper; using bts::io::JsonReader; @@ -34,8 +36,7 @@ void CCApiTradeRecord::to_trade_record(TradeRecord &value) const { value.trade_quantity.value() = static_cast(std::max(last_size * 1000, 1.0)); - value.agg_side = is_buyer_maker ? domain::AggressorSide::Buy - : domain::AggressorSide::Sell; + value.agg_side = is_buyer_maker ? AGGRESSOR_SIDE(BUY) : AGGRESSOR_SIDE(SELL); } bool CCApiTradeRecord::parse( diff --git a/src/app_sparkd/sparkd/md/deribit/DeribitTradeAdaptor.cpp b/src/app_sparkd/sparkd/md/deribit/DeribitTradeAdaptor.cpp index cd516fda4..c8417d90d 100644 --- a/src/app_sparkd/sparkd/md/deribit/DeribitTradeAdaptor.cpp +++ b/src/app_sparkd/sparkd/md/deribit/DeribitTradeAdaptor.cpp @@ -1,5 +1,5 @@ #include "DeribitTradeAdaptor.h" -#include "domain/aggressor_side.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "domain/security_id.h" #include "domain/trade_record.h" #include "spark/core/TimeStamp.h" @@ -11,8 +11,9 @@ namespace bts::md::deribit { +#define AGGRESSOR_SIDE(x) bts::domain::protobufs::AGGRESSOR_SIDE_##x + using bts::core::TimeStamp; -using bts::domain::AggressorSide; using bts::domain::SecurityID; using bts::domain::TradeRecord; using nlohmann::json; @@ -68,7 +69,7 @@ void DeribitTradeAdaptor::on_trades(const vector &trades) { std::string direction; get_value(*trade_it, "direction", direction); bts_trade.agg_side = - direction == "buy" ? AggressorSide::Buy : AggressorSide::Sell; + direction == "buy" ? AGGRESSOR_SIDE(BUY) : AGGRESSOR_SIDE(SELL); } } catch (...) { LOG(md, Error, "Failed to parse DeribitTradeUpdate. json:\n{}", diff --git a/src/app_sparkd/sparkd/md/okx/OkxSide.h b/src/app_sparkd/sparkd/md/okx/OkxSide.h index 2443fb7bb..d02310cc7 100644 --- a/src/app_sparkd/sparkd/md/okx/OkxSide.h +++ b/src/app_sparkd/sparkd/md/okx/OkxSide.h @@ -1,6 +1,6 @@ #pragma once -#include "domain/aggressor_side.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "domain/side.h" #include "spark/core/EnumMacros.h" #include "spark/core/FMT_IMPL.h" @@ -31,7 +31,7 @@ class OkxSide { std::string name_j() const; constexpr domain::Side to_domain_side() const; - constexpr domain::AggressorSide to_domain_agg_side() const; + constexpr domain::protobufs::AggressorSide to_domain_agg_side() const; }; ENUM_OUTPUT_OPS(OkxSide) @@ -59,14 +59,14 @@ constexpr domain::Side OkxSide::to_domain_side() const { } } -constexpr domain::AggressorSide OkxSide::to_domain_agg_side() const { +constexpr domain::protobufs::AggressorSide OkxSide::to_domain_agg_side() const { switch (value) { case BUY: - return domain::AggressorSide::Buy; + return domain::protobufs::AGGRESSOR_SIDE_BUY; case SELL: - return domain::AggressorSide::Sell; + return domain::protobufs::AGGRESSOR_SIDE_SELL; default: - return domain::AggressorSide::None; + return domain::protobufs::AGGRESSOR_SIDE_NONE; } } diff --git a/src/app_sparkd/sparkd/md/platforms/emumba/EmMDListener.cpp b/src/app_sparkd/sparkd/md/platforms/emumba/EmMDListener.cpp index d1012fdc2..7bb406271 100644 --- a/src/app_sparkd/sparkd/md/platforms/emumba/EmMDListener.cpp +++ b/src/app_sparkd/sparkd/md/platforms/emumba/EmMDListener.cpp @@ -138,18 +138,18 @@ TradingStatus convert_trading_status( return TradingStatus::TRADINGSTATUS_UNKNOWN; } -bts::co2::AggressorSide convert_trade_side( +domain::protobufs::AggressorSide convert_trade_side( const emumba::market_data::trade_record &tr) { switch (tr.agg_side) { case emumba::market_data::aggressor_side::buy: - return co2::AggressorSide::AGGRESSOR_SIDE_BUY; + return domain::protobufs::AGGRESSOR_SIDE_BUY; case emumba::market_data::aggressor_side::sell: - return co2::AggressorSide::AGGRESSOR_SIDE_SELL; + return domain::protobufs::AGGRESSOR_SIDE_SELL; case emumba::market_data::aggressor_side::none: - return co2::AggressorSide::AGGRESSOR_SIDE_NONE; + return domain::protobufs::AGGRESSOR_SIDE_NONE; } bts_assert(false); - return co2::AggressorSide::AGGRESSOR_SIDE_NONE; + return domain::protobufs::AGGRESSOR_SIDE_NONE; } bts::api::PutOrCall convert_call_put(emumba::market_data::option_type cp) { diff --git a/src/app_sparkd/sparkd/md/platforms/ice_onixs/ICEListener.cpp b/src/app_sparkd/sparkd/md/platforms/ice_onixs/ICEListener.cpp index 2f06e2e00..1bca80d2e 100644 --- a/src/app_sparkd/sparkd/md/platforms/ice_onixs/ICEListener.cpp +++ b/src/app_sparkd/sparkd/md/platforms/ice_onixs/ICEListener.cpp @@ -1,4 +1,5 @@ #include "ICEListener.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "spark/config/protos/market_data.pb.h" #include "spark/md/protos/co2.pb.h" #include "spark/utils/datetime.h" @@ -272,15 +273,16 @@ void ICEListener::onOrderBookUpdated( // // Trades -AggressorSide map_aggressor(onixs_ice::AggressorSide::Enum agside) { +domain::protobufs::AggressorSide map_aggressor( + onixs_ice::AggressorSide::Enum agside) { switch (agside) { default: case onixs_ice::AggressorSide::NoAggressor: - return AGGRESSOR_SIDE_NONE; + return domain::protobufs::AGGRESSOR_SIDE_NONE; case onixs_ice::AggressorSide::Buy: - return AGGRESSOR_SIDE_BUY; + return domain::protobufs::AGGRESSOR_SIDE_BUY; case onixs_ice::AggressorSide::Sell: - return AGGRESSOR_SIDE_SELL; + return domain::protobufs::AGGRESSOR_SIDE_SELL; } } diff --git a/src/app_sparkd/sparkd/md/platforms/mdp3_onixs/MDP3Listener.h b/src/app_sparkd/sparkd/md/platforms/mdp3_onixs/MDP3Listener.h index ebc42aa65..6f9ef20d8 100644 --- a/src/app_sparkd/sparkd/md/platforms/mdp3_onixs/MDP3Listener.h +++ b/src/app_sparkd/sparkd/md/platforms/mdp3_onixs/MDP3Listener.h @@ -19,15 +19,16 @@ namespace bts { namespace md { -inline co2::AggressorSide map_aggressor(onixs::AggressorSide::Enum agside) { +inline domain::protobufs::AggressorSide map_aggressor( + onixs::AggressorSide::Enum agside) { switch (agside) { default: case onixs::AggressorSide::NoAggressor: - return co2::AGGRESSOR_SIDE_NONE; + return domain::protobufs::AGGRESSOR_SIDE_NONE; case onixs::AggressorSide::Buy: - return co2::AGGRESSOR_SIDE_BUY; + return domain::protobufs::AGGRESSOR_SIDE_BUY; case onixs::AggressorSide::Sell: - return co2::AGGRESSOR_SIDE_SELL; + return domain::protobufs::AGGRESSOR_SIDE_SELL; } } diff --git a/src/app_sparkd/sparkd/md/taifex/TaifexDataGateway.cpp b/src/app_sparkd/sparkd/md/taifex/TaifexDataGateway.cpp index ef0bdcb30..698f36614 100644 --- a/src/app_sparkd/sparkd/md/taifex/TaifexDataGateway.cpp +++ b/src/app_sparkd/sparkd/md/taifex/TaifexDataGateway.cpp @@ -4,12 +4,12 @@ #include "domain/protobufs/venue.pb.h" #include "domain/security.h" #include "domain/security_id.h" +#include "domain/trade_record.h" #include "spark/api/md/TaifexMarketDataConfig.pb.h" #include "spark/config/config.h" #include "spark/config/protos/system_config.pb.h" #include "spark/core/TimeStamp.h" #include "spark/domain/Price.h" -#include "spark/domain/TradeRecord.h" #include "spark/logging/logging.h" #include "spark/md/IMarketDataListener.h" #include "spark/persistence/IDGenerator.h" diff --git a/src/lib_domain/domain/aggressor_side.h b/src/lib_domain/domain/aggressor_side.h index b3b9d5747..57199afcc 100644 --- a/src/lib_domain/domain/aggressor_side.h +++ b/src/lib_domain/domain/aggressor_side.h @@ -1,23 +1,3 @@ #pragma once -#include "system/FMT_IMPL.h" -#include "system/enum_macros.h" - -#include -#include - -namespace bts::domain { - -// clang-format off -#define FOR_ALL_VALUES(per_value) \ - per_value(AggressorSide, None) \ - per_value(AggressorSide, Buy) \ - per_value(AggressorSide, Sell) -// clang-format on - -ENUM_CLASS_DEF(AggressorSide, FOR_ALL_VALUES) - -#undef FOR_ALL_VALUES -} // namespace bts::domain - -FMT_IMPL(bts::domain::AggressorSide, a, "{}", a.name()); +#include "domain/protobufs/aggressor_side.h" diff --git a/src/lib_domain/domain/protobufs/aggressor_side.h b/src/lib_domain/domain/protobufs/aggressor_side.h new file mode 100644 index 000000000..5148b86f4 --- /dev/null +++ b/src/lib_domain/domain/protobufs/aggressor_side.h @@ -0,0 +1,58 @@ +#pragma once + +#include "domain/protobufs/aggressor_side.pb.h" +#include "system/FMT_IMPL.h" +#include "system/enum_macros.h" +#include "system/json/json_reader.h" +#include "system/string_utils.h" + +#include +#include + +namespace bts::domain::protobufs { + +/** + * Parses AggressorSide from a string. Unlike `bts::domain::AggressorSide_Parse`, this + * implementation is case insensitive, and makes the 'AGGRESSOR_SIDE_' prefix optional. + */ +bool aggressor_side_parse_smart(const std::string &str, AggressorSide *result); + +std::ostream &operator<<( + std::ostream &out, const AggressorSide &agg_side) noexcept; + +////////////////////////////////////////////////// +// Definition +////////////////////////////////////////////////// + +inline bool aggressor_side_parse_smart( + const std::string &str, AggressorSide *result) { + if (AggressorSide_Parse(str, result)) { + return true; + } + std::string s = system::string_utils::copy_to_upper(str); + if (AggressorSide_Parse(s, result)) { + return true; + } + const char *prefix = "AGGRESSOR_SIDE_"; + if (!s.starts_with(prefix)) { + s.insert(0, prefix); + } + return AggressorSide_Parse(s, result); +} + +PB_ENUM_FROM_JSON(AggressorSide) +PB_ENUM_TO_JSON(AggressorSide) + +inline std::ostream &operator<<( + std::ostream &out, const AggressorSide &agg_side) noexcept { + out << AggressorSide_Name(agg_side); + return out; +} + +} // namespace bts::domain::protobufs + +FMT_IMPL( + bts::domain::protobufs::AggressorSide, + a, + "{}", + bts::domain::protobufs::AggressorSide_Name(a)); diff --git a/src/lib_domain/domain/protobufs/aggressor_side.proto b/src/lib_domain/domain/protobufs/aggressor_side.proto new file mode 100644 index 000000000..9d1f74e65 --- /dev/null +++ b/src/lib_domain/domain/protobufs/aggressor_side.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package bts.domain.protobufs; + +option csharp_namespace = "bts.domain.protobufs"; + +enum AggressorSide { + AGGRESSOR_SIDE_NONE = 0; + AGGRESSOR_SIDE_BUY = 1; + AGGRESSOR_SIDE_SELL = 2; +} diff --git a/src/lib_domain/domain/trade_record.h b/src/lib_domain/domain/trade_record.h index a6262d674..0da036268 100644 --- a/src/lib_domain/domain/trade_record.h +++ b/src/lib_domain/domain/trade_record.h @@ -14,7 +14,7 @@ class TradeRecord { public: SecurityID sec_id = {}; core::TimeStamp time_stamp = {}; - AggressorSide agg_side = {}; + protobufs::AggressorSide agg_side = {}; Quantity trade_quantity; Price trade_price; TradeRecord() {} diff --git a/src/lib_spark/spark/api/services/MarketDataService.proto b/src/lib_spark/spark/api/services/MarketDataService.proto index 74492508a..9e03347b2 100644 --- a/src/lib_spark/spark/api/services/MarketDataService.proto +++ b/src/lib_spark/spark/api/services/MarketDataService.proto @@ -1,10 +1,10 @@ syntax="proto3"; package bts.api; option csharp_namespace="bts.api"; +import "domain/protobufs/aggressor_side.proto"; import "spark/api/apioptions.proto"; import "spark/api/apicore.proto"; import "spark/domain_model/Security.proto"; -import "spark/md/protos/co2.proto"; message ProductList { repeated bts.api.Product products = 1; @@ -29,7 +29,7 @@ message TickerEntry { double price = 3; uint32 size = 4; uint32 total_volume = 5; - bts.co2.AggressorSide aggressor_side = 6; + bts.domain.protobufs.AggressorSide aggressor_side = 6; bool from_spread = 7; bool gap = 10; } diff --git a/src/lib_spark/spark/domain/DomainSecurityUtils.cpp b/src/lib_spark/spark/domain/DomainSecurityUtils.cpp index 5121f1424..761d4ed44 100644 --- a/src/lib_spark/spark/domain/DomainSecurityUtils.cpp +++ b/src/lib_spark/spark/domain/DomainSecurityUtils.cpp @@ -21,10 +21,7 @@ domain::TradeRecord DomainSecurityUtils::convert( domain::TradeRecord rv; *rv.sec_id = trade.key(); rv.time_stamp = core::TimeStamp::from_int64(trade.time()); - rv.agg_side = - trade.aggressor_side() == co2::AggressorSide::AGGRESSOR_SIDE_BUY - ? AggressorSide::Buy - : AggressorSide::Sell; + rv.agg_side = trade.aggressor_side(); *rv.trade_quantity = trade.size(); rv.trade_price = bts::domain::Price::from_double( bts::md::IntPrice(trade.mantissa(), trade.exponent()).price()); diff --git a/src/lib_spark/spark/md/GeneralMarketDataListener.cpp b/src/lib_spark/spark/md/GeneralMarketDataListener.cpp index f083727a4..5f39c1e3c 100644 --- a/src/lib_spark/spark/md/GeneralMarketDataListener.cpp +++ b/src/lib_spark/spark/md/GeneralMarketDataListener.cpp @@ -216,17 +216,6 @@ bts::md::IntPrice convert_price(bts::domain::Price p) { return bts::md::IntPrice(p.mantissa(), p.exponent()); } -co2::AggressorSide convert_agg_side(bts::domain::AggressorSide side) { - switch (side.value) { - case bts::domain::AggressorSide::Value::Buy: - return co2::AGGRESSOR_SIDE_BUY; - case bts::domain::AggressorSide::Value::Sell: - return co2::AGGRESSOR_SIDE_SELL; - default: - return co2::AGGRESSOR_SIDE_NONE; - } -} - void clear_books(MDArray &md_side) { for (PriceSize &psz : md_side) { psz = PriceSize{}; @@ -374,7 +363,7 @@ void GeneralMarketDataListener::on_trades( utils::TimeStamp::now(), PriceSize( convert_price(tp->trade_price), tp->trade_quantity.value()), - trade_ts, convert_agg_side(tp->agg_side), 0, false); + trade_ts, tp->agg_side, 0, false); } } } diff --git a/src/lib_spark/spark/md/MDProducerHandle.cpp b/src/lib_spark/spark/md/MDProducerHandle.cpp index ec1de51ea..39623fffa 100644 --- a/src/lib_spark/spark/md/MDProducerHandle.cpp +++ b/src/lib_spark/spark/md/MDProducerHandle.cpp @@ -11,6 +11,8 @@ using namespace co2; #define TRADING_STATUS(x) bts::domain::protobufs::TRADINGSTATUS_##x +using bts::domain::protobufs::AggressorSide; + MDProducerHandle::MDProducerHandle( ColdHeader &cheader, HotHeader &hheader, @@ -108,7 +110,7 @@ void MDProducerHandle::add_trade( TimeStamp time, const PriceSize price, LLDateTime tradetime, - co2::AggressorSide agside, + AggressorSide agside, uint32_t volume, bool from_spread) { // Add this trade to the last trade if price/side match diff --git a/src/lib_spark/spark/md/MDProducerHandle.h b/src/lib_spark/spark/md/MDProducerHandle.h index 83843b7a9..f11b74885 100644 --- a/src/lib_spark/spark/md/MDProducerHandle.h +++ b/src/lib_spark/spark/md/MDProducerHandle.h @@ -2,6 +2,7 @@ #include "MDProducerChannel.h" #include "Shm/MDStructure.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "spark/utils/bts_export.h" #include "spark/utils/bts_no_copy.h" #include "spark/utils/datetime.h" @@ -117,7 +118,7 @@ class BTS_EXPORT MDProducerHandle { TimeStamp time, const PriceSize pricesize, datetime::LLDateTime date, - co2::AggressorSide agside, + domain::protobufs::AggressorSide agside, uint32_t total_volume = 0, bool from_spread = false); // cold // Update last_trade without updating trade log diff --git a/src/lib_spark/spark/md/protos/co2.proto b/src/lib_spark/spark/md/protos/co2.proto index 01cb34e5c..e79846d99 100644 --- a/src/lib_spark/spark/md/protos/co2.proto +++ b/src/lib_spark/spark/md/protos/co2.proto @@ -1,6 +1,7 @@ syntax='proto3'; package bts.co2; option csharp_namespace="bts.co2"; +import "domain/protobufs/aggressor_side.proto"; import "spark/domain_model/Security.proto"; enum CoconutSecurityStatus { @@ -103,12 +104,6 @@ message MiscMessage { double session_low_offer = 12; double fixing_price = 13; } - -enum AggressorSide { - AGGRESSOR_SIDE_NONE = 0; - AGGRESSOR_SIDE_BUY = 1; - AGGRESSOR_SIDE_SELL = 2; -} message TradeMessage { uint32 key = 1; @@ -120,7 +115,7 @@ message TradeMessage { uint32 size = 6; uint32 total_volume = 7; bool gap = 8; - AggressorSide aggressor_side = 9; + bts.domain.protobufs.AggressorSide aggressor_side = 9; bool from_spread = 10; } message QuoteRequestMessage { diff --git a/src/lib_spark/spark/orderman/Trade.h b/src/lib_spark/spark/orderman/Trade.h index 588fe71c9..1a1c3f5fe 100644 --- a/src/lib_spark/spark/orderman/Trade.h +++ b/src/lib_spark/spark/orderman/Trade.h @@ -1,7 +1,7 @@ #pragma once +#include "domain/protobufs/aggressor_side.pb.h" #include "spark/domain_model/common.h" -#include "spark/md/protos/co2.pb.h" #include "spark/utils/bts_chrono.h" namespace bts::orderman { @@ -11,7 +11,7 @@ struct Trade { Price price; Quantity quantity; Quantity total_volume; - co2::AggressorSide aggressor_side; + domain::protobufs::AggressorSide aggressor_side; }; } // namespace bts::orderman diff --git a/src/lib_spark/spark/orderman/gateways/sim/SimExecutionGateway.cpp b/src/lib_spark/spark/orderman/gateways/sim/SimExecutionGateway.cpp index 462ed25cb..85f12c2e6 100644 --- a/src/lib_spark/spark/orderman/gateways/sim/SimExecutionGateway.cpp +++ b/src/lib_spark/spark/orderman/gateways/sim/SimExecutionGateway.cpp @@ -1,4 +1,5 @@ #include "SimExecutionGateway.h" +#include "domain/protobufs/aggressor_side.pb.h" #include "spark/api/services/OrderService.pb.h" #include "spark/core/TimeStamp.h" #include "spark/domain_model/Security.h" @@ -39,6 +40,8 @@ namespace bts::orderman { +using bts::domain::protobufs::AggressorSide; + // book conversions /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -678,7 +681,7 @@ void SimExecutionGateway::_write_trade( idx_data->handle.add_trade( now, md::PriceSize(convert_price(price), qty.value()), trade_ts, // TODO - co2::AggressorSide::AGGRESSOR_SIDE_BUY, 0, false); + AggressorSide::AGGRESSOR_SIDE_BUY, 0, false); } else { LOG(OrderMan, Error, "SimExecutionGateway::_write_trade could not find handle for key: {}", diff --git a/src/lib_spark/spark/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp b/src/lib_spark/spark/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp index ec48f4707..b86a49321 100644 --- a/src/lib_spark/spark/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp +++ b/src/lib_spark/spark/orderman/orders/algo/algo_orders/tests/dorman_tests.cpp @@ -511,7 +511,7 @@ TEST_CASE("Dorman profit-orders", "[algo][dorman]") { Trade mkTrade(Price p, Quantity q) { return { Timer::now(), p, q, Quantity{q.value() + 9999}, - co2::AGGRESSOR_SIDE_NONE}; + domain::protobufs::AGGRESSOR_SIDE_NONE}; } TradeVector mkTrades(Price p, Quantity total) {