Skip to content

Commit

Permalink
CryptoExchange.Net v8.0.0, shared interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf authored Sep 27, 2024
1 parent 74b341a commit 4d2985f
Show file tree
Hide file tree
Showing 33 changed files with 2,641 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ GET
true
{
"status": "ok",
"data": [
"data":
{
"margin_account": "USDT",
"position_mode": "single_side"
}
],
,
"ts": 1566899973811
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ GET
true
{
"status": "ok",
"data": [
"data":
{
"margin_account": "USDT",
"position_mode": "single_side"
}
],
,
"ts": 1566899973811
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ POST
true
{
"status": "ok",
"data": [
"data":
{
"margin_account": "USDT",
"position_mode": "single_side"
}
],
,
"ts": 1566899973811
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ POST
true
{
"status": "ok",
"data": [
"data":
{
"margin_account": "BTC-USDT",
"position_mode": "single_side"
}
],
,
"ts": 1566899973811
}
1 change: 1 addition & 0 deletions HTX.Net.UnitTests/TestImplementations/TestSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class TestSocket: IWebsocket
public event Func<Task> OnReconnected;
public event Func<Task> OnReconnecting;
public event Func<int, Task> OnRequestRateLimited;
public event Func<Task> OnConnectRateLimited;
#pragma warning restore 0067
public event Func<int, Task> OnRequestSent;
public event Func<WebSocketMessageType, ReadOnlyMemory<byte>, Task> OnStreamMessage;
Expand Down
10 changes: 8 additions & 2 deletions HTX.Net/Clients/SpotApi/HTXRestClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CryptoExchange.Net.CommonObjects;
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Interfaces.CommonClients;
using CryptoExchange.Net.SharedApis;
using HTX.Net.Enums;
using HTX.Net.Interfaces.Clients.SpotApi;
using HTX.Net.Objects.Internal;
Expand All @@ -10,7 +11,7 @@
namespace HTX.Net.Clients.SpotApi
{
/// <inheritdoc />
internal class HTXRestClientSpotApi : RestApiClient, IHTXRestClientSpotApi, ISpotClient
internal partial class HTXRestClientSpotApi : RestApiClient, IHTXRestClientSpotApi, ISpotClient
{
/// <inheritdoc />
public new HTXRestOptions ClientOptions => (HTXRestOptions)base.ClientOptions;
Expand Down Expand Up @@ -64,8 +65,12 @@ internal HTXRestClientSpotApi(ILogger logger, HttpClient? httpClient, HTXRestOpt

protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer();


/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}";
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null)
{
return $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}";
}

/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
Expand Down Expand Up @@ -529,5 +534,6 @@ protected override Task<WebCallResult<DateTime>> GetServerTimestampAsync()
/// <inheritdoc />
/// TODO make this take an accountId param so we don't need it in the interface?
public ISpotClient CommonSpotClient => this;
public IHTXRestClientSpotApiShared SharedClient => this;
}
}
2 changes: 1 addition & 1 deletion HTX.Net/Clients/SpotApi/HTXRestClientSpotApiAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public async Task<WebCallResult<long>> CancelWithdrawalAsync(long id, Cancellati
#region Get Withdraw Deposit History

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<HTXWithdrawDeposit>>> GetWithdrawDepositHistoryAsync(WithdrawDepositType type, string? asset = null, int? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default)
public async Task<WebCallResult<IEnumerable<HTXWithdrawDeposit>>> GetWithdrawDepositHistoryAsync(WithdrawDepositType type, string? asset = null, long? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default)
{
asset = asset?.ToLowerInvariant();

Expand Down
715 changes: 715 additions & 0 deletions HTX.Net/Clients/SpotApi/HTXRestClientSpotApiShared.cs

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions HTX.Net/Clients/SpotApi/HTXSocketClientSpotApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Objects.Sockets;
using CryptoExchange.Net.SharedApis;
using CryptoExchange.Net.Sockets;
using HTX.Net.Enums;
using HTX.Net.Interfaces.Clients.SpotApi;
Expand All @@ -17,7 +18,7 @@
namespace HTX.Net.Clients.SpotApi
{
/// <inheritdoc />
internal class HTXSocketClientSpotApi : SocketApiClient, IHTXSocketClientSpotApi
internal partial class HTXSocketClientSpotApi : SocketApiClient, IHTXSocketClientSpotApi
{
private static readonly MessagePath _idPath = MessagePath.Get().Property("id");
private static readonly MessagePath _actionPath = MessagePath.Get().Property("action");
Expand Down Expand Up @@ -45,8 +46,10 @@ internal HTXSocketClientSpotApi(ILogger logger, HTXSocketOptions options)

protected override IByteMessageAccessor CreateAccessor() => new SystemTextJsonByteMessageAccessor();

public IHTXSocketClientSpotApiShared SharedClient => this;

/// <inheritdoc />
public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}";
public override string FormatSymbol(string baseAsset, string quoteAsset, TradingMode tradingMode, DateTime? deliverTime = null) => $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}";

/// <inheritdoc />
public override string? GetListenerIdentifier(IMessageAccessor message)
Expand Down Expand Up @@ -79,6 +82,7 @@ public override ReadOnlyMemory<byte> PreprocessStreamMessage(SocketConnection co
return data.DecompressGzip();
}


/// <inheritdoc />
protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials)
=> new HTXAuthenticationProvider(credentials, false);
Expand Down
Loading

0 comments on commit 4d2985f

Please sign in to comment.