Skip to content

Commit

Permalink
Added quantityInBaseAsset and quantityInQuoteAsset to futures orders …
Browse files Browse the repository at this point in the history
…endpoints
  • Loading branch information
JKorf committed Nov 25, 2024
1 parent acec655 commit d2066f2
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 16 deletions.
21 changes: 17 additions & 4 deletions Kucoin.Net/Clients/FuturesApi/KucoinRestClientFuturesApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<WebCallResult<KucoinOrderId>> PlaceOrderAsync(
OrderSide side,
NewOrderType type,
decimal leverage,
int quantity,
int? quantity = null,

decimal? price = null,
TimeInForce? timeInForce = null,
Expand All @@ -57,14 +57,20 @@ public async Task<WebCallResult<KucoinOrderId>> PlaceOrderAsync(
string? clientOrderId = null,
SelfTradePrevention? selfTradePrevention = null,
FuturesMarginMode? marginMode = null,
decimal? quantityInBaseAsset = null,
decimal? quantityInQuoteAsset = null,
CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.AddParameter("symbol", symbol);
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);
Expand Down Expand Up @@ -144,7 +150,7 @@ public async Task<WebCallResult<KucoinOrderId>> PlaceTpSlOrderAsync(
OrderSide side,
NewOrderType type,
decimal leverage,
int quantity,
int? quantity = null,

decimal? price = null,
TimeInForce? timeInForce = null,
Expand All @@ -162,14 +168,21 @@ public async Task<WebCallResult<KucoinOrderId>> PlaceTpSlOrderAsync(
bool? forceHold = null,
string? clientOrderId = null,
SelfTradePrevention? selfTradePrevention = null,

decimal? quantityInBaseAsset = null,
decimal? quantityInQuoteAsset = null,
CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.AddParameter("symbol", symbol);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IKucoinRestClientFuturesApiTrading
/// <param name="hidden">Orders not displaying in order book. When hidden chose</param>
/// <param name="iceberg">Only visible portion of the order is displayed in the order book</param>
/// <param name="visibleSize">The maximum visible size of an iceberg order</param>
/// <param name="quantity">Quantity of contract to buy or sell</param>
/// <param name="quantity">Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="remark">Remark for the order</param>
/// <param name="stopType"></param>
/// <param name="stopPriceType"></param>
Expand All @@ -40,14 +40,16 @@ public interface IKucoinRestClientFuturesApiTrading
/// <param name="selfTradePrevention">Self Trade Prevention mode</param>
/// <param name="clientOrderId">Client order id</param>
/// <param name="marginMode">Margin mode, defaults to Isolated</param>
/// <param name="quantityInBaseAsset">Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="quantityInQuoteAsset">Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="ct">Cancellation token</param>
/// <returns>Order details</returns>
Task<WebCallResult<KucoinOrderId>> PlaceOrderAsync(
string symbol,
OrderSide side,
NewOrderType type,
decimal leverage,
int quantity,
int? quantity = null,
decimal? price = null,
TimeInForce? timeInForce = null,
bool? postOnly = null,
Expand All @@ -64,6 +66,8 @@ Task<WebCallResult<KucoinOrderId>> PlaceOrderAsync(
string? clientOrderId = null,
SelfTradePrevention? selfTradePrevention = null,
FuturesMarginMode? marginMode = null,
decimal? quantityInBaseAsset = null,
decimal? quantityInQuoteAsset = null,
CancellationToken ct = default);

/// <summary>
Expand Down Expand Up @@ -132,7 +136,7 @@ Task<WebCallResult<KucoinOrderId>> PlaceTestOrderAsync(
/// <param name="hidden">Orders not displaying in order book. When hidden chose</param>
/// <param name="iceberg">Only visible portion of the order is displayed in the order book</param>
/// <param name="visibleSize">The maximum visible size of an iceberg order</param>
/// <param name="quantity">Quantity of contract to buy or sell</param>
/// <param name="quantity">Quantity of contract to buy or sell, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="remark">Remark for the order</param>
/// <param name="stopPriceType">Price type</param>
/// <param name="takeProfitPrice">Take profit price</param>
Expand All @@ -142,14 +146,16 @@ Task<WebCallResult<KucoinOrderId>> PlaceTestOrderAsync(
/// <param name="forceHold">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</param>
/// <param name="selfTradePrevention">Self Trade Prevention mode</param>
/// <param name="clientOrderId">Client order id</param>
/// <param name="quantityInBaseAsset">Quantity specified in base asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="quantityInQuoteAsset">Quantity specified in quote asset, one of `quantity`, `quantityInBaseAsset` or `quantityInQuoteAsset` should be provided</param>
/// <param name="ct">Cancellation token</param>
/// <returns>Order details</returns>
Task<WebCallResult<KucoinOrderId>> PlaceTpSlOrderAsync(
string symbol,
OrderSide side,
NewOrderType type,
decimal leverage,
int quantity,
int? quantity = null,

decimal? price = null,
TimeInForce? timeInForce = null,
Expand All @@ -167,6 +173,8 @@ Task<WebCallResult<KucoinOrderId>> PlaceTpSlOrderAsync(
bool? forceHold = null,
string? clientOrderId = null,
SelfTradePrevention? selfTradePrevention = null,
decimal? quantityInBaseAsset = null,
decimal? quantityInQuoteAsset = null,
CancellationToken ct = default);

/// <summary>
Expand Down
Loading

0 comments on commit d2066f2

Please sign in to comment.