From d2066f21c495df95df8d37bf7038a42e3f743fd2 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Mon, 25 Nov 2024 13:53:36 +0100 Subject: [PATCH] Added quantityInBaseAsset and quantityInQuoteAsset to futures orders endpoints --- .../KucoinRestClientFuturesApiTrading.cs | 21 +++++-- .../IKucoinRestClientFuturesApiTrading.cs | 16 +++-- Kucoin.Net/Kucoin.Net.xml | 58 ++++++++++++++++--- .../Futures/KucoinFuturesOrderRequestEntry.cs | 12 +++- 4 files changed, 91 insertions(+), 16 deletions(-) diff --git a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs index 628b9fa..098a69f 100644 --- a/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs +++ b/Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs @@ -38,7 +38,7 @@ public async Task> PlaceOrderAsync( OrderSide side, NewOrderType type, decimal leverage, - int quantity, + int? quantity = null, decimal? price = null, TimeInForce? timeInForce = null, @@ -57,6 +57,8 @@ public async Task> PlaceOrderAsync( string? clientOrderId = null, SelfTradePrevention? selfTradePrevention = null, FuturesMarginMode? marginMode = null, + decimal? quantityInBaseAsset = null, + decimal? quantityInQuoteAsset = null, CancellationToken ct = default) { var parameters = new ParameterCollection(); @@ -64,7 +66,11 @@ public async Task> PlaceOrderAsync( parameters.AddParameter("side", JsonConvert.SerializeObject(side, new OrderSideConverter(false))); parameters.AddParameter("type", JsonConvert.SerializeObject(type, new NewOrderTypeConverter(false))); parameters.AddParameter("leverage", leverage.ToString(CultureInfo.InvariantCulture)); - parameters.AddParameter("size", quantity.ToString(CultureInfo.InvariantCulture)); + + parameters.AddOptionalParameter("size", quantity?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("qty", quantityInBaseAsset?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("valueQty", quantityInQuoteAsset?.ToString(CultureInfo.InvariantCulture)); + parameters.AddParameter("clientOid", clientOrderId ?? Guid.NewGuid().ToString()); parameters.AddOptionalParameter("remark", remark); parameters.AddOptionalParameter("stop", stopType != null ? JsonConvert.SerializeObject(stopType, new StopTypeConverter(false)) : null); @@ -144,7 +150,7 @@ public async Task> PlaceTpSlOrderAsync( OrderSide side, NewOrderType type, decimal leverage, - int quantity, + int? quantity = null, decimal? price = null, TimeInForce? timeInForce = null, @@ -162,6 +168,9 @@ public async Task> PlaceTpSlOrderAsync( bool? forceHold = null, string? clientOrderId = null, SelfTradePrevention? selfTradePrevention = null, + + decimal? quantityInBaseAsset = null, + decimal? quantityInQuoteAsset = null, CancellationToken ct = default) { var parameters = new ParameterCollection(); @@ -169,7 +178,11 @@ public async Task> PlaceTpSlOrderAsync( parameters.AddParameter("side", JsonConvert.SerializeObject(side, new OrderSideConverter(false))); parameters.AddParameter("type", JsonConvert.SerializeObject(type, new NewOrderTypeConverter(false))); parameters.AddParameter("leverage", leverage.ToString(CultureInfo.InvariantCulture)); - parameters.AddParameter("size", quantity.ToString(CultureInfo.InvariantCulture)); + + parameters.AddOptionalParameter("size", quantity?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("qty", quantityInBaseAsset?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("valueQty", quantityInQuoteAsset?.ToString(CultureInfo.InvariantCulture)); + parameters.AddParameter("clientOid", clientOrderId ?? Guid.NewGuid().ToString()); parameters.AddOptionalParameter("remark", remark); parameters.AddOptionalString("triggerStopUpPrice", takeProfitPrice); diff --git a/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs b/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs index 8df6625..cd10c06 100644 --- a/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs +++ b/Kucoin.Net/Interfaces/Clients/FuturesApi/IKucoinRestClientFuturesApiTrading.cs @@ -29,7 +29,7 @@ public interface IKucoinRestClientFuturesApiTrading /// Orders not displaying in order book. When hidden chose /// Only visible portion of the order is displayed in the order book /// The maximum visible size of an iceberg order - /// Quantity of contract to buy or sell + /// Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided /// Remark for the order /// /// @@ -40,6 +40,8 @@ public interface IKucoinRestClientFuturesApiTrading /// Self Trade Prevention mode /// Client order id /// Margin mode, defaults to Isolated + /// Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided + /// Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided /// Cancellation token /// Order details Task> PlaceOrderAsync( @@ -47,7 +49,7 @@ Task> PlaceOrderAsync( OrderSide side, NewOrderType type, decimal leverage, - int quantity, + int? quantity = null, decimal? price = null, TimeInForce? timeInForce = null, bool? postOnly = null, @@ -64,6 +66,8 @@ Task> PlaceOrderAsync( string? clientOrderId = null, SelfTradePrevention? selfTradePrevention = null, FuturesMarginMode? marginMode = null, + decimal? quantityInBaseAsset = null, + decimal? quantityInQuoteAsset = null, CancellationToken ct = default); /// @@ -132,7 +136,7 @@ Task> PlaceTestOrderAsync( /// Orders not displaying in order book. When hidden chose /// Only visible portion of the order is displayed in the order book /// The maximum visible size of an iceberg order - /// Quantity of contract to buy or sell + /// Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided /// Remark for the order /// Price type /// Take profit price @@ -142,6 +146,8 @@ Task> PlaceTestOrderAsync( /// A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default /// Self Trade Prevention mode /// Client order id + /// Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided + /// Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided /// Cancellation token /// Order details Task> PlaceTpSlOrderAsync( @@ -149,7 +155,7 @@ Task> PlaceTpSlOrderAsync( OrderSide side, NewOrderType type, decimal leverage, - int quantity, + int? quantity = null, decimal? price = null, TimeInForce? timeInForce = null, @@ -167,6 +173,8 @@ Task> PlaceTpSlOrderAsync( bool? forceHold = null, string? clientOrderId = null, SelfTradePrevention? selfTradePrevention = null, + decimal? quantityInBaseAsset = null, + decimal? quantityInQuoteAsset = null, CancellationToken ct = default); /// diff --git a/Kucoin.Net/Kucoin.Net.xml b/Kucoin.Net/Kucoin.Net.xml index ebdd01d..290de32 100644 --- a/Kucoin.Net/Kucoin.Net.xml +++ b/Kucoin.Net/Kucoin.Net.xml @@ -181,13 +181,13 @@ - + - + @@ -2856,7 +2856,7 @@ Kucoin Futures trading endpoints, placing and mananging orders. - + Place a new order @@ -2871,7 +2871,7 @@ Orders not displaying in order book. When hidden chose Only visible portion of the order is displayed in the order book The maximum visible size of an iceberg order - Quantity of contract to buy or sell + Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided Remark for the order @@ -2882,6 +2882,8 @@ Self Trade Prevention mode Client order id Margin mode, defaults to Isolated + Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided + Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided Cancellation token Order details @@ -2913,7 +2915,7 @@ Cancellation token Order details - + Place a new take profit / stop loss order @@ -2928,7 +2930,7 @@ Orders not displaying in order book. When hidden chose Only visible portion of the order is displayed in the order book The maximum visible size of an iceberg order - Quantity of contract to buy or sell + Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided Remark for the order Price type Take profit price @@ -2938,6 +2940,8 @@ A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default Self Trade Prevention mode Client order id + Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided + Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided Cancellation token Order details @@ -5558,6 +5562,11 @@ Asset + + + Cross margin risk ratio + + Account transaction info @@ -5905,6 +5914,21 @@ Funding quote symbol + + + Whether symbols supports cross margin position + + + + + Maximum limit buying price + + + + + Minimum limit selling price + + Funding info @@ -5965,6 +5989,16 @@ Predicted value + + + Funding rate cap + + + + + Funding rate floor + + Funding rate history @@ -6147,7 +6181,17 @@ - Amount of contracts to buy or sell + Amount of contracts to buy or sell, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided + + + + + Quantity in base asset, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided + + + + + Quantity in quote asset, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided diff --git a/Kucoin.Net/Objects/Models/Futures/KucoinFuturesOrderRequestEntry.cs b/Kucoin.Net/Objects/Models/Futures/KucoinFuturesOrderRequestEntry.cs index 4fe450e..6ae1c3e 100644 --- a/Kucoin.Net/Objects/Models/Futures/KucoinFuturesOrderRequestEntry.cs +++ b/Kucoin.Net/Objects/Models/Futures/KucoinFuturesOrderRequestEntry.cs @@ -28,11 +28,21 @@ public record KucoinFuturesOrderRequestEntry [JsonConverter(typeof(DecimalStringWriterConverter))] public decimal? Leverage { get; set; } /// - /// Amount of contracts to buy or sell + /// Amount of contracts to buy or sell, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided /// [JsonProperty("size")] public int? Quantity { get; set; } /// + /// Quantity in base asset, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided + /// + [JsonProperty("qty")] + public decimal? QuantityInBaseAsset { get; set; } + /// + /// Quantity in quote asset, one of `Quantity`, `QuantityInBaseAsset` or `QuantityInQuoteAsset` should be provided + /// + [JsonProperty("valueQty")] + public decimal? QuantityInQuoteAsset { get; set; } + /// /// Limit price /// [JsonProperty("price")]