Skip to content

Commit

Permalink
Added SpotApi.Trading.CancelAllOrderAsync endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Aug 6, 2024
1 parent 684e404 commit 0f02973
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
10 changes: 10 additions & 0 deletions BitMart.Net.UnitTests/Endpoints/Spot/Trading/CancelAllOrder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
POST
/spot/v4/cancel_all
true
{
"code": 1000,
"trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1",
"message": "OK",
"data": {
}
}
1 change: 1 addition & 0 deletions BitMart.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public async Task ValidateSpotTradingDataCalls()
await tester.ValidateAsync(client => client.SpotApi.Trading.GetUserTradesAsync(), "GetUserTrades", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.Trading.GetOrderTradesAsync("123"), "GetOrderTrades", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrdersAsync("123"), "CancelOrders", nestedJsonProperty: "data");
await tester.ValidateAsync(client => client.SpotApi.Trading.CancelAllOrderAsync(), "CancelAllOrder");
}

[Test]
Expand Down
13 changes: 13 additions & 0 deletions BitMart.Net/BitMart.Net.xml

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

15 changes: 15 additions & 0 deletions BitMart.Net/Clients/SpotApi/BitMartRestClientSpotApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ public async Task<WebCallResult<BitMartCancelOrdersResult>> CancelOrdersAsync(st

#endregion

#region Cancel Order

/// <inheritdoc />
public async Task<WebCallResult> CancelAllOrderAsync(string? symbol = null, OrderSide? side = null, CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.AddOptional("symbol", symbol);
parameters.AddOptionalEnum("side", side);
var request = _definitions.GetOrCreate(HttpMethod.Post, "/spot/v4/cancel_all", BitMartExchange.RateLimiter.BitMart, 1, true,
new SingleLimitGuard(1, TimeSpan.FromSeconds(3), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey));
return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false);
}

#endregion

#region Place Margin Order

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ public interface IBitMartRestClientSpotApiTrading
/// <param name="ct">Cancellation token</param>
Task<WebCallResult<BitMartCancelOrdersResult>> CancelOrdersAsync(string symbol, IEnumerable<string>? orderIds = null, IEnumerable<string>? clientOrderIds = null, CancellationToken ct = default);

/// <summary>
/// Cancel all orders matching the parameters
/// <para><a href="https://developer-pro.bitmart.com/en/spot/#cancel-all-order-v4-signed" /></para>
/// </summary>
/// <param name="symbol">Filter by symbol</param>
/// <param name="side">Filter by order side</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult> CancelAllOrderAsync(string? symbol = null, OrderSide? side = null, CancellationToken ct = default);

/// <summary>
/// Place a new margin order
/// <para><a href="https://developer-pro.bitmart.com/en/spot/#new-margin-order-v1-signed" /></para>
Expand Down

0 comments on commit 0f02973

Please sign in to comment.