diff --git a/CryptoExchange.Net/SharedApis/SharedQuantity.cs b/CryptoExchange.Net/SharedApis/SharedQuantity.cs
index dcddd06a..e4b1dee7 100644
--- a/CryptoExchange.Net/SharedApis/SharedQuantity.cs
+++ b/CryptoExchange.Net/SharedApis/SharedQuantity.cs
@@ -176,6 +176,42 @@ namespace CryptoExchange.Net.SharedApis
return null;
}
+ ///
+ /// Get a copy of this quantities record with calculated quantities for data not returned by the API based on the provided price and contract size
+ ///
+ /// The relevant price
+ /// The contract size of the symbol
+ /// A copy of this SharedOrderQuantity with calculated quantities
+ public SharedOrderQuantity WithCalculatedQuantities(decimal? price, decimal? contractSize)
+ {
+ var copy = this with {};
+ if (copy.QuantityInBaseAsset == null)
+ {
+ if (copy.QuantityInQuoteAsset != null && price > 0)
+ copy.QuantityInBaseAsset = copy.QuantityInQuoteAsset / price;
+ else if (copy.QuantityInContracts != null && contractSize != null)
+ copy.QuantityInBaseAsset = copy.QuantityInContracts * contractSize;
+ }
+
+ if (copy.QuantityInContracts == null)
+ {
+ if (copy.QuantityInBaseAsset != null && contractSize > 0)
+ copy.QuantityInContracts = copy.QuantityInBaseAsset / contractSize;
+ else if (copy.QuantityInQuoteAsset != null && price > 0 && contractSize > 0)
+ copy.QuantityInContracts = copy.QuantityInQuoteAsset / price / contractSize;
+ }
+
+ if (copy.QuantityInQuoteAsset == null)
+ {
+ if (copy.QuantityInBaseAsset != null && price != null)
+ copy.QuantityInQuoteAsset = copy.QuantityInBaseAsset * price;
+ else if (copy.QuantityInContracts != null && price != null && contractSize != null)
+ copy.QuantityInQuoteAsset = copy.QuantityInContracts * contractSize * price;
+ }
+
+ return copy;
+ }
+
///
public override string ToString() => base.ToString();
}