mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-11 08:22:53 +00:00
Updated SharedFuturesTicker, SharedSpotTicker and SharedKline to use SharedOrderQuantity for volumes. Added AveragePrice property to SharedQuantity model
This commit is contained in:
@@ -24,7 +24,24 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// The volume in the last 24h
|
||||
/// </summary>
|
||||
public decimal Volume { get; set; }
|
||||
public SharedOrderQuantity Volumes { get; set; }
|
||||
|
||||
private decimal? _volume;
|
||||
/// <summary>
|
||||
/// The volume in the last 24h
|
||||
/// </summary>
|
||||
[Obsolete("Use `Volumes` instead")]
|
||||
public decimal Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_volume.HasValue)
|
||||
return _volume.Value;
|
||||
|
||||
return Volumes.QuantityInBaseAsset ?? Volumes.QuantityInContracts ?? 0;
|
||||
}
|
||||
set => _volume = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Change percentage in the last 24h
|
||||
/// </summary>
|
||||
@@ -49,13 +66,20 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedFuturesTicker(SharedSymbol? sharedSymbol, string symbol, decimal? lastPrice, decimal? highPrice, decimal? lowPrice, decimal volume, decimal? changePercentage)
|
||||
public SharedFuturesTicker(
|
||||
SharedSymbol? sharedSymbol,
|
||||
string symbol,
|
||||
decimal? lastPrice,
|
||||
decimal? highPrice,
|
||||
decimal? lowPrice,
|
||||
SharedOrderQuantity volumes,
|
||||
decimal? changePercentage)
|
||||
:base(sharedSymbol, symbol)
|
||||
{
|
||||
LastPrice = lastPrice;
|
||||
HighPrice = highPrice;
|
||||
LowPrice = lowPrice;
|
||||
Volume = volume;
|
||||
Volumes = volumes;
|
||||
ChangePercentage = changePercentage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Kline info
|
||||
/// </summary>
|
||||
[DebuggerDisplay("[{OpenTime}] O: {OpenPrice} H: {HighPrice} L: {LowPrice} C: {ClosePrice} V: {Volume}")]
|
||||
[DebuggerDisplay("[{OpenTime}] O: {OpenPrice} H: {HighPrice} L: {LowPrice} C: {ClosePrice} V: {Volumes}")]
|
||||
public record SharedKline : SharedSymbolModel
|
||||
{
|
||||
/// <summary>
|
||||
@@ -29,15 +29,40 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// Open price
|
||||
/// </summary>
|
||||
public decimal OpenPrice { get; set; }
|
||||
|
||||
private decimal? _volume;
|
||||
/// <summary>
|
||||
/// Volume in the base asset
|
||||
/// </summary>
|
||||
public decimal Volume { get; set; }
|
||||
[Obsolete("Use `Volumes` instead")]
|
||||
public decimal Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_volume.HasValue)
|
||||
return _volume.Value;
|
||||
|
||||
return Volumes.QuantityInBaseAsset ?? Volumes.QuantityInContracts ?? 0;
|
||||
}
|
||||
set => _volume = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// The volume in the last 24h
|
||||
/// </summary>
|
||||
public SharedOrderQuantity Volumes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedKline(SharedSymbol? sharedSymbol, string symbol, DateTime openTime, decimal closePrice, decimal highPrice, decimal lowPrice, decimal openPrice, decimal volume)
|
||||
public SharedKline(
|
||||
SharedSymbol? sharedSymbol,
|
||||
string symbol,
|
||||
DateTime openTime,
|
||||
decimal closePrice,
|
||||
decimal highPrice,
|
||||
decimal lowPrice,
|
||||
decimal openPrice,
|
||||
SharedOrderQuantity volumes)
|
||||
: base(sharedSymbol, symbol)
|
||||
{
|
||||
OpenTime = openTime;
|
||||
@@ -45,7 +70,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
HighPrice = highPrice;
|
||||
LowPrice = lowPrice;
|
||||
OpenPrice = openPrice;
|
||||
Volume = volume;
|
||||
Volumes = volumes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -21,13 +22,31 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public decimal? LowPrice { get; set; }
|
||||
/// <summary>
|
||||
/// The volume in the last 24h
|
||||
/// </summary>
|
||||
public SharedOrderQuantity Volumes { get; set; }
|
||||
|
||||
private decimal? _volume;
|
||||
/// <summary>
|
||||
/// Trade volume in base asset in the last 24h
|
||||
/// </summary>
|
||||
public decimal Volume { get; set; }
|
||||
[Obsolete("Use `Volumes` instead")]
|
||||
public decimal Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_volume.HasValue)
|
||||
return _volume.Value;
|
||||
|
||||
return Volumes.QuantityInBaseAsset ?? Volumes.QuantityInContracts ?? 0;
|
||||
}
|
||||
set => _volume = value;
|
||||
}
|
||||
/// <summary>
|
||||
/// Trade volume in quote asset in the last 24h
|
||||
/// </summary>
|
||||
public decimal? QuoteVolume { get; set; }
|
||||
[Obsolete("Use `Volumes` instead")]
|
||||
public decimal? QuoteVolume => Volumes?.QuantityInQuoteAsset;
|
||||
/// <summary>
|
||||
/// Change percentage in the last 24h
|
||||
/// </summary>
|
||||
@@ -36,13 +55,20 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SharedSpotTicker(SharedSymbol? sharedSymbol, string symbol, decimal? lastPrice, decimal? highPrice, decimal? lowPrice, decimal volume, decimal? changePercentage)
|
||||
public SharedSpotTicker(
|
||||
SharedSymbol? sharedSymbol,
|
||||
string symbol,
|
||||
decimal? lastPrice,
|
||||
decimal? highPrice,
|
||||
decimal? lowPrice,
|
||||
SharedOrderQuantity volumes,
|
||||
decimal? changePercentage)
|
||||
: base(sharedSymbol, symbol)
|
||||
{
|
||||
LastPrice = lastPrice;
|
||||
HighPrice = highPrice;
|
||||
LowPrice = lowPrice;
|
||||
Volume = volume;
|
||||
Volumes = volumes;
|
||||
ChangePercentage = changePercentage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,11 @@ namespace CryptoExchange.Net.SharedApis
|
||||
[JsonConverter(typeof(SharedOrderQuantityConverter))]
|
||||
public record SharedOrderQuantity : SharedQuantityReference
|
||||
{
|
||||
/// <summary>
|
||||
/// The average price based on the base and quote asset quantities
|
||||
/// </summary>
|
||||
public decimal? AveragePrice => QuantityInBaseAsset == 0 ? null : QuantityInQuoteAsset / QuantityInBaseAsset;
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user