Skip to content

Commit

Permalink
Added support for marketUnit (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wtiben authored Jan 16, 2024
1 parent 6c6fe5b commit e23a815
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ByBit.Net/Clients/V5/BybitRestClientApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public async Task<WebCallResult<BybitOrderId>> PlaceOrderAsync(
bool? marketMakerProtection = null,
StopLossTakeProfitMode? stopLossTakeProfitMode = null,
SelfMatchPreventionType? selfMatchPreventionType = null,
MarketUnit? marketUnit = null,
CancellationToken ct = default
)
{
Expand Down Expand Up @@ -95,6 +96,7 @@ public async Task<WebCallResult<BybitOrderId>> PlaceOrderAsync(
parameters.AddOptionalParameter("tpLimitPrice", takeProfitLimitPrice?.ToString(CultureInfo.InvariantCulture));
parameters.AddOptionalParameter("slLimitPrice", stopLossLimitPrice?.ToString(CultureInfo.InvariantCulture));
parameters.AddOptionalParameter("smpType", EnumConverter.GetString(selfMatchPreventionType));
parameters.AddOptionalParameter("marketUnit", EnumConverter.GetString(marketUnit));

var result = await _baseClient.SendRequestAsync<BybitOrderId>(_baseClient.GetUrl("v5/order/create"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false);
if (result)
Expand Down
21 changes: 21 additions & 0 deletions ByBit.Net/Enums/V5/MarketUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using CryptoExchange.Net.Attributes;

namespace Bybit.Net.Enums.V5
{
/// <summary>
/// The unit for qty when create Spot market orders for UTA account
/// </summary>
public enum MarketUnit
{
/// <summary>
/// For example, buy BTCUSDT, then "qty" unit is BTC
/// </summary>
[Map("baseCoin")]
BaseCoin,
/// <summary>
/// For example, sell BTCUSDT, then "qty" unit is USDT
/// </summary>
[Map("quoteCoin")]
QuoteCoin
}
}
2 changes: 2 additions & 0 deletions ByBit.Net/Interfaces/Clients/V5/IBybitRestClientApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public interface IBybitRestClientApiTrading
/// <param name="marketMakerProtection">Market maker protection</param>
/// <param name="stopLossTakeProfitMode">StopLoss / TakeProfit mode</param>
/// <param name="selfMatchPreventionType">Self match prevention type</param>
/// <param name="marketUnit">The unit for qty when creating spot market orders for unified trading account</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<WebCallResult<BybitOrderId>> PlaceOrderAsync(
Expand Down Expand Up @@ -241,6 +242,7 @@ Task<WebCallResult<BybitOrderId>> PlaceOrderAsync(
bool? marketMakerProtection = null,
StopLossTakeProfitMode? stopLossTakeProfitMode = null,
SelfMatchPreventionType? selfMatchPreventionType = null,
MarketUnit? marketUnit = null,
CancellationToken ct = default);

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions ByBit.Net/Objects/Models/V5/BybitPlaceOrderRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,10 @@ public class BybitPlaceOrderRequest
/// </summary>
[JsonProperty("orderIv", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(DecimalToStringConverter))]
public decimal? OrderImpliedVolatility { get; set; }
/// <summary>
/// The unit for qty when creating spot market orders for unified trading account
/// </summary>
[JsonProperty("marketUnit", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(EnumConverter))]
public MarketUnit? MarketUnit { get; set; }
}
}

0 comments on commit e23a815

Please sign in to comment.