diff --git a/CryptoExchange.Net/SharedApis/Models/Rest/PlaceSpotOrderRequest.cs b/CryptoExchange.Net/SharedApis/Models/Rest/PlaceSpotOrderRequest.cs
index a2a2c99..379c6ec 100644
--- a/CryptoExchange.Net/SharedApis/Models/Rest/PlaceSpotOrderRequest.cs
+++ b/CryptoExchange.Net/SharedApis/Models/Rest/PlaceSpotOrderRequest.cs
@@ -18,13 +18,9 @@
///
public SharedTimeInForce? TimeInForce { get; set; }
///
- /// Quantity of the order in base asset or contracts, depending on the exchange.
+ /// Quantity of the order
///
- public decimal? Quantity { get; set; }
- ///
- /// Quantity of the order in quote asset.
- ///
- public decimal? QuoteQuantity { get; set; }
+ public SharedQuantity? Quantity { get; set; }
///
/// Price of the order
///
@@ -41,7 +37,6 @@
/// Side of the order
/// Type of the order
/// Quantity of the order
- /// Quantity of the order in quote asset
/// Price of the order
/// Time in force
/// Client order id
@@ -50,8 +45,7 @@
SharedSymbol symbol,
SharedOrderSide side,
SharedOrderType orderType,
- decimal? quantity = null,
- decimal? quoteQuantity = null,
+ SharedQuantity? quantity = null,
decimal? price = null,
SharedTimeInForce? timeInForce = null,
string? clientOrderId = null,
@@ -60,7 +54,6 @@
OrderType = orderType;
Side = side;
Quantity = quantity;
- QuoteQuantity = quoteQuantity;
Price = price;
TimeInForce = timeInForce;
ClientOrderId = clientOrderId;
diff --git a/CryptoExchange.Net/SharedApis/ResponseModels/SharedSpotOrder.cs b/CryptoExchange.Net/SharedApis/ResponseModels/SharedSpotOrder.cs
index c2808e6..db6e56d 100644
--- a/CryptoExchange.Net/SharedApis/ResponseModels/SharedSpotOrder.cs
+++ b/CryptoExchange.Net/SharedApis/ResponseModels/SharedSpotOrder.cs
@@ -27,22 +27,26 @@ namespace CryptoExchange.Net.SharedApis
/// Time in force for the order
///
public SharedTimeInForce? TimeInForce { get; set; }
- ///
- /// Order quantity in base asset
- ///
- public decimal? Quantity { get; set; }
- ///
- /// Quantity filled in base asset, note that this quantity has not yet included trading fees paid
- ///
- public decimal? QuantityFilled { get; set; }
- ///
- /// Order quantity in quote asset
- ///
- public decimal? QuoteQuantity { get; set; }
- ///
- /// Quantity filled in the quote asset, note that this quantity has not yet included trading fees paid
- ///
- public decimal? QuoteQuantityFilled { get; set; }
+
+ public SharedOrderQuantity? OrderQuantity { get; set; }
+ public SharedOrderQuantity? QuantityFilled { get; set; }
+
+ /////
+ ///// Order quantity in base asset
+ /////
+ //public decimal? Quantity { get; set; }
+ /////
+ ///// Quantity filled in base asset, note that this quantity has not yet included trading fees paid
+ /////
+ //public decimal? QuantityFilled { get; set; }
+ /////
+ ///// Order quantity in quote asset
+ /////
+ //public decimal? QuoteQuantity { get; set; }
+ /////
+ ///// Quantity filled in the quote asset, note that this quantity has not yet included trading fees paid
+ /////
+ //public decimal? QuoteQuantityFilled { get; set; }
///
/// Order price
///
diff --git a/CryptoExchange.Net/SharedApis/SharedQuantity.cs b/CryptoExchange.Net/SharedApis/SharedQuantity.cs
new file mode 100644
index 0000000..25deae3
--- /dev/null
+++ b/CryptoExchange.Net/SharedApis/SharedQuantity.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace CryptoExchange.Net.SharedApis
+{
+ public record SharedQuantityReference
+ {
+ public decimal? QuantityInBaseAsset { get; set; }
+ public decimal? QuantityInQuoteAsset { get; set; }
+ public decimal? QuantityInContracts { get; set; }
+
+ protected SharedQuantityReference(decimal? baseAssetQuantity, decimal? quoteAssetQuantity, decimal? contractQuantity)
+ {
+ QuantityInBaseAsset = baseAssetQuantity;
+ QuantityInQuoteAsset = quoteAssetQuantity;
+ QuantityInContracts = contractQuantity;
+ }
+ }
+
+ public record SharedQuantity : SharedQuantityReference
+ {
+ private SharedQuantity(decimal? baseAssetQuantity, decimal? quoteAssetQuantity, decimal? contractQuantity)
+ : base(baseAssetQuantity, quoteAssetQuantity, contractQuantity)
+ {
+ }
+
+ public static SharedQuantity Base(decimal quantity) => new SharedQuantity(quantity, null, null);
+ public static SharedQuantity Quote(decimal quantity) => new SharedQuantity(null, quantity, null);
+ public static SharedQuantity Contracts(decimal quantity) => new SharedQuantity(null, null, quantity);
+
+ public static SharedQuantity BaseFromQuote(decimal quoteQuantity, decimal price) => new SharedQuantity(Math.Round(quoteQuantity / price, 8), null, null);
+ public static SharedQuantity QuoteFromBase(decimal baseQuantity, decimal price) => new SharedQuantity(Math.Round(baseQuantity * price, 8), null, null);
+ public static SharedQuantity ContractsFromBase(decimal baseQuantity, decimal contractSize) => new SharedQuantity(Math.Round(baseQuantity / contractSize, 8), null, null);
+ public static SharedQuantity ContractsFromQuote(decimal quoteQuantity, decimal contractSize, decimal price) => new SharedQuantity(Math.Round(quoteQuantity / price / contractSize, 8), null, null);
+ }
+
+ public record SharedOrderQuantity : SharedQuantityReference
+ {
+ public SharedOrderQuantity(): base(null, null,null) { }
+
+ public SharedOrderQuantity(decimal? baseAssetQuantity, decimal? quoteAssetQuantity, decimal? contractQuantity)
+ : base(baseAssetQuantity, quoteAssetQuantity, contractQuantity)
+ {
+ }
+ }
+}