refactor: Remove redundant sec type field

The Security class already has a 'type' fn that treats the type as a
function of the security variant. This is better than the 'type' field
in SecurityCommon, because it's naturally in sync with the variant.
This commit is contained in:
John Colvin committed 2023-06-07 13:16:19 -04:00
1 parent 31c7fa4f2c
commit 691545b71a
5 files changed
+2 -9

No files matched your search

-4
View File
@@ -31,7 +31,6 @@ class SecurityCommon {
api::domain::Venue venue;
std::string exchange_sec_id;
SecurityID id{};
api::domain::SecurityType type;
api::domain::Currency currency;
std::string symbol;
std::string group;
@@ -49,7 +48,6 @@ class SecurityCommon {
: venue(DomainSecurityUtils::convert(s.exchange())),
exchange_sec_id(DomainSecurityUtils::get_exchange_id(s)),
id(SecurityID(s.id())),
type(DomainSecurityUtils::convert(DomainSecurityUtils::get_type(s))),
currency(api::domain::Currency::USD), symbol(s.symbol()),
desc(exchange_sec_id),
min_price_increment(s.contract_spec().low_tick()) {}
@@ -69,7 +67,6 @@ inline void from_json(const nlohmann::json &j, SecurityCommon &sc) {
jr.read("venue", sc.venue) &&
jr.read("exchange_id", sc.exchange_sec_id) &&
jr.read("id", sc.id) &&
jr.read("type", sc.type) &&
jr.read("currency", sc.currency) &&
jr.read("symbol", sc.symbol) &&
jr.read("group", sc.group) &&
@@ -93,7 +90,6 @@ inline void to_json(nlohmann::json &j, const SecurityCommon &sc) {
{"venue", api::domain::Venue_Name(sc.venue)},
{"exchange_id", sc.exchange_sec_id},
{"id", sc.id.value()},
{"type", api::domain::SecurityType_Name(sc.type)},
{"currency", api::domain::Currency_Name(sc.currency)},
{"symbol", sc.symbol},
{"group", sc.group},
-1
View File
@@ -70,7 +70,6 @@ void BinanceSpot::parse(
for (const auto &bspot : binance_spots) {
auto &sec = securities.emplace_back();
auto &scomm = sec.security_common;
scomm.type = SEC_TYPE(SPOT);
scomm.venue = venue;
scomm.exchange_sec_id = bspot.symbol;
@@ -73,7 +73,6 @@ void BinanceUsdsFuture::parse(
for (const auto &bf : binance_futs) {
auto &sec = securities.emplace_back();
auto &scomm = sec.security_common;
scomm.type = SEC_TYPE(FUTURE);
scomm.venue = VENUE;
scomm.exchange_sec_id = bf.symbol;
-1
View File
@@ -79,7 +79,6 @@ void FTXFuture::parse(const ccapi::Message &msg, vector<Security> &securities) {
}
auto &sec = securities.emplace_back();
auto &scomm = sec.security_common;
scomm.type = ftx_fut.type.to_security_type();
scomm.venue = VENUE;
scomm.exchange_sec_id = ftx_fut.name;
+2 -2
View File
@@ -88,9 +88,9 @@ void FTXMarket::parse(const ccapi::Message &msg, vector<Security> &securities) {
scomm.min_price_increment = ftx_mkt.price_increment;
scomm.min_quantity = ftx_mkt.min_provide_size;
scomm.min_quantity_increment = ftx_mkt.size_increment;
scomm.type = ftx_mkt.type.to_security_type();
const auto sec_type = ftx_mkt.type.to_security_type();
switch (scomm.type) {
switch (sec_type) {
case SEC_TYPE(UNSPECIFIED):
bts_assert_msgf(
false, "Failed to parse ftx security type from '{}'",