diff --git a/CoinEx.Net.UnitTests/CoinExClientTests.cs b/CoinEx.Net.UnitTests/CoinExClientTests.cs index 124b906..ad6a50a 100644 --- a/CoinEx.Net.UnitTests/CoinExClientTests.cs +++ b/CoinEx.Net.UnitTests/CoinExClientTests.cs @@ -91,22 +91,6 @@ public void SigningString_Should_GiveCorrectSignResult(string input, string outp Assert.That(sign == output); } - [TestCase("BTCUSDT", true)] - [TestCase("NANOUSDTA", true)] - [TestCase("NANOBTC", true)] - [TestCase("ETHBTC", true)] - [TestCase("BEETC", true)] - [TestCase("BETC", false)] - [TestCase("BTC-USDT", false)] - [TestCase("BTC-USD", false)] - public void CheckValidCoinExSymbol(string symbol, bool isValid) - { - if (isValid) - Assert.DoesNotThrow(symbol.ValidateCoinExSymbol); - else - Assert.Throws(typeof(ArgumentException), symbol.ValidateCoinExSymbol); - } - [Test] public void CheckRestInterfaces() { diff --git a/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiExchangeData.cs b/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiExchangeData.cs index f14b0c1..8bb6ed4 100644 --- a/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiExchangeData.cs +++ b/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiExchangeData.cs @@ -60,7 +60,6 @@ public async Task>> GetAsset /// public async Task> GetTickerAsync(string symbol, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); var parameters = new Dictionary { { "market", symbol } @@ -85,7 +84,6 @@ public async Task> GetTickersAsync(Cancell /// public async Task> GetOrderBookAsync(string symbol, int mergeDepth, int? limit = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); mergeDepth.ValidateIntBetween(nameof(mergeDepth), 0, 8); limit?.ValidateIntValues(nameof(limit), 5, 10, 20); @@ -102,8 +100,6 @@ public async Task> GetOrderBookAsync(string symbo /// public async Task>> GetTradeHistoryAsync(string symbol, long? fromId = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); - var parameters = new Dictionary { { "market", symbol } @@ -132,7 +128,6 @@ public async Task>> GetSymbolInfo /// public async Task>> GetKlinesAsync(string symbol, KlineInterval interval, int? limit = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); limit?.ValidateIntBetween(nameof(limit), 1, 1000); var parameters = new Dictionary { diff --git a/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiTrading.cs b/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiTrading.cs index ee1963c..671e740 100644 --- a/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiTrading.cs +++ b/CoinEx.Net/Clients/SpotApi/CoinExRestClientSpotApiTrading.cs @@ -55,8 +55,6 @@ public async Task> PlaceOrderAsync( string? sourceId = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); - var endpoint = ""; if (type == OrderType.Limit) endpoint = PlaceLimitOrderEndpoint; @@ -99,7 +97,6 @@ public async Task> PlaceOrderAsync( /// public async Task>> GetOpenOrdersAsync(string? symbol = null, int? page = null, int? limit = null, CancellationToken ct = default) { - symbol?.ValidateCoinExSymbol(); limit?.ValidateIntBetween(nameof(limit), 1, 100); var parameters = new Dictionary { @@ -115,7 +112,6 @@ public async Task>> GetOpenOrdersAs /// public async Task>> GetOpenStopOrdersAsync(string symbol, int? page = null, int? limit = null, CancellationToken ct = default) { - symbol?.ValidateCoinExSymbol(); limit?.ValidateIntBetween(nameof(limit), 1, 100); var parameters = new Dictionary { @@ -129,7 +125,6 @@ public async Task>> GetOpenStopOrde /// public async Task>> GetClosedOrdersAsync(string symbol, int? page = null, int? limit = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); limit?.ValidateIntBetween(nameof(limit), 1, 100); var parameters = new Dictionary { @@ -144,7 +139,6 @@ public async Task>> GetClosedOrders /// public async Task> GetOrderAsync(string symbol, long orderId, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); var parameters = new Dictionary { { "market", symbol }, @@ -171,7 +165,6 @@ public async Task>> GetOrderTr /// public async Task>> GetUserTradesAsync(string symbol, int? page = null, int? limit = null, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); limit?.ValidateIntBetween(nameof(limit), 1, 100); var parameters = new Dictionary { @@ -186,7 +179,6 @@ public async Task>> Ge /// public async Task> CancelOrderAsync(string symbol, long orderId, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); var parameters = new Dictionary { { "market", symbol }, @@ -202,7 +194,6 @@ public async Task> CancelOrderAsync(string symbol, lo /// public async Task CancelAllOrdersAsync(string symbol, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); var parameters = new Dictionary { { "market", symbol }, @@ -214,7 +205,6 @@ public async Task CancelAllOrdersAsync(string symbol, Cancellatio /// public async Task CancelAllStopOrdersAsync(string symbol, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); var parameters = new Dictionary { { "market", symbol }, diff --git a/CoinEx.Net/Clients/SpotApi/CoinExSocketClientSpotApi.cs b/CoinEx.Net/Clients/SpotApi/CoinExSocketClientSpotApi.cs index 4ae8d20..c7222dd 100644 --- a/CoinEx.Net/Clients/SpotApi/CoinExSocketClientSpotApi.cs +++ b/CoinEx.Net/Clients/SpotApi/CoinExSocketClientSpotApi.cs @@ -112,7 +112,6 @@ public async Task> GetServerTimeAsync() /// public async Task> GetTickerAsync(string symbol, int cyclePeriod) { - symbol.ValidateCoinExSymbol(); var query = await QueryAsync(new CoinExQuery("state.query", new object[] { symbol, cyclePeriod })).ConfigureAwait(false); return query.As(query.Data?.Result); } @@ -120,7 +119,6 @@ public async Task> GetTickerAsync(string sym /// public async Task> GetOrderBookAsync(string symbol, int limit, int mergeDepth) { - symbol.ValidateCoinExSymbol(); mergeDepth.ValidateIntBetween(nameof(mergeDepth), 0, 8); limit.ValidateIntValues(nameof(limit), 5, 10, 20); @@ -131,8 +129,6 @@ public async Task> GetOrderBookAsync(string sy /// public async Task>> GetTradeHistoryAsync(string symbol, int? limit = null, int? fromId = null) { - symbol.ValidateCoinExSymbol(); - var query = await QueryAsync(new CoinExQuery>("deals.query", new object[] { symbol, limit ?? 10, fromId ?? 0 }, false)).ConfigureAwait(false); return query.As>(query.Data?.Result); } @@ -140,8 +136,6 @@ public async Task>> GetTradeHist /// public async Task>> GetKlinesAsync(string symbol, KlineInterval interval) { - symbol.ValidateCoinExSymbol(); - var startTime = DateTimeConverter.ConvertToSeconds(DateTime.UtcNow.AddDays(-1)); var endTime = DateTimeConverter.ConvertToSeconds(DateTime.UtcNow); var query = await QueryAsync(new CoinExQuery>("kline.query", new object[] { symbol, startTime, endTime, interval.ToSeconds() }, false)).ConfigureAwait(false); @@ -158,8 +152,6 @@ public async Task>> GetBalancesAsyn /// public async Task>> GetOpenOrdersAsync(string symbol, OrderSide? side = null, int? offset = null, int? limit = null) { - symbol.ValidateCoinExSymbol(); - var query = await QueryAsync(new CoinExQuery>("order.query", new object[] { symbol, int.Parse(JsonConvert.SerializeObject(side ?? OrderSide.Either, new OrderSideIntConverter(false))), offset ?? 0, limit ?? 10 }, true)).ConfigureAwait(false); return query.As>(query.Data?.Result); } @@ -167,8 +159,6 @@ public async Task>> GetOpe /// public async Task> SubscribeToTickerUpdatesAsync(string symbol, Action> onMessage, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); - var subscription = new CoinExStateSubscription(_logger, symbol, new object[] { symbol }, x => onMessage(x.As(x.Data.Single()))); return await SubscribeAsync(subscription, ct).ConfigureAwait(false); } @@ -183,7 +173,6 @@ public async Task> SubscribeToAllTickerUpdatesAsy /// public async Task> SubscribeToOrderBookUpdatesAsync(string symbol, int limit, int mergeDepth, Action> onMessage, bool diffUpdates, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); mergeDepth.ValidateIntBetween(nameof(mergeDepth), 0, 8); limit.ValidateIntValues(nameof(limit), 5, 10, 20); @@ -194,8 +183,6 @@ public async Task> SubscribeToOrderBookUpdatesAsy /// public async Task> SubscribeToTradeUpdatesAsync(string symbol, Action>> onMessage, CancellationToken ct = default) { - symbol.ValidateCoinExSymbol(); - var subscription = new CoinExDealsSubscription(_logger, symbol, new object[] { symbol }, onMessage); return await SubscribeAsync(subscription, ct).ConfigureAwait(false); } diff --git a/CoinEx.Net/CoinEx.Net.xml b/CoinEx.Net/CoinEx.Net.xml index b507d87..36d3837 100644 --- a/CoinEx.Net/CoinEx.Net.xml +++ b/CoinEx.Net/CoinEx.Net.xml @@ -571,12 +571,6 @@ Extension methods specific to using the CoinEx API - - - Validate the string is a valid CoinEx symbol. - - string to validate - Client for accessing the CoinEx API. diff --git a/CoinEx.Net/ExtensionMethods/CoinExExtensionMethods.cs b/CoinEx.Net/ExtensionMethods/CoinExExtensionMethods.cs index 893bf2c..14917c0 100644 --- a/CoinEx.Net/ExtensionMethods/CoinExExtensionMethods.cs +++ b/CoinEx.Net/ExtensionMethods/CoinExExtensionMethods.cs @@ -8,17 +8,5 @@ namespace CoinEx.Net.ExtensionMethods /// public static class CoinExExtensionMethods { - /// - /// Validate the string is a valid CoinEx symbol. - /// - /// string to validate - public static void ValidateCoinExSymbol(this string symbolString) - { - if (string.IsNullOrEmpty(symbolString)) - throw new ArgumentException("Symbol is not provided"); - - if (!Regex.IsMatch(symbolString, "^([0-9A-Z]{5,})$")) - throw new ArgumentException($"{symbolString} is not a valid CoinEx symbol. Should be [BaseAsset][QuoteAsset], e.g. ETHBTC"); - } } } diff --git a/CoinEx.Net/SymbolOrderBooks/CoinExSpotSymbolOrderBook.cs b/CoinEx.Net/SymbolOrderBooks/CoinExSpotSymbolOrderBook.cs index 7337222..a7eeed8 100644 --- a/CoinEx.Net/SymbolOrderBooks/CoinExSpotSymbolOrderBook.cs +++ b/CoinEx.Net/SymbolOrderBooks/CoinExSpotSymbolOrderBook.cs @@ -50,8 +50,6 @@ public CoinExSpotSymbolOrderBook(string symbol, optionsDelegate(options); Initialize(options); - symbol.ValidateCoinExSymbol(); - _strictLevels = false; _sequencesAreConsecutive = false; _initialDataTimeout = options?.InitialDataTimeout ?? TimeSpan.FromSeconds(30);