diff --git a/CoinbasePro/Network/Authentication/Authenticator.cs b/CoinbasePro/Network/Authentication/Authenticator.cs index 11321175..a9453ad8 100644 --- a/CoinbasePro/Network/Authentication/Authenticator.cs +++ b/CoinbasePro/Network/Authentication/Authenticator.cs @@ -13,6 +13,13 @@ public Authenticator( string unsignedSignature, string passphrase) { + if (string.IsNullOrEmpty(apiKey) || string.IsNullOrEmpty(unsignedSignature) || + string.IsNullOrEmpty(passphrase)) + { + throw new ArgumentException( + $"{nameof(Authenticator)} requires parameters {nameof(apiKey)}, {nameof(unsignedSignature)} and {nameof(passphrase)} to be populated."); + } + ApiKey = apiKey; UnsignedSignature = unsignedSignature; Passphrase = passphrase; diff --git a/CoinbasePro/Services/Products/ProductsService.cs b/CoinbasePro/Services/Products/ProductsService.cs index dc7ee85f..089b0edc 100644 --- a/CoinbasePro/Services/Products/ProductsService.cs +++ b/CoinbasePro/Services/Products/ProductsService.cs @@ -89,8 +89,13 @@ public async Task> GetHistoricRatesAsync( candleList.AddRange(await GetHistoricRatesAsync(productPair, batchStart, batchEnd.Value, (int)granularity)); + var previousBatchEnd = batchEnd; batchEnd = candleList.LastOrDefault()?.Time; + if (previousBatchEnd == batchEnd) { + break; + } + } while (batchStart > start); return candleList; diff --git a/CoinbasePro/WebSocket/WebSocket.cs b/CoinbasePro/WebSocket/WebSocket.cs index 21384bba..b8d6eef4 100644 --- a/CoinbasePro/WebSocket/WebSocket.cs +++ b/CoinbasePro/WebSocket/WebSocket.cs @@ -36,7 +36,7 @@ public class WebSocket : IWebSocket private IWebSocketFeed webSocketFeed; - public WebSocketState State => webSocketFeed.State; + public WebSocketState State => webSocketFeed?.State ?? WebSocketState.None; public WebSocket( Func createWebSocketFeed, @@ -92,6 +92,12 @@ public void Start( public void Stop() { + if (webSocketFeed == null) + { + Log.Warning("Websocket did not attempt to stop as the feed has not been started yet"); + return; + } + if (webSocketFeed.State != WebSocketState.Open) { throw new CoinbaseProWebSocketException(