diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index cafaa72..e156742 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Set GitHub package source run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json" - name: Restore dependencies diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0e18e3e..67110fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Set GitHub package source run: dotnet nuget add source --username JKorf --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/JKorf/index.json" - name: Restore dependencies diff --git a/Kraken.Net.UnitTests/Kraken.Net.UnitTests.csproj b/Kraken.Net.UnitTests/Kraken.Net.UnitTests.csproj index 619e779..5e4e065 100644 --- a/Kraken.Net.UnitTests/Kraken.Net.UnitTests.csproj +++ b/Kraken.Net.UnitTests/Kraken.Net.UnitTests.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net9.0 diff --git a/Kraken.Net.UnitTests/TestImplementations/TestSocket.cs b/Kraken.Net.UnitTests/TestImplementations/TestSocket.cs index ee251f0..8b983b6 100644 --- a/Kraken.Net.UnitTests/TestImplementations/TestSocket.cs +++ b/Kraken.Net.UnitTests/TestImplementations/TestSocket.cs @@ -10,7 +10,7 @@ namespace Kraken.Net.UnitTests.TestImplementations { - public class TestSocket: IWebsocket + public class TestSocket : IWebsocket { public bool CanConnect { get; set; } public bool Connected { get; set; } @@ -122,5 +122,7 @@ public Task ReconnectAsync() { throw new NotImplementedException(); } + + public void UpdateProxy(ApiProxy proxy) => throw new NotImplementedException(); } } diff --git a/Kraken.Net/Clients/FuturesApi/KrakenSocketClientFuturesApi.cs b/Kraken.Net/Clients/FuturesApi/KrakenSocketClientFuturesApi.cs index f9f4c80..dc94a54 100644 --- a/Kraken.Net/Clients/FuturesApi/KrakenSocketClientFuturesApi.cs +++ b/Kraken.Net/Clients/FuturesApi/KrakenSocketClientFuturesApi.cs @@ -34,7 +34,7 @@ internal KrakenSocketClientFuturesApi(ILogger logger, KrakenSocketOptions option { RateLimiter = KrakenExchange.RateLimiter.FuturesSocket; - AddSystemSubscription(new KrakenFuturesInfoSubscription(_logger)); + AddSystemSubscription(new KrakenFuturesInfoSubscription(_logger)); } #endregion diff --git a/Kraken.Net/Clients/KrakenRestClient.cs b/Kraken.Net/Clients/KrakenRestClient.cs index 7098750..628459c 100644 --- a/Kraken.Net/Clients/KrakenRestClient.cs +++ b/Kraken.Net/Clients/KrakenRestClient.cs @@ -1,4 +1,5 @@ using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Objects.Options; using Kraken.Net.Clients.FuturesApi; using Kraken.Net.Clients.SpotApi; using Kraken.Net.Interfaces.Clients; @@ -50,6 +51,13 @@ public KrakenRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, I #region methods + /// + public void SetOptions(UpdateOptions options) + { + SpotApi.SetOptions(options); + FuturesApi.SetOptions(options); + } + /// /// Set the default options to be used when creating new clients /// diff --git a/Kraken.Net/Clients/KrakenSocketClient.cs b/Kraken.Net/Clients/KrakenSocketClient.cs index 67372ae..ba35733 100644 --- a/Kraken.Net/Clients/KrakenSocketClient.cs +++ b/Kraken.Net/Clients/KrakenSocketClient.cs @@ -1,4 +1,5 @@ using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Objects.Options; using Kraken.Net.Clients.FuturesApi; using Kraken.Net.Clients.SpotApi; using Kraken.Net.Interfaces.Clients; @@ -47,6 +48,13 @@ public KrakenSocketClient(IOptions options, ILoggerFactory? #region methods + /// + public void SetOptions(UpdateOptions options) + { + SpotApi.SetOptions(options); + FuturesApi.SetOptions(options); + } + /// /// Set the default options to be used when creating new clients /// diff --git a/Kraken.Net/ExtensionMethods/ServiceCollectionExtensions.cs b/Kraken.Net/ExtensionMethods/ServiceCollectionExtensions.cs index 4d6aff4..c9a3c9d 100644 --- a/Kraken.Net/ExtensionMethods/ServiceCollectionExtensions.cs +++ b/Kraken.Net/ExtensionMethods/ServiceCollectionExtensions.cs @@ -108,6 +108,7 @@ private static IServiceCollection AddKrakenCore( try { handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; + handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; } catch (PlatformNotSupportedException) { } diff --git a/Kraken.Net/Interfaces/Clients/IKrakenRestClient.cs b/Kraken.Net/Interfaces/Clients/IKrakenRestClient.cs index 8df4e28..79cd18b 100644 --- a/Kraken.Net/Interfaces/Clients/IKrakenRestClient.cs +++ b/Kraken.Net/Interfaces/Clients/IKrakenRestClient.cs @@ -1,4 +1,5 @@ -using Kraken.Net.Interfaces.Clients.FuturesApi; +using CryptoExchange.Net.Objects.Options; +using Kraken.Net.Interfaces.Clients.FuturesApi; using Kraken.Net.Interfaces.Clients.SpotApi; namespace Kraken.Net.Interfaces.Clients @@ -18,6 +19,12 @@ public interface IKrakenRestClient : IRestClient /// IKrakenRestClientFuturesApi FuturesApi { get; } + /// + /// Update specific options + /// + /// Options to update. Only specific options are changable after the client has been created + void SetOptions(UpdateOptions options); + /// /// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. /// diff --git a/Kraken.Net/Interfaces/Clients/IKrakenSocketClient.cs b/Kraken.Net/Interfaces/Clients/IKrakenSocketClient.cs index a02551b..5e66420 100644 --- a/Kraken.Net/Interfaces/Clients/IKrakenSocketClient.cs +++ b/Kraken.Net/Interfaces/Clients/IKrakenSocketClient.cs @@ -1,4 +1,5 @@ -using Kraken.Net.Interfaces.Clients.FuturesApi; +using CryptoExchange.Net.Objects.Options; +using Kraken.Net.Interfaces.Clients.FuturesApi; using Kraken.Net.Interfaces.Clients.SpotApi; namespace Kraken.Net.Interfaces.Clients @@ -17,6 +18,12 @@ public interface IKrakenSocketClient : ISocketClient /// IKrakenSocketClientFuturesApi FuturesApi { get; } + /// + /// Update specific options + /// + /// Options to update. Only specific options are changable after the client has been created + void SetOptions(UpdateOptions options); + /// /// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. /// diff --git a/Kraken.Net/Kraken.Net.csproj b/Kraken.Net/Kraken.Net.csproj index 4ebfae1..07a2f74 100644 --- a/Kraken.Net/Kraken.Net.csproj +++ b/Kraken.Net/Kraken.Net.csproj @@ -51,7 +51,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Kraken.Net/Kraken.Net.xml b/Kraken.Net/Kraken.Net.xml index 0f8be47..cd13a26 100644 --- a/Kraken.Net/Kraken.Net.xml +++ b/Kraken.Net/Kraken.Net.xml @@ -237,6 +237,9 @@ The logger factory Http client for this client + + + Set the default options to be used when creating new clients @@ -268,6 +271,9 @@ The logger Option configuration + + + Set the default options to be used when creating new clients @@ -2569,6 +2575,12 @@ Futures API endpoints + + + Update specific options + + Options to update. Only specific options are changable after the client has been created + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. @@ -2590,6 +2602,12 @@ Futures Api + + + Update specific options + + Options to update. Only specific options are changable after the client has been created + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. diff --git a/Kraken.Net/Objects/Internal/KrakenSocketRequestV2.cs b/Kraken.Net/Objects/Internal/KrakenSocketRequestV2.cs index 1347b65..be3dad4 100644 --- a/Kraken.Net/Objects/Internal/KrakenSocketRequestV2.cs +++ b/Kraken.Net/Objects/Internal/KrakenSocketRequestV2.cs @@ -1,12 +1,16 @@ namespace Kraken.Net.Objects.Internal { - internal class KrakenSocketRequestV2 + internal class KrakenSocketRequestV2 { [JsonPropertyName("method")] public string Method { get; set; } = string.Empty; - [JsonPropertyName("params")] - public T Parameters { get; set; } = default!; [JsonPropertyName("req_id")] public long RequestId { get; set; } } + + internal class KrakenSocketRequestV2 : KrakenSocketRequestV2 + { + [JsonPropertyName("params")] + public T Parameters { get; set; } = default!; + } } diff --git a/Kraken.Net/Objects/Options/KrakenSocketOptions.cs b/Kraken.Net/Objects/Options/KrakenSocketOptions.cs index c644411..1c5d5c0 100644 --- a/Kraken.Net/Objects/Options/KrakenSocketOptions.cs +++ b/Kraken.Net/Objects/Options/KrakenSocketOptions.cs @@ -32,7 +32,10 @@ public KrakenSocketOptions() /// /// Options for the Spot API /// - public SocketApiOptions SpotOptions { get; private set; } = new SocketApiOptions(); + public SocketApiOptions SpotOptions { get; private set; } = new SocketApiOptions() + { + SocketNoDataTimeout = TimeSpan.FromSeconds(10) + }; /// /// Options for the Futures API