@@ -37,26 +37,30 @@ class ExecutionManagementServiceBinanceDerivativesBase : public ExecutionManagem
3737 switch (request.getOperation ()) {
3838 case Request::Operation::GET_ACCOUNT_POSITIONS: {
3939 for (const auto & x : document.GetArray ()) {
40- Element element;
41- element.insert (CCAPI_INSTRUMENT, x[" symbol" ].GetString ());
42- element.insert (CCAPI_EM_POSITION_SIDE, x[" positionSide" ].GetString ());
4340 std::string positionAmt;
4441 auto it = x.FindMember (" positionAmt" );
4542 if (it != x.MemberEnd ()) {
4643 positionAmt = it->value .GetString ();
4744 } else {
4845 positionAmt = x[" maxQty" ].GetString ();
4946 }
50- element.insert (CCAPI_EM_POSITION_QUANTITY, positionAmt);
51- element.insert (CCAPI_EM_POSITION_ENTRY_PRICE, x[" entryPrice" ].GetString ());
52- element.insert (CCAPI_EM_POSITION_LEVERAGE, x[" leverage" ].GetString ());
53- if (x.HasMember (" unrealizedProfit" )) {
54- element.insert (CCAPI_EM_UNREALIZED_PNL, x[" unrealizedProfit" ].GetString ());
55- } else {
56- element.insert (CCAPI_EM_UNREALIZED_PNL, x[" unRealizedProfit" ].GetString ());
47+ if (!positionAmt.empty ()) {
48+ const auto & positionAmtDecimal = Decimal (positionAmt);
49+ if (positionAmtDecimal != Decimal::zero) {
50+ Element element;
51+ element.insert (CCAPI_INSTRUMENT, x[" symbol" ].GetString ());
52+ element.insert (CCAPI_EM_POSITION_SIDE, x[" positionSide" ].GetString ());
53+ element.insert (CCAPI_EM_POSITION_QUANTITY, positionAmt);
54+ element.insert (CCAPI_EM_POSITION_ENTRY_PRICE, x[" entryPrice" ].GetString ());
55+ if (x.HasMember (" unrealizedProfit" )) {
56+ element.insert (CCAPI_EM_UNREALIZED_PNL, x[" unrealizedProfit" ].GetString ());
57+ } else {
58+ element.insert (CCAPI_EM_UNREALIZED_PNL, x[" unRealizedProfit" ].GetString ());
59+ }
60+ element.insert (CCAPI_LAST_UPDATED_TIME_SECONDS, UtilTime::convertMillisecondsStrToSecondsStr (x[" updateTime" ].GetString ()));
61+ elementList.emplace_back (std::move (element));
62+ }
5763 }
58- element.insert (CCAPI_LAST_UPDATED_TIME_SECONDS, UtilTime::convertMillisecondsStrToSecondsStr (x[" updateTime" ].GetString ()));
59- elementList.emplace_back (std::move (element));
6064 }
6165 } break ;
6266 default :
0 commit comments