Skip to content

Commit

Permalink
Added support for clientOrderId to restClient.PerpetualFuturesApi.Tra…
Browse files Browse the repository at this point in the history
…ding.GetOrderAsync, CancelOrderAsync and EditOrderAsync
  • Loading branch information
JKorf committed Oct 21, 2024
1 parent 9e5596d commit aa4f6a2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ public async Task<WebCallResult<IEnumerable<GateIoPerpOrder>>> GetOrdersByTimest
/// <inheritdoc />
public async Task<WebCallResult<GateIoPerpOrder>> GetOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.Add("order_id", orderId);
var request = _definitions.GetOrCreate(HttpMethod.Get, $"/api/v4/futures/{settlementAsset}/orders/" + orderId, GateIoExchange.RateLimiter.RestFuturesOther, 1, true);
var request = _definitions.GetOrCreate(HttpMethod.Get, $"/api/v4/futures/{settlementAsset}/orders/" + (orderId?.ToString() ?? clientOrderId), GateIoExchange.RateLimiter.RestFuturesOther, 1, true);
return await _baseClient.SendAsync<GateIoPerpOrder>(request, parameters, ct).ConfigureAwait(false);
}

Expand All @@ -308,12 +308,12 @@ public async Task<WebCallResult<GateIoPerpOrder>> GetOrderAsync(
/// <inheritdoc />
public async Task<WebCallResult<GateIoPerpOrder>> CancelOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.Add("order_id", orderId);
var request = _definitions.GetOrCreate(HttpMethod.Delete, $"/api/v4/futures/{settlementAsset}/orders/" + orderId, GateIoExchange.RateLimiter.RestFuturesOrderCancelation, 1, true);
var request = _definitions.GetOrCreate(HttpMethod.Delete, $"/api/v4/futures/{settlementAsset}/orders/" + (orderId?.ToString() ?? clientOrderId), GateIoExchange.RateLimiter.RestFuturesOrderCancelation, 1, true);
return await _baseClient.SendAsync<GateIoPerpOrder>(request, parameters, ct).ConfigureAwait(false);
}

Expand All @@ -324,18 +324,18 @@ public async Task<WebCallResult<GateIoPerpOrder>> CancelOrderAsync(
/// <inheritdoc />
public async Task<WebCallResult<GateIoPerpOrder>> EditOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
int? quantity = null,
decimal? price = null,
string? amendText = null,
CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.Add("order_id", orderId);
parameters.AddOptional("size", quantity);
parameters.AddOptionalString("price", price);
parameters.AddOptional("amend_text", amendText);
var request = _definitions.GetOrCreate(HttpMethod.Put, $"/api/v4/futures/{settlementAsset}/orders/" + orderId, GateIoExchange.RateLimiter.RestFuturesOrderPlacement, 1, true);
var request = _definitions.GetOrCreate(HttpMethod.Put, $"/api/v4/futures/{settlementAsset}/orders/" + (orderId?.ToString() ?? clientOrderId), GateIoExchange.RateLimiter.RestFuturesOrderPlacement, 1, true);
return await _baseClient.SendAsync<GateIoPerpOrder>(request, parameters, ct).ConfigureAwait(false);
}

Expand Down
35 changes: 20 additions & 15 deletions GateIo.Net/GateIo.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -241,41 +241,47 @@ Task<WebCallResult<IEnumerable<GateIoPerpOrder>>> GetOrdersByTimestampAsync(
/// <para><a href="https://www.gate.io/docs/developers/apiv4/en/#get-a-single-order-2" /></para>
/// </summary>
/// <param name="settlementAsset">The settlement asset. btc, usdt or usd</param>
/// <param name="orderId">Order id</param>
/// <param name="orderId">Order id, either this or clientOrderId should be provided</param>
/// <param name="clientOrderId">Client order id, either this or orderId should be provided</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult<GateIoPerpOrder>> GetOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
CancellationToken ct = default);

/// <summary>
/// Cancel an order
/// <para><a href="https://www.gate.io/docs/developers/apiv4/en/#cancel-a-single-order-2" /></para>
/// </summary>
/// <param name="settlementAsset">The settlement asset. btc, usdt or usd</param>
/// <param name="orderId">Order id</param>
/// <param name="orderId">Order id, either this or clientOrderId should be provided</param>
/// <param name="clientOrderId">Client order id, either this or orderId should be provided</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult<GateIoPerpOrder>> CancelOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
CancellationToken ct = default);

/// <summary>
/// Edit an existing order
/// <para><a href="https://www.gate.io/docs/developers/apiv4/en/#amend-an-order-2" /></para>
/// </summary>
/// <param name="settlementAsset">The settlement asset. btc, usdt or usd</param>
/// <param name="orderId">Order id</param>
/// <param name="orderId">Order id, either this or clientOrderId should be provided</param>
/// <param name="clientOrderId">Client order id, either this or orderId should be provided</param>
/// <param name="quantity">New quantity</param>
/// <param name="price">New price</param>
/// <param name="amendText">Amend text</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult<GateIoPerpOrder>> EditOrderAsync(
string settlementAsset,
long orderId,
long? orderId = null,
string? clientOrderId = null,
int? quantity = null,
decimal? price = null,
string? amendText = null,
Expand Down

0 comments on commit aa4f6a2

Please sign in to comment.