Skip to content

Commit

Permalink
CancelMultipleOrdersAsync fix for InvokeOrderCanceled (#57)
Browse files Browse the repository at this point in the history
* CancelMultipleOrdersAsync fix for InvokeOrderCanceled
  • Loading branch information
mkarakucuk authored Oct 16, 2024
1 parent c2d2b60 commit 7411914
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions OKX.Net/Clients/UnifiedApi/OKXRestClientUnifiedApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,23 @@ public virtual async Task<WebCallResult<IEnumerable<OKXOrderCancelResponse>>> 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<IEnumerable<OKXOrderCancelResponse>>(request, parameters, ct).ConfigureAwait(false);
var result = await _baseClient.SendRawAsync<OKXRestApiResponse<IEnumerable<OKXOrderCancelResponse>>>(request, parameters, ct).ConfigureAwait(false);
if (!result)
return result;
return result.AsError<IEnumerable<OKXOrderCancelResponse>>(result.Error!);

if (result.Data.ErrorCode > 0 && result.Data.ErrorCode != 2)
return result.AsError<IEnumerable<OKXOrderCancelResponse>>(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<IEnumerable<OKXOrderCancelResponse>>(result.Data.Data);
}

/// <inheritdoc />
Expand Down

0 comments on commit 7411914

Please sign in to comment.