Skip to content

added checks during cancel Order #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -724,11 +724,14 @@ protected override async Task OnCancelOrderAsync(string orderId, string? marketS
Dictionary<string, object> payload = await GetNoncePayloadAsync();
if (string.IsNullOrWhiteSpace(marketSymbol))
{
throw new InvalidOperationException("Binance cancel order request requires symbol");
throw new ArgumentNullException("Binance cancel order request requires symbol");
}
payload["symbol"] = marketSymbol!;
payload["orderId"] = orderId;
_ = await MakeJsonRequestAsync<JToken>("/order", BaseUrlApi, payload, "DELETE");
var token = await MakeJsonRequestAsync<JToken>("/order", BaseUrlApi, payload, "DELETE");
var cancelledOrder = ParseOrder(token);
if (cancelledOrder.OrderId != orderId)
throw new APIException($"Cancelled {cancelledOrder.OrderId} when trying to cancel {orderId}");
}

/// <summary>A withdrawal request. Fee is automatically subtracted from the amount.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ExchangeOrderResult ExchangeOrderResult
ClientOrderId = ClientOrderId,
Result = status,
ResultCode = CurrentOrderStatus,
Message = null, // can use for something in the future if needed
Message = OrderRejectReason, // can use for multiple things in the future if needed
Amount = CumulativeFilledQuantity,
Price = OrderPrice,
AveragePrice = CumulativeQuoteAssetTransactedQuantity / CumulativeFilledQuantity, // Average price can be found by doing Z divided by z.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,9 @@ private async Task MakeFillRequest(DateTime? afterDate, string productId, List<E

protected override async Task OnCancelOrderAsync(string orderId, string marketSymbol = null)
{
await MakeJsonRequestAsync<JArray>("orders/" + orderId, null, await GetNoncePayloadAsync(), "DELETE");
var jToken = await MakeJsonRequestAsync<JToken>("orders/" + orderId, null, await GetNoncePayloadAsync(), "DELETE");
if (jToken.ToStringInvariant() != orderId)
throw new APIException($"Cancelled {jToken.ToStringInvariant()} when trying to cancel {orderId}");
}
}

Expand Down