diff --git a/BitMart.Net.UnitTests/Endpoints/Spot/Trading/CancelAllOrder.txt b/BitMart.Net.UnitTests/Endpoints/Spot/Trading/CancelAllOrder.txt new file mode 100644 index 0000000..07e90ba --- /dev/null +++ b/BitMart.Net.UnitTests/Endpoints/Spot/Trading/CancelAllOrder.txt @@ -0,0 +1,10 @@ +POST +/spot/v4/cancel_all +true +{ + "code": 1000, + "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", + "message": "OK", + "data": { + } +} \ No newline at end of file diff --git a/BitMart.Net.UnitTests/RestRequestTests.cs b/BitMart.Net.UnitTests/RestRequestTests.cs index e6cd8ea..9a1de9b 100644 --- a/BitMart.Net.UnitTests/RestRequestTests.cs +++ b/BitMart.Net.UnitTests/RestRequestTests.cs @@ -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] diff --git a/BitMart.Net/BitMart.Net.xml b/BitMart.Net/BitMart.Net.xml index 0c11ee3..bb83c57 100644 --- a/BitMart.Net/BitMart.Net.xml +++ b/BitMart.Net/BitMart.Net.xml @@ -347,6 +347,9 @@ + + + @@ -1977,6 +1980,16 @@ Client order ids to cancel. Either this or orderIds should be provided Cancellation token + + + Cancel all orders matching the parameters + + + Filter by symbol + Filter by order side + Cancellation token + + Place a new margin order diff --git a/BitMart.Net/Clients/SpotApi/BitMartRestClientSpotApiTrading.cs b/BitMart.Net/Clients/SpotApi/BitMartRestClientSpotApiTrading.cs index a9ae6be..6a2b9b2 100644 --- a/BitMart.Net/Clients/SpotApi/BitMartRestClientSpotApiTrading.cs +++ b/BitMart.Net/Clients/SpotApi/BitMartRestClientSpotApiTrading.cs @@ -148,6 +148,21 @@ public async Task> CancelOrdersAsync(st #endregion + #region Cancel Order + + /// + public async Task 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 /// diff --git a/BitMart.Net/Interfaces/Clients/SpotApi/IBitMartRestClientSpotApiTrading.cs b/BitMart.Net/Interfaces/Clients/SpotApi/IBitMartRestClientSpotApiTrading.cs index 9379726..5293d4c 100644 --- a/BitMart.Net/Interfaces/Clients/SpotApi/IBitMartRestClientSpotApiTrading.cs +++ b/BitMart.Net/Interfaces/Clients/SpotApi/IBitMartRestClientSpotApiTrading.cs @@ -57,6 +57,16 @@ public interface IBitMartRestClientSpotApiTrading /// Cancellation token Task> CancelOrdersAsync(string symbol, IEnumerable? orderIds = null, IEnumerable? clientOrderIds = null, CancellationToken ct = default); + /// + /// Cancel all orders matching the parameters + /// + /// + /// Filter by symbol + /// Filter by order side + /// Cancellation token + /// + Task CancelAllOrderAsync(string? symbol = null, OrderSide? side = null, CancellationToken ct = default); + /// /// Place a new margin order ///