1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2026-02-16 14:13:46 +00:00

Merge branch 'master' into feature/userdata-tracker

This commit is contained in:
Jkorf 2026-02-02 08:45:21 +01:00
commit 2f5b9091a8
8 changed files with 128 additions and 11 deletions

View File

@ -6,9 +6,9 @@
<PackageId>CryptoExchange.Net</PackageId> <PackageId>CryptoExchange.Net</PackageId>
<Authors>JKorf</Authors> <Authors>JKorf</Authors>
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description> <Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
<PackageVersion>10.3.0</PackageVersion> <PackageVersion>10.3.1</PackageVersion>
<AssemblyVersion>10.3.0</AssemblyVersion> <AssemblyVersion>10.3.1</AssemblyVersion>
<FileVersion>10.3.0</FileVersion> <FileVersion>10.3.1</FileVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange;CryptoExchange.Net</PackageTags> <PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange;CryptoExchange.Net</PackageTags>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>

View File

@ -32,6 +32,66 @@ namespace CryptoExchange.Net
_symbolInfos[topicId] = new ExchangeInfo(DateTime.UtcNow, updateData.ToDictionary(x => x.Name, x => x.SharedSymbol)); _symbolInfos[topicId] = new ExchangeInfo(DateTime.UtcNow, updateData.ToDictionary(x => x.Name, x => x.SharedSymbol));
} }
/// <summary>
/// Whether the specific topic has been cached
/// </summary>
/// <param name="topicId">Id</param>
public static bool HasCached(string topicId)
{
if (!_symbolInfos.TryGetValue(topicId, out var exchangeInfo))
return false;
return exchangeInfo.Symbols.Count > 0;
}
/// <summary>
/// Whether a specific exchange(topic) support the provided symbol
/// </summary>
/// <param name="topicId">Id for the provided data</param>
/// <param name="symbolName">The symbol name</param>
public static bool SupportsSymbol(string topicId, string symbolName)
{
if (!_symbolInfos.TryGetValue(topicId, out var exchangeInfo))
return false;
if (!exchangeInfo.Symbols.TryGetValue(symbolName, out var symbolInfo))
return false;
return true;
}
/// <summary>
/// Whether a specific exchange(topic) support the provided symbol
/// </summary>
/// <param name="topicId">Id for the provided data</param>
/// <param name="symbol">The symbol info</param>
public static bool SupportsSymbol(string topicId, SharedSymbol symbol)
{
if (!_symbolInfos.TryGetValue(topicId, out var exchangeInfo))
return false;
return exchangeInfo.Symbols.Any(x =>
x.Value.TradingMode == symbol.TradingMode
&& x.Value.BaseAsset == symbol.BaseAsset
&& x.Value.QuoteAsset == symbol.QuoteAsset);
}
/// <summary>
/// Get all symbols for a specific base asset
/// </summary>
/// <param name="topicId">Id for the provided data</param>
/// <param name="baseAsset">Base asset name</param>
public static SharedSymbol[] GetSymbolsForBaseAsset(string topicId, string baseAsset)
{
if (!_symbolInfos.TryGetValue(topicId, out var exchangeInfo))
return [];
return exchangeInfo.Symbols
.Where(x => x.Value.BaseAsset.Equals(baseAsset, StringComparison.InvariantCultureIgnoreCase))
.Select(x => x.Value)
.ToArray();
}
/// <summary> /// <summary>
/// Parse a symbol name to a SharedSymbol /// Parse a symbol name to a SharedSymbol
/// </summary> /// </summary>

View File

@ -12,6 +12,25 @@ namespace CryptoExchange.Net.SharedApis
/// Futures symbol request options /// Futures symbol request options
/// </summary> /// </summary>
EndpointOptions<GetSymbolsRequest> GetFuturesSymbolsOptions { get; } EndpointOptions<GetSymbolsRequest> GetFuturesSymbolsOptions { get; }
/// <summary>
/// Get all futures symbols for a specific base asset
/// </summary>
/// <param name="baseAsset">Asset, for example `ETH`</param>
Task<ExchangeResult<SharedSymbol[]>> GetFuturesSymbolsForBaseAssetAsync(string baseAsset);
/// <summary>
/// Gets whether the client supports a futures symbol
/// </summary>
/// <param name="symbol">The symbol</param>
Task<ExchangeResult<bool>> SupportsFuturesSymbolAsync(SharedSymbol symbol);
/// <summary>
/// Gets whether the client supports a futures symbol
/// </summary>
/// <param name="symbolName">The symbol name</param>
Task<ExchangeResult<bool>> SupportsFuturesSymbolAsync(string symbolName);
/// <summary> /// <summary>
/// Get info on all futures symbols supported on the exchange /// Get info on all futures symbols supported on the exchange
/// </summary> /// </summary>

View File

@ -1,4 +1,5 @@
using System.Threading; using CryptoExchange.Net.Objects;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
@ -13,6 +14,24 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
EndpointOptions<GetSymbolsRequest> GetSpotSymbolsOptions { get; } EndpointOptions<GetSymbolsRequest> GetSpotSymbolsOptions { get; }
/// <summary>
/// Get all spot symbols for a specific base asset
/// </summary>
/// <param name="baseAsset">Asset, for example `ETH`</param>
Task<ExchangeResult<SharedSymbol[]>> GetSpotSymbolsForBaseAssetAsync(string baseAsset);
/// <summary>
/// Gets whether the client supports a spot symbol
/// </summary>
/// <param name="symbol">The symbol</param>
Task<ExchangeResult<bool>> SupportsSpotSymbolAsync(SharedSymbol symbol);
/// <summary>
/// Gets whether the client supports a spot symbol
/// </summary>
/// <param name="symbolName">The symbol name</param>
Task<ExchangeResult<bool>> SupportsSpotSymbolAsync(string symbolName);
/// <summary> /// <summary>
/// Get info on all available spot symbols on the exchange /// Get info on all available spot symbols on the exchange
/// </summary> /// </summary>

View File

@ -38,6 +38,17 @@ namespace CryptoExchange.Net.SharedApis
Exchange = exchange; Exchange = exchange;
} }
/// <summary>
/// ctor
/// </summary>
public ExchangeResult(
string exchange,
T result) :
base(result, null, null)
{
Exchange = exchange;
}
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() => $"{Exchange} - " + base.ToString(); public override string ToString() => $"{Exchange} - " + base.ToString();
} }

View File

@ -55,6 +55,11 @@ namespace CryptoExchange.Net.Trackers.Klines
/// </summary> /// </summary>
SharedKline? Last { get; } SharedKline? Last { get; }
/// <summary>
/// The kline interval
/// </summary>
public SharedKlineInterval Interval { get; }
/// <summary> /// <summary>
/// Event for when a new kline is added /// Event for when a new kline is added
/// </summary> /// </summary>

View File

@ -45,10 +45,6 @@ namespace CryptoExchange.Net.Trackers.Klines
/// </summary> /// </summary>
protected bool _changed = false; protected bool _changed = false;
/// <summary> /// <summary>
/// The kline interval
/// </summary>
protected readonly SharedKlineInterval _interval;
/// <summary>
/// Whether the snapshot has been set /// Whether the snapshot has been set
/// </summary> /// </summary>
protected bool _snapshotSet; protected bool _snapshotSet;
@ -66,6 +62,10 @@ namespace CryptoExchange.Net.Trackers.Klines
/// </summary> /// </summary>
protected DateTime? _firstTimestamp; protected DateTime? _firstTimestamp;
/// <summary>
/// The kline interval
/// </summary>
public SharedKlineInterval Interval { get; }
/// <inheritdoc/> /// <inheritdoc/>
public SyncStatus Status public SyncStatus Status
{ {
@ -165,7 +165,7 @@ namespace CryptoExchange.Net.Trackers.Klines
Exchange = restClient.Exchange; Exchange = restClient.Exchange;
Limit = limit; Limit = limit;
Period = period; Period = period;
_interval = interval; Interval = interval;
_socketClient = socketClient; _socketClient = socketClient;
_restClient = restClient; _restClient = restClient;
} }
@ -180,7 +180,7 @@ namespace CryptoExchange.Net.Trackers.Klines
Status = SyncStatus.Syncing; Status = SyncStatus.Syncing;
_logger.KlineTrackerStarting(SymbolName); _logger.KlineTrackerStarting(SymbolName);
var subResult = await _socketClient.SubscribeToKlineUpdatesAsync(new SubscribeKlineRequest(Symbol, _interval), var subResult = await _socketClient.SubscribeToKlineUpdatesAsync(new SubscribeKlineRequest(Symbol, Interval),
update => update =>
{ {
AddOrUpdate(update.Data); AddOrUpdate(update.Data);
@ -237,7 +237,7 @@ namespace CryptoExchange.Net.Trackers.Klines
var limit = Math.Min(_restClient.GetKlinesOptions.MaxLimit, Limit ?? 100); var limit = Math.Min(_restClient.GetKlinesOptions.MaxLimit, Limit ?? 100);
var request = new GetKlinesRequest(Symbol, _interval, startTime, DateTime.UtcNow, limit: limit); var request = new GetKlinesRequest(Symbol, Interval, startTime, DateTime.UtcNow, limit: limit);
var data = new List<SharedKline>(); var data = new List<SharedKline>();
await foreach (var result in ExchangeHelpers.ExecutePages(_restClient.GetKlinesAsync, request).ConfigureAwait(false)) await foreach (var result in ExchangeHelpers.ExecutePages(_restClient.GetKlinesAsync, request).ConfigureAwait(false))
{ {

View File

@ -67,6 +67,9 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf). Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
## Release notes ## Release notes
* Version 10.3.1 - 27 Jan 2026
* Fixed potential collection modified exception upon logging message not handled in websocket message handling
* Version 10.3.0 - 22 Jan 2026 * Version 10.3.0 - 22 Jan 2026
* Added PlatformInfo class for specifying platform metadata * Added PlatformInfo class for specifying platform metadata
* Added better handling for enabling AutoTimestamp in client options when not implemented in the API * Added better handling for enabling AutoTimestamp in client options when not implemented in the API