79
79
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT
80
80
#include " ccapi_cpp/service/ccapi_market_data_service_bybit.h"
81
81
#endif
82
- #ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
83
- #include " ccapi_cpp/service/ccapi_market_data_service_bybit_derivatives.h"
84
- #endif
85
82
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
86
83
#include " ccapi_cpp/service/ccapi_market_data_service_ascendex.h"
87
84
#endif
186
183
#ifdef CCAPI_ENABLE_EXCHANGE_BYBIT
187
184
#include " ccapi_cpp/service/ccapi_execution_management_service_bybit.h"
188
185
#endif
189
- #ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
190
- #include " ccapi_cpp/service/ccapi_execution_management_service_bybit_derivatives.h"
191
- #endif
192
186
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
193
187
#include " ccapi_cpp/service/ccapi_execution_management_service_ascendex.h"
194
188
#endif
@@ -412,10 +406,6 @@ class Session {
412
406
this ->serviceByServiceNameExchangeMap [CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BYBIT] =
413
407
std::make_shared<MarketDataServiceBybit>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
414
408
#endif
415
- #ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
416
- this ->serviceByServiceNameExchangeMap [CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES] =
417
- std::make_shared<MarketDataServiceBybitDerivatives>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
418
- #endif
419
409
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
420
410
this ->serviceByServiceNameExchangeMap [CCAPI_MARKET_DATA][CCAPI_EXCHANGE_NAME_ASCENDEX] =
421
411
std::make_shared<MarketDataServiceAscendex>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
@@ -550,10 +540,6 @@ class Session {
550
540
this ->serviceByServiceNameExchangeMap [CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BYBIT] =
551
541
std::make_shared<ExecutionManagementServiceBybit>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
552
542
#endif
553
- #ifdef CCAPI_ENABLE_EXCHANGE_BYBIT_DERIVATIVES
554
- this ->serviceByServiceNameExchangeMap [CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES] =
555
- std::make_shared<ExecutionManagementServiceBybitDerivatives>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
556
- #endif
557
543
#ifdef CCAPI_ENABLE_EXCHANGE_ASCENDEX
558
544
this ->serviceByServiceNameExchangeMap [CCAPI_EXECUTION_MANAGEMENT][CCAPI_EXCHANGE_NAME_ASCENDEX] =
559
545
std::make_shared<ExecutionManagementServiceAscendex>(this ->internalEventHandler , sessionOptions, sessionConfigs, this ->serviceContextPtr );
@@ -636,6 +622,22 @@ class Session {
636
622
}
637
623
virtual void subscribe (std::vector<Subscription>& subscriptionList) {
638
624
CCAPI_LOGGER_FUNCTION_ENTER;
625
+ for (auto & subscription : subscriptionList) {
626
+ auto exchange = subscription.getExchange ();
627
+ if (exchange == CCAPI_EXCHANGE_NAME_BYBIT) {
628
+ auto instrumentType = subscription.getInstrumentType ();
629
+ if (instrumentType.empty ()) {
630
+ instrumentType = " spot" ;
631
+ }
632
+ std::vector<std::string> instrumentTypeList = {" spot" , " linear" , " inverse" , " option" };
633
+ if (std::find (instrumentTypeList.begin (), instrumentTypeList.end (), instrumentType) == instrumentTypeList.end ()) {
634
+ this ->onError (Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
635
+ " unsupported exchange instrument types: " + toString (instrumentType) + " . Allowed values: " + toString (instrumentTypeList) + " ." );
636
+ return ;
637
+ }
638
+ subscription.setInstrumentType (instrumentType);
639
+ }
640
+ }
639
641
std::map<std::string, std::vector<Subscription> > subscriptionListByServiceNameMap;
640
642
for (const auto & subscription : subscriptionList) {
641
643
auto serviceName = subscription.getServiceName ();
@@ -650,19 +652,10 @@ class Session {
650
652
return ;
651
653
}
652
654
if (serviceName == CCAPI_MARKET_DATA) {
653
- // std::set<std::string> correlationIdSet;
654
- // std::set<std::string> duplicateCorrelationIdSet;
655
655
std::unordered_set<std::string> unsupportedExchangeFieldSet;
656
- std::map<std::string, std::vector<Subscription> > subscriptionListByExchangeMap;
657
656
auto exchangeFieldMap = this ->sessionConfigs .getExchangeFieldMap ();
658
657
CCAPI_LOGGER_DEBUG (" exchangeFieldMap = " + toString (exchangeFieldMap));
659
658
for (const auto & subscription : subscriptionList) {
660
- // auto correlationId = subscription.getCorrelationId();
661
- // if (correlationIdSet.find(correlationId) != correlationIdSet.end()) {
662
- // duplicateCorrelationIdSet.insert(correlationId);
663
- // } else {
664
- // correlationIdSet.insert(correlationId);
665
- // }
666
659
auto exchange = subscription.getExchange ();
667
660
CCAPI_LOGGER_DEBUG (" exchange = " + exchange);
668
661
auto field = subscription.getField ();
@@ -674,29 +667,16 @@ class Session {
674
667
CCAPI_LOGGER_DEBUG (" unsupported exchange " + exchange + " , field = " + field);
675
668
unsupportedExchangeFieldSet.insert (exchange + " |" + field);
676
669
}
677
- subscriptionListByExchangeMap[exchange].push_back (subscription);
678
670
}
679
- // if (!duplicateCorrelationIdSet.empty()) {
680
- // this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
681
- // "duplicated correlation ids: " + toString(duplicateCorrelationIdSet));
682
- // return;
683
- // }
684
671
if (!unsupportedExchangeFieldSet.empty ()) {
685
672
this ->onError (Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
686
673
" unsupported exchange fields: " + toString (unsupportedExchangeFieldSet));
687
674
return ;
688
675
}
676
+ std::map<std::string, std::vector<Subscription> > subscriptionListByExchangeMap;
689
677
for (const auto & subscription : subscriptionList) {
690
678
auto exchange = subscription.getExchange ();
691
- if (exchange == CCAPI_EXCHANGE_NAME_BYBIT_DERIVATIVES) {
692
- const auto & instrumentType = subscription.getInstrumentType ();
693
- std::vector<std::string> instrumentTypeList = {" usdt-contract" , " usdc-contract" , " usdc-options" };
694
- if (std::find (instrumentTypeList.begin (), instrumentTypeList.end (), instrumentType) == instrumentTypeList.end ()) {
695
- this ->onError (Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
696
- " unsupported exchange instrument types: " + toString (instrumentType) + " . Allowed values: " + toString (instrumentTypeList) + " ." );
697
- return ;
698
- }
699
- }
679
+ subscriptionListByExchangeMap[exchange].push_back (subscription);
700
680
}
701
681
CCAPI_LOGGER_TRACE (" subscriptionListByExchangeMap = " + toString (subscriptionListByExchangeMap));
702
682
for (auto & subscriptionListByExchange : subscriptionListByExchangeMap) {
0 commit comments