mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-11 16:32:57 +00:00
fcb36f7ee0
Added SpotSymbolCatalog to Shared ISpotSymbolRestClient interface Added FuturesSymbolCatalog to Shared IFuturesSymbolRestClient interface Added BaseAssetType, BaseAssetSubType, QuoteAssetType and QuoteAssetSubType to GetSymbolsRequest model Added DisplayName to SharedSpotSymbol and SharedFuturesSymbol models Added BaseAssetType, BaseAssetSubType, QuoteAssetType and QuoteAssetSubType to SharedSpotSymbol and SharedFuturesSymbol models Added IsStableCoin, IsCommodity and IsEquity helper methods to LibraryHelpers
59 lines
2.3 KiB
C#
59 lines
2.3 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace CryptoExchange.Net.SharedApis
|
|
{
|
|
/// <summary>
|
|
/// Options for requesting symbol info
|
|
/// </summary>
|
|
public class GetFuturesSymbolsOptions : EndpointOptions<GetSymbolsRequest, IFuturesSymbolRestClient>
|
|
{
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
public GetFuturesSymbolsOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IFuturesSymbolRestClient.GetFuturesSymbolsAsync))
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override Error? ValidateRequest(GetSymbolsRequest request, IFuturesSymbolRestClient client)
|
|
{
|
|
if (request.BaseAssetType != null && request.BaseAssetSubType != null)
|
|
{
|
|
var error = ValidateAssetTypeCombination(request.BaseAssetType.Value, request.BaseAssetSubType.Value);
|
|
if (error != null)
|
|
return error;
|
|
}
|
|
|
|
if (request.QuoteAssetType != null && request.QuoteAssetSubType != null)
|
|
{
|
|
var error = ValidateAssetTypeCombination(request.QuoteAssetType.Value, request.QuoteAssetSubType.Value);
|
|
if (error != null)
|
|
return error;
|
|
}
|
|
|
|
return base.ValidateRequest(request, client);
|
|
}
|
|
|
|
private Error? ValidateAssetTypeCombination(SharedAssetType type, SharedAssetSubType subType)
|
|
{
|
|
if (type == SharedAssetType.Crypto
|
|
&& (subType == SharedAssetSubType.Commodity
|
|
|| (subType == SharedAssetSubType.Equity)))
|
|
{
|
|
return ArgumentError.Invalid(nameof(GetSymbolsRequest.BaseAssetSubType), $"Invalid combination of asset type filters: {type} and {subType}");
|
|
}
|
|
|
|
if (type == SharedAssetType.TradFi && subType == SharedAssetSubType.StableCoin)
|
|
return ArgumentError.Invalid(nameof(GetSymbolsRequest.BaseAssetSubType), $"Invalid combination of asset type filters: {type} and {subType}");
|
|
|
|
if (type == SharedAssetType.Fiat)
|
|
return ArgumentError.Invalid(nameof(GetSymbolsRequest.BaseAssetSubType), $"Invalid combination of asset type filters: {type} and {subType}");
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|