mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-21 21:33:01 +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>
|
/// <summary>
|
||||||
/// The volume in the last 24h
|
/// The volume in the last 24h
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Change percentage in the last 24h
|
/// Change percentage in the last 24h
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,13 +66,20 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </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)
|
:base(sharedSymbol, symbol)
|
||||||
{
|
{
|
||||||
LastPrice = lastPrice;
|
LastPrice = lastPrice;
|
||||||
HighPrice = highPrice;
|
HighPrice = highPrice;
|
||||||
LowPrice = lowPrice;
|
LowPrice = lowPrice;
|
||||||
Volume = volume;
|
Volumes = volumes;
|
||||||
ChangePercentage = changePercentage;
|
ChangePercentage = changePercentage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kline info
|
/// Kline info
|
||||||
/// </summary>
|
/// </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
|
public record SharedKline : SharedSymbolModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -29,15 +29,40 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// Open price
|
/// Open price
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal OpenPrice { get; set; }
|
public decimal OpenPrice { get; set; }
|
||||||
|
|
||||||
|
private decimal? _volume;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Volume in the base asset
|
/// Volume in the base asset
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </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)
|
: base(sharedSymbol, symbol)
|
||||||
{
|
{
|
||||||
OpenTime = openTime;
|
OpenTime = openTime;
|
||||||
@@ -45,7 +70,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
HighPrice = highPrice;
|
HighPrice = highPrice;
|
||||||
LowPrice = lowPrice;
|
LowPrice = lowPrice;
|
||||||
OpenPrice = openPrice;
|
OpenPrice = openPrice;
|
||||||
Volume = volume;
|
Volumes = volumes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace CryptoExchange.Net.SharedApis
|
namespace CryptoExchange.Net.SharedApis
|
||||||
{
|
{
|
||||||
@@ -21,13 +22,31 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? LowPrice { get; set; }
|
public decimal? LowPrice { get; set; }
|
||||||
/// <summary>
|
/// <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
|
/// Trade volume in base asset in the last 24h
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Trade volume in quote asset in the last 24h
|
/// Trade volume in quote asset in the last 24h
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public decimal? QuoteVolume { get; set; }
|
[Obsolete("Use `Volumes` instead")]
|
||||||
|
public decimal? QuoteVolume => Volumes?.QuantityInQuoteAsset;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change percentage in the last 24h
|
/// Change percentage in the last 24h
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -36,13 +55,20 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </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)
|
: base(sharedSymbol, symbol)
|
||||||
{
|
{
|
||||||
LastPrice = lastPrice;
|
LastPrice = lastPrice;
|
||||||
HighPrice = highPrice;
|
HighPrice = highPrice;
|
||||||
LowPrice = lowPrice;
|
LowPrice = lowPrice;
|
||||||
Volume = volume;
|
Volumes = volumes;
|
||||||
ChangePercentage = changePercentage;
|
ChangePercentage = changePercentage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,11 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
[JsonConverter(typeof(SharedOrderQuantityConverter))]
|
[JsonConverter(typeof(SharedOrderQuantityConverter))]
|
||||||
public record SharedOrderQuantity : SharedQuantityReference
|
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>
|
/// <summary>
|
||||||
/// ctor
|
/// ctor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user