1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-11-14 01:08:08 +00:00

Added SharedTickerType for defining time used for ticker calculations by the API

This commit is contained in:
Jkorf 2025-11-10 09:15:20 +01:00
parent 8043a48c49
commit 6cf9684f55
9 changed files with 157 additions and 6 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace CryptoExchange.Net.SharedApis.Enums
{
/// <summary>
/// Type of ticker
/// </summary>
public enum SharedTickerType
{
/// <summary>
/// The ticker data is calculated based on the last 24 hours
/// </summary>
Day24H,
/// <summary>
/// The ticker data is calculated based on the start of the day at 00:00 on UTC+0
/// </summary>
DayUTc0,
/// <summary>
/// Ticker data is calculated in a different way or not consistent
/// </summary>
Other
}
}

View File

@ -12,7 +12,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Futures get ticker request options
/// </summary>
EndpointOptions<GetTickerRequest> GetFuturesTickerOptions { get; }
GetTickerOptions GetFuturesTickerOptions { get; }
/// <summary>
/// Get ticker info for a specific futures symbol
/// </summary>
@ -23,7 +23,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Futures get tickers request options
/// </summary>
EndpointOptions<GetTickersRequest> GetFuturesTickersOptions { get; }
GetTickersOptions GetFuturesTickersOptions { get; }
/// <summary>
/// Get ticker info for all futures symbols
/// </summary>

View File

@ -12,7 +12,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Spot ticker request options
/// </summary>
EndpointOptions<GetTickerRequest> GetSpotTickerOptions { get; }
GetTickerOptions GetSpotTickerOptions { get; }
/// <summary>
/// Get ticker for a specific spot symbol
/// </summary>
@ -22,7 +22,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Spot tickers request options
/// </summary>
EndpointOptions<GetTickersRequest> GetSpotTickersOptions { get; }
GetTickersOptions GetSpotTickersOptions { get; }
/// <summary>
/// Get tickers for all spot symbols
/// </summary>

View File

@ -13,7 +13,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Ticker subscription options
/// </summary>
EndpointOptions<SubscribeTickerRequest> SubscribeTickerOptions { get; }
SubscribeTickerOptions SubscribeTickerOptions { get; }
/// <summary>
/// Subscribe to ticker updates for a symbol

View File

@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
/// <summary>
/// Tickers subscription options
/// </summary>
EndpointOptions<SubscribeAllTickersRequest> SubscribeAllTickersOptions { get; }
SubscribeTickersOptions SubscribeAllTickersOptions { get; }
/// <summary>
/// Subscribe to tickers updates for all symbols

View File

@ -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
{
/// <summary>
/// Options for requesting ticker
/// </summary>
public class GetTickerOptions : EndpointOptions<GetTickerRequest>
{
/// <summary>
/// Type of ticker calculation
/// </summary>
public SharedTickerType TickerType { get; set; } = SharedTickerType.Day24H;
/// <summary>
/// ctor
/// </summary>
public GetTickerOptions(SharedTickerType? tickerCalcType = null) : base(false)
{
TickerType = tickerCalcType ?? SharedTickerType.Day24H;
}
/// <inheritdoc />
public override string ToString(string exchange)
{
var sb = new StringBuilder(base.ToString(exchange));
sb.AppendLine($"Ticker time calc type: {TickerType}");
return sb.ToString();
}
}
}

View File

@ -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
{
/// <summary>
/// Options for requesting tickers
/// </summary>
public class GetTickersOptions : EndpointOptions<GetTickersRequest>
{
/// <summary>
/// Type of ticker calculation
/// </summary>
public SharedTickerType TickerType { get; set; } = SharedTickerType.Day24H;
/// <summary>
/// ctor
/// </summary>
public GetTickersOptions(SharedTickerType? tickerCalcType = null) : base(false)
{
TickerType = tickerCalcType ?? SharedTickerType.Day24H;
}
/// <inheritdoc />
public override string ToString(string exchange)
{
var sb = new StringBuilder(base.ToString(exchange));
sb.AppendLine($"Ticker time calc type: {TickerType}");
return sb.ToString();
}
}
}

View File

@ -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
{
/// <summary>
/// Options for subscribing to ticker updates
/// </summary>
public class SubscribeTickerOptions : EndpointOptions<SubscribeTickerRequest>
{
/// <summary>
/// Type of ticker calculation
/// </summary>
public SharedTickerType TickerType { get; set; }
/// <summary>
/// ctor
/// </summary>
public SubscribeTickerOptions(SharedTickerType? tickerCalcType = null) : base(false)
{
TickerType = tickerCalcType ?? SharedTickerType.Day24H;
}
}
}

View File

@ -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
{
/// <summary>
/// Options for subscribing to ticker updates
/// </summary>
public class SubscribeTickersOptions : EndpointOptions<SubscribeAllTickersRequest>
{
/// <summary>
/// Type of ticker calculation
/// </summary>
public SharedTickerType TickerType { get; set; }
/// <summary>
/// ctor
/// </summary>
public SubscribeTickersOptions(SharedTickerType? tickerCalcType = null) : base(false)
{
TickerType = tickerCalcType ?? SharedTickerType.Day24H;
}
}
}