Incorrect summarizing of realized profit in partially filled order's execution report?

Hi,

I connect to Binance Futures API via Ruby. I have an issue when I close a position (e.g. LIMIT or MARKET), and the operation is not completed at once but in partial executions.

As I understand, after all the PARTIALLY_FILLED order updates, I get one FILLED message summarizing the result of the execution.

However in that update, the “rp” field (Realized Profit of the trade) comes with the last partial’s “rp” value, and I expect it to be summarized as well as the other fields are.

I have 2 examples:

The first one, APEUSDT, is a LIMIT SELL that shows a total RP or PNL of around 0.79 USDT. However, the summarized order update payload I got says different:

{"L"=>"5.5600", "N"=>"USDT", "R"=>true, "S"=>"SELL", "T"=>1662895612061, "X"=>"FILLED",
"a"=>"0", "b"=>"0", "l"=>"6", "m"=>true, "n"=>"0.00667200", "o"=>"LIMIT", "p"=>"5.5600",
"q"=>"36", "s"=>"APEUSDT", "t"=>268356372, "x"=>"TRADE", "z"=>"36", "ap"=>"5.5600",
"cp"=>false, "ot"=>"LIMIT", "pP"=>false, "ps"=>"BOTH", "rp"=>"0.13200000", "si"=>0,
"sp"=>"0", "ss"=>0, "wt"=>"CONTRACT_PRICE"}

Pleas notice that while quantity (“q” => “36”), for instance, is summarized, “rp”=>“0.13200000” is coincident with last partial execution PNL.

The second example, GALUSDT, is a MARKET SELL that has a (sadly) total PNL of around -12.14 USDT. However, the summarized execution report says:

{"L"=>"3.14170", "N"=>"USDT", "R"=>true, "S"=>"SELL", "T"=>1662900909245, "X"=>"FILLED",
 "a"=>"0", "b"=>"0", "l"=>"16", "m"=>false, "n"=>"0.02010688", "o"=>"MARKET", "p"=>"0", 
"q"=>"60", "s"=>"GALUSDT", "t"=>83651733, "x"=>"TRADE", "z"=>"60", "ap"=>"3.14170", 
"cp"=>false, "ot"=>"MARKET", "pP"=>false, "ps"=>"BOTH", "rp"=>"-3.23680000",
"si"=>0, "sp"=>"0", "ss"=>0, "wt"=>"CONTRACT_PRICE"}

And again, “rp”=>"-3.23680000" is also coincident with last partial execution PNL.

Is there any explanation for this behaviour or maybe it is a bug?

I tried customer service, Case ID #94623810, but I think we didn’t understand each other.

Regards.

rp is the value of the Realized Profit for each trades.

To get all PNLs of ONE order, you will need to sum(rp) with same i ( order ID).

The restful endpoints (/fapi/v1/userTrades) provides order, trades and PNL info that may be helpful to understand.