diff --git a/OKX.Net/Clients/UnifiedApi/OKXRestClientUnifiedApiTrading.cs b/OKX.Net/Clients/UnifiedApi/OKXRestClientUnifiedApiTrading.cs index bb9a5d8..13532b2 100644 --- a/OKX.Net/Clients/UnifiedApi/OKXRestClientUnifiedApiTrading.cs +++ b/OKX.Net/Clients/UnifiedApi/OKXRestClientUnifiedApiTrading.cs @@ -226,20 +226,23 @@ public virtual async Task>> Ca var request = _definitions.GetOrCreate(HttpMethod.Post, $"api/v5/trade/cancel-batch-orders", OKXExchange.RateLimiter.EndpointGate, 1, true, limitGuard: new SingleLimitGuard(300, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); - var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + var result = await _baseClient.SendRawAsync>>(request, parameters, ct).ConfigureAwait(false); if (!result) - return result; + return result.AsError>(result.Error!); + + if (result.Data.ErrorCode > 0 && result.Data.ErrorCode != 2) + return result.AsError>(new OKXRestApiError(result.Data.ErrorCode, result.Data.ErrorMessage!, null)); - foreach (var order in result.Data.Where(r => r.Success)) + foreach (var order in result.Data.Data.Where(r => r.Success)) { _baseClient.InvokeOrderCanceled(new CryptoExchange.Net.CommonObjects.OrderId { Id = order.OrderId.ToString(), - SourceObject = result.Data + SourceObject = order }); } - return result; + return result.As>(result.Data.Data); } ///