Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update Bitget market service APIs and WS from v1 to v2 #477

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ccapi_cpp/ccapi_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
#define CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_BOOKS1 "books1"
#define CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_BOOKS5 "books5"
#define CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_BOOKS15 "books15"
#define CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_TRADES "trade"
#define CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_KLINE "candle"
#define CCAPI_WEBSOCKET_BITMART_CHANNEL_TRADE "spot/trade"
#define CCAPI_WEBSOCKET_BITMART_CHANNEL_PUBLIC_DEPTH5 "spot/depth5"
#define CCAPI_WEBSOCKET_BITMART_CHANNEL_PUBLIC_DEPTH20 "spot/depth20"
Expand Down
12 changes: 12 additions & 0 deletions include/ccapi_cpp/ccapi_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@ class Session {
return;
}
subscription.setInstrumentType(instrumentType);
} else if (exchange == CCAPI_EXCHANGE_NAME_BITGET_FUTURES) {
auto instrumentType = subscription.getInstrumentType();
if (instrumentType.empty()) {
instrumentType = "USDT-FUTURES";
}
std::vector<std::string> instrumentTypeList = {"USDT-FUTURES", "COIN-FUTURES", "USDC-FUTURES"};
if (std::find(instrumentTypeList.begin(), instrumentTypeList.end(), instrumentType) == instrumentTypeList.end()) {
this->onError(Event::Type::SUBSCRIPTION_STATUS, Message::Type::SUBSCRIPTION_FAILURE,
"unsupported exchange instrument types: " + toString(instrumentType) + ". Allowed values: " + toString(instrumentTypeList) + ".");
return;
}
subscription.setInstrumentType(instrumentType);
}
}
std::map<std::string, std::vector<Subscription> > subscriptionListByServiceNameMap;
Expand Down
2 changes: 2 additions & 0 deletions include/ccapi_cpp/ccapi_session_configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ class SessionConfigs CCAPI_FINAL {
std::map<std::string, std::string> fieldWebsocketChannelMapBitget = {
{CCAPI_TRADE, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_TRADES},
{CCAPI_MARKET_DEPTH, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_BOOKS},
{CCAPI_CANDLESTICK, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_KLINE},
};
std::map<std::string, std::string> fieldWebsocketChannelMapBitgetFutures = {
{CCAPI_TRADE, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_TRADES},
{CCAPI_MARKET_DEPTH, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_BOOKS},
{CCAPI_CANDLESTICK, CCAPI_WEBSOCKET_BITGET_BASE_CHANNEL_KLINE},
};
std::map<std::string, std::string> fieldWebsocketChannelMapBitmart = {
{CCAPI_TRADE, CCAPI_WEBSOCKET_BITMART_CHANNEL_TRADE},
Expand Down
11 changes: 7 additions & 4 deletions include/ccapi_cpp/service/ccapi_market_data_service_bitget.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MarketDataServiceBitget : public MarketDataServiceBitgetBase {
ServiceContext* serviceContextPtr)
: MarketDataServiceBitgetBase(eventHandler, sessionOptions, sessionConfigs, serviceContextPtr) {
this->exchangeName = CCAPI_EXCHANGE_NAME_BITGET;
this->baseUrlWs = sessionConfigs.getUrlWebsocketBase().at(this->exchangeName) + "/spot/v1/stream";
this->baseUrlWs = sessionConfigs.getUrlWebsocketBase().at(this->exchangeName) + "/v2/ws/public";
this->baseUrlRest = sessionConfigs.getUrlRestBase().at(this->exchangeName);
this->setHostRestFromUrlRest(this->baseUrlRest);
this->setHostWsFromUrlWs(this->baseUrlWs);
Expand All @@ -27,9 +27,12 @@ class MarketDataServiceBitget : public MarketDataServiceBitgetBase {
// CCAPI_LOGGER_FATAL(std::string("e.what() = ") + e.what());
// }
// #endif
this->getRecentTradesTarget = "/api/spot/v1/market/fills";
this->getInstrumentTarget = "/api/spot/v1/public/product";
this->getInstrumentsTarget = "/api/spot/v1/public/products";
this->getRecentTradesTarget = "/api/v2/spot/market/fills";
this->getHistoricalTradesTarget = "/api/v2/spot/market/fills-history";
this->getInstrumentTarget = "/api/v2/spot/public/symbols";
this->getInstrumentsTarget = "/api/v2/spot/public/symbols";
this->getRecentCandlesticksTarget = "/api/v2/spot/market/candles";
this->getHistoricalCandlesticksTarget = "/api/v2/spot/market/candles";
}
virtual ~MarketDataServiceBitget() {}
};
Expand Down
Loading
Loading