burakoner / OKEx.Net

Open source .Net API wrapper for the @OKEx V5 Rest API and V5 Websocket API
MIT License
86 stars 48 forks source link

SubscribeToOrderUpdates Failed to deserialize data #83

Closed JohnSilver9999 closed 1 year ago

JohnSilver9999 commented 1 year ago

Hi. I am creating the websocket and subscribe var rez = ws.SubscribeToOrderUpdates(OkexInstrumentType.Any, null, null, (data) => { if (data != null) { Console.WriteLine("OrderUpdates Instrument:" + data.Instrument); } });

when data come from server throw exception:

2022.11.17 21:22:18:931 | Warning | OKX WS Api | Socket 1 Failed to deserialize data into type Okex_GridBot.Net.Objects.Core.Okex_GridBotSocketUpdateResponse`1[System.Collections.Generic.IEnumerable`1[Okex_GridBot.Net.Objects.Trade.Okex_GridBotOrder]]: : 
Deserialize JsonSerializationException: Error setting value to 'PositionSide' on 'Okex_GridBot.Net.Objects.Trade.Okex_GridBotOrder'. data: {
  "arg": {
    "channel": "orders",
    "instType": "ANY",
    "uid": "293501884474515456"
  },
  "data": [
    {
      "accFillSz": "48.3585",
      "amendResult": "",
      "avgPx": "0.0396",
      "cTime": "1668700089981",
      "cancelSource": "",
      "category": "normal",
      "ccy": "",
      "clOrdId": "",
      "code": "0",
      "execType": "M",
      "fee": "-0.00153199728",
      "feeCcy": "USDT",
      "fillFee": "-0.00153199728",
      "fillFeeCcy": "USDT",
      "fillNotionalUsd": "1.913502902652",
      "fillPx": "0.0396",
      "fillSz": "48.3585",
      "fillTime": "1668709338877",
      "instId": "FITFI-USDT",
      "instType": "SPOT",
      "lever": "0",
      "msg": "",
      "notionalUsd": "1.913502902652",
      "ordId": "513500627520409602",
      "ordType": "limit",
      "pnl": "0",
      "posSide": "",
      "px": "0.0396",
      "rebate": "0",
      "rebateCcy": "FITFI",
      "reduceOnly": "false",
      "reqId": "",
      "side": "sell",
      "slOrdPx": "",
      "slTriggerPx": "",
      "slTriggerPxType": "",
      "source": "",
      "state": "filled",
      "sz": "48.3585",
      "tag": "538a3965e538BCDE",
      "tdMode": "cash",
      "tgtCcy": "",
      "tpOrdPx": "",
      "tpTriggerPx": "",
      "tpTriggerPxType": "",
      "tradeId": "13202547",
      "uTime": "1668709338878"
    }
  ]

How to fix it fast?

JohnSilver9999 commented 1 year ago

the problem has been solved. in file Okex.Net\Objects\Trade\OkexOrder.cs replace code public OkexPositionSide PositionSide { get; set; } with code public OkexPositionSide? PositionSide { get; set; }

burakoner commented 1 year ago

Thanks for feedback. I updated my local codes. I'll release new version at this weekend

burakoner commented 1 year ago

Version 5.3.0 is released with this commit https://github.com/burakoner/OKEx.Net/commit/1700b679454393180777e3a9eb06772ed0a2d159 Also nuget package is available on https://www.nuget.org/packages/OKEx.Net/5.3.0