diff --git a/Huobi.Net.UnitTests/HuobiClientTests.cs b/Huobi.Net.UnitTests/HuobiClientTests.cs index 28237fa1..ab59619a 100644 --- a/Huobi.Net.UnitTests/HuobiClientTests.cs +++ b/Huobi.Net.UnitTests/HuobiClientTests.cs @@ -12,6 +12,11 @@ using Huobi.Net.ExtensionMethods; using CryptoExchange.Net.Objects.Sockets; using NUnit.Framework.Legacy; +using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Clients; +using System.Net.Http; +using System.Collections.Generic; +using CryptoExchange.Net.Converters.JsonNet; namespace Huobi.Net.UnitTests { @@ -54,44 +59,37 @@ public string SerializeExpected(T data, bool tick) } [Test] - public void CheckRestInterfaces() + public void CheckSignatureExample() { - var assembly = Assembly.GetAssembly(typeof(HuobiRestClientSpotApi)); - var ignore = new string[] { "IHuobiClientSpot" }; - var clientInterfaces = assembly.GetTypes().Where(t => t.Name.StartsWith("IHuobiClientSpot") && !ignore.Contains(t.Name)); + var authProvider = new HuobiAuthenticationProvider( + new ApiCredentials("e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx", "XXXXXXXXXX"), + false + ); + var client = (RestApiClient)new HuobiRestClient().SpotApi; - foreach (var clientInterface in clientInterfaces) - { - var implementation = assembly.GetTypes().Single(t => t.IsAssignableTo(clientInterface) && t != clientInterface); - int methods = 0; - foreach (var method in implementation.GetMethods().Where(m => m.ReturnType.IsAssignableTo(typeof(Task)))) + CryptoExchange.Net.Testing.TestHelpers.CheckSignature( + client, + authProvider, + HttpMethod.Get, + "/v1/order/orders", + (uriParams, bodyParams, headers) => { - var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); - ClassicAssert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); - methods++; - } - Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); - } + return uriParams["Signature"].ToString(); + }, + "2ZQ7/roKBjdnAv8z5DymwzgSaOPyPgJl0BIlq9fa94w=", + new Dictionary + { + { "order-id", "1234567890" } + }, + time: new DateTime(2017, 5, 11, 15, 19, 30, DateTimeKind.Utc), + host: "https://api.huobi.pro"); } [Test] - public void CheckSocketInterfaces() + public void CheckInterfaces() { - var assembly = Assembly.GetAssembly(typeof(HuobiSocketClient)); - var clientInterfaces = assembly.GetTypes().Where(t => t.Name.StartsWith("IHuobiSocketClientSpot")); - - foreach (var clientInterface in clientInterfaces) - { - var implementation = assembly.GetTypes().Single(t => t.IsAssignableTo(clientInterface) && t != clientInterface); - int methods = 0; - foreach (var method in implementation.GetMethods().Where(m => m.ReturnType.IsAssignableTo(typeof(Task>)))) - { - var interfaceMethod = clientInterface.GetMethod(method.Name, method.GetParameters().Select(p => p.ParameterType).ToArray()); - ClassicAssert.NotNull(interfaceMethod, $"Missing interface for method {method.Name} in {implementation.Name} implementing interface {clientInterface.Name}"); - methods++; - } - Debug.WriteLine($"{clientInterface.Name} {methods} methods validated"); - } + CryptoExchange.Net.Testing.TestHelpers.CheckForMissingRestInterfaces(); + CryptoExchange.Net.Testing.TestHelpers.CheckForMissingSocketInterfaces(); } } } diff --git a/Huobi.Net/Clients/HuobiRestClient.cs b/Huobi.Net/Clients/HuobiRestClient.cs index 3e7c6c6b..90824cd1 100644 --- a/Huobi.Net/Clients/HuobiRestClient.cs +++ b/Huobi.Net/Clients/HuobiRestClient.cs @@ -18,10 +18,10 @@ public class HuobiRestClient : BaseRestClient, IHuobiRestClient #region Api clients /// - public IHuobiClientSpotApi SpotApi { get; } + public IHuobiRestClientSpotApi SpotApi { get; } /// - public IHuobiClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } + public IHuobiRestClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } #endregion @@ -49,7 +49,7 @@ public HuobiRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, Ac Initialize(options); SpotApi = AddApiClient(new HuobiRestClientSpotApi(_logger, httpClient, options)); - UsdtMarginSwapApi = AddApiClient(new HuobiClientUsdtMarginSwapApi(_logger, httpClient, options)); + UsdtMarginSwapApi = AddApiClient(new HuobiRestClientUsdtMarginSwapApi(_logger, httpClient, options)); } #endregion diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs index 02650c03..b1c595cc 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs +++ b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs @@ -21,7 +21,7 @@ namespace Huobi.Net.Clients.SpotApi { /// - public class HuobiRestClientSpotApi : RestApiClient, IHuobiClientSpotApi, ISpotClient + public class HuobiRestClientSpotApi : RestApiClient, IHuobiRestClientSpotApi, ISpotClient { /// public new HuobiRestOptions ClientOptions => (HuobiRestOptions)base.ClientOptions; @@ -45,11 +45,11 @@ public class HuobiRestClientSpotApi : RestApiClient, IHuobiClientSpotApi, ISpotC #region Api clients /// - public IHuobiClientSpotApiAccount Account { get; } + public IHuobiRestClientSpotApiAccount Account { get; } /// - public IHuobiClientSpotApiExchangeData ExchangeData { get; } + public IHuobiRestClientSpotApiExchangeData ExchangeData { get; } /// - public IHuobiClientSpotApiTrading Trading { get; } + public IHuobiRestClientSpotApiTrading Trading { get; } #endregion diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs index 10aa299c..4e3580ae 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs +++ b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs @@ -17,7 +17,7 @@ namespace Huobi.Net.Clients.SpotApi { /// - public class HuobiRestClientSpotApiAccount : IHuobiClientSpotApiAccount + public class HuobiRestClientSpotApiAccount : IHuobiRestClientSpotApiAccount { private const string GetUserId = "user/uid"; private const string GetSubAccountUsers = "sub-user/user-list"; diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs index f24570af..a2163c7f 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs +++ b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs @@ -16,7 +16,7 @@ namespace Huobi.Net.Clients.SpotApi { /// - public class HuobiRestClientSpotApiExchangeData : IHuobiClientSpotApiExchangeData + public class HuobiRestClientSpotApiExchangeData : IHuobiRestClientSpotApiExchangeData { private const string MarketTickerEndpoint = "market/tickers"; private const string MarketTickerMergedEndpoint = "market/detail/merged"; diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs index ce4943ee..c9344a5b 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs +++ b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs @@ -19,7 +19,7 @@ namespace Huobi.Net.Clients.SpotApi { /// - public class HuobiRestClientSpotApiTrading : IHuobiClientSpotApiTrading + public class HuobiRestClientSpotApiTrading : IHuobiRestClientSpotApiTrading { private const string PlaceOrderEndpoint = "order/orders/place"; private const string OpenOrdersEndpoint = "order/openOrders"; diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApi.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs similarity index 88% rename from Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApi.cs rename to Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs index 6fe1d892..81f797a5 100644 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApi.cs +++ b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs @@ -18,7 +18,7 @@ namespace Huobi.Net.Clients.FuturesApi { /// - public class HuobiClientUsdtMarginSwapApi : RestApiClient, IHuobiClientUsdtMarginSwapApi + public class HuobiRestClientUsdtMarginSwapApi : RestApiClient, IHuobiRestClientUsdtMarginSwapApi { /// public new HuobiRestOptions ClientOptions => (HuobiRestOptions)base.ClientOptions; @@ -42,21 +42,21 @@ public class HuobiClientUsdtMarginSwapApi : RestApiClient, IHuobiClientUsdtMargi #region Api clients /// - public IHuobiClientUsdtMarginSwapApiAccount Account { get; } + public IHuobiRestClientUsdtMarginSwapApiAccount Account { get; } /// - public HuobiClientUsdtMarginSwapApiExchangeData ExchangeData { get; } + public HuobiRestClientUsdtMarginSwapApiExchangeData ExchangeData { get; } /// - public HuobiClientUsdtMarginSwapApiTrading Trading { get; } + public HuobiRestClientUsdtMarginSwapApiTrading Trading { get; } #endregion #region constructor/destructor - internal HuobiClientUsdtMarginSwapApi(ILogger log, HttpClient? httpClient, HuobiRestOptions options) + internal HuobiRestClientUsdtMarginSwapApi(ILogger log, HttpClient? httpClient, HuobiRestOptions options) : base(log, httpClient, options.Environment.UsdtMarginSwapRestBaseAddress, options, options.UsdtMarginSwapOptions) { - Account = new HuobiClientUsdtMarginSwapApiAccount(this); - ExchangeData = new HuobiClientUsdtMarginSwapApiExchangeData(this); - Trading = new HuobiClientUsdtMarginSwapApiTrading(this); + Account = new HuobiRestClientUsdtMarginSwapApiAccount(this); + ExchangeData = new HuobiRestClientUsdtMarginSwapApiExchangeData(this); + Trading = new HuobiRestClientUsdtMarginSwapApiTrading(this); _brokerId = !string.IsNullOrEmpty(options.BrokerId) ? options.BrokerId! : "AA1ef14811"; } diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiAccount.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs similarity index 98% rename from Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiAccount.cs rename to Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs index 0c71b97d..0d41aaaf 100644 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiAccount.cs +++ b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs @@ -16,11 +16,11 @@ namespace Huobi.Net.Clients.UsdtMarginSwapApi { /// - public class HuobiClientUsdtMarginSwapApiAccount : IHuobiClientUsdtMarginSwapApiAccount + public class HuobiRestClientUsdtMarginSwapApiAccount : IHuobiRestClientUsdtMarginSwapApiAccount { - private readonly HuobiClientUsdtMarginSwapApi _baseClient; + private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - internal HuobiClientUsdtMarginSwapApiAccount(HuobiClientUsdtMarginSwapApi baseClient) + internal HuobiRestClientUsdtMarginSwapApiAccount(HuobiRestClientUsdtMarginSwapApi baseClient) { _baseClient = baseClient; } diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiExchangeData.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs similarity index 98% rename from Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiExchangeData.cs rename to Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs index acb2f03d..4a27713e 100644 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiExchangeData.cs +++ b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs @@ -16,11 +16,11 @@ namespace Huobi.Net.Clients.UsdtMarginSwapApi { /// - public class HuobiClientUsdtMarginSwapApiExchangeData : IHuobiClientUsdtMarginSwapApiExchangeData + public class HuobiRestClientUsdtMarginSwapApiExchangeData : IHuobiRestClientUsdtMarginSwapApiExchangeData { - private readonly HuobiClientUsdtMarginSwapApi _baseClient; + private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - internal HuobiClientUsdtMarginSwapApiExchangeData(HuobiClientUsdtMarginSwapApi baseClient) + internal HuobiRestClientUsdtMarginSwapApiExchangeData(HuobiRestClientUsdtMarginSwapApi baseClient) { _baseClient = baseClient; } diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiTrading.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs similarity index 98% rename from Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiTrading.cs rename to Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs index e5bf5fb4..2c987535 100644 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiClientUsdtMarginSwapApiTrading.cs +++ b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs @@ -14,11 +14,11 @@ namespace Huobi.Net.Clients.UsdtMarginSwapApi { /// - public class HuobiClientUsdtMarginSwapApiTrading : IHuobiClientUsdtMarginSwapApiTrading + public class HuobiRestClientUsdtMarginSwapApiTrading : IHuobiRestClientUsdtMarginSwapApiTrading { - private readonly HuobiClientUsdtMarginSwapApi _baseClient; + private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - internal HuobiClientUsdtMarginSwapApiTrading(HuobiClientUsdtMarginSwapApi baseClient) + internal HuobiRestClientUsdtMarginSwapApiTrading(HuobiRestClientUsdtMarginSwapApi baseClient) { _baseClient = baseClient; } diff --git a/Huobi.Net/Huobi.Net.csproj b/Huobi.Net/Huobi.Net.csproj index 3d72f4ae..8a8a3f49 100644 --- a/Huobi.Net/Huobi.Net.csproj +++ b/Huobi.Net/Huobi.Net.csproj @@ -52,6 +52,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + \ No newline at end of file diff --git a/Huobi.Net/Huobi.Net.xml b/Huobi.Net/Huobi.Net.xml index c291bca3..f20d7b9d 100644 --- a/Huobi.Net/Huobi.Net.xml +++ b/Huobi.Net/Huobi.Net.xml @@ -451,41 +451,41 @@ - + - + - + Event triggered when an order is placed via this client - + Event triggered when an order is canceled via this client - + - + - + - + - + - + - + Construct url @@ -493,247 +493,247 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2340,38 +2340,38 @@ The credentials to set - + Spot API endpoints - + Endpoints related to account settings, info or actions - + Endpoints related to retrieving market and system data - + Endpoints related to orders and trades - + Get the ISpotClient for this client. This is a common interface which allows for some basic operations without knowing any details of the exchange. - + Huobi account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings - + Get the user id associated with the apikey/secret @@ -2379,7 +2379,7 @@ Cancellation token - + Gets a list of users associated with the apikey/secret @@ -2387,7 +2387,7 @@ Cancellation token - + Gets a list of sub-user accounts associated with the sub-user id @@ -2396,7 +2396,7 @@ Cancellation token - + Gets a list of accounts associated with the apikey/secret @@ -2404,7 +2404,7 @@ Cancellation token - + Gets a list of balances for a specific account @@ -2413,7 +2413,7 @@ Cancellation token - + Gets the valuation of all assets @@ -2424,7 +2424,7 @@ Cancellation token - + Transfer assets between accounts @@ -2440,7 +2440,7 @@ Cancellation token - + Gets a list of balance changes of specified user's account @@ -2455,7 +2455,7 @@ Cancellation token - + This endpoint returns the balance changes of specified user's account. @@ -2471,7 +2471,7 @@ Cancellation token - + Gets a list of balances for a specific sub account @@ -2480,7 +2480,7 @@ Cancellation token - + Transfer asset between parent and sub account @@ -2492,7 +2492,7 @@ Cancellation token Unique transfer id - + Parent user and sub user could query deposit address of corresponding chain, for a specific crypto currency (except IOTA). @@ -2501,7 +2501,7 @@ Cancellation token - + Parent user creates a withdraw request from spot account to an external address (exists in your withdraw address list), which doesn't require two-factor-authentication. @@ -2515,7 +2515,7 @@ Cancellation token - + Parent user and sub user searche for all existed withdraws and deposits and return their latest status. @@ -2528,7 +2528,7 @@ Cancellation token - + Repay a margin loan @@ -2540,7 +2540,7 @@ Cancellation token - + Transfer asset from spot account to isolated margin account @@ -2551,7 +2551,7 @@ Cancellation token Transfer id - + Transfer asset from isolated margin to spot account @@ -2562,7 +2562,7 @@ Cancellation token Transfer id - + Get isolated loan interest rate and quotas @@ -2571,7 +2571,7 @@ Cancellation token - + Request a loan on isolated margin @@ -2582,7 +2582,7 @@ Cancellation token Order id - + Repay a isolated margin loan @@ -2592,7 +2592,7 @@ Cancellation token Order id - + Get isolated margin orders history @@ -2608,7 +2608,7 @@ Cancellation token - + Get isolated margin account balance @@ -2618,7 +2618,7 @@ Cancellation token - + Transfer from spot account to cross margin account @@ -2628,7 +2628,7 @@ Cancellation token - + Transfer from cross margin account to spot account @@ -2638,7 +2638,7 @@ Cancellation token - + Get cross margin interest rates and quotas @@ -2646,7 +2646,7 @@ - + Request a loan on cross margin @@ -2656,7 +2656,7 @@ Cancellation token Order id - + Repay a isolated margin loan @@ -2666,7 +2666,7 @@ Cancellation token Order id - + Get cross margin order history @@ -2682,7 +2682,7 @@ Cancellation token - + Get cross margin account balance @@ -2691,7 +2691,7 @@ Cancellation token - + Get repayment history @@ -2707,7 +2707,7 @@ Cancellation token - + Get Current Fee Rate Applied to The User @@ -2716,12 +2716,12 @@ Cancellation token - + Huobi exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. - + Gets the latest ticker for all symbols @@ -2729,7 +2729,7 @@ Cancellation token - + Gets the ticker, including the best bid / best ask for a symbol @@ -2738,7 +2738,7 @@ Cancellation token - + Get candlestick data for a symbol @@ -2749,7 +2749,7 @@ Cancellation token - + Gets the order book for a symbol @@ -2760,7 +2760,7 @@ Cancellation token - + Gets the last trade for a symbol @@ -2769,7 +2769,7 @@ Cancellation token - + Get the last x trades for a symbol @@ -2779,7 +2779,7 @@ Cancellation token - + Gets 24h stats for a symbol @@ -2788,7 +2788,7 @@ Cancellation token - + Gets real time NAV for ETP @@ -2797,7 +2797,7 @@ Cancellation token - + Gets the current market status @@ -2805,7 +2805,7 @@ Cancellation token - + Gets a list of supported symbols @@ -2813,7 +2813,7 @@ Cancellation token - + Gets a list of supported currencies @@ -2821,7 +2821,7 @@ Cancellation token - + Gets a list of supported currencies and chains @@ -2830,7 +2830,7 @@ Cancellation token - + Gets the server time @@ -2838,12 +2838,12 @@ Cancellation token - + Huobi trading endpoints, placing and mananging orders. - + Places an order @@ -2861,7 +2861,7 @@ Cancellation token - + Gets a list of open orders @@ -2873,7 +2873,7 @@ Cancellation token - + Cancels an open order @@ -2882,7 +2882,7 @@ Cancellation token - + Cancels an open order @@ -2891,7 +2891,7 @@ Cancellation token - + Cancel multiple open orders @@ -2901,7 +2901,7 @@ Cancellation token - + Cancel multiple open orders @@ -2913,7 +2913,7 @@ Cancellation token - + Get details of an order @@ -2922,7 +2922,7 @@ Cancellation token - + Get details of an order by client order id @@ -2931,7 +2931,7 @@ Cancellation token - + Gets a list of trades made for a specific order @@ -2940,7 +2940,7 @@ Cancellation token - + Gets a list of orders @@ -2956,7 +2956,7 @@ Cancellation token - + Gets a list of trades for a specific symbol @@ -2972,7 +2972,7 @@ Cancellation token - + Gets a list of history orders @@ -2985,7 +2985,7 @@ Cancellation token - + Place a new conditional order @@ -3004,7 +3004,7 @@ Cancellation token - + Cancel conditional orders @@ -3013,7 +3013,7 @@ Cancelation token - + Get open conditional orders based on the parameters @@ -3028,7 +3028,7 @@ Cancelation token - + Get closed conditional orders @@ -3046,7 +3046,7 @@ Return only entries before this time - + Get a conditional order by id @@ -3230,32 +3230,32 @@ Cancellation token for closing this subscription A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - + Usdt margin swap api endpoints - + Endpoints related to account settings, info or actions - + Endpoints related to retrieving market and system data - + Endpoints related to orders and trades - + Huobi usdt swap account endpoints - + Get asset values @@ -3264,7 +3264,7 @@ Cancellation token - + Get isolated margin account info @@ -3273,7 +3273,7 @@ Cancellation token - + Get cross margin account info @@ -3282,7 +3282,7 @@ Cancellation token - + Get cross margin assets and positions @@ -3291,7 +3291,7 @@ Cancellation token - + Get cross margin available leverage @@ -3303,7 +3303,7 @@ Cancellation token - + Get cross margin positions @@ -3312,7 +3312,7 @@ Cancellation token - + Get cross margin settlement records @@ -3325,7 +3325,7 @@ Cancellation token - + Get cross margin sub account assets @@ -3334,7 +3334,7 @@ Cancellation token - + Get financial records @@ -3348,7 +3348,7 @@ Cancellation token - + Get isolated margin assets and positisons @@ -3357,7 +3357,7 @@ Cancellation token - + Get isolated margin available leverage @@ -3366,7 +3366,7 @@ Cancellation token - + Get isolated margin position info @@ -3375,7 +3375,7 @@ Cancellation token - + Get isolated margin settlement records @@ -3388,7 +3388,7 @@ Cancellation token - + Get isolated margin sub account assets @@ -3397,7 +3397,7 @@ Cancellation token - + Get master sub account transfer records @@ -3410,7 +3410,7 @@ Cancellation token - + Get trading fees @@ -3422,7 +3422,7 @@ Cancellation token - + Switch cross margin position mode @@ -3432,7 +3432,7 @@ Cancellation token - + Switch isolated margin position mode @@ -3442,7 +3442,7 @@ Cancellation token - + Set sub account trading permissions @@ -3452,7 +3452,7 @@ Cancellation token - + Transfer between margin accounts @@ -3465,7 +3465,7 @@ Cancellation token - + Transfer between master and sub account @@ -3480,12 +3480,12 @@ Cancellation token - + Huobi usdt margin swap exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. - + Get basis data @@ -3497,7 +3497,7 @@ Cancellation token - + Get the best current offer @@ -3507,7 +3507,7 @@ Cancellation token - + Get contract info @@ -3520,7 +3520,7 @@ Cancellation token - + Get cross margin adjust factor info @@ -3531,7 +3531,7 @@ Cancellation token - + Get cross margin trade status @@ -3542,7 +3542,7 @@ Cancellation token - + Get cross margin transfer status @@ -3551,7 +3551,7 @@ Cancellation token - + Get cross tiered margin info @@ -3562,7 +3562,7 @@ Cancellation token - + Get estimated funding rate kliens @@ -3573,7 +3573,7 @@ Cancellation token - + Get estimated settlement price @@ -3585,7 +3585,7 @@ Cancellation token - + Get funding rate @@ -3594,7 +3594,7 @@ Cancellation token - + Get funding rates @@ -3603,7 +3603,7 @@ Cancellation token - + Get historical funding rates @@ -3614,7 +3614,7 @@ Cancellation token - + Get historical settlement records @@ -3627,7 +3627,7 @@ Cancellation token - + Get insurance fund history @@ -3638,7 +3638,7 @@ Cancellation token - + Get isolated margin adjust factor info @@ -3647,7 +3647,7 @@ Cancellation token - + Get isolated margin status @@ -3656,7 +3656,7 @@ Cancellation token - + Get isolated margin tier info @@ -3665,7 +3665,7 @@ Cancellation token - + Get klines @@ -3678,7 +3678,7 @@ Cancellation token - + Get last trades @@ -3688,7 +3688,7 @@ Cancellation token - + Get liquidation orders @@ -3702,7 +3702,7 @@ Cancellation token - + Get market data @@ -3711,7 +3711,7 @@ Cancellation token - + Get market datas @@ -3721,7 +3721,7 @@ Cancellation token - + Get open interest @@ -3735,7 +3735,7 @@ Cancellation token - + Get order book @@ -3745,7 +3745,7 @@ Cancellation token - + Get premium index klines @@ -3756,7 +3756,7 @@ Cancellation token - + Get recent trades @@ -3766,7 +3766,7 @@ Cancellation token - + Get server time @@ -3774,7 +3774,7 @@ Cancellation token - + Get swap index price @@ -3783,7 +3783,7 @@ Cancellation token - + Get swap open interest @@ -3795,7 +3795,7 @@ Cancellation token - + Get swap price limitation @@ -3807,7 +3807,7 @@ Cancellation token - + Get swap risk info @@ -3817,12 +3817,12 @@ Cancellation token - + Huobi usdt margin swap trading endpoints, placing and mananging orders. - + Cancel all cross margin orders fitting the parameters @@ -3835,7 +3835,7 @@ Cancellation token - + Cancel all isolated margin order fitting the parameters @@ -3846,7 +3846,7 @@ Cancellation token - + Cancel cross margin order @@ -3859,7 +3859,7 @@ Cancellation token - + Cancel cross margin orders @@ -3872,7 +3872,7 @@ Cancellation token - + Cancel isolated margin order @@ -3883,7 +3883,7 @@ Cancellation token - + Cancel isolated margin orders @@ -3894,7 +3894,7 @@ Cancellation token - + Change cross margin leverage @@ -3906,7 +3906,7 @@ Cancellation token - + Change isolated margin leverage @@ -3916,7 +3916,7 @@ Cancellation token - + Get cross margin closed orders @@ -3932,7 +3932,7 @@ Cancellation token - + Get cross margin open orders @@ -3946,7 +3946,7 @@ Cancellation token - + Get cross margin order @@ -3958,7 +3958,7 @@ Cancellation token - + Get cross margin order details @@ -3968,7 +3968,7 @@ Cancellation token - + Get cross margin orders @@ -3980,7 +3980,7 @@ Cancellation token - + Get cross margin user trades @@ -3993,7 +3993,7 @@ Cancellation token - + Get isolated margin closed orders @@ -4008,7 +4008,7 @@ Cancellation token - + Get isolated margin open orders @@ -4021,7 +4021,7 @@ Cancellation token - + Get isoalted margin order @@ -4032,7 +4032,7 @@ Cancellation token - + Get isolated margin order details @@ -4042,7 +4042,7 @@ Cancellation token - + Get isolated margin orders @@ -4053,7 +4053,7 @@ Cancellation token - + Get isolated margin user trades @@ -4066,7 +4066,7 @@ Cancellation token - + Place a new cross margin order @@ -4091,7 +4091,7 @@ Cancellation token - + Place a new isolated margin order diff --git a/Huobi.Net/HuobiAuthenticationProvider.cs b/Huobi.Net/HuobiAuthenticationProvider.cs index dd9f4785..5b2d7acb 100644 --- a/Huobi.Net/HuobiAuthenticationProvider.cs +++ b/Huobi.Net/HuobiAuthenticationProvider.cs @@ -29,38 +29,33 @@ public HuobiAuthenticationProvider(ApiCredentials credentials, bool signPublicRe public override void AuthenticateRequest(RestApiClient apiClient, Uri uri, HttpMethod method, - Dictionary providedParameters, + IDictionary uriParams, + IDictionary bodyParams, + Dictionary headers, bool auth, ArrayParametersSerialization arraySerialization, HttpMethodParameterPosition parameterPosition, - RequestBodyFormat bodyFormat, - out SortedDictionary uriParameters, - out SortedDictionary bodyParameters, - out Dictionary headers) + RequestBodyFormat bodyFormat) { - uriParameters = parameterPosition == HttpMethodParameterPosition.InUri ? new SortedDictionary(providedParameters) : new SortedDictionary(); - bodyParameters = parameterPosition == HttpMethodParameterPosition.InBody ? new SortedDictionary(providedParameters) : new SortedDictionary(); - headers = new Dictionary(); - if (!auth && !_signPublicRequests) return; // These are always in the uri - uriParameters.Add("AccessKeyId", _credentials.Key!.GetString()); - uriParameters.Add("SignatureMethod", "HmacSHA256"); - uriParameters.Add("SignatureVersion", 2); - uriParameters.Add("Timestamp", GetTimestamp(apiClient).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture)); + uriParams.Add("AccessKeyId", _credentials.Key!.GetString()); + uriParams.Add("SignatureMethod", "HmacSHA256"); + uriParams.Add("SignatureVersion", 2); + uriParams.Add("Timestamp", GetTimestamp(apiClient).ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture)); var absolutePath = uri.AbsolutePath; if (absolutePath.StartsWith("/api")) // Russian api has /api prefix which shouldn't be part of the signature absolutePath = absolutePath.Substring(4); - var sortedParameters = uriParameters.OrderBy(kv => Encoding.UTF8.GetBytes(WebUtility.UrlEncode(kv.Key)!), new ByteOrderComparer()); + var sortedParameters = uriParams.OrderBy(kv => Encoding.UTF8.GetBytes(WebUtility.UrlEncode(kv.Key)!), new ByteOrderComparer()); var paramString = uri.SetParameters(sortedParameters, arraySerialization).Query.Replace("?", ""); paramString = new Regex(@"%[a-f0-9]{2}").Replace(paramString, m => m.Value.ToUpperInvariant()); var signData = $"{method}\n{uri.Host}\n{absolutePath}\n{paramString}"; - uriParameters.Add("Signature", SignHMACSHA256(signData, SignOutputType.Base64)); + uriParams.Add("Signature", SignHMACSHA256(signData, SignOutputType.Base64)); } public HuobiAuthParams GetWebsocketAuthentication(Uri uri) diff --git a/Huobi.Net/Interfaces/Clients/IHuobiClient.cs b/Huobi.Net/Interfaces/Clients/IHuobiClient.cs index f61105c0..aa328060 100644 --- a/Huobi.Net/Interfaces/Clients/IHuobiClient.cs +++ b/Huobi.Net/Interfaces/Clients/IHuobiClient.cs @@ -13,11 +13,11 @@ public interface IHuobiRestClient : IRestClient /// /// Spot endpoints /// - IHuobiClientSpotApi SpotApi { get; } + IHuobiRestClientSpotApi SpotApi { get; } /// /// Usdt margin swap endpoints /// - IHuobiClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } + IHuobiRestClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } /// /// 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/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApi.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs similarity index 76% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApi.cs rename to Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs index 0cc72842..f917be93 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApi.cs +++ b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs @@ -7,22 +7,22 @@ namespace Huobi.Net.Interfaces.Clients.SpotApi /// /// Spot API endpoints /// - public interface IHuobiClientSpotApi : IRestApiClient, IDisposable + public interface IHuobiRestClientSpotApi : IRestApiClient, IDisposable { /// /// Endpoints related to account settings, info or actions /// - IHuobiClientSpotApiAccount Account { get; } + IHuobiRestClientSpotApiAccount Account { get; } /// /// Endpoints related to retrieving market and system data /// - IHuobiClientSpotApiExchangeData ExchangeData { get; } + IHuobiRestClientSpotApiExchangeData ExchangeData { get; } /// /// Endpoints related to orders and trades /// - IHuobiClientSpotApiTrading Trading { get; } + IHuobiRestClientSpotApiTrading Trading { get; } /// /// Get the ISpotClient for this client. This is a common interface which allows for some basic operations without knowing any details of the exchange. diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiAccount.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiAccount.cs rename to Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs index fff273a7..ca691578 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiAccount.cs +++ b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs @@ -11,7 +11,7 @@ namespace Huobi.Net.Interfaces.Clients.SpotApi /// /// Huobi account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings /// - public interface IHuobiClientSpotApiAccount + public interface IHuobiRestClientSpotApiAccount { /// /// Get the user id associated with the apikey/secret diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiExchangeData.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiExchangeData.cs rename to Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs index 5e2c4201..100ca74f 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiExchangeData.cs +++ b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs @@ -11,7 +11,7 @@ namespace Huobi.Net.Interfaces.Clients.SpotApi /// /// Huobi exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. /// - public interface IHuobiClientSpotApiExchangeData + public interface IHuobiRestClientSpotApiExchangeData { /// /// Gets the latest ticker for all symbols diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiTrading.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiTrading.cs rename to Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs index 4395ea1e..5f09e63d 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiClientSpotApiTrading.cs +++ b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs @@ -11,7 +11,7 @@ namespace Huobi.Net.Interfaces.Clients.SpotApi /// /// Huobi trading endpoints, placing and mananging orders. /// - public interface IHuobiClientSpotApiTrading + public interface IHuobiRestClientSpotApiTrading { /// /// Places an order diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApi.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs similarity index 66% rename from Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApi.cs rename to Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs index c42a4b83..dad58356 100644 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApi.cs +++ b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs @@ -6,19 +6,19 @@ namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi /// /// Usdt margin swap api endpoints /// - public interface IHuobiClientUsdtMarginSwapApi : IRestApiClient + public interface IHuobiRestClientUsdtMarginSwapApi : IRestApiClient { /// /// Endpoints related to account settings, info or actions /// - IHuobiClientUsdtMarginSwapApiAccount Account { get; } + IHuobiRestClientUsdtMarginSwapApiAccount Account { get; } /// /// Endpoints related to retrieving market and system data /// - HuobiClientUsdtMarginSwapApiExchangeData ExchangeData { get; } + HuobiRestClientUsdtMarginSwapApiExchangeData ExchangeData { get; } /// /// Endpoints related to orders and trades /// - HuobiClientUsdtMarginSwapApiTrading Trading { get; } + HuobiRestClientUsdtMarginSwapApiTrading Trading { get; } } } \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiAccount.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiAccount.cs rename to Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs index 1970a97f..f732115f 100644 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiAccount.cs +++ b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs @@ -11,7 +11,7 @@ namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi /// /// Huobi usdt swap account endpoints /// - public interface IHuobiClientUsdtMarginSwapApiAccount + public interface IHuobiRestClientUsdtMarginSwapApiAccount { /// /// Get asset values diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiExchangeData.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiExchangeData.cs rename to Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs index 7623f109..69f46db3 100644 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiExchangeData.cs +++ b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs @@ -12,7 +12,7 @@ namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi /// /// Huobi usdt margin swap exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. /// - public interface IHuobiClientUsdtMarginSwapApiExchangeData + public interface IHuobiRestClientUsdtMarginSwapApiExchangeData { /// /// Get basis data diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiTrading.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs similarity index 99% rename from Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiTrading.cs rename to Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs index 177f739a..c5242417 100644 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiClientUsdtMarginSwapApiTrading.cs +++ b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs @@ -10,7 +10,7 @@ namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi /// /// Huobi usdt margin swap trading endpoints, placing and mananging orders. /// - public interface IHuobiClientUsdtMarginSwapApiTrading + public interface IHuobiRestClientUsdtMarginSwapApiTrading { /// /// Cancel all cross margin orders fitting the parameters