ccxt icon indicating copy to clipboard operation
ccxt copied to clipboard

Parsing the unrealized P&L from fetchBalance

Open krasnyd opened this issue 1 year ago • 1 comments

Preliminary Checks

  • [X] I have already searched for existing issues and confirmed that this issue is not a duplicate

Is your feature request related to a problem? Please describe

I am currently working with 4 exchanges and when I call the fetchBalance function, their API always returns the unrealized P&L in the raw data. This value is useful for me since I am combining it with the total balance, so the value does not fluctuate between each API call, as the price changes. It would be really helpful to have this field as a standard. Is there some technical reason, why this cannot be done? Or is it just a feature that nobody so far needed?

  • Bitget: unrealizedPL
  • Gateio: unrealised_pnl
  • Binance: totalUnrealizedProfit
  • Bybit: unrealisedPnl

Describe the solution you'd like

I would like to have the field unrealized P&L parsed as a standard value, so I would not need to process the raw response (in the info) from the API.

Describe alternatives you've considered

I looked at the fetchPositions function and it already contains a field unrealizedPnl, but this requires me to do the second API call because I want to combine it with the current balance on the account. It is possible to use it for my use case, but it's not practical.

krasnyd avatar May 30 '24 00:05 krasnyd

Thanks for the suggestion @krasnyd I'll look into adding unrealizedPnl to the fetchBalance response for you

Dan-krm avatar Aug 15 '24 01:08 Dan-krm