JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.05k stars 429 forks source link

UnrealizedPnL is not correct after upgrading version 10.0.0 #1400

Closed dante1989 closed 3 months ago

dante1989 commented 3 months ago

Position is opened for ETHUSD

Dim BinanceFuturesPositions_CheckBalance = Await clientBinance.CoinFuturesApi.Account.GetPositionInformationAsync For Each LongShortPosition In BinanceFuturesPositions_CheckBalance.Data

                                If LongShortPosition.Symbol = "ETHUSD" Then

                                  Dim  Balance_UnrealizedPnL = LongShortPosition.UnrealizedPnL
                                End IF
                             Next

Version 9.12.0 - 16 Jul 2024: Balance_UnrealizedPnL has a valid value > 0 Version 10.0.0 - 27 Jul 2024: Balance_UnrealizedPnL = 0

JKorf commented 3 months ago

Hi, fixed in the latest version. CoinFutures returns UnRealizedProfit instead of UnrealizedProfit. Json.Net converter allows this, but System.Text.Json doesn't (by default). I've fixed this in latest version, and updated tests to check for capitalization

dante1989 commented 3 months ago

After using the newest version Version 10.1.0 - 07 Aug 2024, i have still the same problem. When i come back Version 9.12.0 again. It is ok.

JKorf commented 3 months ago

Ah you're right. Another case to add in my tests (forgot the JsonInclude attribute). I've tested it and it works with the latest version 10.1.1

dante1989 commented 3 months ago

I have sent the donation, thank you Could you tell us why are you choosing system.text.json?

JKorf commented 3 months ago

Thanks, appreciated.

Sure, mainly 2 reasons:

  1. System.Text.Json is faster
  2. When all libraries have been migrated (long term) the Newtonsoft.Json package can be removed as reference and I think the less third party packages the better. I'd prefer Microsoft packages over third party packages.
dante1989 commented 3 months ago

Thank you