Skip to content

Commit

Permalink
Update CryptoExchange.Net version to 8.5.0, added SetOptions on clien…
Browse files Browse the repository at this point in the history
…ts, added setting of DefaultProxyCredentials to CredentialCache.DefaultCredentials on the DI http client, improved websocket disconnect detection, updated dotnet versions to 9.0
  • Loading branch information
JKorf committed Dec 23, 2024
1 parent 53c252f commit c50cf40
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Kraken.Net.UnitTests/Kraken.Net.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Kraken.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -122,5 +122,7 @@ public Task ReconnectAsync()
{
throw new NotImplementedException();
}

public void UpdateProxy(ApiProxy proxy) => throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal KrakenSocketClientFuturesApi(ILogger logger, KrakenSocketOptions option
{
RateLimiter = KrakenExchange.RateLimiter.FuturesSocket;

AddSystemSubscription(new KrakenFuturesInfoSubscription(_logger));
AddSystemSubscription(new KrakenFuturesInfoSubscription(_logger));
}
#endregion

Expand Down
8 changes: 8 additions & 0 deletions Kraken.Net/Clients/KrakenRestClient.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -50,6 +51,13 @@ public KrakenRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, I

#region methods

/// <inheritdoc />
public void SetOptions(UpdateOptions options)
{
SpotApi.SetOptions(options);
FuturesApi.SetOptions(options);
}

/// <summary>
/// Set the default options to be used when creating new clients
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions Kraken.Net/Clients/KrakenSocketClient.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -47,6 +48,13 @@ public KrakenSocketClient(IOptions<KrakenSocketOptions> options, ILoggerFactory?

#region methods

/// <inheritdoc />
public void SetOptions(UpdateOptions options)
{
SpotApi.SetOptions(options);
FuturesApi.SetOptions(options);
}

/// <summary>
/// Set the default options to be used when creating new clients
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Kraken.Net/ExtensionMethods/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private static IServiceCollection AddKrakenCore(
try
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
}
catch (PlatformNotSupportedException)
{ }
Expand Down
9 changes: 8 additions & 1 deletion Kraken.Net/Interfaces/Clients/IKrakenRestClient.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,6 +19,12 @@ public interface IKrakenRestClient : IRestClient
/// </summary>
IKrakenRestClientFuturesApi FuturesApi { get; }

/// <summary>
/// Update specific options
/// </summary>
/// <param name="options">Options to update. Only specific options are changable after the client has been created</param>
void SetOptions(UpdateOptions options);

/// <summary>
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion Kraken.Net/Interfaces/Clients/IKrakenSocketClient.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +18,12 @@ public interface IKrakenSocketClient : ISocketClient
/// </summary>
IKrakenSocketClientFuturesApi FuturesApi { get; }

/// <summary>
/// Update specific options
/// </summary>
/// <param name="options">Options to update. Only specific options are changable after the client has been created</param>
void SetOptions(UpdateOptions options);

/// <summary>
/// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Kraken.Net/Kraken.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="8.4.3" />
<PackageReference Include="CryptoExchange.Net" Version="8.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
18 changes: 18 additions & 0 deletions Kraken.Net/Kraken.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Kraken.Net/Objects/Internal/KrakenSocketRequestV2.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
namespace Kraken.Net.Objects.Internal
{
internal class KrakenSocketRequestV2<T>
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<T> : KrakenSocketRequestV2
{
[JsonPropertyName("params")]
public T Parameters { get; set; } = default!;
}
}
5 changes: 4 additions & 1 deletion Kraken.Net/Objects/Options/KrakenSocketOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public KrakenSocketOptions()
/// <summary>
/// Options for the Spot API
/// </summary>
public SocketApiOptions SpotOptions { get; private set; } = new SocketApiOptions();
public SocketApiOptions SpotOptions { get; private set; } = new SocketApiOptions()
{
SocketNoDataTimeout = TimeSpan.FromSeconds(10)
};

/// <summary>
/// Options for the Futures API
Expand Down

0 comments on commit c50cf40

Please sign in to comment.