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/
92 stars 64 forks source link

Update BybitPosition.cs to allow CreateTime to be null #193

Closed cckkaallee closed 7 months ago

cckkaallee commented 7 months ago

Get Allowing DateTime to be null should make calling GetPositionsAsync() with no open positions possible.

client.V5Api.Trading.GetPositionsAsync() via BybitEnvironment.Testnet with 0 open positions yields error Message: [23] Deserialize JsonSerializationException: Error setting value to 'CreateTime' on 'Bybit.Net.Objects.Models.V5.BybitPosition'. data: { "retCode": 0, "retMsg": "OK", "result": { "nextPageCursor": "", "category": "linear", "list": [ { "symbol": "BTCPERP", "leverage": "10", "autoAddMargin": 0, "avgPrice": "", "liqPrice": "", "riskLimitValue": "100000", "takeProfit": "", "positionValue": "", "tpslMode": "", "isReduceOnly": false, "riskId": 10001, "trailingStop": "", "unrealisedPnl": "", "markPrice": "", "adlRankIndicator": 0, "cumRealisedPnl": "", "positionMM": "", "createdTime": "", "positionIdx": 0, "positionIM": "", "seq": -1, "updatedTime": "", "side": "", "bustPrice": "", "positionBalance": "", "leverageSysUpdatedTime": "", "size": "0", "positionStatus": "", "mmrSysUpdatedTime": "", "stopLoss": "", "tradeMode": 0 } ] }, "retExtInfo": {}, "time": 1708114419364 }

JKorf commented 7 months ago

Thanks for the PR, but I did already fix this while updating the model so should be good in the latest version