From 6cf9684f5504ab0928dbab1f43b5340cac51056e Mon Sep 17 00:00:00 2001 From: Jkorf Date: Mon, 10 Nov 2025 09:15:20 +0100 Subject: [PATCH] Added SharedTickerType for defining time used for ticker calculations by the API --- .../SharedApis/Enums/SharedTickerType.cs | 25 +++++++++++++ .../Rest/Futures/IFuturesTickerRestClient.cs | 4 +-- .../Rest/Spot/ISpotTickerRestClient.cs | 4 +-- .../Interfaces/Socket/ITickerSocketClient.cs | 2 +- .../Interfaces/Socket/ITickersSocketClient.cs | 2 +- .../Options/Endpoints/GetTickerOptions.cs | 36 +++++++++++++++++++ .../Options/Endpoints/GetTickersOptions.cs | 36 +++++++++++++++++++ .../Subscriptions/SubscribeTickerOptions.cs | 27 ++++++++++++++ .../Subscriptions/SubscribeTickersOptions.cs | 27 ++++++++++++++ 9 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 CryptoExchange.Net/SharedApis/Enums/SharedTickerType.cs create mode 100644 CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickerOptions.cs create mode 100644 CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickersOptions.cs create mode 100644 CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs create mode 100644 CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs diff --git a/CryptoExchange.Net/SharedApis/Enums/SharedTickerType.cs b/CryptoExchange.Net/SharedApis/Enums/SharedTickerType.cs new file mode 100644 index 0000000..da58208 --- /dev/null +++ b/CryptoExchange.Net/SharedApis/Enums/SharedTickerType.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace CryptoExchange.Net.SharedApis.Enums +{ + /// + /// Type of ticker + /// + public enum SharedTickerType + { + /// + /// The ticker data is calculated based on the last 24 hours + /// + Day24H, + /// + /// The ticker data is calculated based on the start of the day at 00:00 on UTC+0 + /// + DayUTc0, + /// + /// Ticker data is calculated in a different way or not consistent + /// + Other + } +} diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesTickerRestClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesTickerRestClient.cs index b11c01c..f96b9b3 100644 --- a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesTickerRestClient.cs +++ b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesTickerRestClient.cs @@ -12,7 +12,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Futures get ticker request options /// - EndpointOptions GetFuturesTickerOptions { get; } + GetTickerOptions GetFuturesTickerOptions { get; } /// /// Get ticker info for a specific futures symbol /// @@ -23,7 +23,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Futures get tickers request options /// - EndpointOptions GetFuturesTickersOptions { get; } + GetTickersOptions GetFuturesTickersOptions { get; } /// /// Get ticker info for all futures symbols /// diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotTickerRestClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotTickerRestClient.cs index 84a9108..5e9a8f3 100644 --- a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotTickerRestClient.cs +++ b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotTickerRestClient.cs @@ -12,7 +12,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Spot ticker request options /// - EndpointOptions GetSpotTickerOptions { get; } + GetTickerOptions GetSpotTickerOptions { get; } /// /// Get ticker for a specific spot symbol /// @@ -22,7 +22,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Spot tickers request options /// - EndpointOptions GetSpotTickersOptions { get; } + GetTickersOptions GetSpotTickersOptions { get; } /// /// Get tickers for all spot symbols /// diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickerSocketClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickerSocketClient.cs index 329d1d3..89ce996 100644 --- a/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickerSocketClient.cs +++ b/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickerSocketClient.cs @@ -13,7 +13,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Ticker subscription options /// - EndpointOptions SubscribeTickerOptions { get; } + SubscribeTickerOptions SubscribeTickerOptions { get; } /// /// Subscribe to ticker updates for a symbol diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickersSocketClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickersSocketClient.cs index f3652c3..4d25ffb 100644 --- a/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickersSocketClient.cs +++ b/CryptoExchange.Net/SharedApis/Interfaces/Socket/ITickersSocketClient.cs @@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Tickers subscription options /// - EndpointOptions SubscribeAllTickersOptions { get; } + SubscribeTickersOptions SubscribeAllTickersOptions { get; } /// /// Subscribe to tickers updates for all symbols diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickerOptions.cs new file mode 100644 index 0000000..cdb4ad0 --- /dev/null +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickerOptions.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.SharedApis.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CryptoExchange.Net.SharedApis +{ + /// + /// Options for requesting ticker + /// + public class GetTickerOptions : EndpointOptions + { + /// + /// Type of ticker calculation + /// + public SharedTickerType TickerType { get; set; } = SharedTickerType.Day24H; + + /// + /// ctor + /// + public GetTickerOptions(SharedTickerType? tickerCalcType = null) : base(false) + { + TickerType = tickerCalcType ?? SharedTickerType.Day24H; + } + + /// + public override string ToString(string exchange) + { + var sb = new StringBuilder(base.ToString(exchange)); + sb.AppendLine($"Ticker time calc type: {TickerType}"); + return sb.ToString(); + } + } +} diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickersOptions.cs new file mode 100644 index 0000000..4913eb1 --- /dev/null +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTickersOptions.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.SharedApis.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace CryptoExchange.Net.SharedApis +{ + /// + /// Options for requesting tickers + /// + public class GetTickersOptions : EndpointOptions + { + /// + /// Type of ticker calculation + /// + public SharedTickerType TickerType { get; set; } = SharedTickerType.Day24H; + + /// + /// ctor + /// + public GetTickersOptions(SharedTickerType? tickerCalcType = null) : base(false) + { + TickerType = tickerCalcType ?? SharedTickerType.Day24H; + } + + /// + public override string ToString(string exchange) + { + var sb = new StringBuilder(base.ToString(exchange)); + sb.AppendLine($"Ticker time calc type: {TickerType}"); + return sb.ToString(); + } + } +} diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs new file mode 100644 index 0000000..076fdb6 --- /dev/null +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs @@ -0,0 +1,27 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.SharedApis.Enums; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CryptoExchange.Net.SharedApis +{ + /// + /// Options for subscribing to ticker updates + /// + public class SubscribeTickerOptions : EndpointOptions + { + /// + /// Type of ticker calculation + /// + public SharedTickerType TickerType { get; set; } + + /// + /// ctor + /// + public SubscribeTickerOptions(SharedTickerType? tickerCalcType = null) : base(false) + { + TickerType = tickerCalcType ?? SharedTickerType.Day24H; + } + } +} diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs new file mode 100644 index 0000000..00c9010 --- /dev/null +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs @@ -0,0 +1,27 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.SharedApis.Enums; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CryptoExchange.Net.SharedApis +{ + /// + /// Options for subscribing to ticker updates + /// + public class SubscribeTickersOptions : EndpointOptions + { + /// + /// Type of ticker calculation + /// + public SharedTickerType TickerType { get; set; } + + /// + /// ctor + /// + public SubscribeTickersOptions(SharedTickerType? tickerCalcType = null) : base(false) + { + TickerType = tickerCalcType ?? SharedTickerType.Day24H; + } + } +}