1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 07:56:12 +00:00
This commit is contained in:
JKorf 2025-03-17 21:48:06 +01:00 committed by Jkorf
parent 6a82a7a411
commit 478cb537fa
3 changed files with 70 additions and 26 deletions

View File

@ -18,13 +18,9 @@
/// </summary>
public SharedTimeInForce? TimeInForce { get; set; }
/// <summary>
/// Quantity of the order in base asset or contracts, depending on the exchange.
/// Quantity of the order
/// </summary>
public decimal? Quantity { get; set; }
/// <summary>
/// Quantity of the order in quote asset.
/// </summary>
public decimal? QuoteQuantity { get; set; }
public SharedQuantity? Quantity { get; set; }
/// <summary>
/// Price of the order
/// </summary>
@ -41,7 +37,6 @@
/// <param name="side">Side of the order</param>
/// <param name="orderType">Type of the order</param>
/// <param name="quantity">Quantity of the order</param>
/// <param name="quoteQuantity">Quantity of the order in quote asset</param>
/// <param name="price">Price of the order</param>
/// <param name="timeInForce">Time in force</param>
/// <param name="clientOrderId">Client order id</param>
@ -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;

View File

@ -27,22 +27,26 @@ namespace CryptoExchange.Net.SharedApis
/// Time in force for the order
/// </summary>
public SharedTimeInForce? TimeInForce { get; set; }
/// <summary>
/// Order quantity in base asset
/// </summary>
public decimal? Quantity { get; set; }
/// <summary>
/// Quantity filled in base asset, note that this quantity has not yet included trading fees paid
/// </summary>
public decimal? QuantityFilled { get; set; }
/// <summary>
/// Order quantity in quote asset
/// </summary>
public decimal? QuoteQuantity { get; set; }
/// <summary>
/// Quantity filled in the quote asset, note that this quantity has not yet included trading fees paid
/// </summary>
public decimal? QuoteQuantityFilled { get; set; }
public SharedOrderQuantity? OrderQuantity { get; set; }
public SharedOrderQuantity? QuantityFilled { get; set; }
///// <summary>
///// Order quantity in base asset
///// </summary>
//public decimal? Quantity { get; set; }
///// <summary>
///// Quantity filled in base asset, note that this quantity has not yet included trading fees paid
///// </summary>
//public decimal? QuantityFilled { get; set; }
///// <summary>
///// Order quantity in quote asset
///// </summary>
//public decimal? QuoteQuantity { get; set; }
///// <summary>
///// Quantity filled in the quote asset, note that this quantity has not yet included trading fees paid
///// </summary>
//public decimal? QuoteQuantityFilled { get; set; }
/// <summary>
/// Order price
/// </summary>

View File

@ -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)
{
}
}
}