mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-04 02:11:11 +00:00
Updated remaining quantity/volumes to SharedOrderQuantity model in Shared APIs, added QuantityType to SharedOrderBook, added auto calculated quote quantity where for SharedOrderQuantity where it makes sense
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -15,26 +16,44 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Quantity of the best ask
|
||||
/// </summary>
|
||||
public decimal BestAskQuantity { get; set; }
|
||||
[Obsolete("Use `BestAskQuantities` instead")]
|
||||
public decimal BestAskQuantity => BestAskQuantities.QuantityInBaseAsset ?? BestAskQuantities.QuantityInContracts ?? 0;
|
||||
/// <summary>
|
||||
/// Quantities of the best ask
|
||||
/// </summary>
|
||||
public SharedOrderQuantity BestAskQuantities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Price of the best bid
|
||||
/// </summary>
|
||||
public decimal BestBidPrice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Quantity of the best bid
|
||||
/// </summary>
|
||||
public decimal BestBidQuantity { get; set; }
|
||||
[Obsolete("Use `BestBidQuantities` instead")]
|
||||
public decimal BestBidQuantity => BestBidQuantities.QuantityInBaseAsset ?? BestBidQuantities.QuantityInContracts ?? 0;
|
||||
/// <summary>
|
||||
/// Quantities of the best bid
|
||||
/// </summary>
|
||||
public SharedOrderQuantity BestBidQuantities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedBookTicker(SharedSymbol? sharedSymbol, string symbol, decimal bestAskPrice, decimal bestAskQuantity, decimal bestBidPrice, decimal bestBidQuantity)
|
||||
public SharedBookTicker(
|
||||
SharedSymbol? sharedSymbol,
|
||||
string symbol,
|
||||
decimal bestAskPrice,
|
||||
SharedOrderQuantity bestAskQuantity,
|
||||
decimal bestBidPrice,
|
||||
SharedOrderQuantity bestBidQuantity)
|
||||
: base(sharedSymbol, symbol)
|
||||
{
|
||||
BestAskPrice = bestAskPrice;
|
||||
BestAskQuantity = bestAskQuantity;
|
||||
BestAskQuantities = bestAskQuantity.WithCalculatedQuantities(bestAskPrice, null);
|
||||
BestBidPrice = bestBidPrice;
|
||||
BestBidQuantity = bestBidQuantity;
|
||||
BestBidQuantities = bestBidQuantity.WithCalculatedQuantities(bestBidPrice, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
using System;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Open interest
|
||||
@@ -8,14 +10,19 @@
|
||||
/// <summary>
|
||||
/// Current open interest
|
||||
/// </summary>
|
||||
public decimal OpenInterest { get; set; }
|
||||
[Obsolete("Use `OpenInterests` instead")]
|
||||
public decimal OpenInterest => OpenInterests.QuantityInBaseAsset ?? OpenInterests.QuantityInContracts ?? 0;
|
||||
/// <summary>
|
||||
/// Current open interest
|
||||
/// </summary>
|
||||
public SharedOrderQuantity OpenInterests { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedOpenInterest(decimal openInterest)
|
||||
public SharedOpenInterest(SharedOrderQuantity openInterest)
|
||||
{
|
||||
OpenInterest = openInterest;
|
||||
OpenInterests = openInterest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public record SharedOrderBook
|
||||
{
|
||||
/// <summary>
|
||||
/// The quantity notation the order book is in, either BaseAsset or Contract
|
||||
/// </summary>
|
||||
public SharedQuantityType QuantityType { get; set; }
|
||||
/// <summary>
|
||||
/// Asks list
|
||||
/// </summary>
|
||||
@@ -19,8 +23,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedOrderBook(ISymbolOrderBookEntry[] asks, ISymbolOrderBookEntry[] bids)
|
||||
public SharedOrderBook(SharedQuantityType quantityType, ISymbolOrderBookEntry[] asks, ISymbolOrderBookEntry[] bids)
|
||||
{
|
||||
QuantityType = quantityType;
|
||||
Asks = asks;
|
||||
Bids = bids;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,12 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Current size of the position
|
||||
/// </summary>
|
||||
public decimal PositionSize { get; set; }
|
||||
[Obsolete("Use `PositionSizes` instead")]
|
||||
public decimal PositionSize => PositionSizes.QuantityInContracts ?? PositionSizes.QuantityInBaseAsset ?? 0;
|
||||
/// <summary>
|
||||
/// Current size of the position
|
||||
/// </summary>
|
||||
public SharedOrderQuantity PositionSizes { get; set; }
|
||||
/// <summary>
|
||||
/// Side of the position
|
||||
/// </summary>
|
||||
@@ -57,10 +62,10 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedPosition(SharedSymbol? sharedSymbol, string symbol, decimal positionSize, DateTime? updateTime)
|
||||
public SharedPosition(SharedSymbol? sharedSymbol, string symbol, SharedOrderQuantity positionSize, DateTime? updateTime)
|
||||
: base(sharedSymbol, symbol)
|
||||
{
|
||||
PositionSize = positionSize;
|
||||
PositionSizes = positionSize;
|
||||
UpdateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,12 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Position size
|
||||
/// </summary>
|
||||
public decimal Quantity { get; set; }
|
||||
[Obsolete("Use `Quantities` instead")]
|
||||
public decimal Quantity => Quantities.QuantityInContracts ?? Quantities .QuantityInBaseAsset ?? 0;
|
||||
/// <summary>
|
||||
/// Position size
|
||||
/// </summary>
|
||||
public SharedOrderQuantity Quantities { get; set; }
|
||||
/// <summary>
|
||||
/// Realized profit/loss
|
||||
/// </summary>
|
||||
@@ -55,7 +60,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
SharedPositionSide side,
|
||||
decimal openPrice,
|
||||
decimal closePrice,
|
||||
decimal quantity,
|
||||
SharedOrderQuantity quantity,
|
||||
decimal realizedPnl,
|
||||
DateTime timestamp)
|
||||
: base(sharedSymbol, symbol)
|
||||
@@ -63,7 +68,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
PositionSide = side;
|
||||
AverageOpenPrice = openPrice;
|
||||
AverageClosePrice = closePrice;
|
||||
Quantity = quantity;
|
||||
Quantities = quantity;
|
||||
RealizedPnl = realizedPnl;
|
||||
Timestamp = timestamp;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public SharedTrade(SharedSymbol? sharedSymbol, string symbol, SharedOrderQuantity quantities, decimal price, DateTime timestamp) : base(sharedSymbol, symbol)
|
||||
{
|
||||
Quantities = quantities;
|
||||
Quantities = quantities.WithCalculatedQuantities(price, null);
|
||||
Price = price;
|
||||
Timestamp = timestamp;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Traded quantity
|
||||
/// </summary>
|
||||
public decimal Quantity { get; set; }
|
||||
[Obsolete("Use `Quantities` instead")]
|
||||
public decimal Quantity => Quantities.QuantityInBaseAsset ?? Quantities.QuantityInQuoteAsset ?? 0;
|
||||
/// <summary>
|
||||
/// Traded quantity
|
||||
/// </summary>
|
||||
public SharedOrderQuantity Quantities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Trade price
|
||||
/// </summary>
|
||||
@@ -53,14 +59,14 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedUserTrade(SharedSymbol? sharedSymbol, string symbol, string orderId, string id, SharedOrderSide? side, decimal quantity, decimal price, DateTime timestamp)
|
||||
public SharedUserTrade(SharedSymbol? sharedSymbol, string symbol, string orderId, string id, SharedOrderSide? side, SharedOrderQuantity quantity, decimal price, DateTime timestamp)
|
||||
: base(sharedSymbol, symbol)
|
||||
{
|
||||
Symbol = symbol;
|
||||
OrderId = orderId;
|
||||
Id = id;
|
||||
Side = side;
|
||||
Quantity = quantity;
|
||||
Quantities = quantity.WithCalculatedQuantities(price, null);
|
||||
Price = price;
|
||||
Timestamp = timestamp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user