JKorf / Bybit.Net

A C# .netstandard client library for the Bybit REST and Websocket V5 API focusing on clear usage and models
https://jkorf.github.io/Bybit.Net/
91 stars 62 forks source link

Inverse V5 GetPositionsAsync get Object reference not set to an instance of an object #181

Closed dante1989 closed 6 months ago

dante1989 commented 6 months ago

Dim BybitFuturesPositions_CheckBalance As WebCallResult(Of Bybit.Net.Objects.Models.V5.BybitResponse(Of Bybit.Net.Objects.Models.V5.BybitPosition)) = Nothing

Try

BybitFuturesPositions_CheckBalance = Await clientBybit.V5Api.Trading.GetPositionsAsync(Bybit.Net.Enums.Category.Inverse, "ETHUSD") For Each LongShortPosition In BybitFuturesPositions_CheckBalance.Data.list Msgbox(LongShortPosition.Quantity) Next Catch ex As Exception Msgbox (ex.Message) End Try

For Inverse, Sometimes it works very well, sometimes i got error: "Object reference not set to an instance of an object" for some hours. For Linear, it is ok

JKorf commented 6 months ago

You should check the value of BybitFuturesPositions_CheckBalance.Success. If this is false then the call wasn't successful and there is additional info in the BybitFuturesPositions_CheckBalance.Error property on why it failed

dante1989 commented 6 months ago

ok, i wil try now

dante1989 commented 6 months ago

I don't see this error appearing anymore, maybe this error comes from Bybit's server and not from our API, thank you