@@ -870,7 +870,7 @@ class MarketDataService : public Service {
870870 const TimePoint& tp, const TimePoint& timeReceived, MarketDataMessage::TypeForData& input, const std::string& field,
871871 const std::map<std::string, std::string>& optionMap, const std::vector<std::string>& correlationIdList,
872872 std::map<Decimal, std::string>& snapshotBid, std::map<Decimal, std::string>& snapshotAsk) {
873- CCAPI_LOGGER_TRACE (" input = " + MarketDataMessage::dataToString (input));
873+ CCAPI_LOGGER_TRACE (" input = " + MarketDataMessage::dataToString<MarketDataMessage::TypeForData> (input));
874874 if (this ->processedInitialSnapshotByConnectionIdChannelIdSymbolIdMap [wsConnectionPtr->id ][channelId][symbolId]) {
875875 std::vector<Message> messageList;
876876 CCAPI_LOGGER_TRACE (" optionMap = " + toString (optionMap));
@@ -988,7 +988,7 @@ class MarketDataService : public Service {
988988 void processTrade (std::shared_ptr<WsConnection> wsConnectionPtr, const std::string& channelId, const std::string& symbolId, Event& event, const TimePoint& tp,
989989 const TimePoint& timeReceived, MarketDataMessage::TypeForData& input, const std::string& field,
990990 const std::map<std::string, std::string>& optionMap, const std::vector<std::string>& correlationIdList, bool isSolicited) {
991- CCAPI_LOGGER_TRACE (" input = " + MarketDataMessage::dataToString (input));
991+ CCAPI_LOGGER_TRACE (" input = " + MarketDataMessage::dataToString<MarketDataMessage::TypeForData> (input));
992992 CCAPI_LOGGER_TRACE (" optionMap = " + toString (optionMap));
993993 bool shouldConflate = optionMap.at (CCAPI_CONFLATE_INTERVAL_MILLISECONDS) != CCAPI_CONFLATE_INTERVAL_MILLISECONDS_DEFAULT;
994994 CCAPI_LOGGER_TRACE (" shouldConflate = " + toString (shouldConflate));
@@ -1459,20 +1459,18 @@ class MarketDataService : public Service {
14591459 }
14601460
14611461 void buildOrderBookInitialOnFail (std::shared_ptr<WsConnection> wsConnectionPtr, const std::string& exchangeSubscriptionId, long delayMilliseconds) {
1462- auto thisDelayMilliseconds = delayMilliseconds * 2 ;
1463- if (thisDelayMilliseconds > 0 ) {
1464- TimerPtr timerPtr (new boost::asio::steady_timer (*this ->serviceContextPtr ->ioContextPtr , std::chrono::milliseconds (thisDelayMilliseconds)));
1465- timerPtr->async_wait ([wsConnectionPtr, exchangeSubscriptionId, thisDelayMilliseconds, that = this ](ErrorCode const & ec) {
1466- if (ec) {
1467- that->onError (Event::Type::SUBSCRIPTION_STATUS, Message::Type::GENERIC_ERROR, ec, " timer" );
1468- } else {
1469- that->buildOrderBookInitial (wsConnectionPtr, exchangeSubscriptionId, thisDelayMilliseconds);
1470- }
1471- });
1472- this ->fetchMarketDepthInitialSnapshotTimerByConnectionIdExchangeSubscriptionIdMap [wsConnectionPtr->id ][exchangeSubscriptionId] = timerPtr;
1473- } else {
1474- this ->buildOrderBookInitial (wsConnectionPtr, exchangeSubscriptionId, thisDelayMilliseconds);
1475- }
1462+ CCAPI_LOGGER_ERROR (" buildOrderBookInitialOnFail: wsConnectionPtr = " + toString (*wsConnectionPtr) + " , exchangeSubscriptionId = " + exchangeSubscriptionId +
1463+ " , delayMilliseconds = " + toString (delayMilliseconds));
1464+ auto thisDelayMilliseconds = delayMilliseconds > 0 ? delayMilliseconds * 2 : 1000 ;
1465+ TimerPtr timerPtr (new boost::asio::steady_timer (*this ->serviceContextPtr ->ioContextPtr , std::chrono::milliseconds (thisDelayMilliseconds)));
1466+ timerPtr->async_wait ([wsConnectionPtr, exchangeSubscriptionId, thisDelayMilliseconds, that = this ](ErrorCode const & ec) {
1467+ if (ec) {
1468+ that->onError (Event::Type::SUBSCRIPTION_STATUS, Message::Type::GENERIC_ERROR, ec, " timer" );
1469+ } else {
1470+ that->buildOrderBookInitial (wsConnectionPtr, exchangeSubscriptionId, thisDelayMilliseconds);
1471+ }
1472+ });
1473+ this ->fetchMarketDepthInitialSnapshotTimerByConnectionIdExchangeSubscriptionIdMap [wsConnectionPtr->id ][exchangeSubscriptionId] = timerPtr;
14761474 }
14771475
14781476 void buildOrderBookInitial (std::shared_ptr<WsConnection> wsConnectionPtr, const std::string& exchangeSubscriptionId, long delayMilliseconds) {
@@ -1536,39 +1534,39 @@ class MarketDataService : public Service {
15361534 }
15371535 }
15381536 }
1539- if (that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id ).find (exchangeSubscriptionId) !=
1540- that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id ).end ()) {
1541- auto it = that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id )
1542- .at (exchangeSubscriptionId)
1543- .upper_bound (versionId);
1544- while (it != that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id )
1545- .at (exchangeSubscriptionId)
1546- .end ()) {
1547- const auto & input = it->second ;
1548- for (const auto & x : input) {
1549- const auto & type = x.first ;
1550- const auto & detail = x.second ;
1551- if (type == MarketDataMessage::DataType::BID) {
1552- for (const auto & y : detail) {
1553- const auto & price = y.at (MarketDataMessage::DataFieldType::PRICE);
1554- const auto & size = y.at (MarketDataMessage::DataFieldType::SIZE);
1555- Decimal decimalPrice (price);
1556- that->updateOrderBook (snapshotBid, decimalPrice, size, that->sessionOptions .enableCheckOrderBookChecksum );
1557- }
1558- } else if (type == MarketDataMessage::DataType::ASK) {
1559- for (const auto & y : detail) {
1560- const auto & price = y.at (MarketDataMessage::DataFieldType::PRICE);
1561- const auto & size = y.at (MarketDataMessage::DataFieldType::SIZE);
1562- Decimal decimalPrice (price);
1563- that->updateOrderBook (snapshotAsk, decimalPrice, size, that->sessionOptions .enableCheckOrderBookChecksum );
1564- }
1537+ // if (that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap.at(wsConnectionPtr->id).find(exchangeSubscriptionId) !=
1538+ // that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap.at(wsConnectionPtr->id).end()) {
1539+ auto it = that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id )
1540+ .at (exchangeSubscriptionId)
1541+ .upper_bound (versionId);
1542+ while (it != that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id )
1543+ .at (exchangeSubscriptionId)
1544+ .end ()) {
1545+ const auto & input = it->second ;
1546+ for (const auto & x : input) {
1547+ const auto & type = x.first ;
1548+ const auto & detail = x.second ;
1549+ if (type == MarketDataMessage::DataType::BID) {
1550+ for (const auto & y : detail) {
1551+ const auto & price = y.at (MarketDataMessage::DataFieldType::PRICE);
1552+ const auto & size = y.at (MarketDataMessage::DataFieldType::SIZE);
1553+ Decimal decimalPrice (price);
1554+ that->updateOrderBook (snapshotBid, decimalPrice, size, that->sessionOptions .enableCheckOrderBookChecksum );
1555+ }
1556+ } else if (type == MarketDataMessage::DataType::ASK) {
1557+ for (const auto & y : detail) {
1558+ const auto & price = y.at (MarketDataMessage::DataFieldType::PRICE);
1559+ const auto & size = y.at (MarketDataMessage::DataFieldType::SIZE);
1560+ Decimal decimalPrice (price);
1561+ that->updateOrderBook (snapshotAsk, decimalPrice, size, that->sessionOptions .enableCheckOrderBookChecksum );
15651562 }
15661563 }
1567- that->orderbookVersionIdByConnectionIdExchangeSubscriptionIdMap [wsConnectionPtr->id ][exchangeSubscriptionId] = it->first ;
1568- it++;
15691564 }
1570- that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id ).erase (exchangeSubscriptionId);
1565+ that->orderbookVersionIdByConnectionIdExchangeSubscriptionIdMap [wsConnectionPtr->id ][exchangeSubscriptionId] = it->first ;
1566+ it++;
15711567 }
1568+ that->marketDataMessageDataBufferByConnectionIdExchangeSubscriptionIdVersionIdMap .at (wsConnectionPtr->id ).erase (exchangeSubscriptionId);
1569+ // }
15721570 Event event;
15731571 event.setType (Event::Type::SUBSCRIPTION_DATA);
15741572 std::vector<Element> elementList;
0 commit comments