mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-02-16 22:23:54 +00:00
Merge branch 'master' of https://github.com/JKorf/CryptoExchange.Net
This commit is contained in:
commit
2c63a83117
@ -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>
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user