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: remove order fetch after submission #853

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
12 changes: 8 additions & 4 deletions src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The above copyright notice and this permission notice shall be included in all c
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -450,10 +451,13 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd

try
{
JToken result = await MakeJsonRequestAsync<JToken>($"/orders", payload: payload, requestMethod: "POST" );
// The Post doesn't return with any status, just a new OrderId. To get the Order Details we have to reQuery.
return await OnGetOrderDetailsAsync(result[ORDERID].ToStringInvariant());
}
JToken jtokenResult = await MakeJsonRequestAsync<JToken>($"/orders", payload: payload, requestMethod: "POST" );
var orderResult = ParseOrder(jtokenResult["success_response"]);
Debug.Assert(jtokenResult.Value<bool>("success") == true);
// the jtokenResult doesn't have the order status inside the "success_response" portion, but rather outside of it, so need to set it manually
orderResult.Result = ExchangeAPIOrderResult.PendingOpen;
return orderResult;
}
catch (Exception ex) // All fails come back with an exception.
{
Logger.Error(ex, "Failed to place coinbase error");
Expand Down
Loading