diff --git a/src/ExchangeSharp/API/Exchanges/OKGroup/OKGroupCommon.cs b/src/ExchangeSharp/API/Exchanges/OKGroup/OKGroupCommon.cs index 2582fcda..331f5b87 100644 --- a/src/ExchangeSharp/API/Exchanges/OKGroup/OKGroupCommon.cs +++ b/src/ExchangeSharp/API/Exchanges/OKGroup/OKGroupCommon.cs @@ -227,9 +227,20 @@ protected override async Task OnGetTradesWebSocketAsync(Func { - ExchangeTrade trade = token.ParseTrade(amountKey: "size", priceKey: "price", + ExchangeTrade trade; + var instrumentType = GetInstrumentType(symbol); + if (instrumentType == "futures") + { + trade = token.ParseTrade(amountKey: "qty", priceKey: "price", + typeKey: "side", timestampKey: "timestamp", + timestampType: TimestampType.Iso8601, idKey: "trade_id"); + } + else + { + trade = token.ParseTrade(amountKey: "size", priceKey: "price", typeKey: "side", timestampKey: "timestamp", timestampType: TimestampType.Iso8601, idKey: "trade_id"); + } await callback(new KeyValuePair(symbol, trade)); }); } @@ -733,6 +744,24 @@ async Task sendMessageAsync(string category, IEnumerable symbolsToSend) return marketSymbols; } - #endregion + private string GetInstrumentType(string marketSymbol) + { + string type; + if (marketSymbol.Split('-').Length == 3 && marketSymbol.Split('-')[2] == "SWAP") + { + type = "swap"; + } + else if (marketSymbol.Split('-').Length == 3 && int.TryParse(marketSymbol.Split('-')[2], out _)) + { + type = "futures"; + } + else + { + type = "spot"; + } + return type; + } + + #endregion } }