From 00ac1967ede1b1d4f3a038eeb20386f11372e6e4 Mon Sep 17 00:00:00 2001 From: JKorf Date: Thu, 24 Aug 2023 18:18:29 +0200 Subject: [PATCH 1/4] wip --- ByBit.Net/Bybit.Net.csproj | 4 +++- .../BybitSocketClientCopyTradingApi.cs | 4 ++-- .../BybitSocketClientDerivativesPublicApi.cs | 4 ++-- .../BybitSocketClientContractApi.cs | 4 ++-- .../BybitSocketClientUnifiedMarginApi.cs | 4 ++-- .../BybitSocketClientInversePerpetualApi.cs | 4 ++-- .../SpotApi/BybitSocketClientBaseSpotApi.cs | 4 ++-- .../BybitSocketClientUsdPerpetualApi.cs | 4 ++-- .../Clients/V5/BybitSocketClientBaseApi.cs | 8 ++++---- .../Clients/V5/BybitSocketClientLinearApi.cs | 10 +++++----- .../Clients/V5/BybitSocketClientOptionApi.cs | 10 +++++----- .../Clients/V5/BybitSocketClientPrivateApi.cs | 18 +++++++++--------- .../Clients/V5/BybitSocketClientSpotApi.cs | 16 ++++++++-------- 13 files changed, 48 insertions(+), 46 deletions(-) diff --git a/ByBit.Net/Bybit.Net.csproj b/ByBit.Net/Bybit.Net.csproj index 7d3a2762..e6f12b05 100644 --- a/ByBit.Net/Bybit.Net.csproj +++ b/ByBit.Net/Bybit.Net.csproj @@ -42,7 +42,6 @@ - all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -52,4 +51,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file diff --git a/ByBit.Net/Clients/CopyTradingApi/BybitSocketClientCopyTradingApi.cs b/ByBit.Net/Clients/CopyTradingApi/BybitSocketClientCopyTradingApi.cs index 2c29c0d3..07ed3fca 100644 --- a/ByBit.Net/Clients/CopyTradingApi/BybitSocketClientCopyTradingApi.cs +++ b/ByBit.Net/Clients/CopyTradingApi/BybitSocketClientCopyTradingApi.cs @@ -155,7 +155,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -275,7 +275,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/DerivativesApi/BybitSocketClientDerivativesPublicApi.cs b/ByBit.Net/Clients/DerivativesApi/BybitSocketClientDerivativesPublicApi.cs index fb39d823..5d081232 100644 --- a/ByBit.Net/Clients/DerivativesApi/BybitSocketClientDerivativesPublicApi.cs +++ b/ByBit.Net/Clients/DerivativesApi/BybitSocketClientDerivativesPublicApi.cs @@ -208,7 +208,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -315,7 +315,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/DerivativesApi/ContractApi/BybitSocketClientContractApi.cs b/ByBit.Net/Clients/DerivativesApi/ContractApi/BybitSocketClientContractApi.cs index 7238673c..6b157fda 100644 --- a/ByBit.Net/Clients/DerivativesApi/ContractApi/BybitSocketClientContractApi.cs +++ b/ByBit.Net/Clients/DerivativesApi/ContractApi/BybitSocketClientContractApi.cs @@ -155,7 +155,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -273,7 +273,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/DerivativesApi/UnifiedMarginApi/BybitSocketClientUnifiedMarginApi.cs b/ByBit.Net/Clients/DerivativesApi/UnifiedMarginApi/BybitSocketClientUnifiedMarginApi.cs index 6ec97343..804b77a3 100644 --- a/ByBit.Net/Clients/DerivativesApi/UnifiedMarginApi/BybitSocketClientUnifiedMarginApi.cs +++ b/ByBit.Net/Clients/DerivativesApi/UnifiedMarginApi/BybitSocketClientUnifiedMarginApi.cs @@ -190,7 +190,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -308,7 +308,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/InversePerpetualApi/BybitSocketClientInversePerpetualApi.cs b/ByBit.Net/Clients/InversePerpetualApi/BybitSocketClientInversePerpetualApi.cs index c73846f7..841132a1 100644 --- a/ByBit.Net/Clients/InversePerpetualApi/BybitSocketClientInversePerpetualApi.cs +++ b/ByBit.Net/Clients/InversePerpetualApi/BybitSocketClientInversePerpetualApi.cs @@ -404,7 +404,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -524,7 +524,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/SpotApi/BybitSocketClientBaseSpotApi.cs b/ByBit.Net/Clients/SpotApi/BybitSocketClientBaseSpotApi.cs index 2f991e6a..1e113918 100644 --- a/ByBit.Net/Clients/SpotApi/BybitSocketClientBaseSpotApi.cs +++ b/ByBit.Net/Clients/SpotApi/BybitSocketClientBaseSpotApi.cs @@ -72,7 +72,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -192,7 +192,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection } var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (!isCheckable) { diff --git a/ByBit.Net/Clients/UsdPerpetualApi/BybitSocketClientUsdPerpetualApi.cs b/ByBit.Net/Clients/UsdPerpetualApi/BybitSocketClientUsdPerpetualApi.cs index 33357b02..038256f8 100644 --- a/ByBit.Net/Clients/UsdPerpetualApi/BybitSocketClientUsdPerpetualApi.cs +++ b/ByBit.Net/Clients/UsdPerpetualApi/BybitSocketClientUsdPerpetualApi.cs @@ -354,7 +354,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -473,7 +473,7 @@ protected override async Task UnsubscribeAsync(SocketConnection connection var message = new BybitRequestMessage { Operation = "unsubscribe", Parameters = requestParams }; var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/V5/BybitSocketClientBaseApi.cs b/ByBit.Net/Clients/V5/BybitSocketClientBaseApi.cs index 9dc685c1..94ca0b3e 100644 --- a/ByBit.Net/Clients/V5/BybitSocketClientBaseApi.cs +++ b/ByBit.Net/Clients/V5/BybitSocketClientBaseApi.cs @@ -64,7 +64,7 @@ public async Task> SubscribeToTradeUpdatesAsync(I return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => "publicTrade." + s).ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => "publicTrade." + s).ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -96,7 +96,7 @@ public async Task> SubscribeToOrderbookUpdatesAsy return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"orderbook.{depth}.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"orderbook.{depth}.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -126,7 +126,7 @@ public async Task> SubscribeToKlineUpdatesAsync(I return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"kline.{EnumConverter.GetString(interval)}.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"kline.{EnumConverter.GetString(interval)}.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -155,7 +155,7 @@ public async Task> SubscribeToLiquidationUpdatesA return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"liquidation.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"liquidation.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } } diff --git a/ByBit.Net/Clients/V5/BybitSocketClientLinearApi.cs b/ByBit.Net/Clients/V5/BybitSocketClientLinearApi.cs index d57caf74..63ae5d30 100644 --- a/ByBit.Net/Clients/V5/BybitSocketClientLinearApi.cs +++ b/ByBit.Net/Clients/V5/BybitSocketClientLinearApi.cs @@ -28,7 +28,7 @@ internal BybitSocketClientLinearApi(ILogger log, BybitSocketOptions options) { SendPeriodic("Ping", options.V5Options.PingInterval, (connection) => { - return new BybitV5RequestMessage("ping", Array.Empty(), NextId().ToString()); + return new BybitV5RequestMessage("ping", Array.Empty(), ExchangeHelpers.NextId().ToString()); }); AddGenericHandler("Heartbeat", (evnt) => { }); } @@ -59,7 +59,7 @@ public async Task> SubscribeToTickerUpdatesAsync( return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -86,7 +86,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -196,10 +196,10 @@ protected override bool MessageMatchesHandler(SocketConnection socketConnection, protected override async Task UnsubscribeAsync(SocketConnection connection, SocketSubscription subscriptionToUnsub) { var requestParams = ((BybitV5RequestMessage)subscriptionToUnsub.Request!).Parameters; - var message = new BybitV5RequestMessage("unsubscribe", requestParams, NextId().ToString()); + var message = new BybitV5RequestMessage("unsubscribe", requestParams, ExchangeHelpers.NextId().ToString()); var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/V5/BybitSocketClientOptionApi.cs b/ByBit.Net/Clients/V5/BybitSocketClientOptionApi.cs index 1b547985..f3c87252 100644 --- a/ByBit.Net/Clients/V5/BybitSocketClientOptionApi.cs +++ b/ByBit.Net/Clients/V5/BybitSocketClientOptionApi.cs @@ -25,7 +25,7 @@ internal BybitSocketClientOptionApi(ILogger log, BybitSocketOptions options) { SendPeriodic("Ping", options.V5Options.PingInterval, (connection) => { - return new BybitV5RequestMessage("ping", Array.Empty(), NextId().ToString()); + return new BybitV5RequestMessage("ping", Array.Empty(), ExchangeHelpers.NextId().ToString()); }); AddGenericHandler("Heartbeat", (evnt) => { }); } @@ -55,7 +55,7 @@ public async Task> SubscribeToTickerUpdatesAsync( return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -82,7 +82,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -201,10 +201,10 @@ protected override bool MessageMatchesHandler(SocketConnection socketConnection, protected override async Task UnsubscribeAsync(SocketConnection connection, SocketSubscription subscriptionToUnsub) { var requestParams = ((BybitV5RequestMessage)subscriptionToUnsub.Request!).Parameters; - var message = new BybitV5RequestMessage("unsubscribe", requestParams, NextId().ToString()); + var message = new BybitV5RequestMessage("unsubscribe", requestParams, ExchangeHelpers.NextId().ToString()); var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/V5/BybitSocketClientPrivateApi.cs b/ByBit.Net/Clients/V5/BybitSocketClientPrivateApi.cs index f358a6c6..3ce0a4d1 100644 --- a/ByBit.Net/Clients/V5/BybitSocketClientPrivateApi.cs +++ b/ByBit.Net/Clients/V5/BybitSocketClientPrivateApi.cs @@ -30,7 +30,7 @@ internal BybitSocketClientPrivateApi(ILogger logger, BybitSocketOptions options) SendPeriodic("Ping", options.V5Options.PingInterval, (connection) => { - return new BybitV5RequestMessage("ping", Array.Empty(), NextId().ToString()); + return new BybitV5RequestMessage("ping", Array.Empty(), ExchangeHelpers.NextId().ToString()); }); AddGenericHandler("Heartbeat", (evnt) => { }); } @@ -56,7 +56,7 @@ public async Task> SubscribeToPositionUpdatesAsyn return await SubscribeAsync( BaseAddress.AppendPath("/v5/private"), - new BybitV5RequestMessage("subscribe", new[] { "position" }, NextId().ToString()), + new BybitV5RequestMessage("subscribe", new[] { "position" }, ExchangeHelpers.NextId().ToString()), null, true, internalHandler, ct).ConfigureAwait(false); } @@ -81,7 +81,7 @@ public async Task> SubscribeToUserTradeUpdatesAsy return await SubscribeAsync( BaseAddress.AppendPath("/v5/private"), - new BybitV5RequestMessage("subscribe", new[] { "execution" }, NextId().ToString()), + new BybitV5RequestMessage("subscribe", new[] { "execution" }, ExchangeHelpers.NextId().ToString()), null, true, internalHandler, ct).ConfigureAwait(false); } @@ -106,7 +106,7 @@ public async Task> SubscribeToOrderUpdatesAsync(A return await SubscribeAsync( BaseAddress.AppendPath("/v5/private"), - new BybitV5RequestMessage("subscribe", new[] { "order" }, NextId().ToString()), + new BybitV5RequestMessage("subscribe", new[] { "order" }, ExchangeHelpers.NextId().ToString()), null, true, internalHandler, ct).ConfigureAwait(false); } @@ -131,7 +131,7 @@ public async Task> SubscribeToWalletUpdatesAsync( return await SubscribeAsync( BaseAddress.AppendPath("/v5/private"), - new BybitV5RequestMessage("subscribe", new[] { "wallet" }, NextId().ToString()), + new BybitV5RequestMessage("subscribe", new[] { "wallet" }, ExchangeHelpers.NextId().ToString()), null, true, internalHandler, ct).ConfigureAwait(false); } @@ -156,7 +156,7 @@ public async Task> SubscribeToGreekUpdatesAsync(A return await SubscribeAsync( BaseAddress.AppendPath("/v5/private"), - new BybitV5RequestMessage("subscribe", new[] { "greeks" }, NextId().ToString()), + new BybitV5RequestMessage("subscribe", new[] { "greeks" }, ExchangeHelpers.NextId().ToString()), null, true, internalHandler, ct).ConfigureAwait(false); } @@ -183,7 +183,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -302,10 +302,10 @@ protected override bool MessageMatchesHandler(SocketConnection socketConnection, protected override async Task UnsubscribeAsync(SocketConnection connection, SocketSubscription subscriptionToUnsub) { var requestParams = ((BybitV5RequestMessage)subscriptionToUnsub.Request!).Parameters; - var message = new BybitV5RequestMessage("unsubscribe", requestParams, NextId().ToString()); + var message = new BybitV5RequestMessage("unsubscribe", requestParams, ExchangeHelpers.NextId().ToString()); var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; diff --git a/ByBit.Net/Clients/V5/BybitSocketClientSpotApi.cs b/ByBit.Net/Clients/V5/BybitSocketClientSpotApi.cs index a9869bdb..23ecc475 100644 --- a/ByBit.Net/Clients/V5/BybitSocketClientSpotApi.cs +++ b/ByBit.Net/Clients/V5/BybitSocketClientSpotApi.cs @@ -27,7 +27,7 @@ internal BybitSocketClientSpotApi(ILogger logger, BybitSocketOptions options) { SendPeriodic("Ping", options.V5Options.PingInterval, (connection) => { - return new BybitV5RequestMessage("ping", Array.Empty(), NextId().ToString()); + return new BybitV5RequestMessage("ping", Array.Empty(), ExchangeHelpers.NextId().ToString()); }); AddGenericHandler("Heartbeat", (evnt) => { }); } @@ -57,7 +57,7 @@ public async Task> SubscribeToTickerUpdatesAsync( return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -86,7 +86,7 @@ public async Task> SubscribeToLeveragedTokenKline return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"kline_lt.{EnumConverter.GetString(interval)}.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"kline_lt.{EnumConverter.GetString(interval)}.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -115,7 +115,7 @@ public async Task> SubscribeToLeveragedTokenTicke return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers_lt.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"tickers_lt.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -144,7 +144,7 @@ public async Task> SubscribeToLeveragedTokenNavUp return await SubscribeAsync( BaseAddress + _baseEndpoint, - new BybitV5RequestMessage("subscribe", symbols.Select(s => $"lt.{s}").ToArray(), NextId().ToString()), + new BybitV5RequestMessage("subscribe", symbols.Select(s => $"lt.{s}").ToArray(), ExchangeHelpers.NextId().ToString()), null, false, internalHandler, ct).ConfigureAwait(false); } @@ -171,7 +171,7 @@ protected override async Task> AuthenticateSocketAsync(SocketCo var result = false; var error = "unspecified error"; - await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, data => + await socketConnection.SendAndWaitAsync(authRequest, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; @@ -281,10 +281,10 @@ protected override bool MessageMatchesHandler(SocketConnection socketConnection, protected override async Task UnsubscribeAsync(SocketConnection connection, SocketSubscription subscriptionToUnsub) { var requestParams = ((BybitV5RequestMessage)subscriptionToUnsub.Request!).Parameters; - var message = new BybitV5RequestMessage("unsubscribe", requestParams, NextId().ToString()); + var message = new BybitV5RequestMessage("unsubscribe", requestParams, ExchangeHelpers.NextId().ToString()); var result = false; - await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, data => + await connection.SendAndWaitAsync(message, ClientOptions.RequestTimeout, null, 1, data => { if (data.Type != JTokenType.Object) return false; From 4ccae3a8ba9a2c1df58fcad95965626041052ca2 Mon Sep 17 00:00:00 2001 From: JKorf Date: Fri, 25 Aug 2023 18:54:12 +0200 Subject: [PATCH 2/4] Updated CryptoExchange.Net --- ByBit.Net/Bybit.Net.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ByBit.Net/Bybit.Net.csproj b/ByBit.Net/Bybit.Net.csproj index e6f12b05..7f0a0b34 100644 --- a/ByBit.Net/Bybit.Net.csproj +++ b/ByBit.Net/Bybit.Net.csproj @@ -52,6 +52,6 @@ - + \ No newline at end of file From b40923cbe80affb0ce38acddca5963dd7ffa9843 Mon Sep 17 00:00:00 2001 From: JKorf Date: Fri, 25 Aug 2023 19:02:24 +0200 Subject: [PATCH 3/4] Updated version --- ByBit.Net/Bybit.Net.csproj | 8 ++++---- README.md | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ByBit.Net/Bybit.Net.csproj b/ByBit.Net/Bybit.Net.csproj index 7f0a0b34..795606af 100644 --- a/ByBit.Net/Bybit.Net.csproj +++ b/ByBit.Net/Bybit.Net.csproj @@ -7,9 +7,9 @@ Bybit.Net JKorf - 3.0.5 - 3.0.5 - 3.0.5 + 3.0.6 + 3.0.6 + 3.0.6 Bybit.Net is a .Net wrapper for the Bybit API. It includes all features the API provides, REST API and Websocket, using clear and readable objects including but not limited to Reading market info, Placing and managing orders and Reading balances and funds false Bybit Bybit.Net C# .Net CryptoCurrency Exchange API wrapper @@ -20,7 +20,7 @@ icon.png en true - 3.0.5 - Fixed default values V5 PlaceOrder parameters + 3.0.6 - Updated CryptoExchange.Net Bybit.Net.xml diff --git a/README.md b/README.md index aa2f0c7c..bffb998b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/s A Discord server is available [here](https://discord.gg/MSpeEtSY8t). Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries. ## Release notes +* Version 3.0.6 - 25 Aug 2023 + * Updated CryptoExchange.Net + * Version 3.0.5 - 05 Aug 2023 * Fixed default values V5 PlaceOrder parameters From 5dc67efc0c48e0d388a80f0caefe664dcba17a60 Mon Sep 17 00:00:00 2001 From: JKorf Date: Fri, 25 Aug 2023 19:27:39 +0200 Subject: [PATCH 4/4] Docs --- .../ContractApi/IBybitRestClientContractApiTrading.md | 6 ++++-- docs/ClientInfo/V5/IBybitRestClientApiTrading.md | 11 +++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/ClientInfo/DerivativesApi/ContractApi/IBybitRestClientContractApiTrading.md b/docs/ClientInfo/DerivativesApi/ContractApi/IBybitRestClientContractApiTrading.md index 57547aa8..948d7b39 100644 --- a/docs/ClientInfo/DerivativesApi/ContractApi/IBybitRestClientContractApiTrading.md +++ b/docs/ClientInfo/DerivativesApi/ContractApi/IBybitRestClientContractApiTrading.md @@ -143,7 +143,7 @@ var result = await client.DerivativesApi\ContractApi.ContractApiTrading.PlaceOrd ``` ```csharp -Task> PlaceOrderAsync(string symbol, OrderSide side, OrderType type, decimal quantity, TimeInForce timeInForce, bool? reduceOnly = default, bool? closeOnTrigger = default, decimal? price = default, string? clientOrderId = default, decimal? takeProfitPrice = default, decimal? stopLossPrice = default, TriggerType? takeProfitTriggerType = default, TriggerType? stopLossTriggerType = default, PositionMode? positionMode = default, long? receiveWindow = default, CancellationToken ct = default); +Task> PlaceOrderAsync(string symbol, OrderSide side, OrderType type, decimal quantity, TimeInForce timeInForce, bool? reduceOnly = default, bool? closeOnTrigger = default, decimal? price = default, string? clientOrderId = default, decimal? takeProfitPrice = default, decimal? stopLossPrice = default, TriggerType? takeProfitTriggerType = default, TriggerType? stopLossTriggerType = default, PositionMode? positionMode = default, StopLossTakeProfitMode? stopLossTakeProfitMode = default, long? receiveWindow = default, CancellationToken ct = default); ``` |Parameter|Description| @@ -162,6 +162,7 @@ Task> PlaceOrderAsync(string symbol, Orde |_[Optional]_ takeProfitTriggerType|Take profit trigger price type, default: LastPrice| |_[Optional]_ stopLossTriggerType|Stop loss trigger price type, default: LastPrice| |_[Optional]_ positionMode|Position mode| +|_[Optional]_ stopLossTakeProfitMode|StopLoss / TakeProfit mode| |_[Optional]_ receiveWindow|The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request| |_[Optional]_ ct|Cancellation token| @@ -217,7 +218,7 @@ var result = await client.DerivativesApi\ContractApi.ContractApiTrading.SetTradi ``` ```csharp -Task SetTradingStop(string symbol, decimal? takeProfitPrice = default, decimal? stopLossPrice = default, decimal? activePrice = default, decimal? trailingStop = default, TriggerType? takeProfitTriggerType = default, TriggerType? stopLossTriggerType = default, decimal? stopLossSize = default, decimal? takeProfitSize = default, PositionMode? positionMode = default, long? receiveWindow = default, CancellationToken ct = default); +Task SetTradingStop(string symbol, decimal? takeProfitPrice = default, decimal? stopLossPrice = default, decimal? activePrice = default, decimal? trailingStop = default, TriggerType? takeProfitTriggerType = default, TriggerType? stopLossTriggerType = default, decimal? stopLossSize = default, decimal? takeProfitSize = default, PositionMode? positionMode = default, StopLossTakeProfitMode? stopLossTakeProfitMode = default, long? receiveWindow = default, CancellationToken ct = default); ``` |Parameter|Description| @@ -232,6 +233,7 @@ Task SetTradingStop(string symbol, decimal? takeProfitPrice = def |_[Optional]_ stopLossSize|Stop loss quantity| |_[Optional]_ takeProfitSize|Take profit quantity| |_[Optional]_ positionMode|Position mode| +|_[Optional]_ stopLossTakeProfitMode|StopLoss / TakeProfit mode| |_[Optional]_ receiveWindow|The receive window for which this request is active. When the request takes longer than this to complete the server will reject the request| |_[Optional]_ ct|Cancellation token| diff --git a/docs/ClientInfo/V5/IBybitRestClientApiTrading.md b/docs/ClientInfo/V5/IBybitRestClientApiTrading.md index 280428a3..362a86e1 100644 --- a/docs/ClientInfo/V5/IBybitRestClientApiTrading.md +++ b/docs/ClientInfo/V5/IBybitRestClientApiTrading.md @@ -233,7 +233,7 @@ var result = await client.V5.ApiTrading.GetOrderHistoryAsync(/* parameters */); ``` ```csharp -Task>> GetOrderHistoryAsync(Category category, string? symbol = default, string? baseAsset = default, string? orderId = default, string? clientOrderId = default, Enums.V5.OrderStatus? status = default, OrderFilter? orderFilter = default, int? limit = default, string? cursor = default, CancellationToken ct = default); +Task>> GetOrderHistoryAsync(Category category, string? symbol = default, string? baseAsset = default, string? orderId = default, string? clientOrderId = default, Enums.V5.OrderStatus? status = default, OrderFilter? orderFilter = default, DateTime? startTime = default, DateTime? endTime = default, int? limit = default, string? cursor = default, CancellationToken ct = default); ``` |Parameter|Description| @@ -245,6 +245,8 @@ Task>> GetOrderHistoryAsync(Category cat |_[Optional]_ clientOrderId|Filter by client order id| |_[Optional]_ status|Filter by status| |_[Optional]_ orderFilter|Order filter| +|_[Optional]_ startTime|Filter by start time| +|_[Optional]_ endTime|Filter by end time| |_[Optional]_ limit|Number of results per page| |_[Optional]_ cursor|Pagination cursor| |_[Optional]_ ct|Cancellation token| @@ -392,7 +394,7 @@ var result = await client.V5.ApiTrading.PlaceOrderAsync(/* parameters */); ``` ```csharp -Task> PlaceOrderAsync(Category category, string symbol, OrderSide side, NewOrderType type, decimal quantity, decimal? price = default, bool? isLeverage = default, TriggerDirection? triggerDirection = default, OrderFilter? orderFilter = default, decimal? triggerPrice = default, TriggerType? triggerBy = default, decimal? orderIv = default, TimeInForce? timeInForce = default, Enums.V5.PositionIdx? positionIdx = default, string? clientOrderId = default, decimal? takeProfit = default, decimal? stopLoss = default, TriggerType? takeProfitTriggerBy = default, TriggerType? stopLossTriggerBy = default, bool? reduceOnly = default, bool? closeOnTrigger = default, bool? marketMakerProtection = default, CancellationToken ct = default); +Task> PlaceOrderAsync(Category category, string symbol, OrderSide side, NewOrderType type, decimal quantity, decimal? price = default, bool? isLeverage = default, TriggerDirection? triggerDirection = default, OrderFilter? orderFilter = default, decimal? triggerPrice = default, TriggerType? triggerBy = default, decimal? orderIv = default, TimeInForce? timeInForce = default, PositionIdx? positionIdx = default, string? clientOrderId = default, OrderType? takeProfitOrderType = default, decimal? takeProfit = default, decimal? takeProfitLimitPrice = default, OrderType? stopLossOrderType = default, decimal? stopLoss = default, decimal? stopLossLimitPrice = default, TriggerType? takeProfitTriggerBy = default, TriggerType? stopLossTriggerBy = default, bool? reduceOnly = default, bool? closeOnTrigger = default, bool? marketMakerProtection = default, StopLossTakeProfitMode? stopLossTakeProfitMode = default, CancellationToken ct = default); ``` |Parameter|Description| @@ -412,13 +414,18 @@ Task> PlaceOrderAsync(Category category, string symb |_[Optional]_ timeInForce|Time in force| |_[Optional]_ positionIdx|Position idx| |_[Optional]_ clientOrderId|Client order id| +|_[Optional]_ takeProfitOrderType|| |_[Optional]_ takeProfit|Take profit price| +|_[Optional]_ takeProfitLimitPrice|| +|_[Optional]_ stopLossOrderType|| |_[Optional]_ stopLoss|Stop loss price| +|_[Optional]_ stopLossLimitPrice|| |_[Optional]_ takeProfitTriggerBy|Take profit trigger| |_[Optional]_ stopLossTriggerBy|Stop loss trigger| |_[Optional]_ reduceOnly|Is reduce only| |_[Optional]_ closeOnTrigger|Close on trigger| |_[Optional]_ marketMakerProtection|Market maker protection| +|_[Optional]_ stopLossTakeProfitMode|StopLoss / TakeProfit mode| |_[Optional]_ ct|Cancellation token|