Skip to content

Commit

Permalink
add clientOrderId to GateIoRestClientSpotApiTrading.EditOrderAsync()
Browse files Browse the repository at this point in the history
  • Loading branch information
alokym86 committed Oct 2, 2024
1 parent 3248f6e commit fcd2e4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion GateIo.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public async Task ValidateSpotTradingCalls()
await tester.ValidateAsync(client => client.SpotApi.Trading.GetOrderAsync("ETH_USDT", 123), "GetOrder", ignoreProperties: new List<string> { "create_time", "update_time", "fill_price" });
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelAllOrdersAsync("ETH_USDT"), "CancelAllOders", ignoreProperties: new List<string> { "create_time", "update_time", "fill_price" });
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrdersAsync(new[] { new GateIoBatchCancelRequest { Id = "123", Symbol = "ETH_USDT" } }), "CancelOrders");
await tester.ValidateAsync(client => client.SpotApi.Trading.EditOrderAsync("ETH_USDT", 123, 123), "EditOrder", ignoreProperties: new List<string> { "create_time", "update_time", "fill_price" });
await tester.ValidateAsync(client => client.SpotApi.Trading.EditOrderAsync("ETH_USDT", 123, price: 123), "EditOrder", ignoreProperties: new List<string> { "create_time", "update_time", "fill_price" });
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrderAsync("ETH_USDT", 123), "CancelOrder", ignoreProperties: new List<string> { "create_time", "update_time", "fill_price" });
await tester.ValidateAsync(client => client.SpotApi.Trading.GetUserTradesAsync(), "GetUserTrades", ignoreProperties: new List<string> { "create_time" });
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrdersAfterAsync(TimeSpan.Zero), "CancelOrdersAfter");
Expand Down
7 changes: 5 additions & 2 deletions GateIo.Net/Clients/SpotApi/GateIoRestClientSpotApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,16 @@ public async Task<WebCallResult<IEnumerable<GateIoCancelResult>>> CancelOrdersAs
/// <inheritdoc />
public async Task<WebCallResult<GateIoOrder>> EditOrderAsync(
string symbol,
long orderId,
long? orderId = null,
string? clientOrderId = null,
decimal? price = null,
decimal? quantity = null,
string? amendText = null,
SpotAccountType? accountType = null,
CancellationToken ct = default)
{
var id = orderId?.ToString() ?? clientOrderId;

var queryParameters = new ParameterCollection();
queryParameters.Add("currency_pair", symbol);

Expand All @@ -238,7 +241,7 @@ public async Task<WebCallResult<GateIoOrder>> EditOrderAsync(
bodyParameters.AddOptionalString("amount", quantity);
bodyParameters.AddOptional("amend_text", amendText);
bodyParameters.AddOptionalEnum("account", accountType);
var request = _definitions.GetOrCreate(new HttpMethod("Patch"), "/api/v4/spot/orders/" + orderId, GateIoExchange.RateLimiter.RestSpotOrderPlacement, 1, true);
var request = _definitions.GetOrCreate(new HttpMethod("Patch"), "/api/v4/spot/orders/" + id, GateIoExchange.RateLimiter.RestSpotOrderPlacement, 1, true);
return await _baseClient.SendAsync<GateIoOrder>(request, queryParameters, bodyParameters, ct).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ Task<WebCallResult<IEnumerable<GateIoCancelResult>>> CancelOrdersAsync(
/// <para><a href="https://www.gate.io/docs/developers/apiv4/#amend-an-order" /></para>
/// </summary>
/// <param name="symbol">Symbol, for example `ETH_USDT`</param>
/// <param name="orderId">Order id</param>
/// <param name="orderId">Order id, either orderId or clientOrderId required</param>
/// <param name="clientOrderId">user custom ID(i.e., t-123c456f), either `orderId` or `clientOrderId` required</param>
/// <param name="price">New price</param>
/// <param name="quantity">New quantity</param>
/// <param name="amendText">Custom info during amending order</param>
Expand All @@ -143,7 +144,8 @@ Task<WebCallResult<IEnumerable<GateIoCancelResult>>> CancelOrdersAsync(
/// <returns></returns>
Task<WebCallResult<GateIoOrder>> EditOrderAsync(
string symbol,
long orderId,
long? orderId,
string? clientOrderId = null,
decimal? price = null,
decimal? quantity = null,
string? amendText = null,
Expand Down

0 comments on commit fcd2e4a

Please sign in to comment.