Skip to content

Commit

Permalink
fix: no correlation Id returned by event notifying orderbook subscrip…
Browse files Browse the repository at this point in the history
…tion with Gate.io
  • Loading branch information
cryptochassis committed Sep 12, 2023
1 parent a24141d commit 27b995a
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 117 deletions.
4 changes: 1 addition & 3 deletions example/src/cross_exchange_arbitrage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_GEMINI)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/custom_service_class/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_compile_definitions(CCAPI_EXPOSE_INTERNAL)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/enable_library_logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_LOG_TRACE)
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE_US)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_OKX)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/generic_private_request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/generic_public_request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_BINANCE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/market_data_advanced_request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/market_data_advanced_subscription/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/market_data_simple_request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
3 changes: 0 additions & 3 deletions example/src/market_data_simple_subscription/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
4 changes: 1 addition & 3 deletions example/src/market_making/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/override_exchange_url_at_runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_OKX)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
4 changes: 1 addition & 3 deletions example/src/utility_set_timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ project(${NAME})
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_COINBASE)
add_executable(${NAME} main.cpp)
if(NOT CCAPI_LEGACY_USE_WEBSOCKETPP)
add_dependencies(${NAME} boost rapidjson)
endif()
add_dependencies(${NAME} boost rapidjson)
6 changes: 3 additions & 3 deletions include/ccapi_cpp/service/ccapi_market_data_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class MarketDataService : public Service {
void onClose(wspp::connection_hdl hdl) override {
CCAPI_LOGGER_FUNCTION_ENTER;
WsConnection& wsConnection = this->getWsConnectionFromConnectionPtr(this->serviceContextPtr->tlsClientPtr->get_con_from_hdl(hdl));
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id);
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.erase(wsConnection.id);
this->exchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id);
this->instrumentGroupByWsConnectionIdMap.erase(wsConnection.id);
this->correlationIdByConnectionIdMap.erase(wsConnection.id);
Expand Down Expand Up @@ -650,7 +650,7 @@ class MarketDataService : public Service {
virtual void onClose(std::shared_ptr<WsConnection> wsConnectionPtr, ErrorCode ec) override {
CCAPI_LOGGER_FUNCTION_ENTER;
WsConnection& wsConnection = *wsConnectionPtr;
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id);
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.erase(wsConnection.id);
this->exchangeJsonPayloadIdByConnectionIdMap.erase(wsConnection.id);
this->instrumentGroupByWsConnectionIdMap.erase(wsConnection.id);
this->correlationIdByConnectionIdMap.erase(wsConnection.id);
Expand Down Expand Up @@ -1787,7 +1787,7 @@ class MarketDataService : public Service {
std::string getInstrumentTarget;
std::string getInstrumentsTarget;
std::map<std::string, int> exchangeJsonPayloadIdByConnectionIdMap;
std::map<std::string, std::map<int, std::vector<std::string>>> exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap;
std::map<std::string, std::map<int, std::vector<std::string>>> exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap;
// only needed for generic public subscription
std::map<std::string, std::string> correlationIdByConnectionIdMap;
std::map<std::string, std::map<std::string, std::map<int64_t, MarketDataMessage::TypeForData>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MarketDataServiceBinanceBase : public MarketDataService {
}
document.AddMember("params", params, allocator);
document.AddMember("id", rj::Value(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).Move(), allocator);
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
exchangeSubscriptionIdList;
this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1;
rj::StringBuffer stringBuffer;
Expand Down Expand Up @@ -127,11 +127,11 @@ class MarketDataServiceBinanceBase : public MarketDataService {
std::vector<std::string> correlationIdList;
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) != this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) {
int id = std::stoi(document["id"].GetString());
if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() &&
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) {
if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() &&
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) {
std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID];
std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID];
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) !=
Expand Down
12 changes: 6 additions & 6 deletions include/ccapi_cpp/service/ccapi_market_data_service_bybit.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MarketDataServiceBybit : public MarketDataServiceBybitBase {
}
document.AddMember("args", args, allocator);
document.AddMember("req_id", rj::Value(std::to_string(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).c_str(), allocator).Move(), allocator);
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
exchangeSubscriptionIdList;
this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1;
rj::StringBuffer stringBuffer;
Expand Down Expand Up @@ -109,11 +109,11 @@ class MarketDataServiceBybit : public MarketDataServiceBybitBase {
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) !=
this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) {
int id = std::stoi(document["req_id"].GetString());
if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() &&
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) {
if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() &&
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) {
std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID];
std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID];
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) !=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class MarketDataServiceBybitDerivatives : public MarketDataServiceBybitBase {
}
document.AddMember("args", args, allocator);
document.AddMember("req_id", rj::Value(std::to_string(this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]).c_str(), allocator).Move(), allocator);
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap[wsConnection.id][this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id]] =
exchangeSubscriptionIdList;
this->exchangeJsonPayloadIdByConnectionIdMap[wsConnection.id] += 1;
rj::StringBuffer stringBuffer;
Expand Down Expand Up @@ -137,11 +137,11 @@ class MarketDataServiceBybitDerivatives : public MarketDataServiceBybitBase {
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.find(wsConnection.id) !=
this->correlationIdListByConnectionIdChannelIdSymbolIdMap.end()) {
int id = std::stoi(document["req_id"].GetString());
if (this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.end() &&
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByExchangeJsonPayloadIdByConnectionIdMap.at(wsConnection.id).at(id)) {
if (this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.find(wsConnection.id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.end() &&
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).find(id) !=
this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).end()) {
for (const auto& exchangeSubscriptionId : this->exchangeSubscriptionIdListByConnectionIdExchangeJsonPayloadIdMap.at(wsConnection.id).at(id)) {
std::string channelId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_CHANNEL_ID];
std::string symbolId = this->channelIdSymbolIdByConnectionIdExchangeSubscriptionIdMap[wsConnection.id][exchangeSubscriptionId][CCAPI_SYMBOL_ID];
if (this->correlationIdListByConnectionIdChannelIdSymbolIdMap.at(wsConnection.id).find(channelId) !=
Expand Down

0 comments on commit 27b995a

Please sign in to comment.