@@ -192,7 +192,7 @@ class ExecutionManagementServiceBitget : public ExecutionManagementServiceBitget
192192 {CCAPI_EM_ORDER_CUMULATIVE_FILLED_QUANTITY , std::make_pair (" baseVolume" , JsonDataType::STRING )},
193193 {CCAPI_EM_ORDER_CUMULATIVE_FILLED_PRICE_TIMES_QUANTITY , std::make_pair (" quoteVolume" , JsonDataType::STRING )},
194194 {CCAPI_EM_ORDER_STATUS , std::make_pair (" status" , JsonDataType::STRING )},
195- {CCAPI_EM_ORDER_INSTRUMENT , std::make_pair (" symbol" , JsonDataType::STRING )}};
195+ {CCAPI_EM_ORDER_INSTRUMENT , std::make_pair (" symbol" , JsonDataType::STRING )}};
196196 const rj::Value& data = document[" data" ];
197197 if (data.IsObject ()) {
198198 Element element;
@@ -278,57 +278,57 @@ class ExecutionManagementServiceBitget : public ExecutionManagementServiceBitget
278278 WsConnection& wsConnection = *wsConnectionPtr;
279279 std::string textMessage (textMessageView);
280280#endif
281- if (textMessage != " pong" ) {
281+ if (textMessage != " pong" ) {
282+ rj::Document document;
283+ document.Parse <rj::kParseNumbersAsStringsFlag >(textMessage.c_str ());
284+ auto it = document.FindMember (" event" );
285+ std::string eventStr = it != document.MemberEnd () ? it->value .GetString () : " " ;
286+ if (eventStr == " login" ) {
282287 rj::Document document;
283- document.Parse <rj::kParseNumbersAsStringsFlag >(textMessage.c_str ());
284- auto it = document.FindMember (" event" );
285- std::string eventStr = it != document.MemberEnd () ? it->value .GetString () : " " ;
286- if (eventStr == " login" ) {
287- rj::Document document;
288- document.SetObject ();
289- auto & allocator = document.GetAllocator ();
290- document.AddMember (" op" , rj::Value (" subscribe" ).Move (), allocator);
291- rj::Value args (rj::kArrayType );
292- const auto & fieldSet = subscription.getFieldSet ();
293- const auto & instrumentSet = subscription.getInstrumentSet ();
294- for (const auto & field : fieldSet) {
295- if (field == CCAPI_EM_ORDER_UPDATE || field == CCAPI_EM_PRIVATE_TRADE ) {
296- for (const auto & instrument : instrumentSet) {
297- rj::Value arg (rj::kObjectType );
298- arg.AddMember (" channel" , rj::Value (" orders" , allocator).Move (), allocator);
299- arg.AddMember (" instId" , rj::Value (instrument.c_str (), allocator).Move (), allocator);
300- arg.AddMember (" instType" , rj::Value (" SPOT" ).Move (), allocator);
301- args.PushBack (arg, allocator);
302- }
303- } else if (field == CCAPI_EM_BALANCE_UPDATE ) {
288+ document.SetObject ();
289+ auto & allocator = document.GetAllocator ();
290+ document.AddMember (" op" , rj::Value (" subscribe" ).Move (), allocator);
291+ rj::Value args (rj::kArrayType );
292+ const auto & fieldSet = subscription.getFieldSet ();
293+ const auto & instrumentSet = subscription.getInstrumentSet ();
294+ for (const auto & field : fieldSet) {
295+ if (field == CCAPI_EM_ORDER_UPDATE || field == CCAPI_EM_PRIVATE_TRADE ) {
296+ for (const auto & instrument : instrumentSet) {
304297 rj::Value arg (rj::kObjectType );
305- arg.AddMember (" channel" , rj::Value (" account " , allocator).Move (), allocator);
306- arg.AddMember (" coin " , rj::Value (" default " , allocator).Move (), allocator);
298+ arg.AddMember (" channel" , rj::Value (" orders " , allocator).Move (), allocator);
299+ arg.AddMember (" instId " , rj::Value (instrument. c_str () , allocator).Move (), allocator);
307300 arg.AddMember (" instType" , rj::Value (" SPOT" ).Move (), allocator);
308301 args.PushBack (arg, allocator);
309302 }
303+ } else if (field == CCAPI_EM_BALANCE_UPDATE ) {
304+ rj::Value arg (rj::kObjectType );
305+ arg.AddMember (" channel" , rj::Value (" account" , allocator).Move (), allocator);
306+ arg.AddMember (" coin" , rj::Value (" default" , allocator).Move (), allocator);
307+ arg.AddMember (" instType" , rj::Value (" SPOT" ).Move (), allocator);
308+ args.PushBack (arg, allocator);
310309 }
311- document.AddMember (" args" , args, allocator);
312- rj::StringBuffer stringBufferSubscribe;
313- rj::Writer<rj::StringBuffer> writerSubscribe (stringBufferSubscribe);
314- document.Accept (writerSubscribe);
315- std::string sendString = stringBufferSubscribe.GetString ();
316- ErrorCode ec;
310+ }
311+ document.AddMember (" args" , args, allocator);
312+ rj::StringBuffer stringBufferSubscribe;
313+ rj::Writer<rj::StringBuffer> writerSubscribe (stringBufferSubscribe);
314+ document.Accept (writerSubscribe);
315+ std::string sendString = stringBufferSubscribe.GetString ();
316+ ErrorCode ec;
317317#ifdef CCAPI_LEGACY_USE_WEBSOCKETPP
318- this ->send (wsConnection.hdl , sendString, wspp::frame::opcode::text, ec);
318+ this ->send (wsConnection.hdl , sendString, wspp::frame::opcode::text, ec);
319319#else
320320 this ->send (wsConnectionPtr, sendString, ec);
321321#endif
322- if (ec) {
323- this ->onError (Event::Type::SUBSCRIPTION_STATUS , Message::Type::SUBSCRIPTION_FAILURE , ec, " subscribe" );
324- }
325- } else {
326- Event event = this ->createEvent (subscription, textMessage, document, eventStr, timeReceived);
327- if (!event.getMessageList ().empty ()) {
328- this ->eventHandler (event, nullptr );
329- }
322+ if (ec) {
323+ this ->onError (Event::Type::SUBSCRIPTION_STATUS , Message::Type::SUBSCRIPTION_FAILURE , ec, " subscribe" );
324+ }
325+ } else {
326+ Event event = this ->createEvent (subscription, textMessage, document, eventStr, timeReceived);
327+ if (!event.getMessageList ().empty ()) {
328+ this ->eventHandler (event, nullptr );
330329 }
331330 }
331+ }
332332} // namespace ccapi
333333Event createEvent (const Subscription& subscription, const std::string& textMessage, const rj::Document& document, const std::string& eventStr,
334334 const TimePoint& timeReceived) {
@@ -440,7 +440,8 @@ Event createEvent(const Subscription& subscription, const std::string& textMessa
440440 event.setMessageList (messageList);
441441 return event;
442442}
443- }; // namespace ccapi
443+ }
444+ ; // namespace ccapi
444445} /* namespace ccapi */
445446#endif
446447#endif
0 commit comments