Wrong - Release PNL

Hey guys,
im using websocket to track the PNL and updating my account (in robot),
now i found a really weird behavior that happens in last two days ( it wasn’t there, and now its appear ).
so im doing something like this:
if ORDER_TRADE_UPDATE
if FILLED
so now instead of full PNL, its giving me part of the PNL so it is making my calculation wrong!!

Trade number 1 ( just the bottom PNL )

Trade number 2 ( fix without any problem !!! )

Trade number 3 ( fix without any problem !!! )

Trade number 4 ( just the bottom PNL )

in robot
image

########### Update
Data from: “fapi/v1/incom”

[
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.07494144',
    asset: 'USDT',
    time: 1648575003000,
    tranId: 9293018971793,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '-0.13440000',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.03284063',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '-0.08640000',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.02111184',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '-0.08820000',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.02111256',
    asset: 'USDT',
    time: 1648579502000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.07413359',
    asset: 'USDT',
    time: 1648894503000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'FUNDING_FEE',
    income: '0.01763640',
    asset: 'USDT',
    time: 1648915204000,
    info: 'FUNDING_FEE',
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'FUNDING_FEE',
    income: '0.01758300',
    asset: 'USDT',
    time: 1648944004000,
    info: 'FUNDING_FEE',
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'FUNDING_FEE',
    income: '0.01756688',
    asset: 'USDT',
    time: 1648972803000,
    info: 'FUNDING_FEE',
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'FUNDING_FEE',
    income: '0.01750594',
    asset: 'USDT',
    time: 1649001604000,
    info: 'FUNDING_FEE',
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '5.51040000',
    asset: 'USDT',
    time: 1649009702000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.03733376',
    asset: 'USDT',
    time: 1649009702000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '4.80200000',
    asset: 'USDT',
    time: 1649009702000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.03267488',
    asset: 'USDT',
    time: 1649009702000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.11252352',
    asset: 'USDT',
    time: 1649017802000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '3.34080000',
    asset: 'USDT',
    time: 1649028602000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.11385984',
    asset: 'USDT',
    time: 1649028602000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.11550800',
    asset: 'USDT',
    time: 1649067301000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.00808444',
    asset: 'USDT',
    time: 1649067301000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '1.84738317',
    asset: 'USDT',
    time: 1649070904000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.11476800',
    asset: 'USDT',
    time: 1649070904000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'REALIZED_PNL',
    income: '0.12231682',
    asset: 'USDT',
    time: 1649070904000,
  },
  {
    symbol: 'LPTUSDT',
    incomeType: 'COMMISSION',
    income: '-0.00803656',
    asset: 'USDT',
    time: 1649070904000,
  }
]

Data from “fapi/v1/userTrades”

[
  {
    symbol: 'LPTUSDT',
    side: 'SELL',
    price: '29.274',
    qty: '6.4',
    realizedPnl: '0',
    marginAsset: 'USDT',
    quoteQty: '187.3536',
    commission: '0.07494144',
    commissionAsset: 'USDT',
    time: 1648575003506,
    positionSide: 'SHORT',
    buyer: false,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.322',
    qty: '2.8',
    realizedPnl: '-0.13440000',
    marginAsset: 'USDT',
    quoteQty: '82.1016',
    commission: '0.03284063',
    commissionAsset: 'USDT',
    time: 1648579502724,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.322',
    qty: '1.8',
    realizedPnl: '-0.08640000',
    marginAsset: 'USDT',
    quoteQty: '52.7796',
    commission: '0.02111184',
    commissionAsset: 'USDT',
    time: 1648579502724,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.323',
    qty: '1.8',
    realizedPnl: '-0.08820000',
    marginAsset: 'USDT',
    quoteQty: '52.7814',
    commission: '0.02111256',
    commissionAsset: 'USDT',
    time: 1648579502724,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'SELL',
    price: '30.889',
    qty: '6',
    realizedPnl: '0',
    marginAsset: 'USDT',
    quoteQty: '185.3340',
    commission: '0.07413359',
    commissionAsset: 'USDT',
    time: 1648894503203,
    positionSide: 'SHORT',
    buyer: false,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.167',
    qty: '3.2',
    realizedPnl: '5.51040000',
    marginAsset: 'USDT',
    quoteQty: '93.3344',
    commission: '0.03733376',
    commissionAsset: 'USDT',
    time: 1649009702374,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.174',
    qty: '2.8',
    realizedPnl: '4.80200000',
    marginAsset: 'USDT',
    quoteQty: '81.6872',
    commission: '0.03267488',
    commissionAsset: 'USDT',
    time: 1649009702374,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '29.303',
    qty: '9.6',
    realizedPnl: '0',
    marginAsset: 'USDT',
    quoteQty: '281.3088',
    commission: '0.11252352',
    commissionAsset: 'USDT',
    time: 1649017802732,
    positionSide: 'LONG',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'SELL',
    price: '29.651',
    qty: '9.6',
    realizedPnl: '3.34080000',
    marginAsset: 'USDT',
    quoteQty: '284.6496',
    commission: '0.11385984',
    commissionAsset: 'USDT',
    time: 1649028602049,
    positionSide: 'LONG',
    buyer: false,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'SELL',
    price: '28.877',
    qty: '10',
    realizedPnl: '0',
    marginAsset: 'USDT',
    quoteQty: '288.7700',
    commission: '0.11550800',
    commissionAsset: 'USDT',
    time: 1649067301661,
    positionSide: 'SHORT',
    buyer: false,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'SELL',
    price: '28.873',
    qty: '0.7',
    realizedPnl: '0',
    marginAsset: 'USDT',
    quoteQty: '20.2111',
    commission: '0.00808444',
    commissionAsset: 'USDT',
    time: 1649067301661,
    positionSide: 'SHORT',
    buyer: false,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '28.692',
    qty: '10',
    realizedPnl: '1.84738317',
    marginAsset: 'USDT',
    quoteQty: '286.9200',
    commission: '0.11476800',
    commissionAsset: 'USDT',
    time: 1649070904430,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  },
  {
    symbol: 'LPTUSDT',
    side: 'BUY',
    price: '28.702',
    qty: '0.7',
    realizedPnl: '0.12231682',
    marginAsset: 'USDT',
    quoteQty: '20.0914',
    commission: '0.00803656',
    commissionAsset: 'USDT',
    time: 1649070904430,
    positionSide: 'SHORT',
    buyer: true,
    maker: false
  }
]

Data from server Logs ( only last one )

{
  symbol: 'LPTUSDT',
  orderSide: 'BUY',
  orderType: 'MARKET',
  timeInForce: 'GTC',
  originalQuantity: 10.7,
  originalPrice: 0,
  averagePrice: 28.6927,
  stopPrice: 0,
  executionType: 'TRADE',
  orderStatus: 'FILLED',
  lastFilledQuantity: 0.7,
  orderFilledAccumulatedQuantity: 10.7,
  lastFilledPrice: 28.702,
  commissionAmount: 0.00803656,
  commissionAsset: 'USDT',
  orderTradeTime: 1649070904430,
  bidsNotional: 0,
  asksNotional: 0,
  isMakerTrade: false,
  isReduceOnly: true,
  stopPriceWorkingType: 'CONTRACT_PRICE',
  originalOrderType: 'MARKET',
  positionSide: 'SHORT',
  isCloseAll: false,
  realisedProfit: 0.12231682,
  pP: false,
  si: 0,
  ss: 0
}

The data presented does not provide enough context to understand what your goal and the issue is.

Please be more clear on what you are trying to achieve, the current implementation and what the actual result is.

im receiving only PART of the PNL from binance

for example, in image number 4, i should’ve $10.3124 as a PNL, but instead i receive $4.802 , ( problem with websocket, there is NO problem with actual money in the futures account )

PNL can be affected by both PARTIALLY_FILLED and FILLED order updates.

i guessed that too :grinning_face_with_smiling_eyes: thanks a lot ill update this post if it solved the problem. :heart_eyes: