diff --git a/Kucoin.Net.UnitTests/Endpoints/Futures/Trading/GetMaxOpenPositionSize.txt b/Kucoin.Net.UnitTests/Endpoints/Futures/Trading/GetMaxOpenPositionSize.txt new file mode 100644 index 00000000..e06ea515 --- /dev/null +++ b/Kucoin.Net.UnitTests/Endpoints/Futures/Trading/GetMaxOpenPositionSize.txt @@ -0,0 +1,14 @@ +GET +/api/v2/getMaxOpenSize +true +{ + "success": true, + "code": "200", + "msg": "success", + "retry": false, + "data": { + "symbol": "XBTUSDTM", + "maxBuyOpenSize": 13808, + "maxSellOpenSize": 13808 + } +} \ No newline at end of file diff --git a/Kucoin.Net.UnitTests/KucoinRestIntegrationTests.cs b/Kucoin.Net.UnitTests/KucoinRestIntegrationTests.cs index c8b4b4c8..31ebe583 100644 --- a/Kucoin.Net.UnitTests/KucoinRestIntegrationTests.cs +++ b/Kucoin.Net.UnitTests/KucoinRestIntegrationTests.cs @@ -144,6 +144,7 @@ public async Task TestFuturesTrading() await RunAndCheckResult(client => client.FuturesApi.Trading.GetClosedOrdersAsync(default, default), true); await RunAndCheckResult(client => client.FuturesApi.Trading.GetUserTradesAsync(default, default, default, default, default, default, default, default, default), true); await RunAndCheckResult(client => client.FuturesApi.Trading.GetRecentUserTradesAsync(default), true); + await RunAndCheckResult(client => client.FuturesApi.Trading.GetMaxOpenPositionSizeAsync("XBTUSDTM", 50000, 1, default), true); } } } diff --git a/Kucoin.Net.UnitTests/RestRequestTests.cs b/Kucoin.Net.UnitTests/RestRequestTests.cs index 5dbe8403..2d64f815 100644 --- a/Kucoin.Net.UnitTests/RestRequestTests.cs +++ b/Kucoin.Net.UnitTests/RestRequestTests.cs @@ -218,6 +218,7 @@ public async Task ValidateFuturesTradingCalls() await tester.ValidateAsync(client => client.FuturesApi.Trading.GetOrderByClientOrderIdAsync("123"), "GetOrderByClientOrderId"); await tester.ValidateAsync(client => client.FuturesApi.Trading.GetUserTradesAsync(), "GetUserTrades", ignoreProperties: new List { "stop" }); await tester.ValidateAsync(client => client.FuturesApi.Trading.GetRecentUserTradesAsync(), "GetRecentUserTrades", ignoreProperties: new List { "stop" }); + await tester.ValidateAsync(client => client.FuturesApi.Trading.GetMaxOpenPositionSizeAsync("XBTUSDTM", 1, 1), "GetMaxOpenPositionSize"); } [Test] diff --git a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiExchangeData.cs b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiExchangeData.cs index 52de3390..cd101814 100644 --- a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiExchangeData.cs +++ b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiExchangeData.cs @@ -60,6 +60,7 @@ public async Task> GetTickerAsync(string symbol #endregion + #region Get Tickers /// public async Task>> GetTickersAsync(CancellationToken ct = default) @@ -68,6 +69,8 @@ public async Task>> GetTickersAsync return await _baseClient.SendAsync>(request, null, ct).ConfigureAwait(false); } + #endregion + #region Order book /// diff --git a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs index 4c13b27a..c3842422 100644 --- a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs +++ b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs @@ -268,5 +268,19 @@ public async Task>> GetRecentU #endregion + #region Get Max Open Position Size + + /// + public async Task> GetMaxOpenPositionSizeAsync(string symbol, decimal price, decimal leverage, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("symbol", symbol); + parameters.Add("price", price); + parameters.Add("leverage", leverage); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"api/v2/getMaxOpenSize", KucoinExchange.RateLimiter.PublicRest, 2, true); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion } } diff --git a/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs b/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs index 55748c87..46656d80 100644 --- a/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs +++ b/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs @@ -243,5 +243,16 @@ Task> PlaceTestOrderAsync( /// List of trades Task>> GetRecentUserTradesAsync(CancellationToken ct = default); + /// + /// Get the max position size + /// + /// + /// Symbol + /// Price/param> + /// Leverage + /// Cancellation token + /// + Task> GetMaxOpenPositionSizeAsync(string symbol, decimal price, decimal leverage, CancellationToken ct = default); + } } diff --git a/Kucoin.Net/Kucoin.Net.xml b/Kucoin.Net/Kucoin.Net.xml index a9e22699..0ce158eb 100644 --- a/Kucoin.Net/Kucoin.Net.xml +++ b/Kucoin.Net/Kucoin.Net.xml @@ -211,6 +211,9 @@ + + + @@ -2841,6 +2844,7 @@ Cancellation token List of trades + Futures socket api @@ -6001,6 +6005,26 @@ Index price + + + Max open size + + + + + Symbol + + + + + Max buy size + + + + + Max sell size + + Order value info diff --git a/Kucoin.Net/Objects/Models/Futures/KucoinMaxOpenSize.cs b/Kucoin.Net/Objects/Models/Futures/KucoinMaxOpenSize.cs new file mode 100644 index 00000000..e8965893 --- /dev/null +++ b/Kucoin.Net/Objects/Models/Futures/KucoinMaxOpenSize.cs @@ -0,0 +1,30 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Kucoin.Net.Objects.Models.Futures +{ + /// + /// Max open size + /// + public record KucoinMaxOpenSize + { + /// + /// Symbol + /// + [JsonProperty("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Max buy size + /// + [JsonProperty("maxBuyOpenSize")] + public long MaxBuyOpenSize { get; set; } + + /// + /// Max sell size + /// + [JsonProperty("maxSellOpenSize")] + public long MaxSellOpenSize { get; set; } + } +}