Add protos for bybit

This commit is contained in:
John Colvin committed 2025-06-13 20:50:29 +00:00
1 parent 922924c31d
commit 43ec58dfe3
15 files changed
+86 -6

No files matched your search

@@ -23,6 +23,7 @@ EnumOptionNames<api::Venue> VenueOption::names() {
NAME_PAIR(api::VENUE_CBOE),
NAME_PAIR(api::VENUE_TAIFEX),
NAME_PAIR(api::VENUE_TWSE),
NAME_PAIR(api::VENUE_BYBIT),
NAME_PAIR(api::VENUE_OKX)};
}
@@ -60,6 +61,8 @@ std::string VenueOption::name(api::Venue venue) {
return "taifex";
case api::VENUE_TWSE:
return "twse";
case api::VENUE_BYBIT:
return "bybit";
default:
return std::to_string(static_cast<int32_t>(venue));
}
@@ -128,6 +128,7 @@ namespace bts.api {
Security.ExchangeDataOneofCase.Taifex => security.Taifex.SecurityDesc,
Security.ExchangeDataOneofCase.Twse => security.Twse.SecurityDesc,
Security.ExchangeDataOneofCase.None => security.Synthetic.Name,
Security.ExchangeDataOneofCase.Bybit => security.Bybit.SecurityDesc,
_ => throw new NotImplementedException("security_desc not implemented for exchange")
};
@@ -179,8 +180,7 @@ namespace bts.api {
domain.Venue.Cboe => Venue.Cboe,
domain.Venue.Taifex => Venue.Taifex,
domain.Venue.Twse => Venue.Twse,
domain.Venue.Bybit => Venue.Bybit,
domain.Venue.Unspecified => Venue.Unset,
_ => throw new NotImplementedException(),
};
@@ -201,7 +201,7 @@ namespace bts.api {
Venue.Cboe => domain.Venue.Cboe,
Venue.Taifex => domain.Venue.Taifex,
Venue.Twse => domain.Venue.Twse,
Venue.Bybit => domain.Venue.Bybit,
Venue.Unset => domain.Venue.Unspecified,
_ => throw new NotImplementedException(),
};
@@ -28,4 +28,5 @@ enum Venue {
VENUE_TAIFEX = 16;
VENUE_CBOE = 17;
VENUE_TWSE = 18;
VENUE_BYBIT = 19;
}
@@ -0,0 +1,16 @@
syntax = "proto3";
import "spark/api/domain/SecurityCriteria.proto";
package bts.api.md;
option csharp_namespace = "bts.api.md";
option cc_enable_arenas = true;
message BybitMarketDataConfig {
uint32 num_depth_levels = 1;
uint32 depth_throttle_ms = 2;
bts.api.domain.SecurityCriteria security_criteria = 3;
string url_rest_base = 4;
string url_ws_base = 5;
}
@@ -14,6 +14,7 @@ import "spark/api/md/OkxMarketDataConfig.proto";
import "spark/api/md/GlbxMarketDataConfig.proto";
import "spark/api/md/TaifexMarketDataConfig.proto";
import "spark/api/md/TwseMarketDataConfig.proto";
import "spark/api/md/BybitMarketDataConfig.proto";
import "spark/api/md/CboeMarketDataConfig.proto";
import "spark/api/md/PyMarketDataProviderConfig.proto";
@@ -34,6 +35,7 @@ message MarketDataConfig {
repeated CboeMarketDataConfig cboe = 9;
repeated TaifexMarketDataConfig taifex =10;
repeated TwseMarketDataConfig twse = 12;
repeated BybitMarketDataConfig bybit = 13;
// Add an entry here for all the exchanges that need their market data to be recorded
repeated EmumbaDeribitMarketDataConfig emumba_deribit = 100;
@@ -27,6 +27,9 @@ std::set<bts::api::Venue> MarketDataConfigUtils::get_live_exchanges(
rv.insert(bts::api::VENUE_TWSE);
if (cfg.cboe_size()>0)
rv.insert(bts::api::VENUE_CBOE);
if (cfg.bybit_size() > 0) {
rv.insert(bts::api::VENUE_BYBIT);
}
return rv;
}
@@ -76,4 +79,4 @@ MarketDataConfigUtils::get_effective_recording_config(
}
} // namespace bts::md
#endif
#endif
@@ -75,6 +75,7 @@ bool AdminServiceUtils::has_exchange(
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_TWSE:
case api::Venue::VENUE_TAIFEX:
case api::Venue::VENUE_BYBIT:
case api::Venue::VENUE_CBOECFE:
case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_:
case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_:
@@ -192,6 +193,7 @@ AdminServiceUtils::resolve_connection(
case api::Venue::VENUE_COINBASE:
case api::Venue::VENUE_TWSE:
case api::Venue::VENUE_TAIFEX:
case api::Venue::VENUE_BYBIT:
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_BINANCE_USDS_FUTURES: {
if (account.has_connections())
@@ -467,6 +469,7 @@ std::string AdminServiceUtils::find_account_exchange_account(
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_TWSE:
case api::Venue::VENUE_TAIFEX:
case api::Venue::VENUE_BYBIT:
case api::Venue::VENUE_CBOECFE:
case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_:
case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_:
@@ -784,6 +787,13 @@ bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(
out_result.set_is_success(true);
return rv;
}
case api::VENUE_BYBIT: {
rv.set_session("bybit_1");
rv.set_account(account_ptr->name());
rv.set_operator_id(user_ptr->name());
out_result.set_is_success(true);
return rv;
}
case api::VENUE_FTX: // TODO
case api::VENUE_BINANCE_COIN_FUTURES:
case api::VENUE_BINANCE_US:
@@ -1189,6 +1199,7 @@ std::string AdminServiceUtils::find_user_exchange_id(
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_TWSE:
case api::Venue::VENUE_TAIFEX:
case api::Venue::VENUE_BYBIT:
case api::Venue::VENUE_CBOECFE:
case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_:
case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_:
@@ -1229,7 +1240,7 @@ std::string AdminServiceUtils::find_user_company_id(
case api::Venue::VENUE_CBOE:
case api::Venue::VENUE_TWSE:
case api::Venue::VENUE_TAIFEX:
case api::Venue::VENUE_BYBIT:
case api::Venue::VENUE_CBOECFE:
case api::Venue::Venue_INT_MIN_SENTINEL_DO_NOT_USE_:
case api::Venue::Venue_INT_MAX_SENTINEL_DO_NOT_USE_:
@@ -4054,6 +4054,11 @@ JetFIX {
max_order_msgs_per_window: 300
venue: VENUE_TAIFEX
}
connection {
name: "bybit_1"
max_order_msgs_per_window: 300
venue: VENUE_BYBIT
}
# CME EXECUTION NEEDS TO BE UPDATED, probably below
# connection {
# name: "onixs_sim"
@@ -4067,4 +4072,4 @@ JetFIX {
# venue: VENUE_CBOE
# }
# }
# }
# }
@@ -62,6 +62,11 @@ SymbolLists {
symbol: "BTC"
symbol: "ETH"
}
list {
key: "BYBIT"
symbol: "BTC"
symbol: "ETH"
}
}
}
@@ -189,5 +194,9 @@ Symbols {
future: @SymbolLists.list[OKX].symbol
option: @SymbolLists.list[OKX].symbol
}
venues {
name: "VENUE_BYBIT"
spot: @SymbolLists.list[BYBIT].symbol
}
}
}
@@ -45,6 +45,8 @@ api::domain::Venue DomainSecurityUtils::convert(bts::api::Venue venue) {
return DOMAIN_VENUE(ICE);
case bts::api::VENUE_OKX:
return DOMAIN_VENUE(OKX);
case bts::api::VENUE_BYBIT:
return DOMAIN_VENUE(BYBIT);
default: {
LOG(md, Error, "convert unknown venue: {}", static_cast<int>(venue));
break;
@@ -77,6 +79,8 @@ bts::api::Venue DomainSecurityUtils::convert(api::domain::Venue venue) {
return api::Venue::VENUE_BINANCE_USDS_FUTURES;
case DOMAIN_VENUE(OKX):
return api::Venue::VENUE_OKX;
case DOMAIN_VENUE(BYBIT):
return api::Venue::VENUE_BYBIT;
case DOMAIN_VENUE(SIM):
return api::Venue::VENUE_SIM;
case DOMAIN_VENUE(COINBASE):
@@ -22,6 +22,7 @@ enum Venue {
VENUE_OKX = 460;
VENUE_TAIFEX = 500;
VENUE_TWSE = 600;
VENUE_BYBIT = 610;
}
enum SecurityType {
@@ -138,6 +139,11 @@ message OkxExchangeData {
string security_desc = 2;
}
message BybitExchangeData {
int64 exchange_id = 10;
string security_desc = 20;
}
message CBOECFEExchangeData {
int64 exchange_id = 10;
string security_desc = 20;
@@ -267,6 +273,7 @@ message Security {
OkxExchangeData okx = 300;
TAIFEXExchangeData taifex = 400;
TWSEExchangeData twse = 500;
BybitExchangeData bybit = 510;
}
}
message SecurityList {
@@ -234,6 +234,10 @@ void convert_security(const FixedSecurity &source, Security *presult) {
dest.mutable_cboe()->set_security_desc(source.security_desc());
dest.mutable_cboe()->set_exchange_id(source.numeric_id);
break;
case Venue::VENUE_BYBIT:
dest.mutable_bybit()->set_security_desc(source.security_desc());
dest.mutable_bybit()->set_exchange_id(source.numeric_id);
break;
case Venue::VENUE_BTS:
break;
default:
@@ -342,6 +346,8 @@ uint64_t exchange_id(const Security &security) {
return security.twse().exchange_id();
case Security::ExchangeDataCase::kTaifex:
return security.taifex().exchange_id();
case Security::ExchangeDataCase::kBybit:
return security.bybit().exchange_id();
// Debatable whether this should be an error or not.
// If is possible that we might create a spread with no exchange in the
// future and if we did this would be a runtime error.
@@ -433,6 +439,10 @@ void convert_security(
dest.numeric_id = src.okx().exchange_id();
dest.security_desc(src.okx().security_desc());
break;
case Security::ExchangeDataCase::kBybit:
dest.numeric_id = src.bybit().exchange_id();
dest.security_desc(src.bybit().security_desc());
break;
case Security::ExchangeDataCase::EXCHANGEDATA_NOT_SET:
break;
}
@@ -203,6 +203,9 @@ struct MDConsumerGroup {
case api::VENUE_TAIFEX:
this->mic = "TAIFEX";
break;
case api::VENUE_BYBIT:
this->mic = "BYBIT";
break;
case api::VENUE_CBOECFE:
case api::Venue_INT_MIN_SENTINEL_DO_NOT_USE_:
case api::Venue_INT_MAX_SENTINEL_DO_NOT_USE_:
+3
View File
@@ -22,6 +22,7 @@ class VenueIndex {
std::optional<T> ice;
std::optional<T> taifex;
std::optional<T> coinbase;
std::optional<T> bybit;
public:
std::optional<T> &get(api::Venue venue) { return get_(*this, venue); }
@@ -67,6 +68,8 @@ class VenueIndex {
return self.okx;
case api::VENUE_TAIFEX:
return self.taifex;
case api::VENUE_BYBIT:
return self.bybit;
case api::VENUE_BTS:
return self.bts;
case api::VENUE_FTX:
@@ -526,6 +526,9 @@ OrderOpResult EMNativeOrder::_on_activate(
case api::VENUE_BINANCE:
session_name = "binance_1";
break;
case api::VENUE_BYBIT:
session_name = "bybit_1";
break;
default:
session_name ="deribit_1";