Skip to content

Commit

Permalink
Added FuturesApi.Trading.GetMaxOpenPositionSizeAsync endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Aug 19, 2024
1 parent f982033 commit 3cfbcab
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
GET
/api/v2/getMaxOpenSize
true
{
"success": true,
"code": "200",
"msg": "success",
"retry": false,
"data": {
"symbol": "XBTUSDTM",
"maxBuyOpenSize": 13808,
"maxSellOpenSize": 13808
}
}
1 change: 1 addition & 0 deletions Kucoin.Net.UnitTests/KucoinRestIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
1 change: 1 addition & 0 deletions Kucoin.Net.UnitTests/RestRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> { "stop" });
await tester.ValidateAsync(client => client.FuturesApi.Trading.GetRecentUserTradesAsync(), "GetRecentUserTrades", ignoreProperties: new List<string> { "stop" });
await tester.ValidateAsync(client => client.FuturesApi.Trading.GetMaxOpenPositionSizeAsync("XBTUSDTM", 1, 1), "GetMaxOpenPositionSize");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public async Task<WebCallResult<KucoinFuturesTick>> GetTickerAsync(string symbol

#endregion

#region Get Tickers

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<KucoinFuturesTick>>> GetTickersAsync(CancellationToken ct = default)
Expand All @@ -68,6 +69,8 @@ public async Task<WebCallResult<IEnumerable<KucoinFuturesTick>>> GetTickersAsync
return await _baseClient.SendAsync<IEnumerable<KucoinFuturesTick>>(request, null, ct).ConfigureAwait(false);
}

#endregion

#region Order book

/// <inheritdoc />
Expand Down
14 changes: 14 additions & 0 deletions Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,5 +268,19 @@ public async Task<WebCallResult<IEnumerable<KucoinFuturesUserTrade>>> GetRecentU

#endregion

#region Get Max Open Position Size

/// <inheritdoc />
public async Task<WebCallResult<KucoinMaxOpenSize>> 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<KucoinMaxOpenSize>(request, parameters, ct).ConfigureAwait(false);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,16 @@ Task<WebCallResult<KucoinOrderId>> PlaceTestOrderAsync(
/// <returns>List of trades</returns>
Task<WebCallResult<IEnumerable<KucoinFuturesUserTrade>>> GetRecentUserTradesAsync(CancellationToken ct = default);

/// <summary>
/// Get the max position size
/// <para><a href="https://www.kucoin.com/docs/rest/futures-trading/positions/get-maximum-open-position-size" /></para>
/// </summary>
/// <param name="symbol">Symbol</param>
/// <param name="price">Price/param>
/// <param name="leverage">Leverage</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult<KucoinMaxOpenSize>> GetMaxOpenPositionSizeAsync(string symbol, decimal price, decimal leverage, CancellationToken ct = default);

Check warning on line 255 in Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has badly formed XML -- 'Expected an end tag for element 'param'.'

Check warning on line 255 in Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has badly formed XML -- 'Expected an end tag for element 'param'.'

Check warning on line 255 in Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has badly formed XML -- 'Expected an end tag for element 'param'.'

Check warning on line 255 in Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs

View workflow job for this annotation

GitHub Actions / build

XML comment has badly formed XML -- 'Expected an end tag for element 'param'.'

}
}
24 changes: 24 additions & 0 deletions Kucoin.Net/Kucoin.Net.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
<member name="M:Kucoin.Net.Clients.FuturesApi.KucoinRestClientFuturesApiTrading.GetRecentUserTradesAsync(System.Threading.CancellationToken)">
<inheritdoc />
</member>
<member name="M:Kucoin.Net.Clients.FuturesApi.KucoinRestClientFuturesApiTrading.GetMaxOpenPositionSizeAsync(System.String,System.Decimal,System.Decimal,System.Threading.CancellationToken)">
<inheritdoc />
</member>
<member name="T:Kucoin.Net.Clients.FuturesApi.KucoinSocketClientFuturesApi">
<inheritdoc cref="T:Kucoin.Net.Interfaces.Clients.FuturesApi.IKucoinSocketClientFuturesApi" />
</member>
Expand Down Expand Up @@ -2841,6 +2844,7 @@
<param name="ct">Cancellation token</param>
<returns>List of trades</returns>
</member>
<!-- Badly formed XML comment ignored for member "M:Kucoin.Net.Interfaces.Clients.FuturesApi.IKucoinRestClientFuturesApiTrading.GetMaxOpenPositionSizeAsync(System.String,System.Decimal,System.Decimal,System.Threading.CancellationToken)" -->
<member name="T:Kucoin.Net.Interfaces.Clients.FuturesApi.IKucoinSocketClientFuturesApi">
<summary>
Futures socket api
Expand Down Expand Up @@ -6001,6 +6005,26 @@
Index price
</summary>
</member>
<member name="T:Kucoin.Net.Objects.Models.Futures.KucoinMaxOpenSize">
<summary>
Max open size
</summary>
</member>
<member name="P:Kucoin.Net.Objects.Models.Futures.KucoinMaxOpenSize.Symbol">
<summary>
Symbol
</summary>
</member>
<member name="P:Kucoin.Net.Objects.Models.Futures.KucoinMaxOpenSize.MaxBuyOpenSize">
<summary>
Max buy size
</summary>
</member>
<member name="P:Kucoin.Net.Objects.Models.Futures.KucoinMaxOpenSize.MaxSellOpenSize">
<summary>
Max sell size
</summary>
</member>
<member name="T:Kucoin.Net.Objects.Models.Futures.KucoinOrderValuation">
<summary>
Order value info
Expand Down
30 changes: 30 additions & 0 deletions Kucoin.Net/Objects/Models/Futures/KucoinMaxOpenSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Kucoin.Net.Objects.Models.Futures
{
/// <summary>
/// Max open size
/// </summary>
public record KucoinMaxOpenSize
{
/// <summary>
/// Symbol
/// </summary>
[JsonProperty("symbol")]
public string Symbol { get; set; } = string.Empty;
/// <summary>
/// Max buy size
/// </summary>
[JsonProperty("maxBuyOpenSize")]
public long MaxBuyOpenSize { get; set; }

/// <summary>
/// Max sell size
/// </summary>
[JsonProperty("maxSellOpenSize")]
public long MaxSellOpenSize { get; set; }
}
}

0 comments on commit 3cfbcab

Please sign in to comment.