Skip to content
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

Coinbase: check for order cancellation failure #855

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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
13 changes: 9 additions & 4 deletions src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
}
catch (Exception ex) // All fails come back with an exception.
{
Logger.Error(ex, "Failed to place coinbase error");
Logger.Error(ex, "Failed to place coinbase order");
var token = JToken.Parse(ex.Message);
return new ExchangeOrderResult(){
Result = ExchangeAPIOrderResult.Rejected,
Expand All @@ -479,9 +479,14 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd

protected override async Task OnCancelOrderAsync(string orderId, string marketSymbol = null, bool isClientOrderId = false)
{
Dictionary<string, object> payload = new Dictionary<string, object>() {{ "order_ids", new [] { orderId } } };
await MakeJsonRequestAsync<JArray>("/orders/batch_cancel", payload: payload, requestMethod: "POST");
}
Dictionary<string, object> payload = new Dictionary<string, object>() {{ "order_ids", new [] { orderId } } };
var responseJObj = await MakeJsonRequestAsync<JObject>("/orders/batch_cancel", payload: payload, requestMethod: "POST");
if (responseJObj["results"][0].Value<bool>("success") != true)
{
Logger.Error("Failed to cancel coinbase order. {0}", responseJObj["results"][0].Value<string>("failure_reason"));
throw new APIException("Failed to cancel coinbase order. " + responseJObj["results"][0].Value<string>("failure_reason"));
}
}

protected override Task<ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
{
Expand Down
Loading