Spot API: how to get PNL of my orders (realized and unrealized) ?

Hi,

I’m currently able to retrieve all my Spot orders, but I also wish to compute the P&L of each order/position.

For example, I can have a working order, so the PNL= last-entry_price (But should I account for commissions etc… maybe it is more complex than this formula).

Also, for closed orders, how can I compute the PNL, should I get the price at “end time”, then also compute like this PNL = price_at(end_time) - entry_price

PS: if it is the case, does the “end_time” is the last “update_time” ?
See here: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#all-orders-user_data

Or, is there another way ?

In spot, when the order if filled, the asset is settled. So you can use it calculate the profit?

It is my question, I do not know how to compute the exact PNL.

  • does my formula are enough ?
  • are they correct ?
  • which API should I call ?

How to do this for realized and unrealized orders ?