diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/CancelWithdrawal.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/CancelWithdrawal.txt new file mode 100644 index 00000000..5c64df66 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/CancelWithdrawal.txt @@ -0,0 +1,6 @@ +POST +/v1/dw/withdraw-virtual/1/cancel +true +{ + "data": 700 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountHistory.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountHistory.txt new file mode 100644 index 00000000..e224004f --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountHistory.txt @@ -0,0 +1,29 @@ +GET +/v1/account/history +true +{ + "status": "ok", + "data": [ + { + "account-id": 10000001, + "currency": "usdt", + "record-id": 359044707902783800, + "transact-amt": "-10.000000000000000000", + "transact-type": "other-types", + "avail-balance": "81.850043797676510303", + "acct-balance": "97.010043797676510318", + "transact-time": 1629882096557 + }, + { + "account-id": 10000001, + "currency": "usdt", + "record-id": 359044690723242100, + "transact-amt": "-10.000000000000000000", + "transact-type": "transfer", + "avail-balance": "81.850043797676510303", + "acct-balance": "87.010043797676510318", + "transact-time": 1629882096569 + } + ], + "next-id": 47996522235 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountLedger.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountLedger.txt new file mode 100644 index 00000000..8bf2f8fa --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccountLedger.txt @@ -0,0 +1,33 @@ +GET +/v2/account/ledger +true +{ + "code": 200, + "message": "success", + "data": [ + { + "accountId": 10000001, + "currency": "usdt", + "transactAmt": 10, + "transactType": "transfer", + "transferType": "margin-transfer-out", + "transactId": 0, + "transactTime": 1629882331066, + "transferer": 28483123, + "transferee": 13496526 + }, + { + "accountId": 10000001, + "currency": "usdt", + "transactAmt": -10, + "transactType": "transfer", + "transferType": "margin-transfer-in", + "transactId": 0, + "transactTime": 1629882096562, + "transferer": 13496526, + "transferee": 28483123 + } + ], + "nextId": 1624316679, + "ok": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccounts.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccounts.txt new file mode 100644 index 00000000..9d55381e --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAccounts.txt @@ -0,0 +1,26 @@ +GET +/v1/account/accounts +true +{ + "status": "ok", + "data": [ + { + "id": 10000001, + "type": "spot", + "subtype": "", + "state": "working" + }, + { + "id": 10000002, + "type": "otc", + "subtype": "", + "state": "working" + }, + { + "id": 10000003, + "type": "point", + "subtype": "", + "state": "working" + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetApiKeyInfo.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetApiKeyInfo.txt new file mode 100644 index 00000000..33a8dfee --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetApiKeyInfo.txt @@ -0,0 +1,30 @@ +GET +/v2/user/api-key +true +{ + "code": 200, + "message": "success", + "data": [ + { + "accessKey": "160bb889-b7XXXXbe-e0XXXXf5-ghxertfvbf", + "status": "normal", + "note": "host", + "permission": "trade,readOnly", + "ipAddresses": "192.168.0.1,192.168.1.1", + "validDays": -1, + "createTime": 1615192704000, + "updateTime": 1623030338000 + }, + { + "accessKey": "5000d371-edXXXXf5tf-40XXXX8b-ab8e5", + "status": "normal", + "note": "host two", + "permission": "readOnly,trade,withdraw", + "ipAddresses": "", + "validDays": 7, + "createTime": 1623158078000, + "updateTime": 1629875976000 + } + ], + "ok": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAssetValuation.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAssetValuation.txt new file mode 100644 index 00000000..d9dd2dc3 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetAssetValuation.txt @@ -0,0 +1,11 @@ +GET +/v2/account/asset-valuation +true +{ + "code": 200, + "data": { + "balance": "34.75", + "timestamp": 1594901254363 + }, + "ok": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetBalances.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetBalances.txt new file mode 100644 index 00000000..a9b7ba3c --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetBalances.txt @@ -0,0 +1,37 @@ +GET +/v1/account/accounts/1/balance +true +{ + "status": "ok", + "data": { + "id": 1000001, + "type": "spot", + "state": "working", + "list": [ + { + "currency": "usdt", + "type": "trade", + "balance": "91.850043797676510303", + "debt": "invalid", + "available": "invalid", + "seq-num": "477" + }, + { + "currency": "usdt", + "type": "frozen", + "balance": "5.160000000000000015", + "debt": "invalid", + "available": "invalid", + "seq-num": "477" + }, + { + "currency": "poly", + "type": "trade", + "balance": "147.928994082840236", + "debt": "invalid", + "available": "invalid", + "seq-num": "2" + } + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDeductAssets.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDeductAssets.txt new file mode 100644 index 00000000..bf9b062d --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDeductAssets.txt @@ -0,0 +1,10 @@ +GET +/v1/account/overview/info +true +{ + "code": 200, + "data": { + "currency": "HTX,TRX" + }, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDepositAddresses.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDepositAddresses.txt new file mode 100644 index 00000000..a63b8540 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetDepositAddresses.txt @@ -0,0 +1,29 @@ +GET +/v2/account/deposit/address +true +{ + "code": 200, + "data": [ + { + "userId": 12345678, + "currency": "btc", + "address": "0xd476b0d77583fbda5180039f1f513b750cb4f527", + "addressTag": "", + "chain": "hbtc" + }, + { + "userId": 12345678, + "currency": "btc", + "address": "16egzDeZiVDJ4D44UbWKN6snLYFjS1aEmJ", + "addressTag": "", + "chain": "btc" + }, + { + "userId": 12345678, + "currency": "btc", + "address": "0xd476b0d77583fbda5180039f1f513b750cb4f527", + "addressTag": "", + "chain": "hrc20btc" + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPlatformValuation.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPlatformValuation.txt new file mode 100644 index 00000000..9dcafc4f --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPlatformValuation.txt @@ -0,0 +1,24 @@ +GET +/v2/account/valuation +true +{ + "code": 200, + "data": { + "updated": { + "success": true, + "time": 1629916724000 + }, + "todayProfitRate": "0.004638293764657609", + "totalBalance": "0.06276321", + "todayProfit": "0.00028977", + "profitAccountBalanceList": [ + { + "distributionType": "11", + "balance": 0.05728808, + "success": true, + "accountBalance": "0.05728808" + } + ] + }, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPointBalance.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPointBalance.txt new file mode 100644 index 00000000..411f0847 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetPointBalance.txt @@ -0,0 +1,19 @@ +GET +/v2/point/account +true +{ + "code": 200, + "data": { + "accountId": "14403739", + "groupIds": [ + { + "groupId": 26, + "expiryDate": 1594396800000, + "remainAmt": "0.3" + } + ], + "acctBalance": "0.30000000", + "accountStatus": "working" + }, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetTradingFees.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetTradingFees.txt new file mode 100644 index 00000000..adfed261 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetTradingFees.txt @@ -0,0 +1,30 @@ +GET +/v2/reference/transact-fee-rate +true +{ + "code": 200, + "data": [ + { + "symbol": "btcusdt", + "actualMakerRate": "0.002", + "actualTakerRate": "0.002", + "takerFeeRate": "0.002", + "makerFeeRate": "0.002" + }, + { + "symbol": "apnusdt", + "actualMakerRate": "0.002", + "actualTakerRate": "0.002", + "takerFeeRate": "0.002", + "makerFeeRate": "0.002" + }, + { + "symbol": "htusdt", + "actualMakerRate": "0.002", + "actualTakerRate": "0.002", + "takerFeeRate": "0.002", + "makerFeeRate": "0.002" + } + ], + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserDeductionInfo.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserDeductionInfo.txt new file mode 100644 index 00000000..d9f0ca48 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserDeductionInfo.txt @@ -0,0 +1,12 @@ +GET +/v1/account/switch/user/info +true +{ + "code": 200, + "data": { + "pointSwitch": "1", + "htxSwitch": "0", + "currency": "HTX" + }, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserId.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserId.txt new file mode 100644 index 00000000..3f6050ba --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetUserId.txt @@ -0,0 +1,7 @@ +GET +/v2/user/uid +true +{ + "code": 200, + "data": 63628520 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawDeposit.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawDeposit.txt new file mode 100644 index 00000000..33a7ae5b --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawDeposit.txt @@ -0,0 +1,40 @@ +GET +/v1/query/deposit-withdraw +true +{ + "status": "ok", + "data": [ + { + "id": 45182894, + "type": "withdraw", + "sub-type": "FAST", + "currency": "usdt", + "chain": "trc20usdt", + "tx-hash": "", + "amount": 400, + "from-addr-tag": "", + "address": "TRwkUYHWgUh23jbKpgTcYHgE9CcBzhGno9", + "address-tag": "", + "fee": 0, + "state": "confirmed", + "created-at": 1612261330443, + "updated-at": 1612261389250 + }, + { + "id": 61003926, + "type": "withdraw", + "sub-type": "FAST", + "currency": "usdt", + "chain": "trc20usdt", + "tx-hash": "", + "amount": 2, + "from-addr-tag": "", + "address": "TYGvZSD1duPctGaMPSP12Fy8BrQMu2KCdp", + "address-tag": "", + "fee": 0, + "state": "confirmed", + "created-at": 1621416907639, + "updated-at": 1621416907788 + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalAddresses.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalAddresses.txt new file mode 100644 index 00000000..af4a6958 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalAddresses.txt @@ -0,0 +1,16 @@ +GET +/v2/account/withdraw/address +true +{ + "code": 200, + "data": [ + { + "currency": "usdt", + "chain": "hrc20usdt", + "note": "tom", + "addressTag": "", + "address": "0x3b994f25c4c25e99d4d26364ffc014cce64600ca" + } + ], + "next-id": 30137790 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalByClientOrderId.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalByClientOrderId.txt new file mode 100644 index 00000000..dc049a99 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalByClientOrderId.txt @@ -0,0 +1,23 @@ +GET +/v1/query/withdraw/client-order-id +true +{ + "status": "ok", + "data": { + "id": 101123262, + "client-order-id": "1113", + "type": "withdraw", + "sub-type": "FAST", + "currency": "usdt", + "chain": "usdt", + "tx-hash": "", + "amount": 1.2, + "from-addr-tag": "", + "address": "1PL24EbWrNNrnMKw1cxAHPsebUz7DdhWTx", + "address-tag": "", + "fee": 0, + "state": "confirmed", + "created-at": 1637758163686, + "updated-at": 1637758251559 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalQuotas.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalQuotas.txt new file mode 100644 index 00000000..cc4e8361 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/GetWithdrawalQuotas.txt @@ -0,0 +1,51 @@ +GET +/v2/account/withdraw/quota +true +{ + "code": 200, + "data": { + "currency": "usdt", + "chains": [ + { + "chain": "hrc20usdt", + "maxWithdrawAmt": "2000000.000000000000000000", + "withdrawQuotaPerDay": "4845303.99999991", + "remainWithdrawQuotaPerDay": "4845303.99999991", + "withdrawQuotaPerYear": "-1", + "remainWithdrawQuotaPerYear": "-1", + "withdrawQuotaTotal": "-1", + "remainWithdrawQuotaTotal": "-1" + }, + { + "chain": "trc20usdt", + "maxWithdrawAmt": "1000000.000000000000000000", + "withdrawQuotaPerDay": "4845303.99999991", + "remainWithdrawQuotaPerDay": "4845303.99999991", + "withdrawQuotaPerYear": "-1", + "remainWithdrawQuotaPerYear": "-1", + "withdrawQuotaTotal": "-1", + "remainWithdrawQuotaTotal": "-1" + }, + { + "chain": "usdt", + "maxWithdrawAmt": "600000.000000000000000000", + "withdrawQuotaPerDay": "4845303.99999991", + "remainWithdrawQuotaPerDay": "4845303.99999991", + "withdrawQuotaPerYear": "-1", + "remainWithdrawQuotaPerYear": "-1", + "withdrawQuotaTotal": "-1", + "remainWithdrawQuotaTotal": "-1" + }, + { + "chain": "usdterc20", + "maxWithdrawAmt": "1000000.000000000000000000", + "withdrawQuotaPerDay": "4845303.99999991", + "remainWithdrawQuotaPerDay": "4845303.99999991", + "withdrawQuotaPerYear": "-1", + "remainWithdrawQuotaPerYear": "-1", + "withdrawQuotaTotal": "-1", + "remainWithdrawQuotaTotal": "-1" + } + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/InternalTransfer.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/InternalTransfer.txt new file mode 100644 index 00000000..25a141b7 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/InternalTransfer.txt @@ -0,0 +1,10 @@ +POST +/v1/account/transfer +true +{ + "status": "ok", + "data": { + "transact-id": 220521190, + "transact-time": 1590662591832 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/SetDeductionSwitch.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/SetDeductionSwitch.txt new file mode 100644 index 00000000..2e0aaf80 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/SetDeductionSwitch.txt @@ -0,0 +1,8 @@ +POST +/v1/account/fee/switch +true +{ + "code": 200, + "data": {}, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/Transfer.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/Transfer.txt new file mode 100644 index 00000000..777e5a38 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/Transfer.txt @@ -0,0 +1,9 @@ +POST +/v2/account/transfer +true +{ + "code": 200, + "data": 176104252, + "message": "Succeed", + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/TransferPoints.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/TransferPoints.txt new file mode 100644 index 00000000..2522732e --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/TransferPoints.txt @@ -0,0 +1,11 @@ +POST +/v2/point/transfer +true +{ + "code": 200, + "data": { + "transactId": "74", + "transactTime": 1594370136458 + }, + "success": true +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/Account/Withdraw.txt b/HTX.Net.UnitTests/Endpoints/Spot/Account/Withdraw.txt new file mode 100644 index 00000000..5825af68 --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/Account/Withdraw.txt @@ -0,0 +1,6 @@ +POST +/v1/dw/withdraw/api/create +true +{ + "data": 700 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Endpoints/Spot/ExchangeData/GetAssets.txt b/HTX.Net.UnitTests/Endpoints/Spot/ExchangeData/GetAssets.txt new file mode 100644 index 00000000..96ffed0d --- /dev/null +++ b/HTX.Net.UnitTests/Endpoints/Spot/ExchangeData/GetAssets.txt @@ -0,0 +1,38 @@ +GET +/v2/settings/common/currencies +false +{ + "status": "ok", + "data": [ + { + "tags": "", + "cawt": false, + "fc": 12, + "sc": 12, + "dma": "1", + "wma": "10", + "ft": "eth", + "whe": false, + "cd": false, + "qc": true, + "sp": "8", + "wp": 6, + "fn": "Tether USDT", + "at": 1, + "cc": "usdt", + "v": true, + "de": true, + "wed": true, + "w": 10006, + "state": "online", + "dn": "USDT", + "dd": "Please don’t deposit any other digital assets except USDT to the above address. Otherwise, you may lose your assets permanently. !>______ - + diff --git a/Huobi.Net.UnitTests/HuobiClientTests.cs b/HTX.Net.UnitTests/HTXRestClientTests.cs similarity index 79% rename from Huobi.Net.UnitTests/HuobiClientTests.cs rename to HTX.Net.UnitTests/HTXRestClientTests.cs index ab59619a..e603b857 100644 --- a/Huobi.Net.UnitTests/HuobiClientTests.cs +++ b/HTX.Net.UnitTests/HTXRestClientTests.cs @@ -1,27 +1,19 @@ -using Huobi.Net.UnitTests.TestImplementations; -using Newtonsoft.Json; +using HTX.Net.UnitTests.TestImplementations; using NUnit.Framework; using System; -using System.Linq; using System.Threading.Tasks; -using System.Reflection; -using System.Diagnostics; -using CryptoExchange.Net.Objects; -using Huobi.Net.Clients; -using Huobi.Net.Clients.SpotApi; -using Huobi.Net.ExtensionMethods; -using CryptoExchange.Net.Objects.Sockets; +using HTX.Net.Clients; 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; +using System.Text.Json; -namespace Huobi.Net.UnitTests +namespace HTX.Net.UnitTests { [TestFixture] - public class HuobiClientTests + public class HTXRestClientTests { [TestCase] public async Task ReceivingErrorResponse_Should_FailCall() @@ -55,17 +47,17 @@ public async Task ReceivingHttpErrorResponse_Should_FailCall() public string SerializeExpected(T data, bool tick) { - return $"{{\"status\": \"ok\", {(tick ? "tick" : "data")}: {JsonConvert.SerializeObject(data)}}}"; + return $"{{\"status\": \"ok\", {(tick ? "tick" : "data")}: {JsonSerializer.Serialize(data)}}}"; } [Test] public void CheckSignatureExample() { - var authProvider = new HuobiAuthenticationProvider( + var authProvider = new HTXAuthenticationProvider( new ApiCredentials("e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx", "XXXXXXXXXX"), false ); - var client = (RestApiClient)new HuobiRestClient().SpotApi; + var client = (RestApiClient)new HTXRestClient().SpotApi; CryptoExchange.Net.Testing.TestHelpers.CheckSignature( client, @@ -88,8 +80,8 @@ public void CheckSignatureExample() [Test] public void CheckInterfaces() { - CryptoExchange.Net.Testing.TestHelpers.CheckForMissingRestInterfaces(); - CryptoExchange.Net.Testing.TestHelpers.CheckForMissingSocketInterfaces(); + CryptoExchange.Net.Testing.TestHelpers.CheckForMissingRestInterfaces(); + CryptoExchange.Net.Testing.TestHelpers.CheckForMissingSocketInterfaces(); } } } diff --git a/HTX.Net.UnitTests/HTXRestIntegrationTests.cs b/HTX.Net.UnitTests/HTXRestIntegrationTests.cs new file mode 100644 index 00000000..2592bfa1 --- /dev/null +++ b/HTX.Net.UnitTests/HTXRestIntegrationTests.cs @@ -0,0 +1,179 @@ +using HTX.Net.Clients; +using HTX.Net.Objects; +using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Testing; +using Microsoft.Extensions.Logging; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using HTX.Net.Enums; + +namespace HTX.Net.UnitTests +{ + [NonParallelizable] + internal class HTXRestIntegrationTests : RestIntergrationTest + { + public override bool Run { get; set; } = true; + + public HTXRestIntegrationTests() + { + } + + public override HTXRestClient GetClient(ILoggerFactory loggerFactory) + { + var key = Environment.GetEnvironmentVariable("APIKEY"); + var sec = Environment.GetEnvironmentVariable("APISECRET"); + + key = "1c8706b1-ed2htwf5tf-c1f359fd-2559d"; + sec = "20c4ff8b-7c9a2297-d231b3a4-2f8b5"; + + Authenticated = key != null && sec != null; + return new HTXRestClient(null, loggerFactory, opts => + { + opts.OutputOriginalData = true; + opts.ApiCredentials = Authenticated ? new ApiCredentials(key, sec) : null; + }); + } + + [Test] + public async Task TestErrorResponseParsing() + { + if (!ShouldRun()) + return; + + var result = await CreateClient().SpotApi.ExchangeData.GetKlinesAsync("TSTTST", Enums.KlineInterval.OneDay, default); + + Assert.That(result.Success, Is.False); + Assert.That(result.Error.Message, Contains.Substring("invalid-parameter")); + } + + [Test] + public async Task TestSpotApiAccount() + { + await RunAndCheckResult(client => client.SpotApi.Account.GetAccountsAsync(default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetPlatformValuationAsync(default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetAssetValuationAsync(Enums.AccountType.Spot, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetPointBalanceAsync(default, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetUserDeductionInfoAsync(default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetDeductAssetsAsync(default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetWithdrawalQuotasAsync("BTC", default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetWithdrawalAddressesAsync("ETH", default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetWithdrawDepositHistoryAsync(default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetTradingFeesAsync(new[] { "ETHUSDT" }, default), true); + await RunAndCheckResult(client => client.SpotApi.Account.GetUserIdAsync(default), true); + } + + [Test] + public async Task TestSpotApiExchangeData() + { + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetSystemStatusAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetSymbolStatusAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetSymbolsAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetAssetsAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetSymbolConfigAsync(default, default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetAssetsAndNetworksAsync(default, default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetServerTimeAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetKlinesAsync("ETHUSDT", Enums.KlineInterval.OneDay, default, default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT", default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetTickersAsync(default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetOrderBookAsync("ETHUSDT", 0, default, default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetLastTradeAsync("ETHUSDT", default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetTradeHistoryAsync("ETHUSDT", default, default), false); + await RunAndCheckResult(client => client.SpotApi.ExchangeData.GetSymbolDetails24HAsync("ETHUSDT", default), false); + } + + [Test] + public async Task TestSpotApiTrading() + { + await RunAndCheckResult(client => client.SpotApi.Trading.GetOpenOrdersAsync(default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Trading.GetClosedOrdersAsync("ETHUSDT", default, default, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Trading.GetHistoricalOrdersAsync("ETHUSDT", default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Trading.GetUserTradesAsync("ETHUSDT", default, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Trading.GetOpenConditionalOrdersAsync(default, default, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.SpotApi.Trading.GetClosedConditionalOrdersAsync("ETHUSDT", Enums.ConditionalOrderStatus.Triggered, default, default, default, default, default, default, default, default, default), true); + } + + [Test] + public async Task TestUsdtFuturesApiAccount() + { + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetAssetValuationAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAccountInfoAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetCrossMarginAccountInfoAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetIsolatedMarginPositionsAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetCrossMarginPositionsAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAssetsAndPositionsAsync("ETH-USDT", default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetCrossMarginAssetsAndPositionsAsync("USDT", default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetFinancialRecordsAsync("USDT", default, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAvailableLeverageAsync(default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetCrossMarginAvailableLeverageAsync(default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetOrderLimitsAsync(Enums.OrderPriceType.BestOffer, "ETH-USDT", default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Account.GetTradingFeesAsync(default, default, default, default, default), true); + } + + [Test] + public async Task TestUsdtFuturesApiExchangeData() + { + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetServerTimeAsync(default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetFundingRateAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetFundingRatesAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetHistoricalFundingRatesAsync("ETH-USDT", default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetLiquidationOrdersAsync("ETH-USDT", Enums.LiquidationTradeType.FullyFilledLiquidationOrders, default, default, default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetHistoricalSettlementRecordsAsync("ETH-USDT", default, default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetTopTraderAccountSentimentAsync("ETH-USDT", Enums.Period.OneDay, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetTopTraderPositionSentimentAsync("ETH-USDT", Enums.Period.OneDay, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginStatusAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetCrossTieredMarginInfoAsync("ETH-USDT", default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginTieredInfoAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetEstimatedSettlementPriceAsync("ETH-USDT", default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginAdjustFactorInfoAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginAdjustFactorInfoAsync("ETH-USDT", default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetInsuranceFundHistoryAsync("ETH-USDT", default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetSwapRiskInfoAsync("ETH-USDT", default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetSwapPriceLimitationAsync("ETH-USDT", default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetSwapOpenInterestAsync("ETH-USDT", default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetContractsAsync(default, default, default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetSwapIndexPriceAsync(default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetContractElementsAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetOrderBookAsync("ETH-USDT", default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetBookTickerAsync(default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, default, default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetMarkPriceKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 100, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetTickerAsync("ETH-USDT", default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetTickersAsync(default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetLastTradesAsync("ETH-USDT", default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetRecentTradesAsync("ETH-USDT", 10, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetOpenInterestHistoryAsync(Enums.InterestPeriod.OneDay, Enums.Unit.Cont, "ETH-USDT", default ,default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetPremiumIndexKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetEstimatedFundingRateKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetBasisDataAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10 , default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginTradeStatusAsync("ETH-USDT", default ,default, default, default), false); + await RunAndCheckResult(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginTransferStatusAsync("USDT", default), false); + } + + [Test] + public async Task TestUsdtFuturesApiTrading() + { + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenOrdersAsync("ETH-USDT", default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenOrdersAsync("ETH-USDT", default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginClosedOrdersAsync("ETH-USDT", Enums.MarginTradeType.BuyShort, true, new[] { OrderStatusFilter.Canceled }, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginClosedOrdersAsync("ETH-USDT", Enums.MarginTradeType.BuyShort, true, new[] { OrderStatusFilter.Canceled }, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginUserTradesAsync("ETH-USDT", Enums.MarginTradeType.BuyShort, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginUserTradesAsync("ETH-USDT", Enums.MarginTradeType.BuyShort, default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenTriggerOrdersAsync("ETH-USDT", default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenTriggerOrdersAsync("ETH-USDT", default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginTriggerOrderHistoryAsync("ETH-USDT", MarginTradeType.BuyLong, 90, OrderStatusFilter.FullyMatched, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginTriggerOrderHistoryAsync(MarginTradeType.BuyLong, 90, OrderStatusFilter.FullyMatched, "ETH-USDT", default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenTpSlOrdersAsync("ETH-USDT", default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenTpSlOrdersAsync("ETH-USDT", default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginTpSlHistoryAsync("ETH-USDT", new[] { TpSlStatus.Canceled }, 90, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetCrossMarginTpSlHistoryAsync(new[] { TpSlStatus.Canceled }, 90, "ETH-USDT", default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetOpenIsolatedMarginTrailingOrdersAsync("ETH-USDT", MarginTradeType.BuyLong, 90, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetOpenCrossMarginTrailingOrdersAsync("ETH-USDT", default, default, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetClosedIsolatedMarginTrailingOrdersAsync("ETH-USDT", new[] { TpSlStatus.Canceled }, MarginTradeType.BuyLong, 90, default, default, default, default), true); + await RunAndCheckResult(client => client.UsdtFuturesApi.Trading.GetClosedCrossMarginTrailingOrdersAsync(new[] { TpSlStatus.Canceled }, MarginTradeType.BuyLong, 90, "ETH-USDT", default, default, default, default, default, default), true); + } + } +} diff --git a/HTX.Net.UnitTests/HTXSocketClientTests.cs b/HTX.Net.UnitTests/HTXSocketClientTests.cs new file mode 100644 index 00000000..b42f8666 --- /dev/null +++ b/HTX.Net.UnitTests/HTXSocketClientTests.cs @@ -0,0 +1,123 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using HTX.Net.UnitTests.TestImplementations; +using NUnit.Framework; +using NUnit.Framework.Legacy; +using System.Text.Json; + +namespace HTX.Net.UnitTests +{ + [TestFixture] + public class HTXSocketClientTests + { + [Test] + public void SubscribeV1_Should_SucceedIfSubbedResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateSocketClient(socket); + + // act + var subTask = client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); + var id = JsonDocument.Parse(socket.LastSendMessage).RootElement.GetProperty("id").GetString(); + socket.InvokeMessage($"{{\"subbed\": \"test\", \"id\":\"{id}\", \"status\": \"ok\"}}"); + var subResult = subTask.Result; + + // assert + Assert.That(subResult.Success); + } + + [Test] + public async Task SubscribeV1_Should_FailIfNoResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateSocketClient(socket, x => + { + x.RequestTimeout = TimeSpan.FromMilliseconds(10); + }); + + // act + var subResult = await client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); + + // assert + ClassicAssert.IsFalse(subResult.Success); + } + + [Test] + public void SubscribeV1_Should_FailIfErrorResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateSocketClient(socket); + + // act + var subTask = client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); + var id = JsonDocument.Parse(socket.LastSendMessage).RootElement.GetProperty("id").GetString(); + socket.InvokeMessage($"{{\"status\": \"error\", \"id\": \"{id}\", \"err-code\": \"Fail\", \"err-msg\": \"failed\"}}"); + var subResult = subTask.Result; + + // assert + ClassicAssert.IsFalse(subResult.Success); + } + + [Test] + public void SubscribeV2_Should_SucceedIfSubbedResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateAuthenticatedSocketClient(socket); + + // act + var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); + socket.InvokeMessage("{\"action\": \"req\", \"code\": 200, \"ch\": \"auth\"}"); + Thread.Sleep(10); + socket.InvokeMessage("{\"action\": \"sub\", \"code\": 200, \"ch\": \"accounts.update#1\"}"); + var subResult = subTask.Result; + + // assert + Assert.That(subResult.Success); + } + + [Test] + public void SubscribeV2_Should_FailIfAuthErrorResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateSocketClient(socket); + + // act + var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); + socket.InvokeMessage("{ \"action\": \"req\", \"ch\": \"auth\", \"code\": 400}"); + var subResult = subTask.Result; + + // assert + ClassicAssert.IsFalse(subResult.Success); + } + + [Test] + public void SubscribeV2_Should_FailIfNoResponse() + { + // arrange + var socket = new TestSocket(); + socket.CanConnect = true; + var client = TestHelpers.CreateSocketClient(socket, x => + { + x.RequestTimeout = TimeSpan.FromMilliseconds(10); + }); + + // act + var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); + var subResult = subTask.Result; + + // assert + ClassicAssert.IsFalse(subResult.Success); + } + } +} diff --git a/HTX.Net.UnitTests/RestRequestTests.cs b/HTX.Net.UnitTests/RestRequestTests.cs new file mode 100644 index 00000000..ac734ebe --- /dev/null +++ b/HTX.Net.UnitTests/RestRequestTests.cs @@ -0,0 +1,333 @@ +using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Testing; +using HTX.Net.Clients; +using HTX.Net.Objects.Models; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace HTX.Net.UnitTests +{ + [TestFixture] + public class RestRequestTests + { + [Test] + public async Task ValidateSpotAccountCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/Spot/Account", "https://api.huobi.pro", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetAccountsAsync(), "GetAccounts"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetBalancesAsync(1), "GetBalances", "data.list", ignoreProperties: new List { "debt", "available" }); + await tester.ValidateAsync(client => client.SpotApi.Account.GetPlatformValuationAsync(), "GetPlatformValuation"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetAssetValuationAsync(Enums.AccountType.Spot), "GetAssetValuation"); + await tester.ValidateAsync(client => client.SpotApi.Account.InternalTransferAsync(1, Enums.AccountType.Spot, 2, 3, Enums.AccountType.Spot, 4, "ETH", 1), "InternalTransfer"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetAccountHistoryAsync(1), "GetAccountHistory"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetAccountLedgerAsync(1), "GetAccountLedger"); + await tester.ValidateAsync(client => client.SpotApi.Account.TransferAsync(Enums.TransferAccount.Spot, Enums.TransferAccount.Futures, "ETH", 1, "ETH"), "Transfer"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetPointBalanceAsync(), "GetPointBalance"); + await tester.ValidateAsync(client => client.SpotApi.Account.TransferPointsAsync("1", "2", "3", 1), "TransferPoints"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetUserDeductionInfoAsync(), "GetUserDeductionInfo"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetDeductAssetsAsync(), "GetDeductAssets"); + await tester.ValidateAsync(client => client.SpotApi.Account.SetDeductionSwitchAsync(Enums.DeductionSwitchType.AssetDeduction), "SetDeductionSwitch"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetDepositAddressesAsync("ETH"), "GetDepositAddresses"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetWithdrawalQuotasAsync("ETH"), "GetWithdrawalQuotas"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetWithdrawalAddressesAsync("ETH"), "GetWithdrawalAddresses"); + await tester.ValidateAsync(client => client.SpotApi.Account.WithdrawAsync("123", "ETH", 1, 1), "Withdraw"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetWithdrawalByClientOrderIdAsync("123"), "GetWithdrawalByClientOrderId"); + await tester.ValidateAsync(client => client.SpotApi.Account.CancelWithdrawalAsync(1), "CancelWithdrawal"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetWithdrawDepositHistoryAsync(Enums.WithdrawDepositType.Withdraw), "GetWithdrawDeposit"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetTradingFeesAsync(new[] { "ETHUSDT" }), "GetTradingFees"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetApiKeyInfoAsync(1), "GetApiKeyInfo"); + await tester.ValidateAsync(client => client.SpotApi.Account.GetUserIdAsync(), "GetUserId"); + } + + [Test] + public async Task ValidateSpotExchangeDataCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/Spot/ExchangeData", "https://api.huobi.pro", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetSymbolStatusAsync(), "GetSymbolStatus"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetSymbolsAsync(), "GetSymbols", ignoreProperties: new List { "p" }); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetAssetsAsync(), "GetAssets"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetSymbolConfigAsync(), "GetSymbolConfig"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetAssetsAndNetworksAsync("ETH"), "GetAssetsAndNetworks"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetKlinesAsync("ETHUSDT", Enums.KlineInterval.OneDay), "GetKlines"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT"), "GetTicker", nestedJsonProperty: "tick"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetTickersAsync(), "GetTickers"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetOrderBookAsync("ETHUSDT", 0), "GetOrderBook", nestedJsonProperty: "tick"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetLastTradeAsync("ETHUSDT"), "GetLastTrade", nestedJsonProperty: "tick"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetTradeHistoryAsync("ETHUSDT"), "GetTradeHistory"); + await tester.ValidateAsync(client => client.SpotApi.ExchangeData.GetSymbolDetails24HAsync("ETHUSDT"), "GetSymbolDetails24H", nestedJsonProperty: "tick"); + } + + [Test] + public async Task ValidateSpotMarginCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/Spot/Margin", "https://api.huobi.pro", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.SpotApi.Margin.RepayLoanAsync("123", "ETH", 1), "RepayLoan"); + await tester.ValidateAsync(client => client.SpotApi.Margin.TransferSpotToIsolatedMarginAsync("123", "ETH", 1), "TransferSpotToIsolatedMargin"); + await tester.ValidateAsync(client => client.SpotApi.Margin.TransferIsolatedMarginToSpotAsync("123", "ETH", 1), "TransferIsolatedMarginToSpot"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetIsolatedLoanInterestRateAndQuotaAsync(), "GetIsolatedLoanInterestRateAndQuota"); + await tester.ValidateAsync(client => client.SpotApi.Margin.RequestIsolatedMarginLoanAsync("ETHUSDT", "ETH", 1), "RequestIsolatedMarginLoan"); + await tester.ValidateAsync(client => client.SpotApi.Margin.RepayIsolatedMarginLoanAsync("123", 1), "RepayIsolatedMarginLoan"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetIsolatedMarginClosedOrdersAsync("123"), "GetIsolatedMarginClosedOrders"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetIsolatedMarginBalanceAsync("ETHUSDT"), "GetIsolatedMarginBalance"); + await tester.ValidateAsync(client => client.SpotApi.Margin.TransferSpotToCrossMarginAsync("ETH", 1), "TransferSpotToCrossMargin"); + await tester.ValidateAsync(client => client.SpotApi.Margin.TransferCrossMarginToSpotAsync("ETH", 1), "TransferCrossMarginToSpot"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetCrossLoanInterestRateAndQuotaAsync(), "GetCrossLoanInterestRateAndQuota"); + await tester.ValidateAsync(client => client.SpotApi.Margin.RequestCrossMarginLoanAsync("ETH", 1), "RequestCrossMarginLoan"); + await tester.ValidateAsync(client => client.SpotApi.Margin.RepayCrossMarginLoanAsync("123", 1), "RepayCrossMarginLoan"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetCrossMarginClosedOrdersAsync(), "GetCrossMarginClosedOrders"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetCrossMarginBalanceAsync(), "GetCrossMarginBalance"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetCrossMarginLimitAsync(), "GetCrossMarginLimit"); + await tester.ValidateAsync(client => client.SpotApi.Margin.GetRepaymentHistoryAsync(), "GetRepaymentHistory"); + } + + [Test] + public async Task ValidateSpotSubAccountCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/Spot/SubAccount", "https://api.huobi.pro", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.SetDeductModeAsync(new[] { "1" }, Enums.DeductMode.Sub), "SetDeductMode"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.CreateSubAccountsAsync(new[] { new HTXSubAccountRequest { UserName = "123" } }), "CreateSubAccounts"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetSubUserListAsync(), "GetSubUserList"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.SetLockAsync(1, Enums.LockAction.Normal), "SetLock"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetSubUserAsync(1), "GetSubUser"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.SetTradableMarketAsync(new[] { "1" }, Enums.SubAccountMarketType.IsolatedMargin, true), "SetTradableMarket"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.SetAssetTransferPermissionsAsync(new[] { "1" }, true), "SetAssetTransferPermissions"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetSubUserAccountsAsync(1), "GetSubUserAccounts"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.CreateApiKeyAsync("1", 1, "123", new[] { "" }, new[] { "" }), "CreateApiKey"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.EditApiKeyAsync(1, "123", "123", new[] {""}, new[] {""}), "EditApiKey"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.DeleteApiKeyAsync(1, "123"), "DeleteApiKey"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.TransferWithSubAccountAsync(1, "ETH", 1, Enums.TransferType.PointFromSubAccount), "TransferWithSubAccount"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetDepositAddressAsync(1, "ETH"), "GetDepositAddress"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetDepositHistoryAsync(1, "ETH"), "GetDepositHistory"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetAggregateBalancesAsync(), "GetAggregateBalances"); + await tester.ValidateAsync(client => client.SpotApi.SubAccount.GetBalancesAsync(1), "GetBalances", ignoreProperties: new List { "debt", "available" }); + } + + [Test] + public async Task ValidateSpotTradingCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/Spot/Trading", "https://api.huobi.pro", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.SpotApi.Trading.PlaceOrderAsync(1, "ETHUSDT", Enums.OrderSide.Buy, Enums.OrderType.IOC, 1), "PlaceOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.PlaceMultipleOrderAsync(new [] { new HTXOrderRequest { } }), "PlaceMultipleOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.PlaceMarginOrderAsync(1, "ETHUSDT", Enums.OrderSide.Buy, Enums.OrderType.IOC, Enums.MarginPurpose.AutomaticLoan, Enums.SourceType.C2CMargin), "PlaceMarginOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrderAsync(1), "CancelOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrderByClientOrderIdAsync("1"), "CancelOrderByClientOrderId"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetOpenOrdersAsync(), "GetOpenOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrdersByCriteriaAsync(), "CancelOrdersByCriteria"); + await tester.ValidateAsync(client => client.SpotApi.Trading.CancelOrdersAsync(new[] { 1L } ), "CancelOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetOrderAsync(1), "GetOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetOrderByClientOrderIdAsync("1"), "GetOrderByClientOrderId"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetOrderTradesAsync(1), "GetOrderTrades"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetClosedOrdersAsync("ETHUSDT"), "GetClosedOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetHistoricalOrdersAsync("ETHUSDT"), "GetHistoricalOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetUserTradesAsync("ETHUSDT"), "GetUserTrades"); + await tester.ValidateAsync(client => client.SpotApi.Trading.PlaceConditionalOrderAsync(1, "ETHUSDT", Enums.OrderSide.Buy, Enums.ConditionalOrderType.Market, 1), "PlaceConditionalOrder"); + await tester.ValidateAsync(client => client.SpotApi.Trading.CancelConditionalOrdersAsync(new[] { "1" }), "CancelConditionalOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetOpenConditionalOrdersAsync(), "GetOpenConditionalOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetClosedConditionalOrdersAsync("ETHUSDT", Enums.ConditionalOrderStatus.Created), "GetClosedConditionalOrders"); + await tester.ValidateAsync(client => client.SpotApi.Trading.GetConditionalOrderAsync("1"), "GetConditionalOrder"); + } + + [Test] + public async Task ValidateUsdtMarginSwapAccountCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/UsdtMarginSwap/Account", "https://api.hbdm.com", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetAssetValuationAsync(), "GetAssetValuation"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAccountInfoAsync(), "GetIsolatedMarginAccountInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginAccountInfoAsync(), "GetCrossMarginAccountInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginPositionsAsync(), "GetIsolatedMarginPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginPositionsAsync(), "GetCrossMarginPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAssetsAndPositionsAsync("ETH-USDT"), "GetIsolatedMarginAssetsAndPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginAssetsAndPositionsAsync("ETH-USDT"), "GetCrossMarginAssetsAndPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetFinancialRecordsAsync("ETH-USDT"), "GetFinancialRecords"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginAvailableLeverageAsync("ETH-USDT"), "GetIsolatedMarginAvailableLeverage"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginAvailableLeverageAsync("ETH-USDT"), "GetCrossMarginAvailableLeverage"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetOrderLimitsAsync(Enums.OrderPriceType.PostOnly), "GetOrderLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetTradingFeesAsync(), "GetTradingFees"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginTransferLimitsAsync(), "GetIsolatedMarginTransferLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginTransferLimitsAsync(), "GetCrossMarginTransferLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginPositionLimitAsync("ETH-USDT"), "GetIsolatedMarginPositionLimit"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginPositionLimitsAsync("ETH-USDT"), "GetCrossMarginPositionLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginLeveragePositionLimitsAsync("ETH-USDT"), "GetIsolatedMarginLeveragePositionLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginLeveragePositionLimitsAsync(Enums.BusinessType.Futures), "GetCrossMarginLeveragePositionLimits"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.TransferMarginAccountsAsync("ETH", "123", "123", 1), "TransferMarginAccounts"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetTradingStatusAsync(), "GetTradingStatus"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.SetIsolatedMarginPositionModeAsync("ETH-USDT", Enums.PositionMode.SingleSide), "SetIsolatedMarginPositionMode"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.SetCrossMarginPositionModeAsync("ETH-USDT", Enums.PositionMode.SingleSide), "SetCrossMarginPositionMode"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginPositionModeAsync("ETH-USDT"), "GetIsolatedMarginPositionMode"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginPositionModeAsync("ETH-USDT"), "GetCrossMarginPositionMode"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetIsolatedMarginSettlementRecordsAsync("ETH-USDT"), "GetIsolatedMarginSettlementRecords"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Account.GetCrossMarginSettlementRecordsAsync("ETH-USDT"), "GetCrossMarginSettlementRecords"); + } + + [Test] + public async Task ValidateUsdtMarginSwapExchangeDataCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/UsdtMarginSwap/ExchangeData", "https://api.hbdm.com", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetFundingRateAsync("ETH-USDT"), "GetFundingRate"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetFundingRatesAsync(), "GetFundingRates"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetHistoricalFundingRatesAsync("ETH-USDT"), "GetHistoricalFundingRates"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetLiquidationOrdersAsync("ETH-USDT", Enums.LiquidationTradeType.FullyFilledLiquidationOrders), "GetLiquidationOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetHistoricalSettlementRecordsAsync("ETH-USDT"), "GetHistoricalSettlementRecords"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetTopTraderAccountSentimentAsync("ETH-USDT", Enums.Period.OneDay), "GetTopTraderAccountSentiment"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetTopTraderPositionSentimentAsync("ETH-USDT", Enums.Period.OneDay), "GetTopTraderPositionSentiment"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginStatusAsync("ETH-USDT"), "GetIsolatedMarginStatus"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetCrossTieredMarginInfoAsync("ETH-USDT"), "GetCrossTieredMarginInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginTieredInfoAsync("ETH-USDT"), "GetIsolatedMarginTieredInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetEstimatedSettlementPriceAsync("ETH-USDT"), "GetEstimatedSettlementPrice"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetIsolatedMarginAdjustFactorInfoAsync("ETH-USDT"), "GetIsolatedMarginAdjustFactorInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginAdjustFactorInfoAsync("ETH-USDT"), "GetCrossMarginAdjustFactorInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetInsuranceFundHistoryAsync("ETH-USDT"), "GetInsuranceFundHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetSwapRiskInfoAsync("ETH-USDT"), "GetSwapRiskInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetSwapPriceLimitationAsync("ETH-USDT"), "GetSwapPriceLimitation"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetSwapOpenInterestAsync("ETH-USDT"), "GetSwapOpenInterest"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetContractsAsync("ETH-USDT"), "GetContractInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetSwapIndexPriceAsync("ETH-USDT"), "GetSwapIndexPrice"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetContractElementsAsync("ETH-USDT"), "GetContractElements"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetOrderBookAsync("ETH-USDT"), "GetOrderBook", nestedJsonProperty: "tick", ignoreProperties: new List { "ch", "id", "mrid" }); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetBookTickerAsync("ETH-USDT"), "GetBookTicker", nestedJsonProperty: "ticks"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay), "GetKlines"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetMarkPriceKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10), "GetMarkPriceKlines"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetTickerAsync("ETH-USDT"), "GetTicker", nestedJsonProperty: "tick"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetTickersAsync("ETH-USDT"), "GetTickers", nestedJsonProperty: "ticks"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetLastTradesAsync("ETH-USDT"), "GetLastTrades", nestedJsonProperty: "tick.data.0"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetRecentTradesAsync("ETH-USDT", 10), "GetRecentTrades", "data.0.data"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetOpenInterestHistoryAsync(Enums.InterestPeriod.OneDay, Enums.Unit.Cont), "GetOpenInterestHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetPremiumIndexKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10), "GetPremiumIndexKlines"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetEstimatedFundingRateKlinesAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10), "GetEstimatedFundingRateKlines"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetBasisDataAsync("ETH-USDT", Enums.KlineInterval.OneDay, 10), "GetBasisData"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginTradeStatusAsync("ETH-USDT"), "GetCrossMarginTradeStatus"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.ExchangeData.GetCrossMarginTransferStatusAsync("ETH-USDT"), "GetCrossMarginTransferStatus"); + } + + [Test] + public async Task ValidateUsdtMarginSwapSubAccountCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/UsdtMarginSwap/SubAccount", "https://api.hbdm.com", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.SetTradingPermissionsAsync(new[] { "1" }, true), "SetTradingPermissions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetTradePermissionsAsync(new[] { "1" }), "GetTradePermissions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetIsolatedMarginAssetsAsync(), "GetIsolatedMarginAssets"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetCrossMarginAssetsAsync(), "GetCrossMarginAssets"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetIsolatedMarginAssetInfoAsync(), "GetIsolatedMarginAssetInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetCrossMarginAssetInfoAsync(), "GetCrossMarginAssetInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetIsolatedMarginPositionsAsync(1), "GetIsolatedMarginPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetCrossMarginPositionsAsync(1), "GetCrossMarginPositions"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.TransferMasterSubAsync("1", "ETH", "1", "2", 1, Enums.MasterSubTransferType.MasterToSub), "TransferMasterSub"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.SubAccount.GetMasterSubTransferRecordsAsync("1", 90), "GetMasterSubTransferRecords"); + } + + [Test] + public async Task ValidateUsdtMarginSwapTradingCalls() + { + var client = new HTXRestClient(opts => + { + opts.AutoTimestamp = false; + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new RestRequestValidator(client, "Endpoints/UsdtMarginSwap/Trading", "https://api.hbdm.com", IsAuthenticated, stjCompare: true, nestedPropertyForCompare: "data"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelOrdersAfterAsync(true, TimeSpan.FromSeconds(10)), "CancelOrdersAfter"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceIsolatedMarginOrderAsync("ETH-USDT", 1, Enums.OrderSide.Buy, 1, Enums.OrderPriceType.Limit), "PlaceIsolatedMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceCrossMarginOrderAsync(1, Enums.OrderSide.Sell, 1, Enums.OrderPriceType.Limit), "PlaceCrossMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelIsolatedMarginOrderAsync("ETH-USDT", 1), "CancelIsolatedMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelCrossMarginOrderAsync(1), "CancelCrossMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelIsolatedMarginOrdersAsync("ETH-USDT", new[] { 1L }, new[] { 1L }), "CancelIsolatedMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelCrossMarginOrdersAsync(new[] { 1L }, new[] { 1L }), "CancelCrossMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllIsolatedMarginOrdersAsync("ETH-USDT"), "CancelAllIsolatedMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllCrossMarginOrdersAsync("ETH-USDT"), "CancelAllCrossMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.SetIsolatedMarginLeverageAsync("ETH-USDT", 1), "SetIsolatedMarginLeverage"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.SetCrossMarginLeverageAsync(1), "SetCrossMarginLeverage"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOrderAsync("ETH-USDT"), "GetIsolatedMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOrderAsync("ETH-USDT"), "GetCrossMarginOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOrdersAsync("ETH-USDT", new[] { 1L }, new[] { 1L }), "GetIsolatedMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOrdersAsync(new[] { 1L }, new[] { 1L }), "GetCrossMarginOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOrderDetailsAsync("ETH-USDT", 1), "GetIsolatedMarginOrderDetails", ignoreProperties: new List { "price" }); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOrderDetailsAsync("ETH-USDT", 1), "GetCrossMarginOrderDetails", ignoreProperties: new List { "price" }); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenOrdersAsync("ETH-USDT", 1), "GetIsolatedMarginOpenOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenOrdersAsync("ETH-USDT"), "GetCrossMarginOpenOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginClosedOrdersAsync("ETH-USDT", Enums.MarginTradeType.LiquidateShort, true, new[] { Enums.OrderStatusFilter.Canceled }), "GetIsolatedMarginClosedOrders", ignoreProperties: new List { "query_id" }); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginClosedOrdersAsync("ETH-USDT", Enums.MarginTradeType.LiquidateShort, true, new[] { Enums.OrderStatusFilter.Canceled }), "GetCrossMarginClosedOrders", ignoreProperties: new List { "query_id" }); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginUserTradesAsync("ETH-USDT", Enums.MarginTradeType.LiquidateShort), "GetIsolatedMarginUserTrades"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginUserTradesAsync("ETH-USDT", Enums.MarginTradeType.LiquidateShort), "GetCrossMarginUserTrades"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CloseIsolatedMarginPositionAsync("ETH-USDT", Enums.OrderSide.Sell), "CloseIsolatedMarginPosition"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CloseCrossMarginPositionAsync(Enums.OrderSide.Sell), "CloseCrossMarginPosition"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceIsolatedMarginTriggerOrderAsync("ETH-USDT", Enums.TriggerType.LesserThanOrEqual, 1, 1, Enums.OrderSide.Buy), "PlaceIsolatedMarginTriggerOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceCrossMarginTriggerOrderAsync(Enums.TriggerType.LesserThanOrEqual, 1, 1, Enums.OrderSide.Buy), "PlaceCrossMarginTriggerOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelIsolatedMarginTriggerOrderAsync("ETH-USDT", "1"), "CancelIsolatedMarginTriggerOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelCrossMarginTriggerOrderAsync("1"), "CancelCrossMarginTriggerOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllIsolatedMarginTriggerOrdersAsync("ETH-USDT"), "CancelAllIsolatedMarginTriggerOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllCrossMarginTriggerOrdersAsync("ETH-USDT"), "CancelAllCrossMarginTriggerOrdersAsync"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenTriggerOrdersAsync("ETH-USDT"), "GetIsolatedMarginOpenTriggerOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenTriggerOrdersAsync("ETH-USDT"), "GetCrossMarginOpenTriggerOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginTriggerOrderHistoryAsync("ETH-USDT", Enums.MarginTradeType.BuyShort, 90, Enums.OrderStatusFilter.FullyMatched), "GetIsolatedMarginTriggerOrderHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginTriggerOrderHistoryAsync(Enums.MarginTradeType.BuyShort, 90, Enums.OrderStatusFilter.FullyMatched), "GetCrossMarginTriggerOrderHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.SetIsolatedMarginTpSlAsync("ETH-USDT", Enums.OrderSide.Sell, 1), "SetIsolatedMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.SetCrossMarginTpSlAsync(Enums.OrderSide.Sell, 1), "SetCrossMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelIsolatedMarginTpSlAsync("ETH-USDT", "1"), "CancelIsolatedMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelCrossMarginTpSlAsync("1"), "CancelCrossMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllIsolatedMarginTpSlAsync("ETH-USDT"), "CancelAllIsolatedMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllCrossMarginTpSlAsync("ETH-USDT"), "CancelAllCrossMarginTpSl"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginOpenTpSlOrdersAsync("ETH-USDT"), "GetIsolatedMarginOpenTpSlOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginOpenTpSlOrdersAsync("ETH-USDT"), "GetCrossMarginOpenTpSlOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginTpSlHistoryAsync("ETH-USDT", new[] { Enums.TpSlStatus.Canceled }, 90), "GetIsolatedMarginTpSlHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginTpSlHistoryAsync(new[] { Enums.TpSlStatus.Canceled }, 90), "GetCrossMarginTpSlHistory"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetIsolatedMarginPositionOpenTpSlInfoAsync("ETH-UST", 1), "GetIsolatedMarginPositionOpenTpSlInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetCrossMarginPositionOpenTpSlInfoAsync(1), "GetCrossMarginPositionOpenTpSlInfo"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceIsolatedMarginTrailingOrderAsync("ETH-USDT", false, Enums.OrderSide.Sell, Enums.Offset.Open, 1, 1, 1, 1, Enums.OrderPriceType.Limit), "PlaceIsolatedMarginTrailingOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.PlaceCrossMarginTrailingOrderAsync(Enums.OrderSide.Sell, Enums.Offset.Open, 1, 1, 1, 1, Enums.OrderPriceType.Limit), "PlaceCrossMarginTrailingOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelIsolatedMarginTrailingOrderAsync("ETH-USDT", "1"), "CancelIsolatedMarginTrailingOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelCrossMarginTrailingOrderAsync("1"), "CancelCrossMarginTrailingOrder"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllIsolatedMarginTrailingOrdersAsync("ETH-USDT"), "CancelAllIsolatedMarginTrailingOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.CancelAllCrossMarginTrailingOrdersAsync("ETH-USDT"), "CancelAllCrossMarginTrailingOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetOpenIsolatedMarginTrailingOrdersAsync("ETH-USDT"), "GetOpenIsolatedMarginTrailingOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetOpenCrossMarginTrailingOrdersAsync("ETH-USDT"), "GetOpenCrossMarginTrailingOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetClosedIsolatedMarginTrailingOrdersAsync("ETH-USDT", new[] { Enums.TpSlStatus.Canceled }, Enums.MarginTradeType.BuyShort, 90), "GetClosedIsolatedMarginTrailingOrders"); + await tester.ValidateAsync(client => client.UsdtFuturesApi.Trading.GetClosedCrossMarginTrailingOrdersAsync(new[] { Enums.TpSlStatus.Canceled }, Enums.MarginTradeType.BuyShort, 90), "GetClosedCrossMarginTrailingOrders"); + } + + private bool IsAuthenticated(WebCallResult result) + { + return result.RequestUrl.Contains("Signature"); + } + } +} diff --git a/HTX.Net.UnitTests/SocketSubscriptionTests.cs b/HTX.Net.UnitTests/SocketSubscriptionTests.cs new file mode 100644 index 00000000..a595f099 --- /dev/null +++ b/HTX.Net.UnitTests/SocketSubscriptionTests.cs @@ -0,0 +1,71 @@ +using HTX.Net.Clients; +using CryptoExchange.Net.Testing; +using NUnit.Framework; +using System.Threading.Tasks; +using HTX.Net.Objects.Models; +using System.Collections.Generic; +using HTX.Net.Objects.Models.Socket; + +namespace HTX.Net.UnitTests +{ + [TestFixture] + public class SocketSubscriptionTests + { + [Test] + public async Task ValidateSpotSubscriptions() + { + var client = new HTXSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/Spot", "wss://api.huobi.pro", "data", stjCompare: true); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToKlineUpdatesAsync("ETHUSDT", Enums.KlineInterval.OneDay, handler), "Klines", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHUSDT", 0, handler), "OrderBook", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToPartialOrderBookUpdates100MilisecondAsync("ETHUSDT", 20, handler), "OrderBookMbp", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToOrderBookChangeUpdatesAsync("ETHUSDT", 5, handler), "OrderBookChange", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToTradeUpdatesAsync("ETHUSDT", handler), "Trades", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToSymbolDetailUpdatesAsync("ETHUSDT", handler), "Symbols", nestedJsonProperty: "tick"); + await tester.ValidateAsync>((client, handler) => client.SpotApi.SubscribeToTickerUpdatesAsync(handler), "Tickers", nestedJsonProperty: "data"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", handler), "Ticker", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToBookTickerUpdatesAsync("ETHUSDT", handler), "BookTicker", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToOrderUpdatesAsync(null, handler), "Order1", nestedJsonProperty: "data"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToAccountUpdatesAsync(handler, null), "Account", nestedJsonProperty: "data"); + await tester.ValidateAsync((client, handler) => client.SpotApi.SubscribeToOrderDetailsUpdatesAsync(null, handler), "OrderTrade", nestedJsonProperty: "data"); + } + + [Test] + public async Task ValidateUsdtMarginSwapSubscriptions() + { + var client = new HTXSocketClient(opts => + { + opts.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "456"); + }); + var tester = new SocketSubscriptionValidator(client, "Subscriptions/UsdtMarginSwap", "wss://api.huobi.pro", stjCompare: true); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToKlineUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, handler), "Klines", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToOrderBookUpdatesAsync("ETH-USDT", 0, handler), "OrderBook", nestedJsonProperty: "tick", ignoreProperties: new List { "ch", "ts" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIncrementalOrderBookUpdatesAsync("ETH-USDT", true, 20, handler), "OrderBookIncr", nestedJsonProperty: "tick", ignoreProperties: new List { "ch", "ts" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToTickerUpdatesAsync("ETH-USDT", handler), "Ticker", nestedJsonProperty: "tick"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToBookTickerUpdatesAsync("ETH-USDT", handler), "BookTicker", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToTradeUpdatesAsync("ETH-USDT", handler), "Trades", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIndexKlineUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, handler), "IndexKline", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToPremiumIndexKlineUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, handler), "PremiumKline", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToEstimatedFundingRateKlineUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, handler), "FundingKlines", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToBasisUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, "open", handler), "Basis", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToMarkPriceKlineUpdatesAsync("ETH-USDT", Enums.KlineInterval.OneDay, handler), "MarkKline", nestedJsonProperty: "tick", ignoreProperties: new List { "ch" }); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToLiquidationUpdatesAsync(handler), "Liquidation", nestedJsonProperty: "data"); + await tester.ValidateAsync>((client, handler) => client.UsdtFuturesApi.SubscribeToFundingRateUpdatesAsync(handler), "Funding", nestedJsonProperty: "data"); + await tester.ValidateAsync>((client, handler) => client.UsdtFuturesApi.SubscribeToContractUpdatesAsync(handler), "Contract", nestedJsonProperty: "data"); + await tester.ValidateAsync>((client, handler) => client.UsdtFuturesApi.SubscribeToContractElementsUpdatesAsync(handler), "ContractElements", nestedJsonProperty: "data"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToSystemStatusUpdatesAsync(handler), "Status"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToOrderUpdatesAsync(Enums.MarginMode.Isolated, handler), "Order"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIsolatedMarginBalanceUpdatesAsync(handler), "IsolatedBalance"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToCrossMarginBalanceUpdatesAsync(handler), "CrossBalance"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIsolatedMarginPositionUpdatesAsync(handler), "IsolatedPositions"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToCrossMarginPositionUpdatesAsync(handler), "CrossPositions"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIsolatedMarginUserTradeUpdatesAsync(handler), "IsolatedTrades"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToCrossMarginUserTradeUpdatesAsync(handler), "CrossTrades"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToIsolatedMarginTriggerOrderUpdatesAsync(handler), "IsolatedTrigger"); + await tester.ValidateAsync((client, handler) => client.UsdtFuturesApi.SubscribeToCrossMarginTriggerOrderUpdatesAsync(handler), "CrossTrigger"); + } + } +} diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Account.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Account.txt new file mode 100644 index 00000000..2f347922 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Account.txt @@ -0,0 +1,18 @@ +> { "action": "req", "ch": "auth", "params": { "authType":"api", "accessKey": "|1|", "signatureMethod": "HmacSHA256", "signatureVersion": "2.1", "timestamp": "|2|", "signature": "|3|" } } +< { "action": "req", "code": 200, "ch": "auth", "data": {} } +> { "action": "sub", "ch": "accounts.update#1" } +< { "action": "sub", "code": 200, "ch": "accounts.update#1", "data": {}} += +{ + "action": "push", + "ch": "accounts.update#1", + "data": { + "currency": "btc", + "accountId": 33385, + "available": "2028.699426619837209087", + "changeType": "order.match", + "accountType":"trade", + "seqNum": "86872993928", + "changeTime": 1574393385167 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/BookTicker.txt b/HTX.Net.UnitTests/Subscriptions/Spot/BookTicker.txt new file mode 100644 index 00000000..f76815ef --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/BookTicker.txt @@ -0,0 +1,16 @@ +> { "sub": "market.ethusdt.bbo", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.bbo", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.bbo", + "ts": 1630994555540, + "tick": { + "seqId": 137005210233, + "ask": 52665.02, + "askSize": 1.502181, + "bid": 52665.01, + "bidSize": 0.178567, + "quoteTime": 1630994555539, + "symbol": "btcusdt" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Klines.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Klines.txt new file mode 100644 index 00000000..01943b1e --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Klines.txt @@ -0,0 +1,17 @@ +> { "sub": "market.ethusdt.kline.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.kline.1day", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.kline.1day", + "ts": 1630981694370, + "tick": { + "id": 1630981680, + "open": 0.074849, + "close": 0.074848, + "low": 0.074848, + "high": 0.074849, + "amount": 2.4448, + "vol": 0.1829884187, + "count": 3 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Order1.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Order1.txt new file mode 100644 index 00000000..bb7e999a --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Order1.txt @@ -0,0 +1,24 @@ +> { "action": "req", "ch": "auth", "params": { "authType":"api", "accessKey": "|1|", "signatureMethod": "HmacSHA256", "signatureVersion": "2.1", "timestamp": "|2|", "signature": "|3|" } } +< { "action": "req", "code": 200, "ch": "auth", "data": {} } +> { "action": "sub", "ch": "orders#*" } +< { "action": "sub", "code": 200, "ch": "orders#*", "data": {}} += +{ + "action":"push", + "ch":"orders#*", + "data": + { + "orderSize":"2.000000000000000000", + "orderCreateTime":1583853365586, + "accountId":992701, + "orderPrice":"77.000000000000000000", + "type":"sell-limit", + "orderId":27163533, + "clientOrderId":"abc123", + "orderSource":"spot-api", + "orderStatus":"submitted", + "symbol":"btcusdt", + "eventType":"creation" + + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/OrderBook.txt b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBook.txt new file mode 100644 index 00000000..feae9a5e --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBook.txt @@ -0,0 +1,31 @@ +> { "sub": "market.ethusdt.depth.step0", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.depth.step0", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.depth.step0", + "ts": 1630983549503, + "tick": { + "bids": [ + [ + 52690.69, + 0.36281 + ], + [ + 52690.68, + 0.2 + ] + ], + "asks": [ + [ + 52690.7, + 0.372591 + ], + [ + 52691.26, + 0.13 + ] + ], + "version": 136998124622, + "ts": 1630983549500 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookChange.txt b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookChange.txt new file mode 100644 index 00000000..db9ccc69 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookChange.txt @@ -0,0 +1,17 @@ +> { "sub": "market.ethusdt.mbp.5", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.mbp.5", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.mbp.5", + "ts": 1573199608679, + "tick": { + "seqNum": 100020146795, + "prevSeqNum": 100020146794, + "asks": [ + [ + 645.14, + 26.75597395914065 + ] + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookMbp.txt b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookMbp.txt new file mode 100644 index 00000000..41fe6cd4 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/OrderBookMbp.txt @@ -0,0 +1,24 @@ +> { "sub": "market.ethusdt.mbp.refresh.20", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.mbp.refresh.20", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.mbp.refresh.20", + "ts": 1573199608679, + "tick": { + "seqNum": 100020142010, + "bids": [ + [618.37, 71.594], + [423.33, 77.726], + [223.18, 47.997], + [219.34, 24.82], + [210.34, 94.463] + ], + "asks": [ + [650.59, 14.909733438479636], + [650.63, 97.996], + [650.77, 97.465], + [651.23, 83.973], + [651.42, 34.465] + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/OrderTrade.txt b/HTX.Net.UnitTests/Subscriptions/Spot/OrderTrade.txt new file mode 100644 index 00000000..f0a76a11 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/OrderTrade.txt @@ -0,0 +1,30 @@ +> { "action": "req", "ch": "auth", "params": { "authType":"api", "accessKey": "|1|", "signatureMethod": "HmacSHA256", "signatureVersion": "2.1", "timestamp": "|2|", "signature": "|3|" } } +< { "action": "req", "code": 200, "ch": "auth", "data": {} } +> { "action": "sub", "ch": "trade.clearing#*#1" } +< { "action": "sub", "code": 200, "ch": "trade.clearing#*#1", "data": {}} += +{ + "ch": "trade.clearing#*#1", + "data": { + "eventType": "trade", + "symbol": "btcusdt", + "orderId": 99998888, + "tradePrice": "9999.99", + "tradeVolume": "0.96", + "orderSide": "buy", + "aggressor": true, + "tradeId": 919219323232, + "tradeTime": 998787897878, + "transactFee": "19.88", + "feeDeduct": "0", + "feeDeductType": "", + "feeCurrency": "btc", + "accountId": 9912791, + "source": "spot-api", + "orderPrice": "10000", + "orderSize": "1", + "clientOrderId": "a001", + "orderCreateTime": 998787897878, + "orderStatus": "partial-filled" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Symbols.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Symbols.txt new file mode 100644 index 00000000..789fe781 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Symbols.txt @@ -0,0 +1,18 @@ +> { "sub": "market.ethusdt.detail", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.detail", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.detail", + "ts": 1630998026649, + "tick": { + "id": 273956868110, + "low": 51000, + "high": 52924.14, + "open": 51823.62, + "close": 52379.99, + "vol": 727676440.200527, + "amount": 13991.028076056185, + "version": 273956868110, + "count": 471348 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Ticker.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Ticker.txt new file mode 100644 index 00000000..3770a682 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Ticker.txt @@ -0,0 +1,22 @@ +> { "sub": "market.ethusdt.ticker", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.ticker", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.ticker", + "ts": 1630982370526, + "tick": { + "open": 51732, + "high": 52785.64, + "low": 51000, + "close": 52735.63, + "amount": 13259.24137056181, + "vol": 687640987.4125315, + "count": 448737, + "bid": 52732.88, + "bidSize": 0.036, + "ask": 52732.89, + "askSize": 0.583653, + "lastPrice": 52735.63, + "lastSize": 0.03 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Tickers.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Tickers.txt new file mode 100644 index 00000000..89c6e72c --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Tickers.txt @@ -0,0 +1,4 @@ +> { "sub": "market.tickers", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.tickers", "ts": 1489474081631 } += +{"ch":"market.tickers","status":"ok","ts":1722857569936,"data":[{"symbol":"sylousdt","open":9.7E-4,"high":0.001055,"low":8.29E-4,"close":8.97E-4,"amount":6.033648738732E8,"vol":566666.2460002552,"count":12651}]} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/Spot/Trades.txt b/HTX.Net.UnitTests/Subscriptions/Spot/Trades.txt new file mode 100644 index 00000000..946f1eda --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/Spot/Trades.txt @@ -0,0 +1,21 @@ +> { "sub": "market.ethusdt.trade.detail", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ethusdt.trade.detail", "ts": 1489474081631 } += +{ + "ch": "market.ethusdt.trade.detail", + "ts": 1630994963175, + "tick": { + "id": 137005445109, + "ts": 1630994963173, + "data": [ + { + "id": 1.3700544510935929e+26, + "ts": 1630994963173, + "tradeId": 102523573486, + "amount": 0.006754, + "price": 52648.62, + "direction": "buy" + } + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Basis.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Basis.txt new file mode 100644 index 00000000..26272e06 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Basis.txt @@ -0,0 +1,14 @@ +> { "sub": "market.ETH-USDT.basis.1day.open", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.basis.1day.open", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.basis.1day.open", + "ts": 1617164081549, + "tick": { + "id": 1617164040, + "index_price": "58686.78333333333", + "contract_price": "58765", + "basis": "78.21666666667", + "basis_rate": "0.0013327816285723049700163397705562309" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/BookTicker.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/BookTicker.txt new file mode 100644 index 00000000..07b2914b --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/BookTicker.txt @@ -0,0 +1,22 @@ +> { "sub": "market.ETH-USDT.bbo", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.bbo", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.bbo", + "ts": 1603707934525, + "tick": { + "mrid": 131599726, + "id": 1603707934, + "bid": [ + 13064, + 38 + ], + "ask": [ + 13072.3, + 205 + ], + "ts": 1603707934525, + "version": 131599726, + "ch": "market.BTC-USDT.bbo" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Contract.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Contract.txt new file mode 100644 index 00000000..0f375d80 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Contract.txt @@ -0,0 +1,41 @@ +> { "op": "sub", "cid": "|1|", "topic": "public.*.contract_info" } +< { "op": "sub", "cid": "|1|", "topic": "public.*.contract_info", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "public.*.contract_info", + "ts": 1639122053894, + "event": "init", + "data": [ + { + "symbol": "MANA", + "contract_code": "MANA-USDT", + "contract_size": 10, + "price_tick": 0.0001, + "settlement_date": "1639123200000", + "create_date": "20210129", + "contract_status": 1, + "support_margin_mode": "all", + "delivery_time": "", + "contract_type": "swap", + "business_type": "swap", + "pair": "MANA-USDT", + "delivery_date": "" + }, + { + "symbol": "NKN", + "contract_code": "NKN-USDT", + "contract_size": 10, + "price_tick": 0.00001, + "settlement_date": "1639123200000", + "create_date": "20210810", + "contract_status": 1, + "support_margin_mode": "all", + "delivery_time": "", + "contract_type": "swap", + "business_type": "swap", + "pair": "NKN-USDT", + "delivery_date": "" + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/ContractElements.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/ContractElements.txt new file mode 100644 index 00000000..014573a1 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/ContractElements.txt @@ -0,0 +1,186 @@ +> { "op": "sub", "cid": "|1|", "topic": "public.*.contract_elements" } +< { "op": "sub", "cid": "|1|", "topic": "public.*.contract_elements", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "event": "init", + "topic": "public.*.contract_elements", + "ts": 1712804933421, + "data": [{ + "contract_code": "DOSE-USDT", + "funding_rate_cap": "0.007800000000000000", + "funding_rate_floor": "-0.007600000000000000", + "mode_type": 2, + "swap_delivery_type": 3, + "settle_period": 4, + "instrument_index_code": "DOSE-USDT", + "price_ticks": [ + { + "business_type": 2, + "price": "0.000010000000000000" + }, + { + "business_type": 1, + "price": "0.000000000100000000" + } + ], + "instrument_values": [ + { + "business_type": 2, + "price": "0.000010000000000000" + }, + { + "business_type": 1, + "price": "0.000010000000000000" + } + ], + "min_level": "1", + "max_level": "74", + "order_limits": [ + { + "open_after_closing": "500000000000.000000000000000000", + "instrument_type": 1, + "open": "500000000000.000000000000000000", + "close": "500000000000.000000000000000000" + }, + { + "open_after_closing": "500000000000.000000000000000000", + "instrument_type": 2, + "open": "500000000000.000000000000000000", + "close": "500000000000.000000000000000000" + }, + { + "open_after_closing": "500000000000.000000000000000000", + "instrument_type": 3, + "open": "500000000000.000000000000000000", + "close": "500000000000.000000000000000000" + }, + { + "open_after_closing": "500000000003.000000000000000000", + "instrument_type": 0, + "open": "500000000001.000000000000000000", + "close": "10005000000002.000000000000000000" + } + ], + "normal_limits": [ + { + "instrument_type": 1, + "open": "999999.910000000000000000", + "close": "999999.920000000000000000" + }, + { + "instrument_type": 2, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 3, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 0, + "open": "999999.910000000000000000", + "close": "999999.920000000000000000" + } + ], + "open_limits": [ + { + "instrument_type": 1, + "open": "999999.930000000000000000", + "close": "999999.940000000000000000" + }, + { + "instrument_type": 2, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 3, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 0, + "open": "999999.930000000000000000", + "close": "999999.940000000000000000" + } + ], + "trade_limits": [ + { + "instrument_type": 1, + "open": "999999.950000000000000000", + "close": "999999.960000000000000000" + }, + { + "instrument_type": 2, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 3, + "open": "999999.990000000000000000", + "close": "999999.990000000000000000" + }, + { + "instrument_type": 0, + "open": "999999.950000000000000000", + "close": "999999.960000000000000000" + } + ], + "real_time_settlement": 0, + "transfer_profit_ratio": 0, + "cross_transfer_profit_ratio": 1, + "instrument_type": [ + 1, + 2, + 3, + 0 + ], + "price_tick": "0.000000000100000000", + "instrument_value": "0.000010000000000000", + "trade_partition": "USDT", + "open_order_limit": "500000000001.000000000000000000", + "offset_order_limit": "10005000000002.000000000000000000", + "long_position_limit": "4000001.000000000000000000", + "short_position_limit": "4000002.000000000000000000", + "contract_infos": [ + { + "contract_code": "DOSE-USDT-231027", + "instrument_type": 1, + "settlement_date": "1694592000000", + "delivery_time": "1698393600000", + "create_date": "20231024", + "contract_status": 1, + "delivery_date": "20231027" + }, + { + "contract_code": "DOSE-USDT-231103", + "instrument_type": 2, + "settlement_date": "1694592000000", + "delivery_time": "1698998400000", + "create_date": "20231024", + "contract_status": 1, + "delivery_date": "20231103" + }, + { + "contract_code": "DOSE-USDT-231229", + "instrument_type": 3, + "settlement_date": "1694592000000", + "delivery_time": "1703836800000", + "create_date": "20231024", + "contract_status": 1, + "delivery_date": "20231229" + }, + { + "contract_code": "DOSE-USDT", + "instrument_type": 0, + "settlement_date": "1712822400000", + "delivery_time": "", + "create_date": "20231024", + "contract_status": 1, + "delivery_date": "" + } + ] + }] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossBalance.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossBalance.txt new file mode 100644 index 00000000..9cb5c62e --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossBalance.txt @@ -0,0 +1,60 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "accounts_cross.*" } +< { "op": "sub", "cid": "|4|", "topic": "accounts_cross.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "accounts_cross", + "ts": 1640756528985, + "event": "snapshot", + "data": [ + { + "margin_mode": "cross", + "margin_account": "USDT", + "margin_asset": "USDT", + "margin_balance": 20.603401615553835, + "margin_static": 20.475701615553835, + "margin_position": 19.30352, + "margin_frozen": 0, + "profit_real": -0.01911684, + "profit_unreal": 0.1277, + "withdraw_available": 1.1721816155538354, + "risk_rate": 25.68347743773394, + "position_mode": "dual_side", + "contract_detail": [ + { + "symbol": "BTC", + "contract_code": "BTC-USDT", + "margin_position": 9.55638, + "margin_frozen": 0, + "margin_available": 1.2998816155538353, + "profit_unreal": -0.0102, + "liquidation_price": 27790.709661740086, + "lever_rate": 5, + "adjust_factor": 0.04, + "contract_type": "swap", + "pair": "BTC-USDT", + "business_type": "swap" + } + ], + "futures_contract_detail": [ + { + "symbol": "BTC", + "contract_code": "BTC-USDT-220325", + "margin_position": 9.74714, + "margin_frozen": 0, + "margin_available": 1.2998816155538353, + "profit_unreal": 0.1379, + "liquidation_price": 28744.509661740085, + "lever_rate": 5, + "adjust_factor": 0.04, + "contract_type": "quarter", + "pair": "BTC-USDT", + "business_type": "futures" + } + ] + } + ], + "uid": "123456789" +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossPositions.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossPositions.txt new file mode 100644 index 00000000..acf12610 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossPositions.txt @@ -0,0 +1,38 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "positions_cross.*" } +< { "op": "sub", "cid": "|4|", "topic": "positions_cross.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "positions_cross", + "ts": 1639107468139, + "event": "order.match", + "data": [ + { + "contract_type": "swap", + "pair": "BTC-USDT", + "business_type": "swap", + "symbol": "BTC", + "contract_code": "BTC-USDT", + "volume": 1, + "available": 1, + "frozen": 0, + "cost_open": 48284.9, + "cost_hold": 48284.9, + "profit_unreal": -0.0001, + "profit_rate": -0.000010355204214985, + "profit": -0.0001, + "margin_asset": "USDT", + "position_margin": 9.65696, + "lever_rate": 5, + "direction": "buy", + "last_price": 48284.8, + "margin_mode": "cross", + "margin_account": "USDT", + "position_mode": "dual_side", + "adl_risk_percent": "3" + } + ], + "uid": "123456789" +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrades.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrades.txt new file mode 100644 index 00000000..ceea33c9 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrades.txt @@ -0,0 +1,45 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "matchOrders_cross.*" } +< { "op": "sub", "cid": "|4|", "topic": "matchOrders_cross.*", "ts": 1670903745088, "err-code": 0 } += +{ + "contract_type": "swap", + "pair": "BTC-USDT", + "business_type": "swap", + "op": "notify", + "topic": "matchOrders_cross", + "ts": 1639705640671, + "uid": "123456789", + "symbol": "BTC", + "contract_code": "BTC-USDT", + "status": 6, + "order_id": 921337601229725700, + "order_id_str": "921337601229725696", + "client_order_id": null, + "order_type": 1, + "volume": 1, + "trade_volume": 1, + "created_at": 1639705601752, + "direction": "sell", + "offset": "open", + "lever_rate": 5, + "price": 47800, + "order_source": "web", + "order_price_type": "limit", + "trade": [ + { + "trade_id": 87890603387, + "id": "87890603387-921337601229725696-1", + "trade_volume": 1, + "trade_price": 47800, + "trade_turnover": 47.8, + "created_at": 1639705640641, + "role": "maker" + } + ], + "margin_mode": "cross", + "margin_account": "USDT", + "is_tpsl": 1, + "reduce_only": 0 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrigger.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrigger.txt new file mode 100644 index 00000000..625fdf78 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/CrossTrigger.txt @@ -0,0 +1,45 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "trigger_order_cross.*" } +< { "op": "sub", "cid": "|4|", "topic": "trigger_order_cross.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "trigger_order_cross.*", + "ts": 1639123353369, + "event": "order", + "uid": "123456789", + "data": [ + { + "contract_type": "swap", + "pair": "BTC-USDT", + "business_type": "swap", + "symbol": "BTC", + "contract_code": "BTC-USDT", + "trigger_type": "le", + "volume": 1, + "order_type": 1, + "direction": "buy", + "offset": "open", + "lever_rate": 1, + "order_id": 918895474461802500, + "order_id_str": "918895474461802496", + "relation_order_id": "-1", + "order_price_type": "limit", + "status": 2, + "order_source": "api", + "trigger_price": 40000, + "triggered_price": null, + "order_price": 40000, + "created_at": 1639123353364, + "triggered_at": 0, + "order_insert_at": 0, + "canceled_at": 0, + "fail_code": null, + "fail_reason": null, + "margin_mode": "cross", + "margin_account": "USDT", + "reduce_only": 0 + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Funding.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Funding.txt new file mode 100644 index 00000000..e0509e4a --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Funding.txt @@ -0,0 +1,19 @@ +> { "op": "sub", "cid": "|1|", "topic": "public.*.funding_rate" } +< { "op": "sub", "cid": "|1|", "topic": "public.*.funding_rate", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "public.*.funding_rate", + "ts": 1603778748166, + "data": [ + { + "symbol": "BTC", + "contract_code": "BTC-USDT", + "fee_asset": "USDT", + "funding_time": "1603778700000", + "funding_rate": "-0.000220068774978695", + "settlement_time": "1603785600000", + "estimated_rate": null + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/FundingKlines.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/FundingKlines.txt new file mode 100644 index 00000000..ae858f38 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/FundingKlines.txt @@ -0,0 +1,18 @@ +> { "sub": "market.ETH-USDT.estimated_rate.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.estimated_rate.1day", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.estimated_rate.1day", + "ts": 1603708560233, + "tick": { + "id": 1603708560, + "open": "0.0001", + "close": "0.0001", + "high": "0.0001", + "low": "0.0001", + "amount": "0", + "vol": "0", + "count": "0", + "trade_turnover": "0" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IndexKline.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IndexKline.txt new file mode 100644 index 00000000..82fd3f7f --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IndexKline.txt @@ -0,0 +1,17 @@ +> { "sub": "market.ETH-USDT.index.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.index.1day", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.index.1day", + "ts": 1607309592214, + "tick": { + "id": 1607309100, + "open": "19213.505", + "close": "19242.05", + "high": "19248.31", + "low": "19213.505", + "amount": "0", + "vol": "0", + "count": 0 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedBalance.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedBalance.txt new file mode 100644 index 00000000..13c0c2fa --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedBalance.txt @@ -0,0 +1,34 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "accounts.*" } +< { "op": "sub", "cid": "|4|", "topic": "accounts.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "accounts", + "ts": 1603711370689, + "event": "order.open", + "data": [ + { + "symbol": "BTC", + "contract_code": "BTC-USDT", + "margin_balance": 79.72434662, + "margin_static": 79.79484662, + "margin_position": 1.31303, + "margin_frozen": 4.0662, + "margin_available": 74.34511662, + "profit_real": 0.03405608, + "profit_unreal": -0.0705, + "withdraw_available": 74.34511662, + "risk_rate": 14.745772976801513, + "liquidation_price": 92163.42096277916, + "lever_rate": 10, + "adjust_factor": 0.075, + "margin_asset": "USDT", + "margin_mode": "isolated", + "margin_account": "BTC-USDT", + "position_mode": "dual_side" + } + ], + "uid": "123456789" +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedPositions.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedPositions.txt new file mode 100644 index 00000000..f4422648 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedPositions.txt @@ -0,0 +1,35 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "positions.*" } +< { "op": "sub", "cid": "|4|", "topic": "positions.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "positions", + "ts": 1603711371803, + "event": "snapshot", + "data": [ + { + "symbol": "BTC", + "contract_code": "BTC-USDT", + "volume": 1, + "available": 0, + "frozen": 1, + "cost_open": 13059.8, + "cost_hold": 13059.8, + "profit_unreal": -0.0705, + "profit_rate": -0.05398244996094886, + "profit": -0.0705, + "position_margin": 1.31303, + "lever_rate": 10, + "direction": "sell", + "last_price": 13130.3, + "margin_asset": "USDT", + "margin_mode": "isolated", + "margin_account": "BTC-USDT", + "position_mode": "dual_side", + "adl_risk_percent": "3" + } + ], + "uid": "123456789" +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrades.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrades.txt new file mode 100644 index 00000000..9fc840ea --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrades.txt @@ -0,0 +1,42 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "matchOrders.*" } +< { "op": "sub", "cid": "|4|", "topic": "matchOrders.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "matchOrders", + "ts": 1600926986125, + "symbol": "BTC", + "contract_code": "BTC-USDT", + "status": 6, + "order_id": 758688290195656700, + "order_id_str": "758688290195656704", + "client_order_id": null, + "order_type": 1, + "created_at": 1600926984112, + "trade": [ + { + "trade_id": 14470, + "id": "14470-758688290195656704-1", + "trade_volume": 1, + "trade_price": 10329.11, + "trade_turnover": 103.2911, + "created_at": 1600926986046, + "role": "taker" + } + ], + "uid": "123456789", + "volume": 1, + "trade_volume": 1, + "direction": "buy", + "offset": "open", + "lever_rate": 5, + "price": 10329.11, + "order_source": "web", + "order_price_type": "opponent", + "margin_mode": "isolated", + "margin_account": "BTC-USDT", + "is_tpsl": 0, + "reduce_only": 0 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrigger.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrigger.txt new file mode 100644 index 00000000..e65cf213 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/IsolatedTrigger.txt @@ -0,0 +1,42 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "trigger_order.*" } +< { "op": "sub", "cid": "|4|", "topic": "trigger_order.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "trigger_order", + "ts": 1603778055069, + "event": "order", + "uid": "123456789", + "data": [ + { + "symbol": "BTC-USDT", + "contract_code": "BTC-USDT", + "trigger_type": "ge", + "volume": 1, + "order_type": 1, + "direction": "sell", + "offset": "open", + "lever_rate": 10, + "order_id": 5, + "order_id_str": "5", + "relation_order_id": "-1", + "order_price_type": "limit", + "status": 2, + "order_source": "web", + "trigger_price": 15000, + "triggered_price": null, + "order_price": 15000, + "created_at": 1603778055064, + "triggered_at": 0, + "order_insert_at": 0, + "canceled_at": 0, + "margin_mode": "isolated", + "margin_account": "BTC-USDT", + "fail_code": null, + "fail_reason": null, + "reduce_only": 0 + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Klines.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Klines.txt new file mode 100644 index 00000000..48936593 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Klines.txt @@ -0,0 +1,19 @@ +> { "sub": "market.ETH-USDT.kline.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.kline.1day", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.kline.1day", + "ts": 1603707124366, + "tick": { + "id": 1603707120, + "mrid": 131592424, + "open": 13067.7, + "close": 13067.7, + "high": 13067.7, + "low": 13067.7, + "amount": 0.004, + "vol": 4, + "trade_turnover": 52.2708, + "count": 1 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Liquidation.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Liquidation.txt new file mode 100644 index 00000000..a23e4cf9 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Liquidation.txt @@ -0,0 +1,24 @@ +> { "op": "sub", "cid": "|1|", "topic": "public.*.liquidation_orders" } +< { "op": "sub", "cid": "|1|", "topic": "public.*.liquidation_orders", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "public.*.liquidation_orders", + "ts": 1639122193214, + "data": [ + { + "symbol": "O3", + "contract_code": "O3-USDT", + "direction": "sell", + "offset": "close", + "volume": 432, + "price": 0.7858, + "created_at": 1639122193172, + "amount": 432, + "trade_turnover": 339.4656, + "contract_type": "swap", + "pair": "O3-USDT", + "business_type": "swap" + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/MarkKline.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/MarkKline.txt new file mode 100644 index 00000000..8d4f1577 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/MarkKline.txt @@ -0,0 +1,18 @@ +> { "sub": "market.ETH-USDT.mark_price.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.mark_price.1day", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.mark_price.1day", + "ts": 1489474082831, + "tick": { + "vol": "0", + "close": "9800.12", + "count": "0", + "high": "9800.12", + "id": 1529898780, + "low": "9800.12", + "open": "9800.12", + "trade_turnover": "0", + "amount": "0" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Order.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Order.txt new file mode 100644 index 00000000..b81db333 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Order.txt @@ -0,0 +1,58 @@ +> {"op": "auth","type": "api","AccessKeyId": "|1|","SignatureMethod": "HmacSHA256","SignatureVersion": "2","Timestamp": "|2|","Signature": "|3|"} +< { "op": "auth", "type":"api", "ts": 1489474081631, "err-code": 0, "data": { "user-id": "12345678" } } +> { "op": "sub", "cid": "|4|", "topic": "orders.*" } +< { "op": "sub", "cid": "|4|", "topic": "orders.*", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "orders.BTC-USDT", + "ts": 1489474082831, + "uid": "123456789", + "symbol": "BTC", + "contract_code": "BTC-USDT", + "volume": 111, + "price": 1111, + "order_price_type": "limit", + "direction": "buy", + "offset": "open", + "status": 6, + "lever_rate": 10, + "order_id": 758684042347171800, + "order_id_str": "758684042347171840", + "client_order_id": 10683, + "order_source": "web", + "order_type": 1, + "created_at": 1408076414000, + "trade_volume": 1, + "trade_turnover": 1200, + "fee": 0, + "liquidation_type": "0", + "trade_avg_price": 10, + "margin_asset": "USDT", + "margin_frozen": 10, + "profit": 2, + "canceled_at": 1408076414000, + "fee_asset": "USDT", + "margin_mode": "isolated", + "margin_account": "BTC-USDT", + "is_tpsl": 0, + "real_profit": 0, + "reduce_only": 0, + "canceled_source": "timeout-canceled-order", + "trade": [ + { + "trade_id": 14469, + "id": "14469-758684042347171840-1", + "trade_volume": 1, + "trade_price": 123.4555, + "trade_fee": 0.234, + "fee_asset": "USDT", + "price": "", + "trade_turnover": 34.123, + "created_at": 1490759594752, + "role": "maker", + "profit": 2, + "real_profit": 0 + } + ] +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBook.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBook.txt new file mode 100644 index 00000000..29880f70 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBook.txt @@ -0,0 +1,34 @@ +> { "sub": "market.ETH-USDT.depth.step0", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.depth.step0", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.depth.step0", + "ts": 1603707576468, + "tick": { + "mrid": 131596447, + "id": 1603707576, + "bids": [ + [ + 13071.9, + 38 + ], + [ + 13068, + 5 + ] + ], + "asks": [ + [ + 13081.9, + 197 + ], + [ + 13099.7, + 371 + ] + ], + "ts": 1603707576467, + "version": 1603707576, + "ch": "market.BTC-USDT.depth.step6" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBookIncr.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBookIncr.txt new file mode 100644 index 00000000..f8bc6c1c --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/OrderBookIncr.txt @@ -0,0 +1,35 @@ +> { "sub": "market.ETH-USDT.depth.size_20.high_freq", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.depth.size_20.high_freq", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.depth.size_20.high_freq", + "tick": { + "asks": [ + [ + 13081.9, + 206 + ], + [ + 13099.7, + 371 + ] + ], + "bids": [ + [ + 13071.9, + 38 + ], + [ + 13060, + 400 + ] + ], + "ch": "market.BTC-USDT.depth.size_20.high_freq", + "event": "snapshot", + "id": 131597620, + "mrid": 131597620, + "ts": 1603707712356, + "version": 1512467 + }, + "ts": 1603707712357 +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/PremiumKline.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/PremiumKline.txt new file mode 100644 index 00000000..d1654cd2 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/PremiumKline.txt @@ -0,0 +1,17 @@ +> { "sub": "market.ETH-USDT.premium_index.1day", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.premium_index.1day", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.premium_index.1day", + "ts": 1603708380380, + "tick": { + "id": 1603708380, + "open": "0.000068125", + "close": "0.000068125", + "high": "0.000068125", + "low": "0.000068125", + "amount": "0", + "vol": "0", + "count": "0" + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Status.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Status.txt new file mode 100644 index 00000000..567a1de0 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Status.txt @@ -0,0 +1,13 @@ +> { "op": "sub", "cid": "|1|", "topic": "public.linear-swap.heartbeat" } +< { "op": "sub", "cid": "|1|", "topic": "public.linear-swap.heartbeat", "ts": 1670903745088, "err-code": 0 } += +{ + "op": "notify", + "topic": "public.linear-swap.heartbeat", + "event": "init", + "ts": 1580815422403, + "data": { + "heartbeat": 0, + "estimated_recovery_time": 1408076414000 + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Ticker.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Ticker.txt new file mode 100644 index 00000000..e55b58d4 --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Ticker.txt @@ -0,0 +1,27 @@ +> { "sub": "market.ETH-USDT.detail", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.detail", "ts": 1489474081631 } += +{ + "ch": "market.ETH-USDT.detail", + "ts": 1603707870528, + "tick": { + "id": 1603707840, + "mrid": 131599205, + "open": 12916.2, + "close": 13065.8, + "high": 13205.3, + "low": 12852.8, + "amount": 30.316, + "vol": 30316, + "trade_turnover": 395073.4918, + "count": 2983, + "ask": [ + 13081.9, + 206 + ], + "bid": [ + 13071.9, + 38 + ] + } +} \ No newline at end of file diff --git a/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Trades.txt b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Trades.txt new file mode 100644 index 00000000..dbb3942f --- /dev/null +++ b/HTX.Net.UnitTests/Subscriptions/UsdtMarginSwap/Trades.txt @@ -0,0 +1,4 @@ +> { "sub": "market.ETH-USDT.trade.detail", "id": "|1|" } +< { "id": "|1|", "status": "ok", "subbed": "market.ETH-USDT.trade.detail", "ts": 1489474081631 } += +{"ch":"market.ETH-USDT.trade.detail","ts":1722863196449,"tick":{"id":100021951274748,"ts":1722863196444,"data":[{"amount":196,"quantity":1.96,"trade_turnover":4403.1204,"ts":1722863196444,"id":1000219512747480000,"price":2246.49,"direction":"sell"}]}} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/TestImplementations/TestHelpers.cs b/HTX.Net.UnitTests/TestImplementations/TestHelpers.cs similarity index 77% rename from Huobi.Net.UnitTests/TestImplementations/TestHelpers.cs rename to HTX.Net.UnitTests/TestImplementations/TestHelpers.cs index 1dc05acf..ee7d1c9c 100644 --- a/Huobi.Net.UnitTests/TestImplementations/TestHelpers.cs +++ b/HTX.Net.UnitTests/TestImplementations/TestHelpers.cs @@ -9,22 +9,18 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using CryptoExchange.Net; using CryptoExchange.Net.Authentication; using CryptoExchange.Net.Interfaces; using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Huobi.Net.Clients; -using Huobi.Net.Enums; -using Huobi.Net.Interfaces; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Objects; -using Huobi.Net.Objects.Options; +using HTX.Net.Clients; +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Objects.Options; using Microsoft.Extensions.Logging; using Moq; using Newtonsoft.Json; -namespace Huobi.Net.UnitTests.TestImplementations +namespace HTX.Net.UnitTests.TestImplementations { public class TestHelpers { @@ -68,55 +64,55 @@ public static bool AreEqual(T self, T to, params string[] ignore) where T : c return self == to; } - public static HuobiSocketClient CreateSocketClient(IWebsocket socket, Action options = null) + public static HTXSocketClient CreateSocketClient(IWebsocket socket, Action options = null) { - HuobiSocketClient client; - client = options != null ? new HuobiSocketClient(options) : new HuobiSocketClient(x => { x.ApiCredentials = new ApiCredentials("Test", "Test"); }); + HTXSocketClient client; + client = options != null ? new HTXSocketClient(options) : new HTXSocketClient(x => { x.ApiCredentials = new ApiCredentials("Test", "Test"); }); client.SpotApi.SocketFactory = Mock.Of(); Mock.Get(client.SpotApi.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny(), It.IsAny())).Returns(socket); return client; } - public static HuobiSocketClient CreateAuthenticatedSocketClient(IWebsocket socket, Action options = null) + public static HTXSocketClient CreateAuthenticatedSocketClient(IWebsocket socket, Action options = null) { - HuobiSocketClient client; - client = options != null ? new HuobiSocketClient(options) : new HuobiSocketClient(x => { x.ApiCredentials = new ApiCredentials("Test", "Test"); }); + HTXSocketClient client; + client = options != null ? new HTXSocketClient(options) : new HTXSocketClient(x => { x.ApiCredentials = new ApiCredentials("Test", "Test"); }); client.SpotApi.SocketFactory = Mock.Of(); Mock.Get(client.SpotApi.SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny(), It.IsAny())).Returns(socket); return client; } - public static IHuobiRestClient CreateClient(Action options = null) + public static IHTXRestClient CreateClient(Action options = null) { - IHuobiRestClient client; - client = options != null ? new HuobiRestClient(options) : new HuobiRestClient(); + IHTXRestClient client; + client = options != null ? new HTXRestClient(options) : new HTXRestClient(); client.SpotApi.RequestFactory = Mock.Of(); return client; } - public static IHuobiRestClient CreateAuthResponseClient(string response, HttpStatusCode statusCode = HttpStatusCode.OK) + public static IHTXRestClient CreateAuthResponseClient(string response, HttpStatusCode statusCode = HttpStatusCode.OK) { - var client = (HuobiRestClient)CreateClient(x => { x.ApiCredentials = new ApiCredentials("Test", "test"); }); + var client = (HTXRestClient)CreateClient(x => { x.ApiCredentials = new ApiCredentials("Test", "test"); }); SetResponse(client, response, statusCode); return client; } - public static IHuobiRestClient CreateResponseClient(string response, Action options = null) + public static IHTXRestClient CreateResponseClient(string response, Action options = null) { - var client = (HuobiRestClient)CreateClient(options); + var client = (HTXRestClient)CreateClient(options); SetResponse(client, response); return client; } - public static IHuobiRestClient CreateResponseClient(T response, Action options = null) + public static IHTXRestClient CreateResponseClient(T response, Action options = null) { - var client = (HuobiRestClient)CreateClient(options); + var client = (HTXRestClient)CreateClient(options); SetResponse(client, JsonConvert.SerializeObject(response)); return client; } - public static void SetResponse(HuobiRestClient client, string responseData, HttpStatusCode statusCode = HttpStatusCode.OK) + public static void SetResponse(HTXRestClient client, string responseData, HttpStatusCode statusCode = HttpStatusCode.OK) { var expectedBytes = Encoding.UTF8.GetBytes(responseData); var responseStream = new MemoryStream(); @@ -176,8 +172,8 @@ public static object GetTestValue(Type type, int i) if (type == typeof(IEnumerable)) return new[] { "string" + i }; - if (type == typeof(IEnumerable)) - return new[] { OrderState.Canceled }; + if (type == typeof(IEnumerable)) + return new[] { OrderStatus.Canceled }; if (type.IsEnum) { diff --git a/Huobi.Net.UnitTests/TestImplementations/TestSocket.cs b/HTX.Net.UnitTests/TestImplementations/TestSocket.cs similarity index 98% rename from Huobi.Net.UnitTests/TestImplementations/TestSocket.cs rename to HTX.Net.UnitTests/TestImplementations/TestSocket.cs index af9444db..e1fc7dd1 100644 --- a/Huobi.Net.UnitTests/TestImplementations/TestSocket.cs +++ b/HTX.Net.UnitTests/TestImplementations/TestSocket.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Net.WebSockets; using System.Security.Authentication; using System.Text; @@ -8,7 +7,7 @@ using CryptoExchange.Net.Objects; using Newtonsoft.Json; -namespace Huobi.Net.UnitTests.TestImplementations +namespace HTX.Net.UnitTests.TestImplementations { public class TestSocket: IWebsocket { diff --git a/Huobi.Net.sln b/HTX.Net.sln similarity index 81% rename from Huobi.Net.sln rename to HTX.Net.sln index 0780bd99..95eed85d 100644 --- a/Huobi.Net.sln +++ b/HTX.Net.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27004.2002 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huobi.Net", "Huobi.Net\Huobi.Net.csproj", "{A58E8B0F-D5E5-42D0-9BC1-9CFDDE192582}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTX.Net", "HTX.Net\HTX.Net.csproj", "{A58E8B0F-D5E5-42D0-9BC1-9CFDDE192582}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Huobi.Net.UnitTests", "Huobi.Net.UnitTests\Huobi.Net.UnitTests.csproj", "{AC3A5D12-F046-45D4-8815-4E4267FA4EE0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTX.Net.UnitTests", "HTX.Net.UnitTests\HTX.Net.UnitTests.csproj", "{AC3A5D12-F046-45D4-8815-4E4267FA4EE0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Huobi.Net/AssemblyInfo.cs b/HTX.Net/AssemblyInfo.cs similarity index 72% rename from Huobi.Net/AssemblyInfo.cs rename to HTX.Net/AssemblyInfo.cs index 4d3ae458..678de02f 100644 --- a/Huobi.Net/AssemblyInfo.cs +++ b/HTX.Net/AssemblyInfo.cs @@ -1 +1 @@ -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Huobi.Net.UnitTests")] \ No newline at end of file +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("HTX.Net.UnitTests")] \ No newline at end of file diff --git a/HTX.Net/Clients/HTXRestClient.cs b/HTX.Net/Clients/HTXRestClient.cs new file mode 100644 index 00000000..69b99022 --- /dev/null +++ b/HTX.Net/Clients/HTXRestClient.cs @@ -0,0 +1,72 @@ +using HTX.Net.Clients.SpotApi; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Objects.Options; +using CryptoExchange.Net.Clients; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Clients.UsdtFutures; + +namespace HTX.Net.Clients +{ + /// + public class HTXRestClient : BaseRestClient, IHTXRestClient + { + #region Api clients + + /// + public IHTXRestClientSpotApi SpotApi { get; } + + /// + public IHTXRestClientUsdtFuturesApi UsdtFuturesApi { get; } + + #endregion + + #region constructor/destructor + /// + /// Create a new instance of the HTXRestClient using provided options + /// + /// Option configuration delegate + public HTXRestClient(Action? optionsDelegate = null) : this(null, null, optionsDelegate) + { + } + + /// + /// Create a new instance of the HTXRestClient + /// + /// Option configuration delegate + /// The logger factory + /// Http client for this client + public HTXRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, Action? optionsDelegate = null) + : base(loggerFactory, "HTX") + { + var options = HTXRestOptions.Default.Copy(); + if (optionsDelegate != null) + optionsDelegate(options); + Initialize(options); + + SpotApi = AddApiClient(new HTXRestClientSpotApi(_logger, httpClient, options)); + UsdtFuturesApi = AddApiClient(new HTXRestClientUsdtFuturesApi(_logger, httpClient, options)); + } + #endregion + + #region methods + /// + /// Set the default options to be used when creating new clients + /// + /// Option configuration delegate + public static void SetDefaultOptions(Action optionsDelegate) + { + var options = HTXRestOptions.Default.Copy(); + optionsDelegate(options); + HTXRestOptions.Default = options; + } + + /// + public void SetApiCredentials(ApiCredentials apiCredentials) + { + SpotApi.SetApiCredentials(apiCredentials); + UsdtFuturesApi.SetApiCredentials(apiCredentials); + } + #endregion + } +} diff --git a/HTX.Net/Clients/HTXSocketClient.cs b/HTX.Net/Clients/HTXSocketClient.cs new file mode 100644 index 00000000..fff8b4b0 --- /dev/null +++ b/HTX.Net/Clients/HTXSocketClient.cs @@ -0,0 +1,74 @@ +using CryptoExchange.Net.Clients; +using HTX.Net.Clients.SpotApi; +using HTX.Net.Clients.UsdtFutures; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Objects.Options; + +namespace HTX.Net.Clients +{ + /// + public class HTXSocketClient : BaseSocketClient, IHTXSocketClient + { + #region fields + /// + public IHTXSocketClientSpotApi SpotApi { get; } + /// + public IHTXSocketClientUsdtFuturesApi UsdtFuturesApi { get; } + #endregion + + #region ctor + /// + /// Create a new instance of the HTXSocketClient + /// + /// The logger factory + public HTXSocketClient(ILoggerFactory? loggerFactory = null) : this((x) => { }, loggerFactory) + { + } + + /// + /// Create a new instance of the HTXSocketClient + /// + /// Option configuration delegate + public HTXSocketClient(Action optionsDelegate) : this(optionsDelegate, null) + { + } + + /// + /// Create a new instance of the HTXSocketClient + /// + /// The logger factory + /// Option configuration delegate + public HTXSocketClient(Action optionsDelegate, ILoggerFactory? loggerFactory = null) : base(loggerFactory, "HTX") + { + var options = HTXSocketOptions.Default.Copy(); + optionsDelegate(options); + Initialize(options); + + SpotApi = AddApiClient(new HTXSocketClientSpotApi(_logger, options)); + UsdtFuturesApi = AddApiClient(new HTXSocketClientUsdtFuturesApi(_logger, options)); + } + #endregion + + #region methods + /// + /// Set the default options to be used when creating new clients + /// + /// Option configuration delegate + public static void SetDefaultOptions(Action optionsDelegate) + { + var options = HTXSocketOptions.Default.Copy(); + optionsDelegate(options); + HTXSocketOptions.Default = options; + } + + /// + public void SetApiCredentials(ApiCredentials apiCredentials) + { + SpotApi.SetApiCredentials(apiCredentials); + UsdtFuturesApi.SetApiCredentials(apiCredentials); + } + #endregion + } +} diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApi.cs similarity index 68% rename from Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs rename to HTX.Net/Clients/SpotApi/HTXRestClientSpotApi.cs index 0feccc35..138214fb 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApi.cs +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApi.cs @@ -1,30 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Clients; using CryptoExchange.Net.CommonObjects; using CryptoExchange.Net.Converters.MessageParsing; using CryptoExchange.Net.Interfaces.CommonClients; -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Options; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; - -namespace Huobi.Net.Clients.SpotApi +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Options; + +namespace HTX.Net.Clients.SpotApi { /// - internal class HuobiRestClientSpotApi : RestApiClient, IHuobiRestClientSpotApi, ISpotClient + internal class HTXRestClientSpotApi : RestApiClient, IHTXRestClientSpotApi, ISpotClient { /// - public new HuobiRestOptions ClientOptions => (HuobiRestOptions)base.ClientOptions; + public new HTXRestOptions ClientOptions => (HTXRestOptions)base.ClientOptions; internal static TimeSyncState _timeSyncState = new TimeSyncState("Spot Api"); @@ -38,45 +27,62 @@ internal class HuobiRestClientSpotApi : RestApiClient, IHuobiRestClientSpotApi, public event Action? OnOrderCanceled; /// - public string ExchangeName => "Huobi"; + public string ExchangeName => "HTX"; internal readonly string _brokerId; #region Api clients /// - public IHuobiRestClientSpotApiAccount Account { get; } + public IHTXRestClientSpotApiAccount Account { get; } + /// + public IHTXRestClientSpotApiExchangeData ExchangeData { get; } + /// + public IHTXRestClientSpotApiMargin Margin { get; } /// - public IHuobiRestClientSpotApiExchangeData ExchangeData { get; } + public IHTXRestClientSpotApiSubAccount SubAccount { get; } /// - public IHuobiRestClientSpotApiTrading Trading { get; } + public IHTXRestClientSpotApiTrading Trading { get; } #endregion #region constructor/destructor - internal HuobiRestClientSpotApi(ILogger logger, HttpClient? httpClient, HuobiRestOptions options) + internal HTXRestClientSpotApi(ILogger logger, HttpClient? httpClient, HTXRestOptions options) : base(logger, httpClient, options.Environment.RestBaseAddress, options, options.SpotOptions) { - Account = new HuobiRestClientSpotApiAccount(this); - ExchangeData = new HuobiRestClientSpotApiExchangeData(this); - Trading = new HuobiRestClientSpotApiTrading(this); + Account = new HTXRestClientSpotApiAccount(this); + ExchangeData = new HTXRestClientSpotApiExchangeData(this); + SubAccount = new HTXRestClientSpotApiSubAccount(this); + Margin = new HTXRestClientSpotApiMargin(this); + Trading = new HTXRestClientSpotApiTrading(this); _brokerId = !string.IsNullOrEmpty(options.BrokerId) ? options.BrokerId! : "AA1ef14811"; } #endregion + protected override IStreamMessageAccessor CreateAccessor() => new SystemTextJsonStreamMessageAccessor(); + + protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer(); + /// public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}"; /// protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) - => new HuobiAuthenticationProvider(credentials, ClientOptions.SignPublicRequests); + => new HTXAuthenticationProvider(credentials, ClientOptions.SignPublicRequests); #region methods + internal async Task> SendToAddressRawAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) where T : class + { + return await base.SendAsync(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + } + + internal Task> SendAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); - internal async Task> SendHuobiV2Request(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) + internal async Task> SendToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) { - var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); + var result = await base.SendAsync>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); if (!result || result.Data == null) return result.AsError(result.Error!); @@ -86,9 +92,9 @@ internal async Task> SendHuobiV2Request(Uri uri, HttpMethod return result.As(result.Data.Data); } - internal async Task> SendHuobiTimestampRequest(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) + internal async Task> SendHTXTimestampRequest(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) { - var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); + var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); if (!result || result.Data == null) return result.AsError<(T, DateTime)>(result.Error!); @@ -98,14 +104,48 @@ internal async Task> SendHuobiV2Request(Uri uri, HttpMethod return result.As((result.Data.Data, result.Data.Timestamp)); } - internal async Task> SendHuobiRequest(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) + internal Task> SendTimestampAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendTimestampToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task> SendTimestampToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) { - var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); + var result = await base.SendAsync>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); if (!result || result.Data == null) - return result.AsError(result.Error!); + return result.AsError<(T, DateTime)>(result.Error!); if (result.Data.ErrorCode != null) - return result.AsError(new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage)); + return result.AsError<(T, DateTime)>(new ServerError($"{result.Data.ErrorCode}-{result.Data.ErrorMessage}")); + + return result.As((result.Data.Data, result.Data.Timestamp)); + } + + internal Task SendBasicAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendBasicToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task SendBasicToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + { + var result = await base.SendAsync(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + if (!result || result.Data == null) + return result.AsDatalessError(result.Error!); + + if (!string.IsNullOrEmpty(result.Data.ErrorCode)) + return result.AsDatalessError(new ServerError(result.Data.ErrorCode!, result.Data.ErrorMessage!)); + + return result.AsDataless(); + + } + + internal Task> SendBasicAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendBasicToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task> SendBasicToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + { + var result = await base.SendAsync>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + if (!result || result.Data == null) + return result.AsError(result.Error!); + + if (!string.IsNullOrEmpty(result.Data.ErrorCode)) + return result.AsError(new ServerError(result.Data.ErrorCode!, result.Data.ErrorMessage!)); return result.As(result.Data.Data); } @@ -131,26 +171,17 @@ protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable(MessagePath.Get().Property("err-code")); - var msg = accessor.GetValue(MessagePath.Get().Property("err-msg")); + var code = accessor.GetValue(MessagePath.Get().Property("code")); + var errCode = accessor.GetValue(MessagePath.Get().Property("err-code")); + var msg = accessor.GetValue(MessagePath.Get().Property("message")) ?? accessor.GetValue(MessagePath.Get().Property("err-msg")); - if (code == null && msg == null) - return null; + if (code > 0 && code != 200) + return new ServerError(code!.Value, msg!); - return new ServerError($"{code}, {msg}"); - } + if (!string.IsNullOrEmpty(errCode)) + return new ServerError($"{errCode}: {msg}"); - /// - /// Construct url - /// - /// - /// - /// - internal Uri GetUrl(string endpoint, string? version = null) - { - if (version == null) - return new Uri(BaseAddress.AppendPath(endpoint)); - return new Uri(BaseAddress.AppendPath($"v{version}", endpoint)); + return null; } internal void InvokeOrderPlaced(OrderId id) @@ -166,7 +197,7 @@ internal void InvokeOrderCanceled(OrderId id) #region common interface /// - /// Get the name of a symbol for Huobi based on the base and quote asset + /// Get the name of a symbol for HTX based on the base and quote asset /// /// /// @@ -175,15 +206,15 @@ internal void InvokeOrderCanceled(OrderId id) async Task>> IBaseRestClient.GetSymbolsAsync(CancellationToken ct) { - var symbols = await ExchangeData.GetSymbolsAsync(ct: ct).ConfigureAwait(false); + var symbols = await ExchangeData.GetSymbolConfigAsync(ct: ct).ConfigureAwait(false); if (!symbols) return symbols.As>(null); return symbols.As(symbols.Data.Select(d => new Symbol { SourceObject = d, - Name = d.Name, - MinTradeQuantity = d.MinLimitOrderQuantity, + Name = d.Symbol, + MinTradeQuantity = d.MinOrderQuantity, PriceDecimals = d.PricePrecision, QuantityDecimals = d.QuantityPrecision })); @@ -192,7 +223,7 @@ async Task>> IBaseRestClient.GetSymbolsAsync(C async Task> IBaseRestClient.GetTickerAsync(string symbol, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.GetTickerAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.GetTickerAsync), nameof(symbol)); var tickers = await ExchangeData.GetTickersAsync(ct: ct).ConfigureAwait(false); if (!tickers) @@ -235,10 +266,10 @@ async Task>> IBaseRestClient.GetTickersAsync(C async Task>> IBaseRestClient.GetKlinesAsync(string symbol, TimeSpan timespan, DateTime? startTime, DateTime? endTime, int? limit, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.GetKlinesAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.GetKlinesAsync), nameof(symbol)); if (startTime != null || endTime != null) - throw new ArgumentException($"Huobi does not support the {nameof(startTime)}/{nameof(endTime)} parameters for the method {nameof(IBaseRestClient.GetKlinesAsync)}"); + throw new ArgumentException($"HTX does not support the {nameof(startTime)}/{nameof(endTime)} parameters for the method {nameof(IBaseRestClient.GetKlinesAsync)}"); var klines = await ExchangeData.GetKlinesAsync(symbol, GetKlineIntervalFromTimespan(timespan), limit ?? 500, ct: ct).ConfigureAwait(false); if (!klines) @@ -259,7 +290,7 @@ async Task>> IBaseRestClient.GetKlinesAsync(str async Task> IBaseRestClient.GetOrderBookAsync(string symbol, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.GetOrderBookAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.GetOrderBookAsync), nameof(symbol)); var book = await ExchangeData.GetOrderBookAsync(symbol, 0, ct: ct).ConfigureAwait(false); if (!book) @@ -276,7 +307,7 @@ async Task> IBaseRestClient.GetOrderBookAsync(string sy async Task>> IBaseRestClient.GetRecentTradesAsync(string symbol, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.GetRecentTradesAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.GetRecentTradesAsync), nameof(symbol)); var trades = await ExchangeData.GetTradeHistoryAsync(symbol, 100, ct).ConfigureAwait(false); if (!trades) @@ -295,10 +326,10 @@ async Task>> IBaseRestClient.GetRecentTradesAsy async Task> ISpotClient.PlaceOrderAsync(string symbol, CommonOrderSide side, CommonOrderType type, decimal quantity, decimal? price, string? accountId, string? clientOrderId, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.PlaceOrderAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.PlaceOrderAsync), nameof(symbol)); if (string.IsNullOrEmpty(accountId) || !long.TryParse(accountId, out var id)) - throw new ArgumentException(nameof(accountId) + " required for Huobi " + nameof(ISpotClient.PlaceOrderAsync), nameof(accountId)); + throw new ArgumentException(nameof(accountId) + " required for HTX " + nameof(ISpotClient.PlaceOrderAsync), nameof(accountId)); var huobiType = GetOrderType(type); var result = await Trading.PlaceOrderAsync(id, symbol, side == CommonOrderSide.Sell ? Enums.OrderSide.Sell: Enums.OrderSide.Buy, huobiType, quantity, price, clientOrderId: clientOrderId, ct: ct).ConfigureAwait(false); @@ -314,7 +345,7 @@ async Task> ISpotClient.PlaceOrderAsync(string symbol, Co async Task> IBaseRestClient.GetOrderAsync(string orderId, string? symbol, CancellationToken ct) { if(!long.TryParse(orderId, out var id)) - throw new ArgumentException("Invalid order id for Huobi " + nameof(ISpotClient.GetOrderAsync), nameof(orderId)); + throw new ArgumentException("Invalid order id for HTX " + nameof(ISpotClient.GetOrderAsync), nameof(orderId)); var order = await Trading.GetOrderAsync(id, ct: ct).ConfigureAwait(false); if (!order) @@ -331,14 +362,14 @@ async Task> IBaseRestClient.GetOrderAsync(string orderId, s Timestamp = order.Data.CreateTime, Side = order.Data.Side == OrderSide.Buy ? CommonOrderSide.Buy: CommonOrderSide.Sell, Type = order.Data.Type == OrderType.Limit ? CommonOrderType.Limit: order.Data.Type == OrderType.Market ? CommonOrderType.Market: CommonOrderType.Other, - Status = order.Data.State == OrderState.Canceled || order.Data.State == OrderState.PartiallyCanceled ? CommonOrderStatus.Canceled: order.Data.State == OrderState.Filled ? CommonOrderStatus.Filled: CommonOrderStatus.Active + Status = order.Data.Status == OrderStatus.Canceled || order.Data.Status == OrderStatus.PartiallyCanceled ? CommonOrderStatus.Canceled: order.Data.Status == OrderStatus.Filled ? CommonOrderStatus.Filled: CommonOrderStatus.Active }); } async Task>> IBaseRestClient.GetOrderTradesAsync(string orderId, string? symbol, CancellationToken ct) { if (!long.TryParse(orderId, out var id)) - throw new ArgumentException("Invalid order id for Huobi " + nameof(ISpotClient.GetOrderAsync), nameof(orderId)); + throw new ArgumentException("Invalid order id for HTX " + nameof(ISpotClient.GetOrderAsync), nameof(orderId)); var result = await Trading.GetOrderTradesAsync(id, ct: ct).ConfigureAwait(false); if (!result) @@ -376,7 +407,7 @@ async Task>> IBaseRestClient.GetOpenOrdersAsync Timestamp = o.CreateTime, Side = o.Side == OrderSide.Buy ? CommonOrderSide.Buy : CommonOrderSide.Sell, Type = o.Type == OrderType.Limit ? CommonOrderType.Limit : o.Type == OrderType.Market ? CommonOrderType.Market : CommonOrderType.Other, - Status = o.State == OrderState.Canceled || o.State == OrderState.PartiallyCanceled ? CommonOrderStatus.Canceled : o.State == OrderState.Filled ? CommonOrderStatus.Filled : CommonOrderStatus.Active + Status = o.Status == OrderStatus.Canceled || o.Status == OrderStatus.PartiallyCanceled ? CommonOrderStatus.Canceled : o.Status == OrderStatus.Filled ? CommonOrderStatus.Filled : CommonOrderStatus.Active } )); } @@ -384,7 +415,7 @@ async Task>> IBaseRestClient.GetOpenOrdersAsync async Task>> IBaseRestClient.GetClosedOrdersAsync(string? symbol, CancellationToken ct) { if (string.IsNullOrEmpty(symbol)) - throw new ArgumentException(nameof(symbol) + " required for Huobi " + nameof(ISpotClient.GetClosedOrdersAsync), nameof(symbol)); + throw new ArgumentException(nameof(symbol) + " required for HTX " + nameof(ISpotClient.GetClosedOrdersAsync), nameof(symbol)); var result = await Trading.GetClosedOrdersAsync(symbol!, ct: ct).ConfigureAwait(false); if (!result) @@ -402,7 +433,7 @@ async Task>> IBaseRestClient.GetClosedOrdersAsy Timestamp = o.CreateTime, Side = o.Side == OrderSide.Buy ? CommonOrderSide.Buy : CommonOrderSide.Sell, Type = o.Type == OrderType.Limit ? CommonOrderType.Limit : o.Type == OrderType.Market ? CommonOrderType.Market : CommonOrderType.Other, - Status = o.State == OrderState.Canceled || o.State == OrderState.PartiallyCanceled ? CommonOrderStatus.Canceled : o.State == OrderState.Filled ? CommonOrderStatus.Filled : CommonOrderStatus.Active + Status = o.Status == OrderStatus.Canceled || o.Status == OrderStatus.PartiallyCanceled ? CommonOrderStatus.Canceled : o.Status == OrderStatus.Filled ? CommonOrderStatus.Filled : CommonOrderStatus.Active } )); } @@ -410,7 +441,7 @@ async Task>> IBaseRestClient.GetClosedOrdersAsy async Task> IBaseRestClient.CancelOrderAsync(string orderId, string? symbol, CancellationToken ct) { if (!long.TryParse(orderId, out var id)) - throw new ArgumentException("Invalid order id for Huobi " + nameof(ISpotClient.CancelOrderAsync), nameof(orderId)); + throw new ArgumentException("Invalid order id for HTX " + nameof(ISpotClient.CancelOrderAsync), nameof(orderId)); var result = await Trading.CancelOrderAsync(id, ct: ct).ConfigureAwait(false); if (!result) @@ -426,7 +457,7 @@ async Task> IBaseRestClient.CancelOrderAsync(string order async Task>> IBaseRestClient.GetBalancesAsync(string? accountId, CancellationToken ct) { if (string.IsNullOrEmpty(accountId) || !long.TryParse(accountId, out var id)) - throw new ArgumentException(nameof(accountId) + " required for Huobi " + nameof(ISpotClient.GetBalancesAsync), nameof(accountId)); + throw new ArgumentException(nameof(accountId) + " required for HTX " + nameof(ISpotClient.GetBalancesAsync), nameof(accountId)); var balances = await Account.GetBalancesAsync(long.Parse(accountId), ct: ct).ConfigureAwait(false); if (!balances) @@ -479,7 +510,7 @@ private static KlineInterval GetKlineIntervalFromTimespan(TimeSpan timeSpan) if (timeSpan == TimeSpan.FromDays(30) || timeSpan == TimeSpan.FromDays(31)) return KlineInterval.OneMonth; if (timeSpan == TimeSpan.FromDays(365)) return KlineInterval.OneYear; - throw new ArgumentException("Unsupported timespan for Huobi Klines, check supported intervals using Huobi.Net.Objects.HuobiPeriod"); + throw new ArgumentException("Unsupported timespan for HTX Klines, check supported intervals using HTX.Net.Objects.HTXPeriod"); } #endregion diff --git a/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiAccount.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiAccount.cs new file mode 100644 index 00000000..370641f8 --- /dev/null +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiAccount.cs @@ -0,0 +1,435 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Objects.Internal; +using CryptoExchange.Net.RateLimiting.Guards; + +namespace HTX.Net.Clients.SpotApi +{ + /// + internal class HTXRestClientSpotApiAccount : IHTXRestClientSpotApiAccount + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientSpotApi _baseClient; + + internal HTXRestClientSpotApiAccount(HTXRestClientSpotApi baseClient) + { + _baseClient = baseClient; + } + + #region Get Accounts + + /// + public async Task>> GetAccountsAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v1/account/accounts", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Balances + + /// + public async Task>> GetBalancesAsync(long accountId, CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/account/accounts/{accountId}/balance", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + if (!result) + return result.AsError>(result.Error!); + + return result.As(result.Data.Data); + } + + #endregion + + #region Get Platform Valuation + + /// + public async Task> GetPlatformValuationAsync(AccountType? accountType = null, string? valuationAsset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalEnum("accountType", accountType); + parameters.AddOptionalParameter("valuationCurrency", valuationAsset); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/account/valuation", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(3, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Asset Valuation + + /// + public async Task> GetAssetValuationAsync(AccountType accountType, string? valuationCurrency = null, long? subUserId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddEnum("accountType", accountType); + parameters.AddOptionalParameter("valuationCurrency", valuationCurrency); + parameters.AddOptionalParameter("subUid", subUserId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/account/asset-valuation", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Internal Transfer + + /// + public async Task> InternalTransferAsync(long fromUserId, AccountType fromAccountType, long fromAccountId, + long toUserId, AccountType toAccountType, long toAccountId, string asset, decimal quantity, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "from-account-id", fromAccountId.ToString(CultureInfo.InvariantCulture)}, + { "from-user", fromUserId.ToString(CultureInfo.InvariantCulture)}, + + { "to-account-id", toAccountId.ToString(CultureInfo.InvariantCulture)}, + { "to-user", toUserId.ToString(CultureInfo.InvariantCulture)}, + + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, + }; + parameters.AddEnum("from-account-type", fromAccountType); + parameters.AddEnum("to-account-type", toAccountType); + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/account/transfer", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Account History + + /// + public async Task>> GetAccountHistoryAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + limit?.ValidateIntBetween(nameof(limit), 1, 500); + + var parameters = new ParameterCollection() + { + { "account-id", accountId } + }; + parameters.AddOptionalParameter("currency", asset); + parameters.AddOptionalParameter("transact-types", transactionTypes == null ? null : string.Join(",", transactionTypes.Select(s => EnumConverter.GetString(s)))); + parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("size", limit); + parameters.AddOptionalEnum("sort", sort); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/account/history", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(5, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Account Ledger + + /// + public async Task>> GetAccountLedgerAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + limit?.ValidateIntBetween(nameof(limit), 1, 500); + + var parameters = new ParameterCollection() + { + { "accountId", accountId } + }; + parameters.AddOptionalParameter("currency", asset); + parameters.AddOptionalParameter("transactTypes", transactionTypes == null ? null : string.Join(",", transactionTypes.Select(s => EnumConverter.GetString(s)))); + parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("limit", limit); + parameters.AddOptionalParameter("fromId", fromId?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalEnum("sort", sort); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/account/ledger", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Transfer + + /// + public async Task> TransferAsync(TransferAccount fromAccount, TransferAccount toAccount, string asset, decimal quantity, string marginAccount, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddEnum("from", fromAccount); + parameters.AddEnum("to", toAccount); + parameters.Add("currency", asset); + parameters.AddString("amount", quantity); + parameters.Add("margin-account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/account/transfer", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(10, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Point Balance + + /// + public async Task> GetPointBalanceAsync(string? subUserId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("subUid", subUserId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/point/account", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Transfer Points + + /// + public async Task> TransferPointsAsync(string fromUserId, string toUserId, string groupId, decimal quantity, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("fromUid", fromUserId); + parameters.Add("toUid", toUserId); + parameters.Add("groupId", groupId); + parameters.AddString("amount", quantity); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/point/transfer", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get User Deduction Info + + /// + public async Task> GetUserDeductionInfoAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v1/account/switch/user/info", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(5, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Deduct Assets + + /// + public async Task> GetDeductAssetsAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v1/account/overview/info", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(5, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Set Deduction Switch + + /// + public async Task SetDeductionSwitchAsync(DeductionSwitchType switchType, string? deductionAsset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddEnumAsInt("switchType", switchType); + parameters.AddOptional("deductionCurrency", deductionAsset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v1/account/fee/switch", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result.AsDataless(); + } + + #endregion + + #region Get Deposit Addresses + + /// + public async Task>> GetDepositAddressesAsync(string asset, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() { { "currency", asset } }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/account/deposit/address", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Withdrawal Quotas + + /// + public async Task> GetWithdrawalQuotasAsync(string? asset = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptional("currency", asset); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/account/withdraw/quota", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Withdrawal Addresses + + /// + public async Task>> GetWithdrawalAddressesAsync(string asset, string? network = null, string? note = null, int? limit = null, long? fromId = null, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.Add("currency", asset); + parameters.AddOptional("chain", network); + parameters.AddOptional("note", note); + parameters.AddOptional("limit", limit); + parameters.AddOptional("fromId", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/account/withdraw/address", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Withdraw + + /// + public async Task> WithdrawAsync(string address, string asset, decimal quantity, decimal fee, string? network = null, string? addressTag = null, string? clientOrderId = null, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "address", address }, + { "currency", asset }, + { "amount", quantity }, + { "fee", fee }, + }; + + parameters.AddOptionalParameter("chain", network); + parameters.AddOptionalParameter("addr-tag", addressTag); + parameters.AddOptionalParameter("client-order-id", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/dw/withdraw/api/create", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Withdrawal By Client Order Id + + /// + public async Task> GetWithdrawalByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("clientOrderId", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v1/query/withdraw/client-order-id", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + if (result.Data == null) + return new WebCallResult(new ServerError("Not found")); + + return result; + } + + #endregion + + #region Cancel Withdrawal + + /// + public async Task> CancelWithdrawalAsync(long id, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Post, $"/v1/dw/withdraw-virtual/{id}/cancel", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendToAddressRawAsync>(_baseClient.BaseAddress, request, parameters, ct).ConfigureAwait(false); + return result.As(result.Data?.Data ?? default); + } + + #endregion + + #region Get Withdraw Deposit History + + /// + public async Task>> GetWithdrawDepositHistoryAsync(WithdrawDepositType type, string? asset = null, int? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddEnum("type", type); + parameters.AddOptionalParameter("currency", asset); + parameters.AddOptionalParameter("from", from?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("size", size?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalEnum("direct", direction); + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/query/deposit-withdraw", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Trading Fees Rates + + /// + public async Task>> GetTradingFeesAsync(IEnumerable symbols, + CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddParameter("symbols", string.Join(",", symbols.Select(s => s.ToLowerInvariant()))); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/reference/transact-fee-rate", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Api Key Info + + /// + public async Task>> GetApiKeyInfoAsync(long userId, string? apiKey = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("accessKey", apiKey); + parameters.Add("uid", userId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/user/api-key", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get User Id + + /// + public async Task> GetUserIdAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/user/uid", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + } +} diff --git a/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiExchangeData.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiExchangeData.cs new file mode 100644 index 00000000..6183b844 --- /dev/null +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiExchangeData.cs @@ -0,0 +1,271 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients.SpotApi; +using CryptoExchange.Net.RateLimiting.Guards; + +namespace HTX.Net.Clients.SpotApi +{ + /// + internal class HTXRestClientSpotApiExchangeData : IHTXRestClientSpotApiExchangeData + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientSpotApi _baseClient; + + internal HTXRestClientSpotApiExchangeData(HTXRestClientSpotApi baseClient) + { + _baseClient = baseClient; + } + + #region Get System Status + + /// + public async Task> GetSystemStatusAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "api/v2/summary.json", HTXExchange.RateLimiter.EndpointLimit, 1, false); + var result = await _baseClient.SendToAddressRawAsync("https://status.huobigroup.com", request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Symbol Status + + /// + public async Task> GetSymbolStatusAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/market-status", HTXExchange.RateLimiter.EndpointLimit, 1, false, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + return await _baseClient.SendAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Symbols + + /// + public async Task>> GetSymbolsAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/settings/common/symbols", HTXExchange.RateLimiter.EndpointLimit, 1, false, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Assets + + /// + public async Task>> GetAssetsAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/settings/common/currencies", HTXExchange.RateLimiter.EndpointLimit, 1, false, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Symbol Config + + /// + public async Task>> GetSymbolConfigAsync(IEnumerable? symbols = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("symbols", symbols == null ? null : string.Join(",", symbols.Select(s => s.ToLowerInvariant()))); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v1/settings/common/market-symbols", HTXExchange.RateLimiter.EndpointLimit, 1, false, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Assets And Networks + + /// + public async Task>> GetAssetsAndNetworksAsync(string? asset = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptional("currency", asset); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/reference/currencies", HTXExchange.RateLimiter.EndpointLimit, 1, false, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Server Time + + /// + public async Task> GetServerTimeAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v1/common/timestamp", HTXExchange.RateLimiter.EndpointLimit, 1, false, preventCaching: true, + limitGuard: new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + if (!result) + return result.AsError(result.Error!); + var time = DateTimeConverter.ParseFromDouble(result.Data)!; + return result.As(time); + } + + #endregion + + #region Get Klines + + /// + public async Task>> GetKlinesAsync(string symbol, KlineInterval period, int? limit = null, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + limit?.ValidateIntBetween(nameof(limit), 0, 2000); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + }; + parameters.AddEnum("period", period); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/history/kline", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4500, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Ticker + + /// + public async Task> GetTickerAsync(string symbol, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + var parameters = new ParameterCollection() + { + { "symbol", symbol } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/detail/merged", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4500, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendTimestampAsync(request, parameters, ct).ConfigureAwait(false); + if (!result) + return result.AsError(result.Error!); + + result.Data.Item1.Timestamp = result.Data.Item2; + return result.As(result.Data.Item1); + } + + #endregion + + #region Get Tickers + + /// + public async Task> GetTickersAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/tickers", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4500, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendTimestampAsync>(request, null, ct).ConfigureAwait(false); + if (!result) + return result.AsError(result.Error!); + + return result.As(new HTXSymbolTicks() { Ticks = result.Data.Item1, Timestamp = result.Data.Item2 }); + } + + #endregion + + #region Get Order Book + + /// + public async Task> GetOrderBookAsync(string symbol, int mergeStep, int? limit = null, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + mergeStep.ValidateIntBetween(nameof(mergeStep), 0, 5); + limit?.ValidateIntValues(nameof(limit), 5, 10, 20); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + { "type", "step"+mergeStep } + }; + parameters.AddOptionalParameter("depth", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/depth", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4000, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendTimestampAsync(request, parameters, ct).ConfigureAwait(false); + if (!result) + return result.AsError(result.Error!); + + return result.As(result.Data.Item1); + } + + #endregion + + #region Get Last Trade + + /// + public async Task> GetLastTradeAsync(string symbol, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + var parameters = new ParameterCollection() + { + { "symbol", symbol } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/trade", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4500, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Trade History + + /// + public async Task>> GetTradeHistoryAsync(string symbol, int? limit = null, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + limit?.ValidateIntBetween(nameof(limit), 0, 2000); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + }; + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/history/trade", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(3000, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Symbol Details 24H + + /// + public async Task> GetSymbolDetails24HAsync(string symbol, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + var parameters = new ParameterCollection() + { + { "symbol", symbol } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, "market/detail", HTXExchange.RateLimiter.SpotMarketLimit, 1, false, + new SingleLimitGuard(4500, TimeSpan.FromMinutes(5), RateLimitWindowType.Sliding)); + var result = await _baseClient.SendTimestampAsync(request, parameters, ct).ConfigureAwait(false); + if (!result) + return result.AsError(result.Error!); + + result.Data.Item1.Timestamp = result.Data.Item2; + return result.As(result.Data.Item1); + } + + #endregion + + } +} diff --git a/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiMargin.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiMargin.cs new file mode 100644 index 00000000..e9ca61c9 --- /dev/null +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiMargin.cs @@ -0,0 +1,375 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients.SpotApi; +using CryptoExchange.Net.RateLimiting.Guards; + +namespace HTX.Net.Clients.SpotApi +{ + /// + internal class HTXRestClientSpotApiMargin : IHTXRestClientSpotApiMargin + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientSpotApi _baseClient; + + internal HTXRestClientSpotApiMargin(HTXRestClientSpotApi baseClient) + { + _baseClient = baseClient; + } + + #region Repay Loan + + /// + public async Task>> RepayLoanAsync(string accountId, string asset, decimal quantity, string? transactionId = null, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "accountId", accountId }, + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) } + }; + + parameters.AddOptionalParameter("transactId", transactionId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "v2/account/repayment", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Transfer Spot To Isolated Margin + + /// + public async Task> TransferSpotToIsolatedMarginAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/dw/transfer-in/margin", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Transfer Isolated To Spot Margin + + /// + public async Task> TransferIsolatedMarginToSpotAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/dw/transfer-out/margin", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Loan Interest Rate And Quota + + /// + public async Task>> GetIsolatedLoanInterestRateAndQuotaAsync(IEnumerable? symbols = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("symbols", symbols == null? null: string.Join(",", symbols.Select(s => s.ToLowerInvariant()))); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/margin/loan-info", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Request Isolated Margin Loan + + /// + public async Task> RequestIsolatedMarginLoanAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + symbol = symbol.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/margin/orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Repay Isolated Margin Loan + + /// + public async Task> RepayIsolatedMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "amount", quantity.ToString(CultureInfo.InvariantCulture) } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/margin/orders/{orderId}/repay", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Closed Orders + + /// + public async Task>> GetIsolatedMarginClosedOrdersAsync( + string symbol, + IEnumerable? states = null, + DateTime? startDate = null, + DateTime? endDate= null, + string? from = null, + FilterDirection? direction = null, + int? limit = null, + int? subUserId = null, + CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol } + }; + + parameters.AddOptionalParameter("states", states == null ? null : string.Join(",", states.Select(EnumConverter.GetString))); + parameters.AddOptionalParameter("start-date", startDate?.ToString("yyyy-mm-dd")); + parameters.AddOptionalParameter("end-date", endDate?.ToString("yyyy-mm-dd")); + parameters.AddOptionalParameter("from", from); + parameters.AddOptionalParameter("direct", EnumConverter.GetString(direction)); + parameters.AddOptionalParameter("size", limit); + parameters.AddOptionalParameter("sub-uid", subUserId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/margin/loan-orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Balance + + /// + public async Task>> GetIsolatedMarginBalanceAsync(string symbol, int? subUserId = null, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol } + }; + + parameters.AddOptionalParameter("sub-uid", subUserId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/margin/accounts/balance", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Transfer Spot To Cross Margin + + /// + public async Task> TransferSpotToCrossMarginAsync(string asset, decimal quantity, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "currency", asset }, + { "amount", quantity }, + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/cross-margin/transfer-in", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(10, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Transfer Cross Margin To Spot + + /// + public async Task> TransferCrossMarginToSpotAsync(string asset, decimal quantity, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "currency", asset }, + { "amount", quantity }, + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/cross-margin/transfer-out", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(10, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Loan Interest Rate And Quota + + /// + public async Task>> GetCrossLoanInterestRateAndQuotaAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v1/cross-margin/loan-info", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Request Cross Margin Loan + + /// + public async Task> RequestCrossMarginLoanAsync(string asset, decimal quantity, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "currency", asset }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/cross-margin/orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Repay Cross Margin Loan + + /// + public async Task RepayCrossMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "amount", quantity.ToString(CultureInfo.InvariantCulture) } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/cross-margin/orders/{orderId}/repay", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Closed Orders + + /// + public async Task>> GetCrossMarginClosedOrdersAsync( + string? asset = null, + MarginOrderStatus? state = null, + DateTime? startDate = null, + DateTime? endDate = null, + string? from = null, + FilterDirection? direction = null, + int? limit = null, + int? subUserId = null, + CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("currency", asset); + parameters.AddOptionalParameter("state", EnumConverter.GetString(state)); + parameters.AddOptionalParameter("start-date", startDate?.ToString("yyyy-mm-dd")); + parameters.AddOptionalParameter("end-date", endDate?.ToString("yyyy-mm-dd")); + parameters.AddOptionalParameter("from", from); + parameters.AddOptionalParameter("direct", EnumConverter.GetString(direction)); + parameters.AddOptionalParameter("size", limit); + parameters.AddOptionalParameter("sub-uid", subUserId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/cross-margin/loan-orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(10, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Balance + + /// + public async Task> GetCrossMarginBalanceAsync(int? subUserId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("sub-uid", subUserId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/cross-margin/accounts/balance", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Limit + + /// + public async Task>> GetCrossMarginLimitAsync(string? asset = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptional("currency", asset); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/margin/limit", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Repayment History + + /// + public async Task>> GetRepaymentHistoryAsync(long? repayId = null, long? accountId =null, string? asset =null, DateTime? startTime = null, DateTime? endTime = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("repayId", repayId); + parameters.AddOptionalParameter("accountId", accountId); + parameters.AddOptionalParameter("currency", asset); + parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("sort", sort); + parameters.AddOptionalParameter("limit", limit); + parameters.AddOptionalParameter("fromId", fromId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/account/repayment", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + } +} diff --git a/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiSubAccount.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiSubAccount.cs new file mode 100644 index 00000000..4660bd33 --- /dev/null +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiSubAccount.cs @@ -0,0 +1,287 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients.SpotApi; +using CryptoExchange.Net.RateLimiting.Guards; + +namespace HTX.Net.Clients.SpotApi +{ + /// + internal class HTXRestClientSpotApiSubAccount : IHTXRestClientSpotApiSubAccount + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientSpotApi _baseClient; + + internal HTXRestClientSpotApiSubAccount(HTXRestClientSpotApi baseClient) + { + _baseClient = baseClient; + } + + #region Set Deduct Mode + + /// + public async Task>> SetDeductModeAsync(IEnumerable subUserIds, DeductMode deductMode, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUids", string.Join(",", subUserIds)); + parameters.AddEnum("deductMode", deductMode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/deduct-mode", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Create Sub Account + + /// + public async Task>> CreateSubAccountsAsync(IEnumerable accounts, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("userList", accounts); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/creation", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Sub User List + + /// + public async Task>> GetSubUserListAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/sub-user/user-list", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Set Lock + + /// + public async Task> SetLockAsync(long subUserId, LockAction lockAction, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + parameters.AddEnum("action", lockAction); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/management", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Sub User + + /// + public async Task> GetSubUserAsync(long subUserId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/sub-user/user-state", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Set Tradable Market + + /// + public async Task>> SetTradableMarketAsync(IEnumerable subUserIds, SubAccountMarketType accountType, bool enabled, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUids", string.Join(",", subUserIds)); + parameters.AddEnum("accountType", accountType); + parameters.Add("enabled", enabled ? "activated": "deactivated"); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/tradable-market", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Set Asset Transfer Permissions + + /// + public async Task>> SetAssetTransferPermissionsAsync(IEnumerable subUserIds, bool enabled, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUids", string.Join(",", subUserIds)); + parameters.Add("transferrable", enabled); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/transferability", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Sub User Accounts + + /// + public async Task> GetSubUserAccountsAsync(long subUserId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "subUid", subUserId.ToString(CultureInfo.InvariantCulture)} + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/sub-user/account-list", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Create Api Key + + /// + public async Task> CreateApiKeyAsync(string otpToken, long subUserId, string note, IEnumerable permissions, IEnumerable ipAddresses, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("otpToken", otpToken); + parameters.Add("subUid", subUserId); + parameters.Add("note", note); + parameters.Add("permission", string.Join(",", permissions)); + parameters.Add("ipAddresses", string.Join(",", ipAddresses)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/api-key-generation", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Edit Api Key + + /// + public async Task> EditApiKeyAsync(long subUserId, string apiKey, string note, IEnumerable permissions, IEnumerable ipAddresses, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + parameters.Add("accessKey", apiKey); + parameters.Add("note", note); + parameters.Add("permission", string.Join(",", permissions)); + parameters.Add("ipAddresses", string.Join(",", ipAddresses)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/api-key-modification", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Delete Api Key + + /// + public async Task DeleteApiKeyAsync(long subUserId, string apiKey, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + parameters.Add("accessKey", apiKey); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/v2/sub-user/api-key-deletion", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result.AsDataless(); + } + + #endregion + + #region Transfer With Sub Account + + /// + public async Task> TransferWithSubAccountAsync(long subAccountId, string asset, decimal quantity, TransferType transferType, CancellationToken ct = default) + { + asset.ValidateNotNull(nameof(asset)); + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "sub-uid", subAccountId }, + { "currency", asset }, + { "amount", quantity } + }; + parameters.AddEnum("type", transferType); + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/subuser/transfer", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Deposit Address + + /// + public async Task>> GetDepositAddressAsync(long subUserId, string asset, CancellationToken ct = default) + { + asset = asset.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + parameters.Add("currency", asset); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/sub-user/deposit-address", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Deposit History + + /// + public async Task>> GetDepositHistoryAsync(long subUserId, string? asset = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) + { + asset = asset?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.Add("subUid", subUserId); + parameters.AddOptional("currency", asset); + parameters.AddOptionalMilliseconds("startTime", startTime); + parameters.AddOptionalMilliseconds("endTime", endTime); + parameters.AddOptionalEnum("sort", sort); + parameters.AddOptional("limit", limit); + parameters.AddOptional("fromId", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/sub-user/query-deposit", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Aggregate Balances + + /// + public async Task>> GetAggregateBalancesAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v1/subuser/aggregate-balance", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(2, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Balances + + /// + public async Task>> GetBalancesAsync(long subAccountId, CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/account/accounts/{subAccountId}", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + + } +} diff --git a/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiTrading.cs b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiTrading.cs new file mode 100644 index 00000000..2b14061b --- /dev/null +++ b/HTX.Net/Clients/SpotApi/HTXRestClientSpotApiTrading.cs @@ -0,0 +1,502 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients.SpotApi; +using CryptoExchange.Net.CommonObjects; +using CryptoExchange.Net.RateLimiting.Guards; + +namespace HTX.Net.Clients.SpotApi +{ + /// + internal class HTXRestClientSpotApiTrading : IHTXRestClientSpotApiTrading + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientSpotApi _baseClient; + + internal HTXRestClientSpotApiTrading(HTXRestClientSpotApi baseClient) + { + _baseClient = baseClient; + } + + #region Place Order + + /// + public async Task> PlaceOrderAsync( + long accountId, + string symbol, + Enums.OrderSide side, + Enums.OrderType type, + decimal quantity, + decimal? price = null, + string? clientOrderId = null, + SourceType? source = null, + decimal? stopPrice = null, + Operator? stopOperator = null, + CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + if (type == Enums.OrderType.StopLimit) + throw new ArgumentException("Stop limit orders not supported by API"); + + var orderType = EnumConverter.GetString(side) + "-" + EnumConverter.GetString(type); + + var parameters = new ParameterCollection() + { + { "account-id", accountId }, + { "symbol", symbol }, + { "type", orderType } + }; + parameters.AddString("amount", quantity); + + clientOrderId ??= ExchangeHelpers.AppendRandomString(_baseClient._brokerId, 64); + + parameters.AddOptionalParameter("client-order-id", clientOrderId); + parameters.AddOptionalString("stop-price", stopPrice); + parameters.AddOptionalEnum("source", source); + parameters.AddOptionalEnum("operator", stopOperator); + parameters.AddOptionalString("price", price); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/orders/place", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + if (result) + _baseClient.InvokeOrderPlaced(new OrderId { SourceObject = result.Data, Id = result.Data.ToString(CultureInfo.InvariantCulture) }); + return result; + } + + #endregion + + #region Place Multiple Order + + /// + public async Task>> PlaceMultipleOrderAsync( + IEnumerable orders, + CancellationToken ct = default) + { + var data = new List(); + foreach (var order in orders) + { + var orderType = EnumConverter.GetString(order.Side) + "-" + EnumConverter.GetString(order.Type); + + var parameters = new ParameterCollection() + { + { "account-id", order.AccountId }, + { "symbol", order.Symbol.ToLowerInvariant() }, + { "type", orderType } + }; + parameters.AddString("amount", order.Quantity); + order.ClientOrderId ??= ExchangeHelpers.AppendRandomString(_baseClient._brokerId, 64); + + parameters.AddOptionalParameter("client-order-id", order.ClientOrderId); + parameters.AddOptionalString("stop-price", order.StopPrice); + parameters.AddOptionalEnum("source", order.Source); + parameters.AddOptionalEnum("operator", order.StopOperator); + parameters.AddOptionalString("price", order.Price); + data.Add(parameters); + } + + var orderParameters = new ParameterCollection(); + orderParameters.SetBody(data); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/batch-orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync>(request, orderParameters, ct).ConfigureAwait(false); + if (result.Success) + { + foreach (var order in result.Data.Where(d => d.Success)) + _baseClient.InvokeOrderPlaced(new OrderId { SourceObject = order, Id = order.OrderId.ToString() }); + } + return result; + } + + #endregion + + #region Place Margin Order + + /// + public async Task> PlaceMarginOrderAsync( + long accountId, + string symbol, + Enums.OrderSide side, + Enums.OrderType type, + Enums.MarginPurpose purpose, + SourceType source, + decimal? quantity = null, + decimal? quoteQuantity = null, + decimal? borrowQuantity = null, + decimal? price = null, + decimal? stopPrice = null, + Operator? stopOperator = null, + CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + if (type == Enums.OrderType.StopLimit) + throw new ArgumentException("Stop limit orders not supported by API"); + + var orderType = EnumConverter.GetString(side) + "-" + EnumConverter.GetString(type); + + var parameters = new ParameterCollection() + { + { "account-id", accountId }, + { "symbol", symbol }, + { "type", orderType } + }; + parameters.AddEnum("trade-purpose", purpose); + parameters.AddEnum("source", source); + + parameters.AddOptionalString("amount", quantity); + parameters.AddOptionalString("market-amount", quoteQuantity); + parameters.AddOptionalString("borrow-amount", borrowQuantity); + parameters.AddOptionalString("price", price); + parameters.AddOptionalString("stop-price", stopPrice); + parameters.AddOptionalEnum("operator", stopOperator); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/auto/place", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + if (result) + _baseClient.InvokeOrderPlaced(new OrderId { SourceObject = result.Data, Id = result.Data.OrderId.ToString(CultureInfo.InvariantCulture) }); + return result; + } + + #endregion + + #region Cancel Order + + /// + public async Task> CancelOrderAsync(long orderId, CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v1/order/orders/{orderId}/submitcancel", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + var result = await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + if (result) + _baseClient.InvokeOrderCanceled(new OrderId { SourceObject = result.Data, Id = result.Data.ToString(CultureInfo.InvariantCulture) }); + return result; + } + + #endregion + + #region Cancel Order By Client Order Id + + /// + public async Task> CancelOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "client-order-id", clientOrderId } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/orders/submitCancelClientOrder", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(100, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Open Orders + + /// + public async Task>> GetOpenOrdersAsync(long? accountId = null, string? symbol = null, Enums.OrderSide? side = null, int? limit = null, CancellationToken ct = default) + { + symbol = symbol?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("account-id", accountId); + parameters.AddOptionalParameter("symbol", symbol); + parameters.AddOptionalEnum("side", side); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "v1/order/openOrders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Orders By Criteria + + /// + public async Task> CancelOrdersByCriteriaAsync(long? accountId = null, IEnumerable? symbols = null, Enums.OrderSide? side = null, int? limit = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("account-id", accountId?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("symbol", symbols == null ? null : string.Join(",", symbols.Select(x => x.ToLowerInvariant()))); + parameters.AddOptionalEnum("side", side); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/orders/batchCancelOpenOrders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Orders + + /// + public async Task> CancelOrdersAsync(IEnumerable? orderIds = null, IEnumerable? clientOrderIds = null, CancellationToken ct = default) + { + if (orderIds == null && clientOrderIds == null) + throw new ArgumentException("Either orderIds or clientOrderIds should be provided"); + + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("order-ids", orderIds?.Select(s => s.ToString(CultureInfo.InvariantCulture))); + parameters.AddOptionalParameter("client-order-ids", clientOrderIds?.Select(s => s.ToString(CultureInfo.InvariantCulture))); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/orders/batchcancel", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + // /v2/algo-orders/cancel-all-after + + #region Get Order + + /// + public async Task> GetOrderAsync(long orderId, CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/orders/{orderId}", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Order By Client Order Id + + /// + public async Task> GetOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "clientOrderId", clientOrderId } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/orders/getClientOrder", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Order Trades + + /// + public async Task>> GetOrderTradesAsync(long orderId, CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/orders/{orderId}/matchresults", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Closed Orders + + /// + public async Task>> GetClosedOrdersAsync(string symbol, IEnumerable? states = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + + states ??= new OrderStatus[] { OrderStatus.Filled, OrderStatus.Canceled, OrderStatus.PartiallyCanceled }; + + var parameters = new ParameterCollection() + { + { "states", string.Join(",", states.Select(s => EnumConverter.GetString(s))) } + }; + parameters.AddOptionalParameter("symbol", symbol); + parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("types", types == null ? null : string.Join(",", types.Select(s => EnumConverter.GetString(s)))); + parameters.AddOptionalParameter("from", fromId); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Historical Orders + + /// + public async Task>> GetHistoricalOrdersAsync(string? symbol = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) + { + symbol = symbol?.ToLowerInvariant(); + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("symbol", symbol); + parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/history", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get User Trades + + /// + public async Task>> GetUserTradesAsync(string? symbol = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) + { + symbol = symbol?.ToLowerInvariant(); + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("symbol", symbol); + parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("types", types == null ? null : string.Join(",", types.Select(s => EnumConverter.GetString(s)))); + parameters.AddOptionalParameter("from", fromId); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptionalParameter("size", limit); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v1/order/matchresults", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Place Conditional Order + + /// + public async Task> PlaceConditionalOrderAsync( + long accountId, + string symbol, + OrderSide side, + ConditionalOrderType type, + decimal stopPrice, + decimal? quantity = null, + decimal? price = null, + decimal? quoteQuantity = null, + decimal? trailingRate = null, + TimeInForce? timeInForce = null, + string? clientOrderId = null, + CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "accountId", accountId }, + { "symbol", symbol }, + { "orderSide", EnumConverter.GetString(side) }, + { "orderType", EnumConverter.GetString(type) }, + { "clientOrderId", clientOrderId ?? Guid.NewGuid().ToString() } + }; + parameters.AddString("stopPrice", stopPrice); + + parameters.AddOptionalString("orderPrice", price); + parameters.AddOptionalString("orderSize", quantity); + parameters.AddOptionalString("orderValue", quoteQuantity); + parameters.AddOptionalEnum("timeInForce", timeInForce); + parameters.AddOptionalString("trailingRate", trailingRate); + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v2/algo-orders", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Conditional Orders + + /// + public async Task> CancelConditionalOrdersAsync(IEnumerable clientOrderIds, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "clientOrderIds", clientOrderIds } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Post, $"v2/algo-orders/cancellation", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Open Conditional Orders + + /// + public async Task>> GetOpenConditionalOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, ConditionalOrderType? type = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) + { + symbol = symbol?.ToLowerInvariant(); + + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("accountId", accountId); + parameters.AddOptionalParameter("symbol", symbol); + parameters.AddOptionalParameter("orderSide", EnumConverter.GetString(side)); + parameters.AddOptionalParameter("orderType", EnumConverter.GetString(type)); + parameters.AddOptionalParameter("sort", sort); + parameters.AddOptionalParameter("limit", limit); + parameters.AddOptionalParameter("fromId", fromId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v2/algo-orders/opening", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Closed Conditional Orders + + /// + public async Task>> GetClosedConditionalOrdersAsync( + string symbol, + ConditionalOrderStatus status, + long? accountId = null, + OrderSide? side = null, + ConditionalOrderType? type = null, + DateTime? startTime = null, + DateTime? endTime = null, + string? sort = null, + int? limit = null, + long? fromId = null, + CancellationToken ct = default) + { + symbol = symbol.ToLowerInvariant(); + + var parameters = new ParameterCollection() + { + { "symbol", symbol }, + { "orderStatus", EnumConverter.GetString(status) } + }; + parameters.AddOptionalParameter("accountId", accountId); + parameters.AddOptionalParameter("orderSide", EnumConverter.GetString(side)); + parameters.AddOptionalParameter("orderType", EnumConverter.GetString(type)); + parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("sort", sort); + parameters.AddOptionalParameter("limit", limit); + parameters.AddOptionalParameter("fromId", fromId); + + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v2/algo-orders/history", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Conditional Order + + /// + public async Task> GetConditionalOrderAsync(string clientOrderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "clientOrderId", clientOrderId } + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, $"v2/algo-orders/specific", HTXExchange.RateLimiter.EndpointLimit, 1, true, + new SingleLimitGuard(20, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey)); + return await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + } +} diff --git a/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs b/HTX.Net/Clients/SpotApi/HTXSocketClientSpotApi.cs similarity index 50% rename from Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs rename to HTX.Net/Clients/SpotApi/HTXSocketClientSpotApi.cs index 41de33ee..8d4b7ea8 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs +++ b/HTX.Net/Clients/SpotApi/HTXSocketClientSpotApi.cs @@ -1,35 +1,23 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using CryptoExchange.Net.Authentication; +using System.Net.WebSockets; using CryptoExchange.Net.Clients; using CryptoExchange.Net.Converters.MessageParsing; -using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Huobi.Net.ExtensionMethods; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.Objects.Options; -using Huobi.Net.Objects.Sockets; -using Huobi.Net.Objects.Sockets.Queries; -using Huobi.Net.Objects.Sockets.Subscriptions; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using HuobiOrderUpdate = Huobi.Net.Objects.Models.Socket.HuobiOrderUpdate; - -namespace Huobi.Net.Clients.SpotApi +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Options; +using HTX.Net.Objects.Sockets; +using HTX.Net.Objects.Sockets.Queries; +using HTX.Net.Objects.Sockets.Subscriptions; + +using HTXOrderUpdate = HTX.Net.Objects.Models.Socket.HTXOrderUpdate; + +namespace HTX.Net.Clients.SpotApi { /// - internal class HuobiSocketClientSpotApi : SocketApiClient, IHuobiSocketClientSpotApi + internal class HTXSocketClientSpotApi : SocketApiClient, IHTXSocketClientSpotApi { private static readonly MessagePath _idPath = MessagePath.Get().Property("id"); private static readonly MessagePath _actionPath = MessagePath.Get().Property("action"); @@ -40,17 +28,23 @@ internal class HuobiSocketClientSpotApi : SocketApiClient, IHuobiSocketClientSpo #endregion #region ctor - internal HuobiSocketClientSpotApi(ILogger logger, HuobiSocketOptions options) + internal HTXSocketClientSpotApi(ILogger logger, HTXSocketOptions options) : base(logger, options.Environment.SocketBaseAddress, options, options.SpotOptions) { KeepAliveInterval = TimeSpan.Zero; - AddSystemSubscription(new HuobiSpotPingSubscription(_logger)); - AddSystemSubscription(new HuobiPingSubscription(_logger)); + AddSystemSubscription(new HTXSpotPingSubscription(_logger)); + AddSystemSubscription(new HTXPingSubscription(_logger)); + + RateLimiter = HTXExchange.RateLimiter.SpotConnection; } #endregion + protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer(); + + protected override IByteMessageAccessor CreateAccessor() => new SystemTextJsonByteMessageAccessor(); + /// public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToLowerInvariant()}{quoteAsset.ToLowerInvariant()}"; @@ -65,7 +59,7 @@ internal HuobiSocketClientSpotApi(ILogger logger, HuobiSocketOptions options) if (string.Equals(action, "ping", StringComparison.Ordinal)) return "pingV2"; - var ping = message.GetValue(_pingPath); + var ping = message.GetValue(_pingPath); if (ping != null) return "pingV3"; @@ -87,181 +81,185 @@ public override ReadOnlyMemory PreprocessStreamMessage(SocketConnection co /// protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) - => new HuobiAuthenticationProvider(credentials, false); + => new HTXAuthenticationProvider(credentials, false); /// protected override Query GetAuthenticationRequest(SocketConnection connection) { - return new HuobiAuthQuery(new HuobiAuthRequest + return new HTXAuthQuery(new HTXAuthRequest { Action = "req", Channel = "auth", - Params = ((HuobiAuthenticationProvider)AuthenticationProvider!).GetWebsocketAuthentication(new Uri(BaseAddress.AppendPath("ws/v2"))) + Params = ((HTXAuthenticationProvider)AuthenticationProvider!).GetWebsocketAuthentication(new Uri(BaseAddress.AppendPath("ws/v2"))) }); } /// - public async Task>> GetKlinesAsync(string symbol, KlineInterval period) + public async Task>> GetKlinesAsync(string symbol, KlineInterval period) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); - var query = new HuobiQuery>($"market.{symbol}.kline.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", false); + var query = new HTXQuery>($"market.{symbol}.kline.{EnumConverter.GetString(period)}", false); var result = await QueryAsync(BaseAddress.AppendPath("ws"), query).ConfigureAwait(false); - return result ? result.As(result.Data.Data) : result.AsError>(result.Error!); + return result ? result.As(result.Data.Data) : result.AsError>(result.Error!); } /// - public async Task> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval period, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval period, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.kline.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(symbol)), false); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.kline.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> GetOrderBookWithMergeStepAsync(string symbol, int mergeStep) + public async Task> GetOrderBookWithMergeStepAsync(string symbol, int mergeStep) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); mergeStep.ValidateIntBetween(nameof(mergeStep), 0, 5); - var query = new HuobiQuery($"market.{symbol}.depth.step{mergeStep}", false); + var query = new HTXQuery($"market.{symbol}.depth.step{mergeStep}", false); var result = await QueryAsync(BaseAddress.AppendPath("ws"), query).ConfigureAwait(false); - return result ? result.As(result.Data.Data) : result.AsError(result.Error!); + return result ? result.As(result.Data.Data) : result.AsError(result.Error!); } /// - public async Task> GetOrderBookAsync(string symbol, int levels) + public async Task> GetOrderBookAsync(string symbol, int levels) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); levels.ValidateIntValues(nameof(levels), 5, 20, 150, 400); - var query = new HuobiQuery($"market.{symbol}.mbp.{levels}", false); + var query = new HTXQuery($"market.{symbol}.mbp.{levels}", false); var result = await QueryAsync(BaseAddress.AppendPath("feed"), query).ConfigureAwait(false); - return result ? result.As(result.Data.Data) : result.AsError(result.Error!); + return result ? result.As(result.Data.Data) : result.AsError(result.Error!); } /// - public async Task> SubscribeToPartialOrderBookUpdates1SecondAsync(string symbol, int mergeStep, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToPartialOrderBookUpdates1SecondAsync(string symbol, int mergeStep, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); mergeStep.ValidateIntBetween(nameof(mergeStep), 0, 5); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.depth.step{mergeStep}", x => onData(x.WithSymbol(symbol)), false); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.depth.step{mergeStep}", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToPartialOrderBookUpdates100MilisecondAsync(string symbol, int levels, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToPartialOrderBookUpdates100MilisecondAsync(string symbol, int levels, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); levels.ValidateIntValues(nameof(levels), 5, 10, 20); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.mbp.refresh.{levels}", x => onData(x.WithSymbol(symbol)), false); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.mbp.refresh.{levels}", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToOrderBookChangeUpdatesAsync(string symbol, int levels, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToOrderBookChangeUpdatesAsync(string symbol, int levels, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); levels.ValidateIntValues(nameof(levels), 5, 20, 150, 400); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.mbp.{levels}", x => onData(x.WithSymbol(symbol)), false); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.mbp.{levels}", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("feed"), subscription, ct).ConfigureAwait(false); } /// - public async Task>> GetTradeHistoryAsync(string symbol) + public async Task>> GetTradeHistoryAsync(string symbol) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); - var query = new HuobiQuery>($"market.{symbol}.trade.detail", false); + var query = new HTXQuery>($"market.{symbol}.trade.detail", false); var result = await QueryAsync(BaseAddress.AppendPath("ws"), query).ConfigureAwait(false); - return result ? result.As(result.Data.Data) : result.AsError>(result.Error!); + return result ? result.As(result.Data.Data) : result.AsError>(result.Error!); } /// - public async Task> SubscribeToTradeUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToTradeUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.trade.detail", x => onData(x.WithSymbol(symbol)), false); + symbol = symbol.ToLowerInvariant(); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.trade.detail", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> GetSymbolDetailsAsync(string symbol) + public async Task> GetSymbolDetailsAsync(string symbol) { - symbol = symbol.ValidateHuobiSymbol(); + symbol = symbol.ToLowerInvariant(); - var query = new HuobiQuery($"market.{symbol}.detail", false); + var query = new HTXQuery($"market.{symbol}.detail", false); var result = await QueryAsync(BaseAddress.AppendPath("ws"), query).ConfigureAwait(false); if (!result) - return result.AsError(result.Error!); + return result.AsError(result.Error!); result.Data.Data.Timestamp = result.Data.Timestamp; return result.As(result.Data.Data); } /// - public async Task> SubscribeToSymbolDetailUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToSymbolDetailUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) { - symbol = symbol.ValidateHuobiSymbol(); - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.detail", x => onData(x.WithSymbol(symbol)), false); + symbol = symbol.ToLowerInvariant(); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.detail", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToTickerUpdatesAsync(Action>> onData, CancellationToken ct = default) + public async Task> SubscribeToTickerUpdatesAsync(Action>> onData, CancellationToken ct = default) { - var subscription = new HuobiSubscription>(_logger, $"market.tickers", onData, false); + var subscription = new HTXSubscription>(_logger, $"market.tickers", onData, false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) { - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.ticker", x => onData(x.WithSymbol(symbol)), false); + symbol = symbol.ToLowerInvariant(); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.ticker", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToBestOfferUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) + public async Task> SubscribeToBookTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default) { - var subscription = new HuobiSubscription(_logger, $"market.{symbol}.bbo", x => onData(x.WithSymbol(symbol)), false); + symbol = symbol.ToLowerInvariant(); + var subscription = new HTXSubscription(_logger, $"market.{symbol}.bbo", x => onData(x.WithSymbol(symbol)), false); return await SubscribeAsync(BaseAddress.AppendPath("ws"), subscription, ct).ConfigureAwait(false); } /// public async Task> SubscribeToOrderUpdatesAsync( string? symbol = null, - Action>? onOrderSubmitted = null, - Action>? onOrderMatched = null, - Action>? onOrderCancelation = null, - Action>? onConditionalOrderTriggerFailure = null, - Action>? onConditionalOrderCanceled = null, + Action>? onOrderSubmitted = null, + Action>? onOrderMatched = null, + Action>? onOrderCancelation = null, + Action>? onConditionalOrderTriggerFailure = null, + Action>? onConditionalOrderCanceled = null, CancellationToken ct = default) { - symbol = symbol?.ValidateHuobiSymbol(); + symbol = symbol?.ToLowerInvariant(); - var subscription = new HuobiOrderSubscription(_logger, symbol, onOrderSubmitted, onOrderMatched, onOrderCancelation, onConditionalOrderTriggerFailure, onConditionalOrderCanceled); + var subscription = new HTXOrderSubscription(_logger, symbol, onOrderSubmitted, onOrderMatched, onOrderCancelation, onConditionalOrderTriggerFailure, onConditionalOrderCanceled); return await SubscribeAsync(BaseAddress.AppendPath("ws/v2"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToAccountUpdatesAsync(Action> onAccountUpdate, int? updateMode = null, CancellationToken ct = default) + public async Task> SubscribeToAccountUpdatesAsync(Action> onAccountUpdate, int? updateMode = null, CancellationToken ct = default) { if (updateMode != null && (updateMode > 2 || updateMode < 0)) throw new ArgumentException("UpdateMode should be either 0, 1 or 2"); - var subscription = new HuobiAccountSubscription(_logger, "accounts.update#" + (updateMode ?? 1), onAccountUpdate, true); + var subscription = new HTXAccountSubscription(_logger, "accounts.update#" + (updateMode ?? 1), onAccountUpdate, true); return await SubscribeAsync(BaseAddress.AppendPath("ws/v2"), subscription, ct).ConfigureAwait(false); } /// - public async Task> SubscribeToOrderDetailsUpdatesAsync(string? symbol = null, Action>? onOrderMatch = null, Action>? onOrderCancel = null, CancellationToken ct = default) + public async Task> SubscribeToOrderDetailsUpdatesAsync(string? symbol = null, Action>? onOrderMatch = null, Action>? onOrderCancel = null, CancellationToken ct = default) { - var subscription = new HuobiOrderDetailsSubscription(_logger, symbol, onOrderMatch, onOrderCancel); + symbol = symbol?.ToLowerInvariant(); + + var subscription = new HTXOrderDetailsSubscription(_logger, symbol, onOrderMatch, onOrderCancel); return await SubscribeAsync(BaseAddress.AppendPath("ws/v2"), subscription, ct).ConfigureAwait(false); } } diff --git a/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApi.cs b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApi.cs new file mode 100644 index 00000000..1bdf5ee7 --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApi.cs @@ -0,0 +1,153 @@ +using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Converters.MessageParsing; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Options; + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXRestClientUsdtFuturesApi : RestApiClient, IHTXRestClientUsdtFuturesApi + { + /// + public new HTXRestOptions ClientOptions => (HTXRestOptions)base.ClientOptions; + + internal static TimeSyncState _timeSyncState = new TimeSyncState("Usdt Margin Swap Api"); + + /// + public string ExchangeName => "HTX"; + + internal readonly string _brokerId; + + #region Api clients + + /// + public IHTXRestClientUsdtFuturesApiAccount Account { get; } + /// + public IHTXRestClientUsdtFuturesApiExchangeData ExchangeData { get; } + /// + public IHTXRestClientUsdtFuturesApiSubAccount SubAccount { get; } + /// + public IHTXRestClientUsdtFuturesApiTrading Trading { get; } + + #endregion + + #region constructor/destructor + internal HTXRestClientUsdtFuturesApi(ILogger log, HttpClient? httpClient, HTXRestOptions options) + : base(log, httpClient, options.Environment.UsdtMarginSwapRestBaseAddress, options, options.UsdtMarginSwapOptions) + { + Account = new HTXRestClientUsdtMarginSwapApiAccount(this); + ExchangeData = new HTXRestClientUsdtFuturesApiExchangeData(this); + SubAccount = new HTXRestClientUsdtFuturesApiSubAccount(this); + Trading = new HTXRestClientUsdtFuturesApiTrading(this); + + _brokerId = !string.IsNullOrEmpty(options.BrokerId) ? options.BrokerId! : "AA1ef14811"; + } + #endregion + + protected override IStreamMessageAccessor CreateAccessor() => new SystemTextJsonStreamMessageAccessor(); + + protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer(); + + /// + public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}-{quoteAsset.ToUpperInvariant()}"; + + /// + protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) + => new HTXAuthenticationProvider(credentials, ClientOptions.SignPublicRequests); + + internal async Task> SendToAddressRawAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) where T : class + { + return await base.SendAsync(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + } + + internal Task> SendAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task> SendToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + { + var result = await base.SendAsync>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + if (!result || result.Data == null) + return result.AsError(result.Error!); + + if (result.Data.Code != 200) + return result.AsError(new ServerError(result.Data.Code, result.Data.Message)); + + return result.As(result.Data.Data); + } + + internal Task SendBasicAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendBasicToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task SendBasicToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + { + var result = await base.SendAsync(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + if (!result || result.Data == null) + return result.AsDatalessError(result.Error!); + + if (!string.IsNullOrEmpty(result.Data.ErrorCode)) + return result.AsDatalessError(new ServerError(result.Data.ErrorCode!, result.Data.ErrorMessage!)); + + return result.AsDataless(); + + } + + internal Task> SendBasicAsync(RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + => SendBasicToAddressAsync(BaseAddress, definition, parameters, cancellationToken, weight); + + internal async Task> SendBasicToAddressAsync(string baseAddress, RequestDefinition definition, ParameterCollection? parameters, CancellationToken cancellationToken, int? weight = null) + { + var result = await base.SendAsync>(baseAddress, definition, parameters, cancellationToken, null, weight).ConfigureAwait(false); + if (!result || result.Data == null) + return result.AsError(result.Error!); + + if (!string.IsNullOrEmpty(result.Data.ErrorCode)) + return result.AsError(new ServerError(result.Data.ErrorCode!, result.Data.ErrorMessage!)); + + return result.As(result.Data.Data); + } + + /// + protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, IMessageAccessor accessor) + { + if (!accessor.IsJson) + return new ServerError(accessor.GetOriginalString()); + + var code = accessor.GetValue(MessagePath.Get().Property("err-code")); + var msg = accessor.GetValue(MessagePath.Get().Property("err-msg")); + + if (code == null || msg == null) + return new ServerError(accessor.GetOriginalString()); + + + return new ServerError($"{code}, {msg}"); + } + + /// + protected override ServerError? TryParseError(IMessageAccessor accessor) + { + if (!accessor.IsJson) + return new ServerError(accessor.GetOriginalString()); + + var errCode = accessor.GetValue(MessagePath.Get().Property("err-code")); + var msg = accessor.GetValue(MessagePath.Get().Property("err-msg")); + + if (!string.IsNullOrEmpty(errCode)) + return new ServerError($"{errCode}: {msg}"); + + return null; + } + + /// + protected override Task> GetServerTimestampAsync() + => ExchangeData.GetServerTimeAsync(); + + /// + public override TimeSyncInfo? GetTimeSyncInfo() + => new TimeSyncInfo(_logger, ApiOptions.AutoTimestamp ?? ClientOptions.AutoTimestamp, ApiOptions.TimestampRecalculationInterval ?? ClientOptions.TimestampRecalculationInterval, _timeSyncState); + + /// + public override TimeSpan? GetTimeOffset() + => _timeSyncState.TimeOffset; + } +} diff --git a/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiAccount.cs b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiAccount.cs new file mode 100644 index 00000000..965896f2 --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiAccount.cs @@ -0,0 +1,418 @@ +using HTX.Net.Objects.Models.UsdtMarginSwap; +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXRestClientUsdtMarginSwapApiAccount : IHTXRestClientUsdtFuturesApiAccount + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientUsdtFuturesApi _baseClient; + + internal HTXRestClientUsdtMarginSwapApiAccount(HTXRestClientUsdtFuturesApi baseClient) + { + _baseClient = baseClient; + } + + #region Get Asset Valuation + + /// + public async Task>> GetAssetValuationAsync(string? asset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("valuation_asset", asset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_balance_valuation", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Account Info + + /// + public async Task>> GetIsolatedMarginAccountInfoAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_account_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Account Info + + /// + public async Task>> GetCrossMarginAccountInfoAsync(string? marginAccount = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_account_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Positions + + /// + public async Task>> GetIsolatedMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_position_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Positions + + /// + public async Task>> GetCrossMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_position_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Assets And Positions + + /// + public async Task>> GetIsolatedMarginAssetsAndPositionsAsync(string contractCode, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_account_position_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Assets And Positions + + /// + public async Task> GetCrossMarginAssetsAndPositionsAsync(string marginAccount, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "margin_account", marginAccount } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_account_position_info", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Financial Records + + /// + public async Task>> GetFinancialRecordsAsync(string marginAccount, string? contractCode = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, long? fromId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("mar_acct", marginAccount); + parameters.AddOptional("from_id", fromId); + parameters.AddOptional("contract", contractCode); + parameters.AddOptional("type", types?.Any() == true ? string.Join(",", types) : null); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", direction); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v3/swap_financial_record", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + // /linear-swap-api/v3/swap_financial_record_exact + + #region Get Isolated Margin Available Leverage + + /// + public async Task>> GetIsolatedMarginAvailableLeverageAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_available_level_rate", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Available Leverage + + /// + public async Task>> GetCrossMarginAvailableLeverageAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_available_level_rate", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Order Limits + + /// + public async Task> GetOrderLimitsAsync(OrderPriceType orderType, string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddEnum("order_price_type", orderType); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("business_type", businessType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_order_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Trading Fees + + /// + public async Task>> GetTradingFeesAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_fee", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Transfer Limits + + /// + public async Task>> GetIsolatedMarginTransferLimitsAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_transfer_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Transfer Limits + + /// + public async Task>> GetCrossMarginTransferLimitsAsync(string? marginAccount = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_transfer_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Position Limit + + /// + public async Task>> GetIsolatedMarginPositionLimitAsync(string contractCode, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_position_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Position Limits + + /// + public async Task>> GetCrossMarginPositionLimitsAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, string? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("business_type", businessType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_position_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Leverage Position Limits + + /// + public async Task>> GetIsolatedMarginLeveragePositionLimitsAsync(string? contractCode = null, int? leverageRate = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("lever_rate", leverageRate); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_lever_position_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Leverage Position Limits + + /// + public async Task>> GetCrossMarginLeveragePositionLimitsAsync(BusinessType businessType, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddEnum("business_type", businessType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_lever_position_limit", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Transfer Margin Accounts + + /// + public async Task> TransferMarginAccountsAsync(string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, long? clientOrderId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "asset", asset }, + { "from_margin_account", fromMarginAccount }, + { "to_margin_account", toMarginAccount }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, + }; + parameters.AddOptionalParameter("client_order_id", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_transfer_inner", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Trading Status + + /// + public async Task>> GetTradingStatusAsync(CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_api_trading_status", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Set Isolated Margin Position Mode + + /// + public async Task> SetIsolatedMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "margin_account", marginAccount }, + { "position_mode", EnumConverter.GetString(positionMode) }, + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_switch_position_mode", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result.As(result.Data?.First()); + } + + #endregion + + #region Set Cross Margin Position Mode + + /// + public async Task> SetCrossMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "margin_account", marginAccount }, + { "position_mode", EnumConverter.GetString(positionMode) }, + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_switch_position_mode", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result.As(result.Data?.First()); + } + + #endregion + + #region Get Isolated Margin Position Mode + + /// + public async Task>> GetIsolatedMarginPositionModeAsync(string marginAccount, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_position_side", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Position Mode + + /// + public async Task>> GetCrossMarginPositionModeAsync(string marginAccount, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_cross_position_side", HTXExchange.RateLimiter.EndpointLimit, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Settlement Records + + /// + public async Task> GetIsolatedMarginSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_user_settlement_records", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Settlement Records + + /// + public async Task> GetCrossMarginSettlementRecordsAsync(string marginAccount, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "margin_account", marginAccount } + }; + parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_cross_user_settlement_records", HTXExchange.RateLimiter.EndpointLimit, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + } +} diff --git a/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiExchangeData.cs b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiExchangeData.cs new file mode 100644 index 00000000..3a1b39de --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiExchangeData.cs @@ -0,0 +1,578 @@ +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXRestClientUsdtFuturesApiExchangeData : IHTXRestClientUsdtFuturesApiExchangeData + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientUsdtFuturesApi _baseClient; + + internal HTXRestClientUsdtFuturesApiExchangeData(HTXRestClientUsdtFuturesApi baseClient) + { + _baseClient = baseClient; + } + + #region Get Server Time + + /// + public async Task> GetServerTimeAsync(CancellationToken ct = default) + { + var request = _definitions.GetOrCreate(HttpMethod.Get, "api/v1/timestamp", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync(request, null, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Funding Rate + + /// + public async Task> GetFundingRateAsync(string contractCode, CancellationToken ct = default) + { + var parameters = new ParameterCollection() { + { "contract_code", contractCode } + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_funding_rate", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Funding Rates + + /// + public async Task>> GetFundingRatesAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_batch_funding_rate", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Historical Funding Rates + + /// + public async Task> GetHistoricalFundingRatesAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_historical_funding_rate", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Liquidation Orders + + /// + public async Task>> GetLiquidationOrdersAsync( + string contractCode, + LiquidationTradeType tradeType, + string? symbol = null, + DateTime? startTime = null, + DateTime? endTime = null, + FilterDirection? direction = null, + long? fromId = null, + CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract", contractCode }, + { "trade_type", EnumConverter.GetString(tradeType) }, + }; + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptional("from_id", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v3/swap_liquidation_orders", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Historical Settlement Records + + /// + public async Task> GetHistoricalSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); + parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_settlement_records", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Top Trader Account Sentiment + + /// + public async Task> GetTopTraderAccountSentimentAsync(string contractCode, Period period, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnum("period", period); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_elite_account_ratio", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Top Trader Position Sentiment + + /// + public async Task> GetTopTraderPositionSentimentAsync(string contractCode, Period period, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnum("period", period); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_elite_position_ratio", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Status + + /// + public async Task>> GetIsolatedMarginStatusAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_api_state", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Tiered Margin Info + + /// + public async Task>> GetCrossTieredMarginInfoAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_cross_ladder_margin", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Tiered Info + + /// + public async Task>> GetIsolatedMarginTieredInfoAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_ladder_margin", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Estimated Setllement Price + + /// + public async Task>> GetEstimatedSettlementPriceAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_estimated_settlement_price", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Adjust Factor Info + + /// + public async Task>> GetIsolatedMarginAdjustFactorInfoAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_adjustfactor", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Adjust Factor Info + + /// + public async Task>> GetCrossMarginAdjustFactorInfoAsync(string? contractCode = null, string? asset = null, ContractType? type = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", asset); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(type)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_cross_adjustfactor", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Insurance Fund History + + /// + public async Task> GetInsuranceFundHistoryAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_insurance_fund", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Swap Risk Info + + /// + public async Task>> GetSwapRiskInfoAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_risk_info", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Swap Price Limitation + + /// + public async Task>> GetSwapPriceLimitationAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_price_limit", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Swap Open Interest + + /// + public async Task>> GetSwapOpenInterestAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_open_interest", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Contracts + + /// + public async Task>> GetContractsAsync(string? contractCode = null, MarginMode? supportMarginMode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("support_margin_mode", supportMarginMode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_contract_info", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Swap Index Price + + /// + public async Task>> GetSwapIndexPriceAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-api/v1/swap_index", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Contract Elements + + /// + public async Task>> GetContractElementsAsync(string contractCode, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_query_elements", HTXExchange.RateLimiter.UsdtPublicReference, 1, false); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Order Book + + /// + public async Task> GetOrderBookAsync(string contractCode, int? mergeStep = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "type", "step" + (mergeStep ?? 0) }, + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/depth", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Book Ticker + + /// + public async Task>> GetBookTickerAsync(string? contractCode = null, BusinessType? type = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(type)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/bbo", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Klines + + /// + public async Task>> GetKlinesAsync(string contractCode, KlineInterval interval, DateTime? startTime = null, DateTime? endTime = null, int? limit = null, CancellationToken ct = default) + { + if (startTime == null && endTime == null && limit == null) + limit = 100; // Limit is required if no time is given + + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "period", EnumConverter.GetString(interval) } + }; + parameters.AddOptionalParameter("size", limit); + parameters.AddOptionalParameter("from", DateTimeConverter.ConvertToSeconds(startTime)); + parameters.AddOptionalParameter("to", DateTimeConverter.ConvertToSeconds(endTime)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/history/kline", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Mark Price Klines + + /// + public async Task>> GetMarkPriceKlinesAsync(string contractCode, KlineInterval klineInterval, int limit, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnum("period", klineInterval); + parameters.Add("size", limit); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/index/market/history/linear_swap_mark_price_kline", HTXExchange.RateLimiter.PublicMarket, 1, false); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Ticker + + /// + public async Task> GetTickerAsync(string contractCode, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/detail/merged", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Tickers + + /// + public async Task>> GetTickersAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/v2/linear-swap-ex/market/detail/batch_merged", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Last Trade + + /// + public async Task> GetLastTradesAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/trade", HTXExchange.RateLimiter.PublicMarket, 1, false); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result.As(result.Data?.Data?.First()!); + } + + #endregion + + #region Get Recent Trades + + /// + public async Task>> GetRecentTradesAsync(string contractCode, int limit, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "size", limit } + }; + + var request = _definitions.GetOrCreate(HttpMethod.Get, "linear-swap-ex/market/history/trade", HTXExchange.RateLimiter.PublicMarket, 1, false); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result.As(result.Data?.SelectMany(d => d.Data)!); + } + + #endregion + + #region Get Open Interest + + /// + public async Task> GetOpenInterestHistoryAsync(InterestPeriod period, Unit unit, string? contractCode = null, string? symbol = null, ContractType? type = null, int? limit = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "period", EnumConverter.GetString(period) }, + { "amount_type", EnumConverter.GetString(unit) }, + }; + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("size", limit); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(type)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_his_open_interest", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Premium Index Klines + + /// + public async Task>> GetPremiumIndexKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "period", EnumConverter.GetString(interval) }, + { "size", limit } + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "/index/market/history/linear_swap_premium_index_kline", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Estimated Funding Rate Klines + + /// + public async Task>> GetEstimatedFundingRateKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "period", EnumConverter.GetString(interval) }, + { "size", limit } + }; + var request = _definitions.GetOrCreate(HttpMethod.Get, "index/market/history/linear_swap_estimated_rate_kline", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Basis Data + + /// + public async Task>> GetBasisDataAsync(string contractCode, KlineInterval interval, int limit, string? basisPriceType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "period", EnumConverter.GetString(interval) }, + { "size", limit } + }; + parameters.AddOptionalParameter("basis_price_type", basisPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/index/market/history/linear_swap_basis", HTXExchange.RateLimiter.PublicMarket, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Trade Status + + /// + public async Task>> GetCrossMarginTradeStatusAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_cross_trade_state", HTXExchange.RateLimiter.UsdtRead, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Transfer Status + + /// + public async Task>> GetCrossMarginTransferStatusAsync(string? marginAccount = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_cross_transfer_state", HTXExchange.RateLimiter.UsdtRead, 1, false); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + } +} diff --git a/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiSubAccount.cs b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiSubAccount.cs new file mode 100644 index 00000000..907b35c7 --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiSubAccount.cs @@ -0,0 +1,186 @@ +using HTX.Net.Objects.Models.UsdtMarginSwap; +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXRestClientUsdtFuturesApiSubAccount : IHTXRestClientUsdtFuturesApiSubAccount + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientUsdtFuturesApi _baseClient; + + internal HTXRestClientUsdtFuturesApiSubAccount(HTXRestClientUsdtFuturesApi baseClient) + { + _baseClient = baseClient; + } + + #region Set Trading Permissions + + /// + public async Task> SetTradingPermissionsAsync(IEnumerable subAccountUids, bool enabled, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "sub_uid", string.Join(",", subAccountUids) }, + { "sub_auth", enabled ? "1": "0" } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_sub_auth", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Trade Permissions + + /// + public async Task> GetTradePermissionsAsync(IEnumerable? subAccountUids = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("sub_uid", subAccountUids == null ? null : string.Join(",", subAccountUids)); + parameters.AddOptionalMillisecondsString("start_time", startTime); + parameters.AddOptionalMillisecondsString("end_time", endTime); + parameters.AddOptionalEnum("direction", filterDirection); + parameters.AddOptional("from_id", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Get, "/linear-swap-api/v1/swap_sub_auth_list", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Assets + + /// + public async Task>> GetIsolatedMarginAssetsAsync(string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_sub_account_list", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Assets + + /// + public async Task>> GetCrossMarginAssetsAsync(string? marginAccount = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("margin_account", marginAccount); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_sub_account_list", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Asset Info + + /// + public async Task> GetIsolatedMarginAssetInfoAsync(string? contractCode = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_sub_account_info_list", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Asset Info + + /// + public async Task> GetCrossMarginAssetInfoAsync(string? marginAccount = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("margin_account", marginAccount); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_sub_account_info_list", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + // /linear-swap-api/v1/swap_sub_account_info + // /linear-swap-api/v1/swap_cross_sub_account_info + + #region Get Isolated Margin Positions + + /// + public async Task>> GetIsolatedMarginPositionsAsync(long subUserId, string? contractCode = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("sub_uid", subUserId); + parameters.AddOptional("contract_code", contractCode); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_sub_position_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Positions + + /// + public async Task>> GetCrossMarginPositionsAsync(long subUserId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("sub_uid", subUserId); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_sub_position_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Transfer Master Sub + + /// + public async Task> TransferMasterSubAsync(string subUid, string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, MasterSubTransferType type, long? clientOrderId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "sub_uid", subUid }, + { "asset", asset }, + { "from_margin_account", fromMarginAccount }, + { "to_margin_account", toMarginAccount }, + { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, + { "type", type == MasterSubTransferType.SubToMaster ? "sub_to_master": "master_to_sub" }, + }; + parameters.AddOptionalParameter("client_order_id", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_master_sub_transfer", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Master Sub Transfer Records + + /// + public async Task> GetMasterSubTransferRecordsAsync(string marginAccount, int daysInHistory, MasterSubTransferType? type = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "margin_account", marginAccount }, + { "create_date", daysInHistory } + }; + parameters.AddOptionalParameter("transfer_type", EnumConverter.GetString(type)); + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_master_sub_transfer_record", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + } +} diff --git a/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiTrading.cs b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiTrading.cs new file mode 100644 index 00000000..aeac4158 --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiTrading.cs @@ -0,0 +1,1160 @@ +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXRestClientUsdtFuturesApiTrading : IHTXRestClientUsdtFuturesApiTrading + { + private static readonly RequestDefinitionCache _definitions = new RequestDefinitionCache(); + private readonly HTXRestClientUsdtFuturesApi _baseClient; + + internal HTXRestClientUsdtFuturesApiTrading(HTXRestClientUsdtFuturesApi baseClient) + { + _baseClient = baseClient; + } + + #region Cancel Orders After + + /// + public async Task> CancelOrdersAfterAsync(bool enable, TimeSpan? timeout = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("on_off", enable); + parameters.AddOptional("time_out", (int?)timeout?.TotalMilliseconds); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/linear-cancel-after", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Place Isolated Margin Order + + /// + public async Task> PlaceIsolatedMarginOrderAsync( + string contractCode, + long quantity, + OrderSide side, + int leverageRate, + OrderPriceType orderPriceType, + decimal? price = null, + Offset? offset = null, + decimal? takeProfitTriggerPrice = null, + decimal? takeProfitOrderPrice = null, + OrderPriceType? takeProfitOrderPriceType = null, + decimal? stopLossTriggerPrice = null, + decimal? stopLossOrderPrice = null, + OrderPriceType? stopLossOrderPriceType = null, + bool? reduceOnly = null, + long? clientOrderId = null, + CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "volume", quantity }, + { "direction", EnumConverter.GetString(side) }, + { "lever_rate", leverageRate }, + { "channel_code", _baseClient._brokerId }, + { "order_price_type", EnumConverter.GetString(orderPriceType) } + }; + parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); + parameters.AddOptionalParameter("tp_trigger_price", takeProfitTriggerPrice); + parameters.AddOptionalParameter("tp_order_price", takeProfitOrderPrice); + parameters.AddOptionalParameter("tp_order_price_type", EnumConverter.GetString(takeProfitOrderPriceType)); + parameters.AddOptionalParameter("sl_trigger_price", stopLossTriggerPrice); + parameters.AddOptionalParameter("sl_order_price", stopLossOrderPrice); + parameters.AddOptionalParameter("sl_order_price_type", EnumConverter.GetString(stopLossOrderPriceType)); + parameters.AddOptionalParameter("reduce_only", reduceOnly == null ? null : reduceOnly.Value ? "1" : "0"); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Place Cross Margin Order + + /// + public async Task> PlaceCrossMarginOrderAsync( + long quantity, + OrderSide side, + int leverageRate, + OrderPriceType orderPriceType, + string? contractCode = null, + string? symbol = null, + ContractType? contractType = null, + decimal? price = null, + Offset? offset = null, + decimal? takeProfitTriggerPrice = null, + decimal? takeProfitOrderPrice = null, + OrderPriceType? takeProfitOrderPriceType = null, + decimal? stopLossTriggerPrice = null, + decimal? stopLossOrderPrice = null, + OrderPriceType? stopLossOrderPriceType = null, + bool? reduceOnly = null, + long? clientOrderId = null, + CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "volume", quantity }, + { "direction", EnumConverter.GetString(side) }, + { "lever_rate", leverageRate }, + { "channel_code", _baseClient._brokerId }, + { "order_price_type", EnumConverter.GetString(orderPriceType) } + }; + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture)); + parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); + parameters.AddOptionalParameter("tp_trigger_price", takeProfitTriggerPrice); + parameters.AddOptionalParameter("tp_order_price", takeProfitOrderPrice); + parameters.AddOptionalParameter("tp_order_price_type", EnumConverter.GetString(takeProfitOrderPriceType)); + parameters.AddOptionalParameter("sl_trigger_price", stopLossTriggerPrice); + parameters.AddOptionalParameter("sl_order_price", stopLossOrderPrice); + parameters.AddOptionalParameter("sl_order_price_type", EnumConverter.GetString(stopLossOrderPriceType)); + parameters.AddOptionalParameter("reduce_only", reduceOnly == null ? null : reduceOnly.Value ? "1" : "0"); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + // /linear-swap-api/v1/swap_batchorder + // /linear-swap-api/v1/swap_cross_batchorder + + + #region Cancel Isolated Margin Order + + /// + public async Task> CancelIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("order_id", orderId); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Cross Margin Order + + /// + public async Task> CancelCrossMarginOrderAsync(long? orderId = null, long? clientOrderId = null, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("order_id", orderId); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Isolated Margin Orders + + /// + public async Task> CancelIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderId, IEnumerable clientOrderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "order_id", string.Join(",", orderId) }, + { "client_order_id", string.Join(",", clientOrderId) } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel Cross Margin Orders + + /// + public async Task> CancelCrossMarginOrdersAsync(IEnumerable orderId, IEnumerable clientOrderId, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "order_id", string.Join(",", orderId) }, + { "client_order_id", string.Join(",", clientOrderId) } + }; + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel All Isolated Margin Orders + + /// + public async Task> CancelAllIsolatedMarginOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("direction", EnumConverter.GetString(side)); + parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cancelall", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Cancel All Cross Margin Orders + + /// + public async Task> CancelAllCrossMarginOrdersAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + parameters.AddOptionalParameter("direction", EnumConverter.GetString(side)); + parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_cancelall", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Set Isolated Margin Leverage + + /// + public async Task> SetIsolatedMarginLeverageAsync(string contractCode, int leverageRate, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "lever_rate", leverageRate }, + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_switch_lever_rate", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Set Cross Margin Leverage + + /// + public async Task> SetCrossMarginLeverageAsync(int leverageRate, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "lever_rate", leverageRate }, + }; + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_switch_lever_rate", HTXExchange.RateLimiter.UsdtTrade, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Order + + /// + public async Task>> GetIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("order_id", orderId); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_order_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Order + + /// + public async Task>> GetCrossMarginOrderAsync(string? contractCode = null, string? symbol = null, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + parameters.AddOptionalParameter("order_id", orderId); + parameters.AddOptionalParameter("client_order_id", clientOrderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_order_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Orders + + /// + public async Task>> GetIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderIds, IEnumerable clientOrderIds, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + if (orderIds?.Any() == true) + parameters.AddOptionalParameter("order_id", string.Join(",", orderIds)); + if (clientOrderIds?.Any() == true) + parameters.AddOptionalParameter("client_order_id", string.Join(",", clientOrderIds)); + + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_order_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Orders + + /// + public async Task>> GetCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? symbol = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("pair", symbol); + if (orderIds?.Any() == true) + parameters.AddOptionalParameter("order_id", string.Join(",", orderIds)); + if (clientOrderIds?.Any() == true) + parameters.AddOptionalParameter("client_order_id", clientOrderIds); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_order_info", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync>(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Order Details + + /// + public async Task> GetIsolatedMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "order_id", orderId } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_order_detail", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Order Details + + /// + public async Task> GetCrossMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode }, + { "order_id", orderId } + }; + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_order_detail", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Open Orders + + /// + public async Task> GetIsolatedMarginOpenOrdersAsync(string contractCode, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "contract_code", contractCode } + }; + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + parameters.AddOptionalParameter("sort_by", sortBy); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Cross Margin Open Orders + + /// + public async Task> GetCrossMarginOpenOrdersAsync(string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptionalParameter("contract_code", contractCode); + parameters.AddOptionalParameter("page_index", page); + parameters.AddOptionalParameter("page_size", pageSize); + parameters.AddOptionalParameter("sort_by", sortBy); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + return await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + } + + #endregion + + #region Get Isolated Margin Closed Orders + + /// + public async Task>> GetIsolatedMarginClosedOrdersAsync(string contractCode, MarginTradeType tradeType, bool allOrders, IEnumerable? status = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, long? fromId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract", contractCode); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("type", allOrders ? 1 : 2); + parameters.Add("status", string.Join(",", status.Select(EnumConverter.GetString))); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptional("from_id", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v3/swap_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Closed Orders + + /// + public async Task>> GetCrossMarginClosedOrdersAsync( + string contractCode, + MarginTradeType tradeType, + bool allOrders, + IEnumerable status, + string? pair = null, + DateTime? startTime = null, + DateTime? endTime = null, + FilterDirection? direction = null, + long? fromId = null, + CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract", contractCode); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("type", allOrders ? 1 : 2); + parameters.AddOptional("status", status?.Any() == true ? string.Join(",", status.Select(EnumConverter.GetString)) : null); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", direction); + parameters.AddOptional("from_id", fromId); + parameters.AddOptional("pair", pair); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v3/swap_cross_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + // /linear-swap-api/v3/swap_hisorders_exact + // /linear-swap-api/v3/swap_cross_hisorders_exact + + #region Get Isolated Margin User Trades + + /// + public async Task>> GetIsolatedMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, string? pair = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract", contractCode); + parameters.AddEnum("trade_type", tradeType); + parameters.AddOptional("pair", pair); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", filterDirection); + parameters.AddOptional("from_id", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v3/swap_matchresults", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin User Trades + + /// + public async Task>> GetCrossMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, string? pair = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract", contractCode); + parameters.AddEnum("trade_type", tradeType); + parameters.AddOptional("pair", pair); + parameters.AddOptionalMilliseconds("start_time", startTime); + parameters.AddOptionalMilliseconds("end_time", endTime); + parameters.AddOptionalEnum("direct", filterDirection); + parameters.AddOptional("from_id", fromId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v3/swap_cross_matchresults ", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendAsync>(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + // /linear-swap-api/v3/swap_matchresults_exact + // /linear-swap-api/v3/swap_cross_matchresults_exact + + #region Close Isolated Margin Position + + /// + public async Task> CloseIsolatedMarginPositionAsync(string contractCode, OrderSide direction, long? clientOrderId = null, LightningPriceType? orderPriceType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnum("direction", direction); + parameters.AddOptional("client_order_id", clientOrderId); + parameters.AddOptionalEnum("order_price_type", orderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_lightning_close_position", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Close Cross Margin Position + + /// + public async Task> CloseCrossMarginPositionAsync(OrderSide direction, string? contractCode = null, string? pair = null, ContractType? contractType = null, long? clientOrderId = null, LightningPriceType? orderPriceType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddEnum("direction", direction); + parameters.AddOptionalEnum("contractType", contractType); + parameters.AddOptional("client_order_id", clientOrderId); + parameters.AddOptionalEnum("order_price_type", orderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_lightning_close_position ", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Place Isolated Margin Trigger Order + + /// + public async Task> PlaceIsolatedMarginTriggerOrderAsync(string contractCode, TriggerType triggerType, decimal triggerPrice, decimal quantity, OrderSide side, Offset? offset = null, bool? reduceOnly = null, decimal? orderPrice = null, OrderPriceType? orderPriceType = null, int? leverageRate = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "channel_code", _baseClient._brokerId } + }; + parameters.Add("contract_code", contractCode); + parameters.AddEnum("trigger_type", triggerType); + parameters.Add("trigger_price", triggerPrice); + parameters.Add("volume", quantity); + parameters.AddEnum("direction", side); + parameters.AddOptionalEnum("offset", offset); + parameters.AddOptional("reduce_only", reduceOnly); + parameters.AddOptional("order_price", orderPrice); + parameters.AddOptionalEnum("order_price_type", orderPriceType); + parameters.AddOptional("lever_rate", leverageRate); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_trigger_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Place Cross Margin Trigger Order + + /// + public async Task> PlaceCrossMarginTriggerOrderAsync(TriggerType triggerType, decimal triggerPrice, decimal quantity, OrderSide side, string? contractCode = null, string? pair = null, ContractType? contractType = null, Offset? offset = null, bool? reduceOnly = null, decimal? orderPrice = null, OrderPriceType? orderPriceType = null, int? leverageRate = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "channel_code", _baseClient._brokerId } + }; + parameters.AddOptional("contract_code", contractCode); + parameters.AddEnum("trigger_type", triggerType); + parameters.Add("trigger_price", triggerPrice); + parameters.Add("volume", quantity); + parameters.AddEnum("direction", side); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("offset", offset); + parameters.AddOptional("pair", pair); + parameters.AddOptional("reduce_only", reduceOnly); + parameters.AddOptional("order_price", orderPrice); + parameters.AddOptionalEnum("order_price_type", orderPriceType); + parameters.AddOptional("lever_rate", leverageRate); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_trigger_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Isolated Margin Trigger Order + + /// + public async Task> CancelIsolatedMarginTriggerOrderAsync(string contractCode, string orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_trigger_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Cross Margin Trigger Order + + /// + public async Task> CancelCrossMarginTriggerOrderAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.Add("order_id", orderId); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_trigger_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Isolated Margin Trigger Orders + + /// + public async Task> CancelAllIsolatedMarginTriggerOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddOptionalEnum("direction", side); + parameters.AddOptionalEnum("offset", offset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_trigger_cancelall", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Isolated Margin Trigger Orders + + /// + public async Task> CancelAllCrossMarginTriggerOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("direction", side); + parameters.AddOptionalEnum("offset", offset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_trigger_cancelall ", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Open Trigger Orders + + /// + public async Task> GetIsolatedMarginOpenTriggerOrdersAsync(string contractCode, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_trigger_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Open Trigger Orders + + /// + public async Task> GetCrossMarginOpenTriggerOrdersAsync(string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_trigger_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Trigger Order History + + /// + public async Task> GetIsolatedMarginTriggerOrderHistoryAsync(string contractCode, MarginTradeType tradeType, int daysPast, OrderStatusFilter status, int? page = null, int? pageIndex = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("create_date", daysPast); + parameters.AddEnum("status", status); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageIndex); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_trigger_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Trigger Order History + + /// + public async Task> GetCrossMarginTriggerOrderHistoryAsync(MarginTradeType tradeType, int daysPast, OrderStatusFilter status, string? contractCode = null, string? pair = null, ContractType? contractType = null, int? page = null, int? pageIndex = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("create_date", daysPast); + parameters.AddEnum("status", status); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageIndex); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_trigger_hisorders ", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Set Isolated Margin Tp Sl + + /// + public async Task> SetIsolatedMarginTpSlAsync(string contractCode, OrderSide side, decimal quantity, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddEnum("direction", side); + parameters.Add("volume", quantity); + parameters.AddOptional("tp_trigger_price", takeProfitTriggerPrice); + parameters.AddOptional("tp_order_price", takeProfitOrderPrice); + parameters.AddOptionalEnum("tp_order_price_type", takeProfitOrderPriceType); + parameters.AddOptional("sl_trigger_price", stopLossTriggerPrice); + parameters.AddOptional("sl_order_price", stopLossOrderPrice); + parameters.AddOptionalEnum("sl_order_price_type", stopLossOrderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_tpsl_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Set Cross Margin Tp Sl + + /// + public async Task> SetCrossMarginTpSlAsync(OrderSide side, decimal quantity, string? contractCode = null, string? pair = null, ContractType? contractType = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddEnum("direction", side); + parameters.Add("volume", quantity); + parameters.AddOptional("tp_trigger_price", takeProfitTriggerPrice); + parameters.AddOptional("tp_order_price", takeProfitOrderPrice); + parameters.AddOptionalEnum("tp_order_price_type", takeProfitOrderPriceType); + parameters.AddOptional("sl_trigger_price", stopLossTriggerPrice); + parameters.AddOptional("sl_order_price", stopLossOrderPrice); + parameters.AddOptionalEnum("sl_order_price_type", stopLossOrderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_tpsl_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Isolated Margin Tp Sl + + /// + public async Task> CancelIsolatedMarginTpSlAsync(string contractCode, string orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_tpsl_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Cross Margin Tp Sl + + /// + public async Task> CancelCrossMarginTpSlAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_tpsl_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Isolated Margin Tp Sl + + /// + public async Task> CancelAllIsolatedMarginTpSlAsync(string contractCode, OrderSide? side = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddOptionalEnum("direction", side); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_tpsl_cancelall", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Cross Margin Tp Sl + + /// + public async Task> CancelAllCrossMarginTpSlAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("pair", pair); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("direction", side); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_tpsl_cancelall ", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Open Tp Sl Orders + + /// + public async Task> GetIsolatedMarginOpenTpSlOrdersAsync(string? contractCode = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_tpsl_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Open Tp Sl Orders + + /// + public async Task> GetCrossMarginOpenTpSlOrdersAsync(string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptionalEnumAsInt("trade_type", tradeType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_tpsl_openorders ", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Tp Sl History + + /// + public async Task> GetIsolatedMarginTpSlHistoryAsync(string contractCode, IEnumerable tpSlOrderStatus, int daysPast, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("status", string.Join(",", tpSlOrderStatus.Select(EnumConverter.GetString))); + parameters.Add("create_date", daysPast); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_tpsl_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Tp Sl History + + /// + public async Task> GetCrossMarginTpSlHistoryAsync(IEnumerable tpSlOrderStatus, int daysPast, string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.Add("status", string.Join(",", tpSlOrderStatus.Select(EnumConverter.GetString))); + parameters.Add("create_date", daysPast); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_tpsl_hisorders ", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Isolated Margin Position Open Tp Sl Info + + /// + public async Task> GetIsolatedMarginPositionOpenTpSlInfoAsync(string contractCode, long orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_relation_tpsl_order", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Cross Margin Position Open Tp Sl Info + + /// + public async Task> GetCrossMarginPositionOpenTpSlInfoAsync(long orderId, string? contractCode = null, string? pair = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("pair", pair); + parameters.AddOptional("contract_code", contractCode); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_relation_tpsl_order", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Place Isolated Margin Trailing Order + + /// + public async Task> PlaceIsolatedMarginTrailingOrderAsync(string contractCode, bool reduceOnly, OrderSide side, Offset offset, int leverageRate, decimal quantity, decimal callbackRate, decimal activePrice, OrderPriceType orderPriceType, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "channel_code", _baseClient._brokerId } + }; + parameters.Add("contract_code", contractCode); + parameters.Add("reduce_only", reduceOnly ? 1 : 0); + parameters.AddEnum("direction", side); + parameters.AddEnum("offset", offset); + parameters.Add("lever_rate", leverageRate); + parameters.Add("volume", quantity); + parameters.Add("callback_rate", callbackRate); + parameters.Add("active_price", activePrice); + parameters.AddEnum("order_price_type", orderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_track_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Place Cross Margin Trailing Order + + /// + public async Task> PlaceCrossMarginTrailingOrderAsync(OrderSide side, Offset offset, int leverageRate, decimal quantity, decimal callbackRate, decimal activePrice, OrderPriceType orderPriceType, string? contractCode = null, string? pair = null, ContractType? contractType = null, bool? reduceOnly = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection() + { + { "channel_code", _baseClient._brokerId } + }; + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + if (reduceOnly.HasValue) + parameters.Add("reduce_only", reduceOnly.Value ? 1 : 0); + parameters.AddEnum("direction", side); + parameters.AddEnum("offset", offset); + parameters.Add("lever_rate", leverageRate); + parameters.Add("volume", quantity); + parameters.Add("callback_rate", callbackRate); + parameters.Add("active_price", activePrice); + parameters.AddEnum("order_price_type", orderPriceType); + var request = _definitions.GetOrCreate(HttpMethod.Post, "linear-swap-api/v1/swap_cross_track_order", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Isolated Margin Trailing Order + + /// + public async Task> CancelIsolatedMarginTrailingOrderAsync(string contractCode, string orderId, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_track_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel Cross Margin Trailing Order + + /// + public async Task> CancelCrossMarginTrailingOrderAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.Add("order_id", orderId); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_track_cancel", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Isolated Margin Trailing Orders + + /// + public async Task> CancelAllIsolatedMarginTrailingOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddOptionalEnum("direction", side); + parameters.AddOptionalEnum("offset", offset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_track_cancelall", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Cancel All Cross Margin Trailing Orders + + /// + public async Task> CancelAllCrossMarginTrailingOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptionalEnum("direction", side); + parameters.AddOptionalEnum("offset", offset); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_track_cancelall ", HTXExchange.RateLimiter.UsdtTrade, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Open Isolated Margin Trailing Orders + + /// + public async Task> GetOpenIsolatedMarginTrailingOrdersAsync(string contractCode, MarginTradeType? tradeType = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.AddOptionalEnum("trade_type", tradeType); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_track_openorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Open Cross Margin Trailing Orders + + /// + public async Task> GetOpenCrossMarginTrailingOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, MarginTradeType? tradeType = null, int? page = null, int? pageSize = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("trade_type", tradeType); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_track_openorders ", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Closed Isolated Margin Trailing Orders + + /// + public async Task> GetClosedIsolatedMarginTrailingOrdersAsync(string contractCode, IEnumerable tpSlOrderStatus, MarginTradeType tradeType, int daysPast, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.Add("contract_code", contractCode); + parameters.Add("status", string.Join(",", tpSlOrderStatus.Select(EnumConverter.GetString))); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("create_date", daysPast); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_track_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + #region Get Closed Cross Margin Trailing Orders + + /// + public async Task> GetClosedCrossMarginTrailingOrdersAsync(IEnumerable tpSlOrderStatus, MarginTradeType tradeType, int daysPast, string? contractCode = null, string? pair = null, ContractType? contractType = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) + { + var parameters = new ParameterCollection(); + parameters.AddOptional("contract_code", contractCode); + parameters.AddOptional("pair", pair); + parameters.AddOptionalEnum("contract_type", contractType); + parameters.Add("status", string.Join(",", tpSlOrderStatus.Select(EnumConverter.GetString))); + parameters.AddEnumAsInt("trade_type", tradeType); + parameters.Add("create_date", daysPast); + parameters.AddOptional("page_index", page); + parameters.AddOptional("page_size", pageSize); + parameters.AddOptional("sort_by", sortBy); + var request = _definitions.GetOrCreate(HttpMethod.Post, "/linear-swap-api/v1/swap_cross_track_hisorders", HTXExchange.RateLimiter.UsdtRead, 1, true); + var result = await _baseClient.SendBasicAsync(request, parameters, ct).ConfigureAwait(false); + return result; + } + + #endregion + + } +} diff --git a/HTX.Net/Clients/UsdtFutures/HTXSocketClientUsdtFuturesApi.cs b/HTX.Net/Clients/UsdtFutures/HTXSocketClientUsdtFuturesApi.cs new file mode 100644 index 00000000..88282c8c --- /dev/null +++ b/HTX.Net/Clients/UsdtFutures/HTXSocketClientUsdtFuturesApi.cs @@ -0,0 +1,294 @@ +using System.Net.WebSockets; +using CryptoExchange.Net.Clients; +using CryptoExchange.Net.Converters.MessageParsing; +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Enums; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Options; +using HTX.Net.Objects.Sockets.Queries; +using HTX.Net.Objects.Sockets.Subscriptions; + + +namespace HTX.Net.Clients.UsdtFutures +{ + /// + internal class HTXSocketClientUsdtFuturesApi : SocketApiClient, IHTXSocketClientUsdtFuturesApi + { + private static readonly MessagePath _idPath = MessagePath.Get().Property("id"); + private static readonly MessagePath _actionPath = MessagePath.Get().Property("action"); + private static readonly MessagePath _channelPath = MessagePath.Get().Property("ch"); + private static readonly MessagePath _pingPath = MessagePath.Get().Property("ping"); + + + private static readonly MessagePath _cidPath = MessagePath.Get().Property("cid"); + private static readonly MessagePath _opPath = MessagePath.Get().Property("op"); + private static readonly MessagePath _topicPath = MessagePath.Get().Property("topic"); + + #region ctor + internal HTXSocketClientUsdtFuturesApi(ILogger logger, HTXSocketOptions options) + : base(logger, options.Environment.UsdtMarginSwapSocketBaseAddress, options, options.UsdtMarginSwapOptions) + { + KeepAliveInterval = TimeSpan.Zero; + + AddSystemSubscription(new HTXPingSubscription(_logger)); + AddSystemSubscription(new HTXOpPingSubscription(_logger)); + + RateLimiter = HTXExchange.RateLimiter.UsdtConnection; + } + + #endregion + + protected override IMessageSerializer CreateSerializer() => new SystemTextJsonMessageSerializer(); + + protected override IByteMessageAccessor CreateAccessor() => new SystemTextJsonByteMessageAccessor(); + + /// + public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}-{quoteAsset.ToUpperInvariant()}"; + + /// + public override ReadOnlyMemory PreprocessStreamMessage(SocketConnection connection, WebSocketMessageType type, ReadOnlyMemory data) + { + if (type != WebSocketMessageType.Binary) + return data; + + return data.DecompressGzip(); + } + + protected override Query? GetAuthenticationRequest(SocketConnection connection) + { + var request = ((HTXAuthenticationProvider)AuthenticationProvider!).GetWebsocketAuthentication2(connection.ConnectionUri); + return new HTXOpAuthQuery(request); + } + + /// + public override string? GetListenerIdentifier(IMessageAccessor message) + { + var id = message.GetValue(_idPath) ?? message.GetValue(_cidPath); + if (id != null) + return id; + + var ping = message.GetValue(_pingPath); + if (ping != null) + return "pingV3"; + + var opPing = message.GetValue(_opPath); + if (string.Equals(opPing, "ping")) + return "ping"; + + if (string.Equals(opPing, "auth")) + return "auth"; + + var channel = message.GetValue(_channelPath); + var action = message.GetValue(_actionPath); + if (action != null && action != "push") + return action + channel; + + var topic = message.GetValue(_topicPath); + if (topic != null) + { + if (topic.EndsWith(".liquidation_orders")) + topic = "public.*.liquidation_orders"; + if (topic.EndsWith(".funding_rate")) + topic = "public.*.funding_rate"; + if (topic.StartsWith("accounts.")) + topic = "accounts"; + if (topic.StartsWith("orders.")) + topic = "orders"; + if (topic.StartsWith("accounts_cross.")) + topic = "accounts_cross"; + if (topic.StartsWith("orders_cross.")) + topic = "orders_cross"; + + return topic; + } + + return channel; + } + + /// + protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) + => new HTXAuthenticationProvider(credentials, false); + + /// + public async Task> SubscribeToKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.kline.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToOrderBookUpdatesAsync(string contractCode, int mergeStep, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.depth.step" + mergeStep, x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIncrementalOrderBookUpdatesAsync(string contractCode, bool snapshot, int limit, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXIncrementalOrderBookSubscription(_logger, snapshot, $"market.{contractCode.ToUpperInvariant()}.depth.size_{limit}.high_freq", x => onData(x.WithSymbol(contractCode))); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.detail", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToBookTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.bbo", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToTradeUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.trade.detail", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.index.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToPremiumIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.premium_index.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToEstimatedFundingRateKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.estimated_rate.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToBasisUpdatesAsync(string contractCode, KlineInterval period, string priceType, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.basis.{EnumConverter.GetString(period)}.{priceType}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToMarkPriceKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) + { + var subscription = new HTXSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.mark_price.{EnumConverter.GetString(period)}", x => onData(x.WithSymbol(contractCode)), false); + return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToLiquidationUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "public.*.liquidation_orders", "public.*.liquidation_orders", onData, false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToFundingRateUpdatesAsync(Action>> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "public.*.funding_rate", "public.*.funding_rate", x => onData(x.As(x.Data.Data)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToContractUpdatesAsync(Action>> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "public.*.contract_info", "public.*.contract_info", x => onData(x.As(x.Data.Data)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToContractElementsUpdatesAsync(Action>> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "public.*.contract_elements", "public.*.contract_elements", x => onData(x.As(x.Data.Data)), false); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToSystemStatusUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "public.linear-swap.heartbeat", "public.linear-swap.heartbeat", onData, false); + return await SubscribeAsync(BaseAddress.AppendPath("center-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToOrderUpdatesAsync(MarginMode mode, Action> onData, CancellationToken ct = default) + { + if (mode == MarginMode.All) + throw new ArgumentException("Mode should be either Cross or Isolated", nameof(mode)); + + var topic = mode == MarginMode.Cross ? "orders_cross" : "orders"; + var subscription = new HTXOpSubscription(_logger, topic, topic + ".*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIsolatedMarginBalanceUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "accounts", "accounts.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToCrossMarginBalanceUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "accounts_cross", "accounts_cross.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIsolatedMarginPositionUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "positions", "positions.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToCrossMarginPositionUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "positions_cross", "positions_cross.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIsolatedMarginUserTradeUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "matchOrders", "matchOrders.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToCrossMarginUserTradeUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "matchOrders_cross", "matchOrders_cross.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToIsolatedMarginTriggerOrderUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "trigger_order", "trigger_order.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + + /// + public async Task> SubscribeToCrossMarginTriggerOrderUpdatesAsync(Action> onData, CancellationToken ct = default) + { + var subscription = new HTXOpSubscription(_logger, "trigger_order_cross.*", "trigger_order_cross.*", onData, true); + return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-notification"), subscription, ct).ConfigureAwait(false); + } + } +} diff --git a/Huobi.Net/Enums/AccountActivation.cs b/HTX.Net/Enums/AccountActivation.cs similarity index 70% rename from Huobi.Net/Enums/AccountActivation.cs rename to HTX.Net/Enums/AccountActivation.cs index 47b93165..38c8494d 100644 --- a/Huobi.Net/Enums/AccountActivation.cs +++ b/HTX.Net/Enums/AccountActivation.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Account activation @@ -8,10 +10,12 @@ public enum AccountActivation /// /// Activated /// + [Map("activated")] Activated, /// /// Deactivated /// + [Map("deactivated")] Deactivated } } diff --git a/Huobi.Net/Enums/AccountEventType.cs b/HTX.Net/Enums/AccountEventType.cs similarity index 75% rename from Huobi.Net/Enums/AccountEventType.cs rename to HTX.Net/Enums/AccountEventType.cs index 9c991c26..709f64ea 100644 --- a/Huobi.Net/Enums/AccountEventType.cs +++ b/HTX.Net/Enums/AccountEventType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Event type @@ -8,50 +10,62 @@ public enum AccountEventType /// /// Order placed event /// + [Map("order.place")] OrderPlaced, /// /// Order matched event /// + [Map("order.match")] OrderMatched, /// /// Order refunded event /// + [Map("order.refund")] OrderRefunded, /// /// Order canceled event /// + [Map("order.cancel")] OrderCanceled, /// /// Order fee refunded event /// + [Map("order.fee-refund")] OrderFeeRefunded, /// /// Margin transfer event /// + [Map("margin.transfer")] MarginTransfer, /// /// Margin loan event /// + [Map("margin.loan")] MarginLoan, /// /// Margin interest event /// + [Map("margin.interest")] MarginInterest, /// /// Margin repay event /// + [Map("margin.repay")] MarginRepay, /// /// Other event /// + [Map("other")] Other, /// /// Deposit event /// + [Map("deposit")] Deposit, /// /// Withdraw event /// + [Map("withdraw")] Withdraw } } diff --git a/Huobi.Net/Enums/AccountState.cs b/HTX.Net/Enums/AccountStatus.cs similarity index 60% rename from Huobi.Net/Enums/AccountState.cs rename to HTX.Net/Enums/AccountStatus.cs index 5b770821..2771d3fb 100644 --- a/Huobi.Net/Enums/AccountState.cs +++ b/HTX.Net/Enums/AccountStatus.cs @@ -1,17 +1,21 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Account state /// - public enum AccountState + public enum AccountStatus { /// /// Working /// + [Map("working", "normal")] Working, /// /// Locked /// + [Map("lock")] Locked } } diff --git a/Huobi.Net/Enums/AccountType.cs b/HTX.Net/Enums/AccountType.cs similarity index 75% rename from Huobi.Net/Enums/AccountType.cs rename to HTX.Net/Enums/AccountType.cs index 8b8066f9..8d802373 100644 --- a/Huobi.Net/Enums/AccountType.cs +++ b/HTX.Net/Enums/AccountType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Account type @@ -8,54 +10,67 @@ public enum AccountType /// /// Spot account /// + [Map("spot")] Spot, /// /// Margin account /// + [Map("margin")] Margin, /// /// Super margin account /// + [Map("super-margin")] SuperMargin, /// /// Otc account /// + [Map("otc")] Otc, /// /// Point account /// + [Map("point")] Point, /// /// Investment account /// + [Map("investment")] Investment, /// /// Borrow account /// + [Map("borrow")] Borrow, /// /// Grid trading /// + [Map("grid-trading")] GridTrading, /// /// Deposit earning /// + [Map("deposit-earning")] DepositEarning, /// /// Otc options /// + [Map("otc-options")] OtcOptions, /// /// Minepool /// + [Map("minepool")] Minepool, /// /// Etf /// + [Map("etf")] Etf, /// /// Crypto loans /// + [Map("crypto-loans")] CryptoLoans } } diff --git a/HTX.Net/Enums/ApiKeyStatus.cs b/HTX.Net/Enums/ApiKeyStatus.cs new file mode 100644 index 00000000..2ae68315 --- /dev/null +++ b/HTX.Net/Enums/ApiKeyStatus.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Api key status + /// + public enum ApiKeyStatus + { + /// + /// Normal + /// + [Map("normal")] + Normal, + /// + /// Expired + /// + [Map("expired")] + Expired + } +} diff --git a/HTX.Net/Enums/AssetStatus.cs b/HTX.Net/Enums/AssetStatus.cs new file mode 100644 index 00000000..bf19cda5 --- /dev/null +++ b/HTX.Net/Enums/AssetStatus.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Asset status + /// + public enum AssetStatus + { + /// + /// Normal + /// + [Map("normal")] + Normal, + /// + /// Delisted + /// + [Map("delisted")] + Delisted + } +} diff --git a/HTX.Net/Enums/AssetType.cs b/HTX.Net/Enums/AssetType.cs new file mode 100644 index 00000000..29a65fde --- /dev/null +++ b/HTX.Net/Enums/AssetType.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Asset type + /// + public enum AssetType + { + /// + /// Virtual asset + /// + [Map("1")] + Virtual, + /// + /// Fiat asset + /// + [Map("2")] + Fiat + } +} diff --git a/HTX.Net/Enums/BalanceType.cs b/HTX.Net/Enums/BalanceType.cs new file mode 100644 index 00000000..bc780b69 --- /dev/null +++ b/HTX.Net/Enums/BalanceType.cs @@ -0,0 +1,61 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Balance type + /// + public enum BalanceType + { + /// + /// Trade balance + /// + [Map("trade")] + Trade, + /// + /// Frozen balance + /// + [Map("frozen")] + Frozen, + /// + /// Loan balance + /// + [Map("loan")] + Loan, + /// + /// Locked balance + /// + [Map("lock")] + Lock, + /// + /// Bank balance + /// + [Map("bank")] + Bank, + /// + /// Interest balance + /// + [Map("interest")] + Interest, + /// + /// Credit repay + /// + [Map("credit-repay")] + CreditRepay, + /// + /// Trust asset + /// + [Map("trust-asset")] + TrustAsset, + /// + /// Transfer out available + /// + [Map("transfer-out-available")] + TransferOutAvailable, + /// + /// Loan available + /// + [Map("loan-available")] + LoanAvailable + } +} diff --git a/Huobi.Net/Enums/BusinessType.cs b/HTX.Net/Enums/BusinessType.cs similarity index 93% rename from Huobi.Net/Enums/BusinessType.cs rename to HTX.Net/Enums/BusinessType.cs index f915788a..110357ea 100644 --- a/Huobi.Net/Enums/BusinessType.cs +++ b/HTX.Net/Enums/BusinessType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Business type diff --git a/HTX.Net/Enums/ComponentStatus.cs b/HTX.Net/Enums/ComponentStatus.cs new file mode 100644 index 00000000..fbf03915 --- /dev/null +++ b/HTX.Net/Enums/ComponentStatus.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Component status + /// + public enum ComponentStatus + { + /// + /// Operational + /// + [Map("operational")] + Operational, + /// + /// Degraded performance + /// + [Map("degraded_performance")] + DegradedPerformance, + /// + /// Partial outage + /// + [Map("partial_outage")] + PartialOutage, + /// + /// Major outage + /// + [Map("major_outage")] + MajorOutage, + /// + /// Under maintance + /// + [Map("under maintenance")] + UnderMaintenance + } +} diff --git a/Huobi.Net/Enums/ConditionalOrderStatus.cs b/HTX.Net/Enums/ConditionalOrderStatus.cs similarity index 95% rename from Huobi.Net/Enums/ConditionalOrderStatus.cs rename to HTX.Net/Enums/ConditionalOrderStatus.cs index e42366e3..dc3af5c0 100644 --- a/Huobi.Net/Enums/ConditionalOrderStatus.cs +++ b/HTX.Net/Enums/ConditionalOrderStatus.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Status of a conditional order diff --git a/Huobi.Net/Enums/ConditionalOrderType.cs b/HTX.Net/Enums/ConditionalOrderType.cs similarity index 93% rename from Huobi.Net/Enums/ConditionalOrderType.cs rename to HTX.Net/Enums/ConditionalOrderType.cs index 999fc65f..a9533b44 100644 --- a/Huobi.Net/Enums/ConditionalOrderType.cs +++ b/HTX.Net/Enums/ConditionalOrderType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Conditional order type diff --git a/Huobi.Net/Enums/ContractStatus.cs b/HTX.Net/Enums/ContractStatus.cs similarity index 97% rename from Huobi.Net/Enums/ContractStatus.cs rename to HTX.Net/Enums/ContractStatus.cs index 718f409c..c0fa58f1 100644 --- a/Huobi.Net/Enums/ContractStatus.cs +++ b/HTX.Net/Enums/ContractStatus.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Contract status diff --git a/Huobi.Net/Enums/ContractType.cs b/HTX.Net/Enums/ContractType.cs similarity index 96% rename from Huobi.Net/Enums/ContractType.cs rename to HTX.Net/Enums/ContractType.cs index 3e3ffa4d..6ba533b7 100644 --- a/Huobi.Net/Enums/ContractType.cs +++ b/HTX.Net/Enums/ContractType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Contract type diff --git a/Huobi.Net/Enums/CurrencyStatus.cs b/HTX.Net/Enums/CurrencyStatus.cs similarity index 69% rename from Huobi.Net/Enums/CurrencyStatus.cs rename to HTX.Net/Enums/CurrencyStatus.cs index 65f4bac1..cf185e69 100644 --- a/Huobi.Net/Enums/CurrencyStatus.cs +++ b/HTX.Net/Enums/CurrencyStatus.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Status @@ -8,10 +10,12 @@ public enum CurrencyStatus /// /// Allowed /// + [Map("allowed")] Allowed, /// /// Prohibited /// + [Map("prohibited")] Prohibited } } diff --git a/HTX.Net/Enums/DeductMode.cs b/HTX.Net/Enums/DeductMode.cs new file mode 100644 index 00000000..72b21677 --- /dev/null +++ b/HTX.Net/Enums/DeductMode.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Sub account deduct mode + /// + public enum DeductMode + { + /// + /// Deduct from master + /// + [Map("master")] + Master, + /// + /// Deduct from sub + /// + [Map("sub")] + Sub + } +} diff --git a/HTX.Net/Enums/DeductionSwitchType.cs b/HTX.Net/Enums/DeductionSwitchType.cs new file mode 100644 index 00000000..ee3fb31b --- /dev/null +++ b/HTX.Net/Enums/DeductionSwitchType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Deduction switch type + /// + public enum DeductionSwitchType + { + /// + /// Point card deduction + /// + [Map("0")] + PointCardDeduction, + /// + /// Asset deduction + /// + [Map("1")] + AssetDeduction, + /// + /// Close deduction + /// + [Map("2")] + CloseDeduction + } +} diff --git a/HTX.Net/Enums/ElementBusinessType.cs b/HTX.Net/Enums/ElementBusinessType.cs new file mode 100644 index 00000000..f4e6e247 --- /dev/null +++ b/HTX.Net/Enums/ElementBusinessType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Business type + /// + public enum ElementBusinessType + { + /// + /// Perpetual futures + /// + [Map("1")] + PerpetualFutures, + /// + /// Delivery futures + /// + [Map("2")] + DeliveryFutures, + /// + /// Perpetual + Delivery futures + /// + [Map("3")] + PerpetualAndDeliveryFutures + } +} diff --git a/HTX.Net/Enums/ElementInstrumentType.cs b/HTX.Net/Enums/ElementInstrumentType.cs new file mode 100644 index 00000000..7055a4ed --- /dev/null +++ b/HTX.Net/Enums/ElementInstrumentType.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Instrument type + /// + public enum ElementInstrumentType + { + /// + /// Perpetual futures + /// + [Map("0")] + PerpetualFutures, + /// + /// Weekly futures + /// + [Map("1")] + WeeklyFutures, + /// + /// Bi-weekly futures + /// + [Map("2")] + BiWeeklyFutures, + /// + /// Quarterly futures + /// + [Map("3")] + QuarterlyFutures, + /// + /// Bi-quareterly futures + /// + [Map("4")] + BiQuarterlyFutures, + } +} diff --git a/HTX.Net/Enums/ElementModeType.cs b/HTX.Net/Enums/ElementModeType.cs new file mode 100644 index 00000000..4d0ac8d3 --- /dev/null +++ b/HTX.Net/Enums/ElementModeType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Margin mode type + /// + public enum ElementModeType + { + /// + /// Isolated margin + /// + [Map("1")] + IsolatedMargin, + /// + /// Cross and isolated margin + /// + [Map("2")] + CrossAndIsolatedMargin, + /// + /// Cross margin + /// + [Map("3")] + CrossMargin + } +} diff --git a/HTX.Net/Enums/EventOrderTrigger.cs b/HTX.Net/Enums/EventOrderTrigger.cs new file mode 100644 index 00000000..5019fa8c --- /dev/null +++ b/HTX.Net/Enums/EventOrderTrigger.cs @@ -0,0 +1,31 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Trigger order event + /// + public enum EventOrderTrigger + { + /// + /// Trigger order placed + /// + [Map("order")] + TriggerPlaced, + /// + /// Trigger order canceled + /// + [Map("cancel")] + TriggerCanceled, + /// + /// Successfully triggered + /// + [Map("trigger_success")] + TriggerSuccess, + /// + /// Failed to trigger + /// + [Map("trigger_fail")] + TriggerFail + } +} diff --git a/HTX.Net/Enums/EventTrigger.cs b/HTX.Net/Enums/EventTrigger.cs new file mode 100644 index 00000000..b6b109a3 --- /dev/null +++ b/HTX.Net/Enums/EventTrigger.cs @@ -0,0 +1,66 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Event trigger + /// + public enum EventTrigger + { + /// + /// Open order + /// + [Map("order.open")] + Open, + /// + /// Order match + /// + [Map("order.match")] + Match, + /// + /// Settlement and delivery + /// + [Map("settlement")] + Settlement, + /// + /// Order liquidation + /// + [Map("order.liquidation")] + Liquidation, + /// + /// Order cancel + /// + [Map("order.cancel")] + Cancel, + /// + /// Asset transfer + /// + [Map("contract.transfer")] + Transfer, + /// + /// System + /// + [Map("contract.system")] + System, + /// + /// Other + /// + [Map("other")] + Other, + /// + /// Switch leverage + /// + [Map("switch_lever_rate")] + SwitchLeverageRate, + /// + /// Initial update + /// + [Map("init")] + Initial, + /// + /// Snapshot + /// + [Map("snapshot")] + Snapshot + } +} diff --git a/Huobi.Net/Enums/FeeDeductState.cs b/HTX.Net/Enums/FeeDeductStatus.cs similarity index 64% rename from Huobi.Net/Enums/FeeDeductState.cs rename to HTX.Net/Enums/FeeDeductStatus.cs index 777e577a..6fcf8983 100644 --- a/Huobi.Net/Enums/FeeDeductState.cs +++ b/HTX.Net/Enums/FeeDeductStatus.cs @@ -1,17 +1,21 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Fee deduction status. /// - public enum FeeDeductState + public enum FeeDeductStatus { /// /// In deduction /// + [Map("ongoing")] Ongoing, /// /// Deduction completed /// + [Map("done")] Done, } } diff --git a/Huobi.Net/Enums/FeeType.cs b/HTX.Net/Enums/FeeType.cs similarity index 70% rename from Huobi.Net/Enums/FeeType.cs rename to HTX.Net/Enums/FeeType.cs index 40f7c8de..5d0b2df2 100644 --- a/Huobi.Net/Enums/FeeType.cs +++ b/HTX.Net/Enums/FeeType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Fee type @@ -8,14 +10,17 @@ public enum FeeType /// /// Fixed /// + [Map("fixed")] Fixed, /// /// Circulated /// + [Map("circulated")] Circulated, /// /// Ratio /// + [Map("ratio")] Ratio } } diff --git a/Huobi.Net/Enums/FilterDirection.cs b/HTX.Net/Enums/FilterDirection.cs similarity index 93% rename from Huobi.Net/Enums/FilterDirection.cs rename to HTX.Net/Enums/FilterDirection.cs index d7435e1d..c33571bf 100644 --- a/Huobi.Net/Enums/FilterDirection.cs +++ b/HTX.Net/Enums/FilterDirection.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Filter direction diff --git a/Huobi.Net/Enums/FinancialRecordType.cs b/HTX.Net/Enums/FinancialRecordType.cs similarity index 99% rename from Huobi.Net/Enums/FinancialRecordType.cs rename to HTX.Net/Enums/FinancialRecordType.cs index 730296c7..c292ef59 100644 --- a/Huobi.Net/Enums/FinancialRecordType.cs +++ b/HTX.Net/Enums/FinancialRecordType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Financial record type diff --git a/HTX.Net/Enums/IncidentStatus.cs b/HTX.Net/Enums/IncidentStatus.cs new file mode 100644 index 00000000..a7b22e26 --- /dev/null +++ b/HTX.Net/Enums/IncidentStatus.cs @@ -0,0 +1,31 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Incident status + /// + public enum IncidentStatus + { + /// + /// Investigating + /// + [Map("investigating")] + Investigating, + /// + /// Identified + /// + [Map("identified")] + Identified, + /// + /// Monitoring + /// + [Map("monitoring")] + Monitoring, + /// + /// Resolved + /// + [Map("resolved")] + Resolved + } +} diff --git a/Huobi.Net/Enums/InstrumentStatus.cs b/HTX.Net/Enums/InstrumentStatus.cs similarity index 90% rename from Huobi.Net/Enums/InstrumentStatus.cs rename to HTX.Net/Enums/InstrumentStatus.cs index e231ba7d..7df3908c 100644 --- a/Huobi.Net/Enums/InstrumentStatus.cs +++ b/HTX.Net/Enums/InstrumentStatus.cs @@ -1,4 +1,4 @@ -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Status of an instrument diff --git a/Huobi.Net/Enums/InterestPeriod.cs b/HTX.Net/Enums/InterestPeriod.cs similarity index 95% rename from Huobi.Net/Enums/InterestPeriod.cs rename to HTX.Net/Enums/InterestPeriod.cs index 7024589d..80556033 100644 --- a/Huobi.Net/Enums/InterestPeriod.cs +++ b/HTX.Net/Enums/InterestPeriod.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Interest period diff --git a/Huobi.Net/Enums/KlineInterval.cs b/HTX.Net/Enums/KlineInterval.cs similarity index 98% rename from Huobi.Net/Enums/KlineInterval.cs rename to HTX.Net/Enums/KlineInterval.cs index 54b3e4ea..eb79c753 100644 --- a/Huobi.Net/Enums/KlineInterval.cs +++ b/HTX.Net/Enums/KlineInterval.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Interval for klines, int value represent the time in seconds diff --git a/HTX.Net/Enums/LightningPriceType.cs b/HTX.Net/Enums/LightningPriceType.cs new file mode 100644 index 00000000..3415d3c7 --- /dev/null +++ b/HTX.Net/Enums/LightningPriceType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Price type + /// + public enum LightningPriceType + { + /// + /// Market + /// + [Map("market")] + Market, + /// + /// Fill or kill + /// + [Map("lightning_fok")] + LightningFok, + /// + /// Immediate or cancel + /// + [Map("lightning_ioc")] + LightningIoc + } +} diff --git a/Huobi.Net/Enums/LiquidationTradeType.cs b/HTX.Net/Enums/LiquidationTradeType.cs similarity index 95% rename from Huobi.Net/Enums/LiquidationTradeType.cs rename to HTX.Net/Enums/LiquidationTradeType.cs index f3e4e206..6bd9b1a2 100644 --- a/Huobi.Net/Enums/LiquidationTradeType.cs +++ b/HTX.Net/Enums/LiquidationTradeType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Trade type diff --git a/Huobi.Net/Enums/LiquidationType.cs b/HTX.Net/Enums/LiquidationType.cs similarity index 96% rename from Huobi.Net/Enums/LiquidationType.cs rename to HTX.Net/Enums/LiquidationType.cs index 1b461e1c..8da989f4 100644 --- a/Huobi.Net/Enums/LiquidationType.cs +++ b/HTX.Net/Enums/LiquidationType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Liquidation type diff --git a/Huobi.Net/Enums/OrderSide.cs b/HTX.Net/Enums/LockAction.cs similarity index 51% rename from Huobi.Net/Enums/OrderSide.cs rename to HTX.Net/Enums/LockAction.cs index 34097798..98bb6047 100644 --- a/Huobi.Net/Enums/OrderSide.cs +++ b/HTX.Net/Enums/LockAction.cs @@ -1,21 +1,21 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// - /// Order side + /// Lock /// - public enum OrderSide + public enum LockAction { /// - /// Buy + /// Lock /// - [Map("buy")] - Buy, + [Map("lock")] + Lock, /// - /// Sell + /// Normal /// - [Map("sell")] - Sell + [Map("normal")] + Normal } } diff --git a/HTX.Net/Enums/MaintenanceStatus.cs b/HTX.Net/Enums/MaintenanceStatus.cs new file mode 100644 index 00000000..20a4bad7 --- /dev/null +++ b/HTX.Net/Enums/MaintenanceStatus.cs @@ -0,0 +1,31 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Maintenance status + /// + public enum MaintenanceStatus + { + /// + /// Scheduled + /// + [Map("scheduled")] + Scheduled, + /// + /// In progress + /// + [Map("in progress")] + InProgress, + /// + /// Verifying + /// + [Map("verifying")] + Verifying, + /// + /// Completed + /// + [Map("completed")] + Completed + } +} diff --git a/Huobi.Net/Enums/MarginMode.cs b/HTX.Net/Enums/MarginMode.cs similarity index 94% rename from Huobi.Net/Enums/MarginMode.cs rename to HTX.Net/Enums/MarginMode.cs index a56612d2..c3016a4f 100644 --- a/Huobi.Net/Enums/MarginMode.cs +++ b/HTX.Net/Enums/MarginMode.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Margin mode diff --git a/Huobi.Net/Enums/MarginOrderStatus.cs b/HTX.Net/Enums/MarginOrderStatus.cs similarity index 96% rename from Huobi.Net/Enums/MarginOrderStatus.cs rename to HTX.Net/Enums/MarginOrderStatus.cs index 80d40bd9..0a54c92b 100644 --- a/Huobi.Net/Enums/MarginOrderStatus.cs +++ b/HTX.Net/Enums/MarginOrderStatus.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Status of a margin order diff --git a/Huobi.Net/Enums/MarginOrderType.cs b/HTX.Net/Enums/MarginOrderType.cs similarity index 95% rename from Huobi.Net/Enums/MarginOrderType.cs rename to HTX.Net/Enums/MarginOrderType.cs index 24825277..50e93c2c 100644 --- a/Huobi.Net/Enums/MarginOrderType.cs +++ b/HTX.Net/Enums/MarginOrderType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Margin order type diff --git a/HTX.Net/Enums/MarginPurpose.cs b/HTX.Net/Enums/MarginPurpose.cs new file mode 100644 index 00000000..7dfbfb0e --- /dev/null +++ b/HTX.Net/Enums/MarginPurpose.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Margin order purpose + /// + public enum MarginPurpose + { + /// + /// Loan + /// + [Map("1")] + AutomaticLoan, + /// + /// Repayment + /// + [Map("2")] + AutomaticRepayment + } +} diff --git a/Huobi.Net/Enums/MarginTradeType.cs b/HTX.Net/Enums/MarginTradeType.cs similarity index 76% rename from Huobi.Net/Enums/MarginTradeType.cs rename to HTX.Net/Enums/MarginTradeType.cs index 8effcfa2..678f02a9 100644 --- a/Huobi.Net/Enums/MarginTradeType.cs +++ b/HTX.Net/Enums/MarginTradeType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Trade type @@ -33,6 +33,16 @@ public enum MarginTradeType [Map("4")] SellLong, /// + /// Liquidate long positions + /// + [Map("5")] + LiquidateLong, + /// + /// Liquidate short positions + /// + [Map("6")] + LiquidateShort, + /// /// Buy one way /// [Map("17")] diff --git a/Huobi.Net/Enums/MarketStatus.cs b/HTX.Net/Enums/MarketStatus.cs similarity index 76% rename from Huobi.Net/Enums/MarketStatus.cs rename to HTX.Net/Enums/MarketStatus.cs index d1b80e65..768856a1 100644 --- a/Huobi.Net/Enums/MarketStatus.cs +++ b/HTX.Net/Enums/MarketStatus.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Status of the market @@ -8,14 +10,17 @@ public enum MarketStatus /// /// Operating normally /// + [Map("1")] Normal = 1, /// /// Trading halted /// + [Map("2")] Halted = 2, /// /// Only cancelation is possible /// + [Map("3")] CancelOnly = 3 } } diff --git a/Huobi.Net/Enums/MasterSubTransferType.cs b/HTX.Net/Enums/MasterSubTransferType.cs similarity index 94% rename from Huobi.Net/Enums/MasterSubTransferType.cs rename to HTX.Net/Enums/MasterSubTransferType.cs index 32075b17..bd97838e 100644 --- a/Huobi.Net/Enums/MasterSubTransferType.cs +++ b/HTX.Net/Enums/MasterSubTransferType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Transfer type between master and sub account diff --git a/HTX.Net/Enums/NetworkStatus.cs b/HTX.Net/Enums/NetworkStatus.cs new file mode 100644 index 00000000..aef29330 --- /dev/null +++ b/HTX.Net/Enums/NetworkStatus.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Network action status + /// + public enum NetworkStatus + { + /// + /// Allowed + /// + [Map("allowed")] + Allowed, + /// + /// Prohibited + /// + [Map("prohibited")] + Prohibited + } +} diff --git a/Huobi.Net/Enums/Offset.cs b/HTX.Net/Enums/Offset.cs similarity index 94% rename from Huobi.Net/Enums/Offset.cs rename to HTX.Net/Enums/Offset.cs index 865b4da7..40bfca82 100644 --- a/Huobi.Net/Enums/Offset.cs +++ b/HTX.Net/Enums/Offset.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Offset diff --git a/Huobi.Net/Enums/Operator.cs b/HTX.Net/Enums/Operator.cs similarity index 76% rename from Huobi.Net/Enums/Operator.cs rename to HTX.Net/Enums/Operator.cs index 1909904b..e0040d2b 100644 --- a/Huobi.Net/Enums/Operator.cs +++ b/HTX.Net/Enums/Operator.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Stop price operator @@ -8,10 +10,12 @@ public enum Operator /// /// Greater than or equal to stop price /// + [Map("gte")] GreaterThanOrEqual, /// /// Less than or equal to stop price /// + [Map("lte")] LesserThanOrEqual } } diff --git a/Huobi.Net/Enums/OrderPriceType.cs b/HTX.Net/Enums/OrderPriceType.cs similarity index 93% rename from Huobi.Net/Enums/OrderPriceType.cs rename to HTX.Net/Enums/OrderPriceType.cs index 0e8492e4..51a419da 100644 --- a/Huobi.Net/Enums/OrderPriceType.cs +++ b/HTX.Net/Enums/OrderPriceType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Order price type @@ -92,5 +92,10 @@ public enum OrderPriceType /// [Map("optimal_20_fok")] FillOrKillOptimal20, + /// + /// Formula price + /// + [Map("formula_price")] + FormulaPrice } } diff --git a/Huobi.Net/Enums/OrderRole.cs b/HTX.Net/Enums/OrderRole.cs similarity index 72% rename from Huobi.Net/Enums/OrderRole.cs rename to HTX.Net/Enums/OrderRole.cs index 37a31b52..ae61c811 100644 --- a/Huobi.Net/Enums/OrderRole.cs +++ b/HTX.Net/Enums/OrderRole.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Order role @@ -8,10 +10,12 @@ public enum OrderRole /// /// Maker of an order book entry /// + [Map("maker")] Maker, /// /// Taker of an order book entry /// + [Map("taker")] Taker } } diff --git a/HTX.Net/Enums/OrderSide.cs b/HTX.Net/Enums/OrderSide.cs new file mode 100644 index 00000000..63449dee --- /dev/null +++ b/HTX.Net/Enums/OrderSide.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Order side + /// + public enum OrderSide + { + /// + /// Buy + /// + [Map("buy", "buy-market", "buy-limit", "buy-ioc", "buy-limit-maker", "buy-stop-limit", "buy-limit-fok", "buy-stop-limit-fok", "buy-limit-grid", "buy-market-grid")] + Buy, + /// + /// Sell + /// + [Map("sell", "sell-market", "sell-limit", "sell-ioc", "sell-limit-maker", "sell-stop-limit", "sell-limit-fok", "sell-stop-limit-fok", "sell-limit-grid", "sell-market-grid")] + Sell + } +} diff --git a/Huobi.Net/Enums/OrderState.cs b/HTX.Net/Enums/OrderStatus.cs similarity index 70% rename from Huobi.Net/Enums/OrderState.cs rename to HTX.Net/Enums/OrderStatus.cs index 9cb2521e..c765ab7d 100644 --- a/Huobi.Net/Enums/OrderState.cs +++ b/HTX.Net/Enums/OrderStatus.cs @@ -1,41 +1,51 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// - /// Order state + /// Order status /// - public enum OrderState + public enum OrderStatus { /// /// Pre-submitted /// + [Map("pre-submitted")] PreSubmitted, /// /// Submitted, nothing filled yet /// + [Map("submitted")] Submitted, /// /// Partially filled /// + [Map("partial-filled")] PartiallyFilled, /// /// Partially filled, then canceled /// + [Map("partial-canceled")] PartiallyCanceled, /// /// Filled completely /// + [Map("filled")] Filled, /// /// Canceled without fill /// + [Map("canceled")] Canceled, /// /// Created /// + [Map("created")] Created, /// /// Rejected /// + [Map("rejected")] Rejected } } diff --git a/HTX.Net/Enums/OrderStatusFilter.cs b/HTX.Net/Enums/OrderStatusFilter.cs new file mode 100644 index 00000000..a0ac9a09 --- /dev/null +++ b/HTX.Net/Enums/OrderStatusFilter.cs @@ -0,0 +1,46 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Order status filter + /// + public enum OrderStatusFilter + { + /// + /// Placing in book + /// + [Map("1", "2")] + ReadyToPlace, + /// + /// Submitted orders + /// + [Map("3")] + Submitted, + /// + /// Partially matched orders + /// + [Map("4")] + PartiallyMatched, + /// + /// Partially canceled orders + /// + [Map("5")] + PartiallyCanceled, + /// + /// Fully executed orders + /// + [Map("6")] + FullyMatched, + /// + /// Canceled orders + /// + [Map("7")] + Canceled, + /// + /// Canceled orders + /// + [Map("11")] + Canceling + } +} diff --git a/Huobi.Net/Enums/OrderType.cs b/HTX.Net/Enums/OrderType.cs similarity index 61% rename from Huobi.Net/Enums/OrderType.cs rename to HTX.Net/Enums/OrderType.cs index 127189a7..c37bbc33 100644 --- a/Huobi.Net/Enums/OrderType.cs +++ b/HTX.Net/Enums/OrderType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Order type @@ -8,38 +10,47 @@ public enum OrderType /// /// Limit /// + [Map("limit", "buy-limit", "sell-limit")] Limit, /// /// Market /// + [Map("market", "buy-market", "sell-market")] Market, /// /// Immediate or cancel /// + [Map("ioc", "buy-ioc", "sell-ioc")] IOC, /// /// Limit maker /// + [Map("limit-maker", "buy-limit-maker", "sell-limit-maker")] LimitMaker, /// /// Stop limit /// + [Map("stop-limit", "buy-stop-limit", "sell-stop-limit")] StopLimit, /// /// Fill or kill limit /// + [Map("limit-fok", "buy-limit-fok", "sell-limit-fok")] FillOrKillLimit, /// /// Fill or kill stop limit /// + [Map("stop-limit-fok", "buy-stop-limit-fok", "sell-stop-limit-fok")] FillOrKillStopLimit, /// /// Grid market order /// + [Map("buy-market-grid", "sell-market-grid")] MarketGrid, /// /// Grid limit order /// + [Map("buy-limit-grid", "sell-limit-grid")] LimitGrid, } } diff --git a/HTX.Net/Enums/Period.cs b/HTX.Net/Enums/Period.cs new file mode 100644 index 00000000..462e5a1a --- /dev/null +++ b/HTX.Net/Enums/Period.cs @@ -0,0 +1,41 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Period + /// + public enum Period + { + /// + /// Five minutes + /// + [Map("5min")] + FiveMinutes, + /// + /// Fifteen minutes + /// + [Map("15min")] + FifteenMinutes, + /// + /// Thirty minutes + /// + [Map("30min")] + ThirtyMinutes, + /// + /// One hour + /// + [Map("60min")] + OneHour, + /// + /// Four hours + /// + [Map("4hour")] + FourHours, + /// + /// One day + /// + [Map("1day")] + OneDay + } +} diff --git a/HTX.Net/Enums/PointAccountStatus.cs b/HTX.Net/Enums/PointAccountStatus.cs new file mode 100644 index 00000000..b77fe203 --- /dev/null +++ b/HTX.Net/Enums/PointAccountStatus.cs @@ -0,0 +1,42 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Point account status + /// + public enum PointAccountStatus + { + /// + /// Working + /// + [Map("working")] + Working, + /// + /// Lock + /// + [Map("lock")] + Lock, + /// + /// Fl sys + /// + [Map("fl-sys")] + FlSys, + /// + /// Fl mgt + /// + [Map("fl-mgt")] + FlMgt, + /// + /// Fl end + /// + [Map("fl-end")] + FlEnd, + /// + /// Fl negative + /// + [Map("fl-negative")] + FlNegative, + } + +} diff --git a/Huobi.Net/Enums/PositionMode.cs b/HTX.Net/Enums/PositionMode.cs similarity index 93% rename from Huobi.Net/Enums/PositionMode.cs rename to HTX.Net/Enums/PositionMode.cs index d8c3613a..602fd182 100644 --- a/Huobi.Net/Enums/PositionMode.cs +++ b/HTX.Net/Enums/PositionMode.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Position mode diff --git a/Huobi.Net/Enums/SettlementType.cs b/HTX.Net/Enums/SettlementType.cs similarity index 93% rename from Huobi.Net/Enums/SettlementType.cs rename to HTX.Net/Enums/SettlementType.cs index 81ec6333..51625eea 100644 --- a/Huobi.Net/Enums/SettlementType.cs +++ b/HTX.Net/Enums/SettlementType.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Settlement type diff --git a/Huobi.Net/Enums/SortingType.cs b/HTX.Net/Enums/SortingType.cs similarity index 71% rename from Huobi.Net/Enums/SortingType.cs rename to HTX.Net/Enums/SortingType.cs index f5a62457..7a1546c5 100644 --- a/Huobi.Net/Enums/SortingType.cs +++ b/HTX.Net/Enums/SortingType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Sorting order @@ -8,10 +10,12 @@ public enum SortingType /// /// Ascending /// + [Map("asc")] Ascending, /// /// Descending /// + [Map("desc")] Descending } } diff --git a/Huobi.Net/Enums/SourceType.cs b/HTX.Net/Enums/SourceType.cs similarity index 71% rename from Huobi.Net/Enums/SourceType.cs rename to HTX.Net/Enums/SourceType.cs index 237324ad..e98658b3 100644 --- a/Huobi.Net/Enums/SourceType.cs +++ b/HTX.Net/Enums/SourceType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Source @@ -8,18 +10,22 @@ public enum SourceType /// /// Spot api /// + [Map("spot-api")] Spot, /// /// Isolate margin api /// + [Map("margin-api")] IsolatedMargin, /// /// Cross margin api /// + [Map("super-margin-api")] CrossMargin, /// /// c2c margin api /// + [Map("c2c-margin-api")] C2CMargin } } diff --git a/HTX.Net/Enums/SubAccountMarketType.cs b/HTX.Net/Enums/SubAccountMarketType.cs new file mode 100644 index 00000000..e4e6894b --- /dev/null +++ b/HTX.Net/Enums/SubAccountMarketType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Market type + /// + public enum SubAccountMarketType + { + /// + /// Isolated margin + /// + [Map("isolated-margin")] + IsolatedMargin, + /// + /// Cross margin + /// + [Map("cross-margin")] + CrossMargin, + /// + /// Spot + /// + [Map("spot")] + Spot + } +} diff --git a/HTX.Net/Enums/SwapDeliveryType.cs b/HTX.Net/Enums/SwapDeliveryType.cs new file mode 100644 index 00000000..a0125436 --- /dev/null +++ b/HTX.Net/Enums/SwapDeliveryType.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Delivery type + /// + public enum SwapDeliveryType + { + /// + /// Perpetual futures + /// + [Map("1")] + UsdtPerpetualFutures, + /// + /// Delivery futures + /// + [Map("2")] + UsdtDeliveryFutures, + /// + /// Both USDT perpetual and delivery futures + /// + [Map("3")] + UsdtPerpetualAndDeliveryFutures + } +} diff --git a/Huobi.Net/Enums/SwapMarginOrderStatus.cs b/HTX.Net/Enums/SwapMarginOrderStatus.cs similarity index 97% rename from Huobi.Net/Enums/SwapMarginOrderStatus.cs rename to HTX.Net/Enums/SwapMarginOrderStatus.cs index fc6c884f..c8bedbe4 100644 --- a/Huobi.Net/Enums/SwapMarginOrderStatus.cs +++ b/HTX.Net/Enums/SwapMarginOrderStatus.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Order status diff --git a/HTX.Net/Enums/SymbolStatus.cs b/HTX.Net/Enums/SymbolStatus.cs new file mode 100644 index 00000000..30ff34e4 --- /dev/null +++ b/HTX.Net/Enums/SymbolStatus.cs @@ -0,0 +1,51 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Symbol status + /// + public enum SymbolStatus + { + /// + /// Unknown + /// + [Map("unknown")] + Unknown, + /// + /// Not online + /// + [Map("not-online")] + NotOnline, + /// + /// Not yet online + /// + [Map("pre-online")] + PreOnline, + /// + /// Online + /// + [Map("online")] + Online, + /// + /// Offline + /// + [Map("offline")] + Offline, + /// + /// Suspended + /// + [Map("suspend")] + Suspended, + /// + /// Transfer board + /// + [Map("transfer-board")] + TransferBoard, + /// + /// Fuse + /// + [Map("fuse")] + Fuse + } +} diff --git a/HTX.Net/Enums/SystemStatusIndicator.cs b/HTX.Net/Enums/SystemStatusIndicator.cs new file mode 100644 index 00000000..3967f195 --- /dev/null +++ b/HTX.Net/Enums/SystemStatusIndicator.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// System status indicator + /// + public enum SystemStatusIndicator + { + /// + /// None + /// + [Map("none")] + None, + /// + /// Minor + /// + [Map("minor")] + Minor, + /// + /// Major + /// + [Map("major")] + Major, + /// + /// Critical + /// + [Map("critical")] + Critical, + /// + /// Maintenance + /// + [Map("maintenance")] + Maintenance + } +} diff --git a/Huobi.Net/Enums/TimeInForce.cs b/HTX.Net/Enums/TimeInForce.cs similarity index 96% rename from Huobi.Net/Enums/TimeInForce.cs rename to HTX.Net/Enums/TimeInForce.cs index b87894db..5d169a5d 100644 --- a/Huobi.Net/Enums/TimeInForce.cs +++ b/HTX.Net/Enums/TimeInForce.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Time an order is active diff --git a/HTX.Net/Enums/TpSlStatus.cs b/HTX.Net/Enums/TpSlStatus.cs new file mode 100644 index 00000000..88e4a193 --- /dev/null +++ b/HTX.Net/Enums/TpSlStatus.cs @@ -0,0 +1,71 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Tp/Sl order status + /// + public enum TpSlStatus + { + /// + /// All (for filtering) + /// + [Map("0")] + All, + /// + /// Not activated + /// + [Map("1")] + NotActivated, + /// + /// Ready to submit + /// + [Map("2")] + ReadyToSubmit, + /// + /// Submitting orders + /// + [Map("3")] + Submitting, + /// + /// Orders successfully submited + /// + [Map("4")] + SubmitSuccess, + /// + /// Orders failed to submit + /// + [Map("5")] + SubmitFailed, + /// + /// Orders canceled + /// + [Map("6")] + Canceled, + /// + /// Canceled orders not found + /// + [Map("8")] + CanceledOrderNotFound, + /// + /// Orders canceling + /// + [Map("9")] + Canceling, + /// + /// Failed + /// + [Map("10")] + Failed, + /// + /// Expired + /// + [Map("11")] + Expired, + /// + /// Not activated - Expired + /// + [Map("12")] + NotActivatedExpired + } +} diff --git a/HTX.Net/Enums/TpslOrderType.cs b/HTX.Net/Enums/TpslOrderType.cs new file mode 100644 index 00000000..31cdd36b --- /dev/null +++ b/HTX.Net/Enums/TpslOrderType.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Take profit / stop loss type + /// + public enum TpslOrderType + { + /// + /// Take profit order + /// + [Map("tp")] + TakeProfit, + /// + /// Stop loss order + /// + [Map("sl")] + StopLoss + } +} diff --git a/Huobi.Net/Enums/TransactionType.cs b/HTX.Net/Enums/TransactionType.cs similarity index 74% rename from Huobi.Net/Enums/TransactionType.cs rename to HTX.Net/Enums/TransactionType.cs index 9aa68836..00919993 100644 --- a/Huobi.Net/Enums/TransactionType.cs +++ b/HTX.Net/Enums/TransactionType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Transaction type @@ -8,58 +10,72 @@ public enum TransactionType /// /// Trade /// + [Map("trade")] Trade, /// /// ETF /// + [Map("etf")] Etf, /// /// Transaction fee /// + [Map("transact-fee")] TransactionFee, /// /// Deduction /// + [Map("fee-deduction")] Deduction, /// /// Transfer between accounts /// + [Map("transfer")] Transfer, /// /// Credit /// + [Map("credit")] Credit, /// /// Liquidation /// + [Map("liquidation")] Liquidation, /// /// Interest /// + [Map("interest")] Interest, /// /// Deposit /// + [Map("deposit")] Deposit, /// /// Withdraw /// + [Map("withdraw")] Withdraw, /// /// Withdraw fee /// + [Map("withdraw-fee")] WithdrawFee, /// /// Exchange /// + [Map("exchange")] Exchange, /// /// Other types /// + [Map("other-types")] Other, /// /// Rebate /// + [Map("rebate")] Rebate } } diff --git a/HTX.Net/Enums/TransferAccount.cs b/HTX.Net/Enums/TransferAccount.cs new file mode 100644 index 00000000..5a22c403 --- /dev/null +++ b/HTX.Net/Enums/TransferAccount.cs @@ -0,0 +1,36 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Account type for transfer + /// + public enum TransferAccount + { + /// + /// Spot + /// + [Map("spot")] + Spot, + /// + /// Linear swap + /// + [Map("linear-swap")] + LinearSwap, + /// + /// OTC + /// + [Map("otc")] + Otc, + /// + /// Futures + /// + [Map("futures")] + Futures, + /// + /// Swap + /// + [Map("swap")] + Swap + } +} diff --git a/Huobi.Net/Enums/TransferType.cs b/HTX.Net/Enums/TransferType.cs similarity index 69% rename from Huobi.Net/Enums/TransferType.cs rename to HTX.Net/Enums/TransferType.cs index e22c7641..496f83b8 100644 --- a/Huobi.Net/Enums/TransferType.cs +++ b/HTX.Net/Enums/TransferType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Transfer type @@ -8,18 +10,22 @@ public enum TransferType /// /// From sub account /// + [Map("master-transfer-in")] FromSubAccount, /// /// To sub account /// + [Map("master-transfer-out")] ToSubAccount, /// /// Point from sub account /// + [Map("master-point-transfer-in")] PointFromSubAccount, /// /// Point to sub account /// + [Map("master-point-transfer-out")] PointToSubAccount } } diff --git a/HTX.Net/Enums/TriggerType.cs b/HTX.Net/Enums/TriggerType.cs new file mode 100644 index 00000000..2e1858cd --- /dev/null +++ b/HTX.Net/Enums/TriggerType.cs @@ -0,0 +1,21 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Trigger type + /// + public enum TriggerType + { + /// + /// Greater than or equal to price + /// + [Map("ge")] + GreaterThanOrEqual, + /// + /// Lesser than or equal to price + /// + [Map("le")] + LesserThanOrEqual + } +} diff --git a/Huobi.Net/Enums/Unit.cs b/HTX.Net/Enums/Unit.cs similarity index 92% rename from Huobi.Net/Enums/Unit.cs rename to HTX.Net/Enums/Unit.cs index fc8f6b6e..bb53500d 100644 --- a/Huobi.Net/Enums/Unit.cs +++ b/HTX.Net/Enums/Unit.cs @@ -1,6 +1,6 @@ using CryptoExchange.Net.Attributes; -namespace Huobi.Net.Enums +namespace HTX.Net.Enums { /// /// Unit type diff --git a/Huobi.Net/Enums/UserState.cs b/HTX.Net/Enums/UserStatus.cs similarity index 57% rename from Huobi.Net/Enums/UserState.cs rename to HTX.Net/Enums/UserStatus.cs index a0f5559a..dd7a6883 100644 --- a/Huobi.Net/Enums/UserState.cs +++ b/HTX.Net/Enums/UserStatus.cs @@ -1,17 +1,21 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// - /// User state + /// User status /// - public enum UserState + public enum UserStatus { /// /// Normal /// + [Map("normal")] Normal, /// /// Locked /// + [Map("lock")] Locked } } diff --git a/HTX.Net/Enums/ValuationBalanceType.cs b/HTX.Net/Enums/ValuationBalanceType.cs new file mode 100644 index 00000000..293810bc --- /dev/null +++ b/HTX.Net/Enums/ValuationBalanceType.cs @@ -0,0 +1,86 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// Balance type + /// + public enum ValuationBalanceType + { + /// + /// Spot + /// + [Map("1")] + Spot, + /// + /// Isolated + /// + [Map("2")] + IsolatedMargin, + /// + /// Cross + /// + [Map("3")] + CrossMargin, + /// + /// Coin futures + /// + [Map("4")] + CoinFutures, + /// + /// Flat + /// + [Map("5")] + Flat, + /// + /// Minepool + /// + [Map("6", "16")] + Minepool, + /// + /// Coin swaps + /// + [Map("7")] + CoinSwaps, + /// + /// Investment + /// + [Map("8")] + Investment, + /// + /// Borrow + /// + [Map("9")] + Borrow, + /// + /// Earn + /// + [Map("10")] + Earn, + /// + /// Usdt swaps + /// + [Map("11")] + UsdtSwaps, + /// + /// Option + /// + [Map("12")] + Option, + /// + /// Otc-options + /// + [Map("13")] + OtcOptions, + /// + /// Crypto loans + /// + [Map("14")] + CryptoLoans, + /// + /// Grid trading + /// + [Map("15")] + GridTrading, + } +} diff --git a/HTX.Net/Enums/WithdrawDepositStatus.cs b/HTX.Net/Enums/WithdrawDepositStatus.cs new file mode 100644 index 00000000..1cbc6670 --- /dev/null +++ b/HTX.Net/Enums/WithdrawDepositStatus.cs @@ -0,0 +1,96 @@ +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums +{ + /// + /// The status of a transfer + /// + public enum WithdrawDepositStatus + { + /// + /// Awaiting verification + /// + [Map("verifying")] + Verifying, + /// + /// Verification failed + /// + [Map("failed")] + Failed, + /// + /// Withdraw request submitted successfully + /// + [Map("submitted")] + Submitted, + /// + /// Under examination for withdraw validation + /// + [Map("reexamine")] + Reexamine, + /// + /// Withdraw canceled by user + /// + [Map("canceled")] + Canceled, + /// + /// Withdraw validation passed + /// + [Map("pass")] + Pass, + /// + /// Withdraw validation rejected + /// + [Map("reject")] + Reject, + /// + /// Withdraw is about to be released + /// + [Map("pre-transfer")] + PreTransfer, + /// + /// On-chain transfer initiated + /// + [Map("wallet-transfer")] + WalletTransfer, + /// + /// Transfer rejected by chain + /// + [Map("wallet-reject")] + WalletReject, + /// + /// On-chain transfer completed with one confirmation for withdraw or for at least one block for deposit + /// + [Map("confirmed")] + Confirmed, + /// + /// On-chain transfer faied to get confirmation + /// + [Map("confirm-error")] + ConfirmError, + /// + /// Withdraw terminated by system + /// + [Map("repealed")] + Repealed, + /// + /// On-chain transfer has not been received + /// + [Map("unknown")] + Unknown, + /// + /// On-chain transfer waits for first confirmation + /// + [Map("confirming")] + Confirming, + /// + /// Multiple on-chain confirmation happened + /// + [Map("safe")] + Safe, + /// + /// Confirmed but currently in an orphan branch + /// + [Map("orphan")] + Orphan + } +} diff --git a/Huobi.Net/Enums/WithdrawDepositType.cs b/HTX.Net/Enums/WithdrawDepositType.cs similarity index 62% rename from Huobi.Net/Enums/WithdrawDepositType.cs rename to HTX.Net/Enums/WithdrawDepositType.cs index 343f2ece..693991c5 100644 --- a/Huobi.Net/Enums/WithdrawDepositType.cs +++ b/HTX.Net/Enums/WithdrawDepositType.cs @@ -1,4 +1,6 @@ -namespace Huobi.Net.Enums +using CryptoExchange.Net.Attributes; + +namespace HTX.Net.Enums { /// /// Define transfer type @@ -8,10 +10,12 @@ public enum WithdrawDepositType /// /// Deposit /// + [Map("deposit")] Deposit, /// /// Withdraw /// - Withdraw - } + [Map("withdraw")] + Withdraw + } } diff --git a/Huobi.Net/ExtensionMethods/CryptoClientExtensions.cs b/HTX.Net/ExtensionMethods/CryptoClientExtensions.cs similarity index 50% rename from Huobi.Net/ExtensionMethods/CryptoClientExtensions.cs rename to HTX.Net/ExtensionMethods/CryptoClientExtensions.cs index ee966089..0074286d 100644 --- a/Huobi.Net/ExtensionMethods/CryptoClientExtensions.cs +++ b/HTX.Net/ExtensionMethods/CryptoClientExtensions.cs @@ -1,5 +1,5 @@ -using Huobi.Net.Clients; -using Huobi.Net.Interfaces.Clients; +using HTX.Net.Clients; +using HTX.Net.Interfaces.Clients; namespace CryptoExchange.Net.Interfaces { @@ -9,17 +9,17 @@ namespace CryptoExchange.Net.Interfaces public static class CryptoClientExtensions { /// - /// Get the Huobi REST Api client + /// Get the HTX REST Api client /// /// /// - public static IHuobiRestClient Huobi(this ICryptoRestClient baseClient) => baseClient.TryGet(() => new HuobiRestClient()); + public static IHTXRestClient HTX(this ICryptoRestClient baseClient) => baseClient.TryGet(() => new HTXRestClient()); /// - /// Get the Huobi Websocket Api client + /// Get the HTX Websocket Api client /// /// /// - public static IHuobiSocketClient Huobi(this ICryptoSocketClient baseClient) => baseClient.TryGet(() => new HuobiSocketClient()); + public static IHTXSocketClient HTX(this ICryptoSocketClient baseClient) => baseClient.TryGet(() => new HTXSocketClient()); } } diff --git a/HTX.Net/ExtensionMethods/HTXExtensionMethods.cs b/HTX.Net/ExtensionMethods/HTXExtensionMethods.cs new file mode 100644 index 00000000..e263da66 --- /dev/null +++ b/HTX.Net/ExtensionMethods/HTXExtensionMethods.cs @@ -0,0 +1,9 @@ +namespace HTX.Net.ExtensionMethods +{ + /// + /// Extension methods specific to using the HTX API + /// + public static class HTXExtensionMethods + { + } +} diff --git a/Huobi.Net/ExtensionMethods/ServiceCollectionExtensions.cs b/HTX.Net/ExtensionMethods/ServiceCollectionExtensions.cs similarity index 58% rename from Huobi.Net/ExtensionMethods/ServiceCollectionExtensions.cs rename to HTX.Net/ExtensionMethods/ServiceCollectionExtensions.cs index f00e5e9f..cb4355a2 100644 --- a/Huobi.Net/ExtensionMethods/ServiceCollectionExtensions.cs +++ b/HTX.Net/ExtensionMethods/ServiceCollectionExtensions.cs @@ -1,13 +1,10 @@ using CryptoExchange.Net.Clients; -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Clients; -using Huobi.Net.Interfaces; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Objects.Options; -using Huobi.Net.SymbolOrderBooks; -using System; +using HTX.Net.Clients; +using HTX.Net.Interfaces; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Objects.Options; +using HTX.Net.SymbolOrderBooks; using System.Net; -using System.Net.Http; namespace Microsoft.Extensions.DependencyInjection { @@ -17,34 +14,35 @@ namespace Microsoft.Extensions.DependencyInjection public static class ServiceCollectionExtensions { /// - /// Add the IHuobiClient and IHuobiSocketClient to the sevice collection so they can be injected + /// Add the IRestHTXClient and IHTXSocketClient to the sevice collection so they can be injected /// /// The service collection /// Set default options for the rest client /// Set default options for the socket client - /// The lifetime of the IHuobiSocketClient for the service collection. Defaults to Singleton. + /// The lifetime of the IHTXSocketClient for the service collection. Defaults to Singleton. /// - public static IServiceCollection AddHuobi( + public static IServiceCollection AddHTX( this IServiceCollection services, - Action? defaultRestOptionsDelegate = null, - Action? defaultSocketOptionsDelegate = null, + Action? defaultRestOptionsDelegate = null, + Action? defaultSocketOptionsDelegate = null, ServiceLifetime? socketClientLifeTime = null) { - var restOptions = HuobiRestOptions.Default.Copy(); + var restOptions = HTXRestOptions.Default.Copy(); if (defaultRestOptionsDelegate != null) { defaultRestOptionsDelegate(restOptions); - HuobiRestClient.SetDefaultOptions(defaultRestOptionsDelegate); + HTXRestClient.SetDefaultOptions(defaultRestOptionsDelegate); } if (defaultSocketOptionsDelegate != null) - HuobiSocketClient.SetDefaultOptions(defaultSocketOptionsDelegate); + HTXSocketClient.SetDefaultOptions(defaultSocketOptionsDelegate); - services.AddHttpClient(options => + services.AddHttpClient(options => { options.Timeout = restOptions.RequestTimeout; - }).ConfigurePrimaryHttpMessageHandler(() => { + }).ConfigurePrimaryHttpMessageHandler(() => + { var handler = new HttpClientHandler(); if (restOptions.Proxy != null) { @@ -59,12 +57,12 @@ public static IServiceCollection AddHuobi( services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(x => x.GetRequiredService().SpotApi.CommonSpotClient); + services.AddTransient(); + services.AddTransient(x => x.GetRequiredService().SpotApi.CommonSpotClient); if (socketClientLifeTime == null) - services.AddSingleton(); + services.AddSingleton(); else - services.Add(new ServiceDescriptor(typeof(IHuobiSocketClient), typeof(HuobiSocketClient), socketClientLifeTime.Value)); + services.Add(new ServiceDescriptor(typeof(IHTXSocketClient), typeof(HTXSocketClient), socketClientLifeTime.Value)); return services; } } diff --git a/Huobi.Net/Huobi.Net.csproj b/HTX.Net/HTX.Net.csproj similarity index 72% rename from Huobi.Net/Huobi.Net.csproj rename to HTX.Net/HTX.Net.csproj index 0a974f1c..41e3c1eb 100644 --- a/Huobi.Net/Huobi.Net.csproj +++ b/HTX.Net/HTX.Net.csproj @@ -5,26 +5,26 @@ 10.0 - Huobi.Net + HTX.Net JKorf 5.7.0 5.7.0 5.7.0 - Huobi.Net is a client library for accessing the Huobi REST and Websocket API. All data is mapped to readable models and enum values. Additional features include automatic websocket (re)connection management, an implementation for maintaining a client side order book, easy integration with other exchange client libraries and more. + HTX.Net is a client library for accessing the HTX REST and Websocket API. All data is mapped to readable models and enum values. Additional features include automatic websocket (re)connection management, client side rate limiting, an implementation for maintaining a client side order book, easy integration with other exchange client libraries and more. false - Huobi;Huobi.Net;Huobi Client;Huobi API;CryptoCurrency;CryptoCurrency Exchange + HTX;HTX.Net;HTX Client;HTX API;CryptoCurrency;CryptoCurrency Exchange;Huobi;Huobi.Net git - https://github.com/JKorf/Huobi.Net.git - https://github.com/JKorf/Huobi.Net + https://github.com/JKorf/HTX.Net.git + https://github.com/JKorf/HTX.Net MIT icon.png README.md en true - https://github.com/JKorf/Huobi.Net?tab=readme-ov-file#release-notes + https://github.com/JKorf/HTX.Net?tab=readme-ov-file#release-notes - Huobi.Net.xml + HTX.Net.xml true diff --git a/HTX.Net/HTX.Net.xml b/HTX.Net/HTX.Net.xml new file mode 100644 index 00000000..22b3cff9 --- /dev/null +++ b/HTX.Net/HTX.Net.xml @@ -0,0 +1,17354 @@ + + + + HTX.Net + + + + + + + + + + + + + + Create a new instance of the HTXRestClient using provided options + + Option configuration delegate + + + + Create a new instance of the HTXRestClient + + Option configuration delegate + The logger factory + Http client for this client + + + + Set the default options to be used when creating new clients + + Option configuration delegate + + + + + + + + + + + + + + + + Create a new instance of the HTXSocketClient + + The logger factory + + + + Create a new instance of the HTXSocketClient + + Option configuration delegate + + + + Create a new instance of the HTXSocketClient + + The logger factory + Option configuration delegate + + + + Set the default options to be used when creating new clients + + Option configuration delegate + + + + + + + + + + + + + Event triggered when an order is placed via this client + + + + + Event triggered when an order is canceled via this client + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get the name of a symbol for HTX based on the base and quote asset + + + + + + + + + + + + + + + + + TODO make this take an accountId param so we don't need it in the interface? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Account activation + + + + + Activated + + + + + Deactivated + + + + + Event type + + + + + Order placed event + + + + + Order matched event + + + + + Order refunded event + + + + + Order canceled event + + + + + Order fee refunded event + + + + + Margin transfer event + + + + + Margin loan event + + + + + Margin interest event + + + + + Margin repay event + + + + + Other event + + + + + Deposit event + + + + + Withdraw event + + + + + Account state + + + + + Working + + + + + Locked + + + + + Account type + + + + + Spot account + + + + + Margin account + + + + + Super margin account + + + + + Otc account + + + + + Point account + + + + + Investment account + + + + + Borrow account + + + + + Grid trading + + + + + Deposit earning + + + + + Otc options + + + + + Minepool + + + + + Etf + + + + + Crypto loans + + + + + Api key status + + + + + Normal + + + + + Expired + + + + + Asset status + + + + + Normal + + + + + Delisted + + + + + Asset type + + + + + Virtual asset + + + + + Fiat asset + + + + + Balance type + + + + + Trade balance + + + + + Frozen balance + + + + + Loan balance + + + + + Locked balance + + + + + Bank balance + + + + + Interest balance + + + + + Credit repay + + + + + Trust asset + + + + + Transfer out available + + + + + Loan available + + + + + Business type + + + + + Futures + + + + + Swap + + + + + Component status + + + + + Operational + + + + + Degraded performance + + + + + Partial outage + + + + + Major outage + + + + + Under maintance + + + + + Status of a conditional order + + + + + Created and active + + + + + Canceled + + + + + Rejected + + + + + Triggered + + + + + Conditional order type + + + + + Limit order + + + + + Market order + + + + + Contract status + + + + + Delisting + + + + + Listing + + + + + Pending listing + + + + + Suspension + + + + + Suspending of listing + + + + + In settlement + + + + + Delivering + + + + + Settlement completed + + + + + Delivered + + + + + Contract type + + + + + Swap + + + + + This week + + + + + Next week + + + + + Quarter + + + + + Next quarter + + + + + Status + + + + + Allowed + + + + + Prohibited + + + + + Deduction switch type + + + + + Point card deduction + + + + + Asset deduction + + + + + Close deduction + + + + + Sub account deduct mode + + + + + Deduct from master + + + + + Deduct from sub + + + + + Business type + + + + + Perpetual futures + + + + + Delivery futures + + + + + Perpetual + Delivery futures + + + + + Instrument type + + + + + Perpetual futures + + + + + Weekly futures + + + + + Bi-weekly futures + + + + + Quarterly futures + + + + + Bi-quareterly futures + + + + + Margin mode type + + + + + Isolated margin + + + + + Cross and isolated margin + + + + + Cross margin + + + + + Trigger order event + + + + + Trigger order placed + + + + + Trigger order canceled + + + + + Successfully triggered + + + + + Failed to trigger + + + + + Event trigger + + + + + Open order + + + + + Order match + + + + + Settlement and delivery + + + + + Order liquidation + + + + + Order cancel + + + + + Asset transfer + + + + + System + + + + + Other + + + + + Switch leverage + + + + + Initial update + + + + + Snapshot + + + + + Fee deduction status. + + + + + In deduction + + + + + Deduction completed + + + + + Fee type + + + + + Fixed + + + + + Circulated + + + + + Ratio + + + + + Filter direction + + + + + Get results after + + + + + Get results before + + + + + Financial record type + + + + + Close long + + + + + Close short + + + + + Fees for open position - taker + + + + + Fess for open position - maker + + + + + Fees for close positon - taker + + + + + Fees for close potion - maker + + + + + Close long for delivery + + + + + Close short for delibery + + + + + Delivery fee + + + + + Close long for liquidation + + + + + Close short for liquidation + + + + + Transfer spot to contract + + + + + Transfer contract to spot + + + + + Settle unrealized long + + + + + Settle unrealized short + + + + + Clawback + + + + + System + + + + + Activity price rewards + + + + + Rebate + + + + + Funding fee income + + + + + Funding fee expenditure + + + + + Transfer to sub account + + + + + Transfer from sub account + + + + + Transfer to master account + + + + + Transfer from master account + + + + + Transfer from other margin account + + + + + Transfer to other margin account + + + + + Adl close long + + + + + Adl close short + + + + + Incident status + + + + + Investigating + + + + + Identified + + + + + Monitoring + + + + + Resolved + + + + + Status of an instrument + + + + + Normal + + + + + Delisted + + + + + Interest period + + + + + One hour + + + + + Four hours + + + + + Twelf hours + + + + + One day + + + + + Interval for klines, int value represent the time in seconds + + + + + 1m + + + + + 5m + + + + + 15m + + + + + 30m + + + + + 1h + + + + + 4h + + + + + 1d + + + + + 1w + + + + + 1m + + + + + 1y + + + + + Price type + + + + + Market + + + + + Fill or kill + + + + + Immediate or cancel + + + + + Trade type + + + + + Fully filled liquidation orders + + + + + Liquidated close orders + + + + + Liquidated open orders + + + + + Liquidation type + + + + + Not a liquidation + + + + + Long and short netting + + + + + Partial liquidation + + + + + Full liquidation + + + + + Lock + + + + + Lock + + + + + Normal + + + + + Maintenance status + + + + + Scheduled + + + + + In progress + + + + + Verifying + + + + + Completed + + + + + Margin mode + + + + + Cross margin + + + + + Isolated margin + + + + + All (filter) + + + + + Status of a margin order + + + + + Created + + + + + Loaned + + + + + Paid + + + + + Invalid + + + + + Failed + + + + + Margin order type + + + + + Quoatation + + + + + Canceled order + + + + + Forced liquidation + + + + + Delivery + + + + + Margin order purpose + + + + + Loan + + + + + Repayment + + + + + Trade type + + + + + All trades + + + + + Buy long + + + + + Sell short + + + + + Buy short + + + + + Sell long + + + + + Liquidate long positions + + + + + Liquidate short positions + + + + + Buy one way + + + + + Sell one way + + + + + Status of the market + + + + + Operating normally + + + + + Trading halted + + + + + Only cancelation is possible + + + + + Transfer type between master and sub account + + + + + Transfer from master to sub + + + + + Transfer from sub to master + + + + + Network action status + + + + + Allowed + + + + + Prohibited + + + + + Offset + + + + + Open + + + + + Close + + + + + Both + + + + + Stop price operator + + + + + Greater than or equal to stop price + + + + + Less than or equal to stop price + + + + + Order price type + + + + + Market + + + + + Limit + + + + + Best offer + + + + + Post only + + + + + Optimal 5 + + + + + Optimal 10 + + + + + Optimal 20 + + + + + Immediate or cancel + + + + + Fill or kill + + + + + Immediate or cancel at best bid + + + + + Immediate or cancel optimal 5 + + + + + Immediate or cancel optimal 10 + + + + + Immediate or cancel optimal 20 + + + + + Fill or kill best offer + + + + + Fill or kill optimal 5 + + + + + Fill or kill optimal 10 + + + + + Fill or kill optimal 20 + + + + + Formula price + + + + + Order role + + + + + Maker of an order book entry + + + + + Taker of an order book entry + + + + + Order side + + + + + Buy + + + + + Sell + + + + + Order status + + + + + Pre-submitted + + + + + Submitted, nothing filled yet + + + + + Partially filled + + + + + Partially filled, then canceled + + + + + Filled completely + + + + + Canceled without fill + + + + + Created + + + + + Rejected + + + + + Order status filter + + + + + Placing in book + + + + + Submitted orders + + + + + Partially matched orders + + + + + Partially canceled orders + + + + + Fully executed orders + + + + + Canceled orders + + + + + Canceled orders + + + + + Order type + + + + + Limit + + + + + Market + + + + + Immediate or cancel + + + + + Limit maker + + + + + Stop limit + + + + + Fill or kill limit + + + + + Fill or kill stop limit + + + + + Grid market order + + + + + Grid limit order + + + + + Period + + + + + Five minutes + + + + + Fifteen minutes + + + + + Thirty minutes + + + + + One hour + + + + + Four hours + + + + + One day + + + + + Point account status + + + + + Working + + + + + Lock + + + + + Fl sys + + + + + Fl mgt + + + + + Fl end + + + + + Fl negative + + + + + Position mode + + + + + Single side + + + + + Dual side + + + + + Settlement type + + + + + Settlement + + + + + Delivery + + + + + Sorting order + + + + + Ascending + + + + + Descending + + + + + Source + + + + + Spot api + + + + + Isolate margin api + + + + + Cross margin api + + + + + c2c margin api + + + + + Market type + + + + + Isolated margin + + + + + Cross margin + + + + + Spot + + + + + Delivery type + + + + + Perpetual futures + + + + + Delivery futures + + + + + Both USDT perpetual and delivery futures + + + + + Order status + + + + + Ready to submit + + + + + Submitting + + + + + Submitted / active + + + + + Partially filled + + + + + Partially filled, cancelled + + + + + Filled + + + + + Cancelled + + + + + Cancelling + + + + + Symbol status + + + + + Unknown + + + + + Not online + + + + + Not yet online + + + + + Online + + + + + Offline + + + + + Suspended + + + + + Transfer board + + + + + Fuse + + + + + System status indicator + + + + + None + + + + + Minor + + + + + Major + + + + + Critical + + + + + Maintenance + + + + + Time an order is active + + + + + Good until the order is canceled + + + + + Should execute at least partly upon placing + + + + + Should enter the book upon placing + + + + + Should fill entirely upon placing + + + + + Take profit / stop loss type + + + + + Take profit order + + + + + Stop loss order + + + + + Tp/Sl order status + + + + + All (for filtering) + + + + + Not activated + + + + + Ready to submit + + + + + Submitting orders + + + + + Orders successfully submited + + + + + Orders failed to submit + + + + + Orders canceled + + + + + Canceled orders not found + + + + + Orders canceling + + + + + Failed + + + + + Expired + + + + + Not activated - Expired + + + + + Transaction type + + + + + Trade + + + + + ETF + + + + + Transaction fee + + + + + Deduction + + + + + Transfer between accounts + + + + + Credit + + + + + Liquidation + + + + + Interest + + + + + Deposit + + + + + Withdraw + + + + + Withdraw fee + + + + + Exchange + + + + + Other types + + + + + Rebate + + + + + Account type for transfer + + + + + Spot + + + + + Linear swap + + + + + OTC + + + + + Futures + + + + + Swap + + + + + Transfer type + + + + + From sub account + + + + + To sub account + + + + + Point from sub account + + + + + Point to sub account + + + + + Trigger type + + + + + Greater than or equal to price + + + + + Lesser than or equal to price + + + + + Unit type + + + + + Cont + + + + + Crypto currency + + + + + User status + + + + + Normal + + + + + Locked + + + + + Balance type + + + + + Spot + + + + + Isolated + + + + + Cross + + + + + Coin futures + + + + + Flat + + + + + Minepool + + + + + Coin swaps + + + + + Investment + + + + + Borrow + + + + + Earn + + + + + Usdt swaps + + + + + Option + + + + + Otc-options + + + + + Crypto loans + + + + + Grid trading + + + + + The status of a transfer + + + + + Awaiting verification + + + + + Verification failed + + + + + Withdraw request submitted successfully + + + + + Under examination for withdraw validation + + + + + Withdraw canceled by user + + + + + Withdraw validation passed + + + + + Withdraw validation rejected + + + + + Withdraw is about to be released + + + + + On-chain transfer initiated + + + + + Transfer rejected by chain + + + + + On-chain transfer completed with one confirmation for withdraw or for at least one block for deposit + + + + + On-chain transfer faied to get confirmation + + + + + Withdraw terminated by system + + + + + On-chain transfer has not been received + + + + + On-chain transfer waits for first confirmation + + + + + Multiple on-chain confirmation happened + + + + + Confirmed but currently in an orphan branch + + + + + Define transfer type + + + + + Deposit + + + + + Withdraw + + + + + Extension methods specific to using the HTX API + + + + + HTX environments + + + + + Spot Rest client address + + + + + Spot Rest client address for USDT margin swap API + + + + + Base address for socket API + + + + + Socket base address for the USDT margin swap API + + + + + Live environment + + + + + Create a custom environment + + + + + + + + + + + HTX exchange information and configuration + + + + + Exchange name + + + + + Url to the main website + + + + + Urls to the API documentation + + + + + Rate limiter configuration for the HTX API + + + + + Rate limiter configuration for the HTX API + + + + + Event for when a rate limit is triggered + + + + + Client for accessing the HTX API. + + + + + Spot endpoints + + + + + Usdt futures endpoints + + + + + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. + + The credentials to set + + + + Client for accessing the HTX websocket API. + + + + + Spot streams + + + + + Usdt futures streams + + + + + Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. + + 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 margin + + + + + Endpoints related to sub-accounts + + + + + 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. + + + + + + HTX account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings + + + + + Get the user id associated with the apikey/secret + + + Cancellation token + + + + + Get a list of accounts associated with the apikey/secret + + + Cancellation token + + + + + Get a list of balances for a specific account + + + The id of the account to get the balances for, account ids can be retrieved with GetAccountsAsync. + Cancellation token + + + + + Get platform asset valuation + + + Filter by account type + Valuation asset, only BTC supported at the moment + + + + + + Get the valuation of all assets + + + Type of account to valuate + The asset to get the value in + The id of the sub user + Cancellation token + + + + + Get a list of balance changes of specified user's account + + + The id of the account to get the account history for, account ids can be retrieved with GetAccountsAsync. + Asset name, for example `ETH` + Blance change types + Far point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days + Near point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days + Sorting order (Ascending by default) + Maximum number of items in each response (from 1 to 500, default is 100) + Cancellation token + + + + + Get the balance changes of specified user's account. + + + The id of the account to get the ledger for, account ids can be retrieved with GetAccountsAsync. + Asset name, for example `ETH` + Blanace change types + Far point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days + Near point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days + Sorting order (Ascending by default) + Maximum number of items in each response (from 1 to 500, default is 100) + Only get orders with ID before or after this. Used together with the direction parameter + Cancellation token + + + + + Transfer asset between accounts + + + Source account type + Target account type + The asset, for example `ETH` + Quantity + Margin account. Use `USDT` for cross margin + Cancellation token + + + + Get the deposit addresses for an asset + + + Asset, for example `ETH` + Cancellation token + + + + + Withdraw an asset from the account to an address + + + The desination address of this withdraw + Asset, for example `ETH` + The quantity of asset to withdraw + The fee to pay with this withdraw + Set as "usdt" to withdraw USDT to OMNI, set as "trc20usdt" to withdraw USDT to TRX + A tag specified for this address + Client order id + Cancellation token + + + + + Get withdrawal/deposit history + + + Transfer type to search + The asset to withdraw, for example `ETH` + The transfer id to begin search + The number of items to return + the order of response + Cancellation token + + + + + Get current trading fees for symbols + + + Filter on symbol, for example `ETHUSDT` + Cancellation token + + + + + Get point balance + + + Sub user id to request for + Cancellation token + + + + Transfer points to another user + + + From user id + To user id + Group id + Quantity + Cancellation token + + + + Get user deduction info + + + Cancellation token + + + + Get deduction assets + + + Cancellation token + + + + Set deduction switch + + + Deduction switch type + Asset + Cancellation token + + + + Get withdrawal quota + + + Filter by asset, for example `ETH` + Cancellation token + + + + Get withdrawal addresses + + + The asset, for example `ETH` + Filter by network + Filter by note + Max number of results + Return results after this id + Cancellation token + + + + Get a withdrawal by client order id + + + The client order id + Cancellation token + + + + Cancel a pending withdrawal + + + The withdrawal id + Cancellation token + + + + Get API key info + + + User id + The API key + Cancellation token + + + + Transfer assets between accounts + + + From user id + From account type + From account id + To user id + To account type + To account id + Asset to transfer, for example `ETH` + Amount to transfer + Cancellation token + + + + + HTX exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. + + + + + Get current system status and announcements + + + Cancellation token + + + + Get supported symbols + + + Cancellation token + + + + Get supported assets + + + Cancellation token + + + + Get symbol trading configuration + + + Filter by symbols, for example `ETHUSDT` + Cancellation token + + + + Get assets and network information + + + Filter by asset, for example `ETH` + Cancellation token + + + + Gets the latest ticker for all symbols + + + Cancellation token + + + + + Gets the ticker, including the best bid / best ask for a symbol + + + The symbol to get the ticker for, for example `ETHUSDT` + Cancellation token + + + + + Get kline/candlestick data for a symbol + + + The symbol to get the data for, for example `ETHUSDT` + The period of a single candlestick + The amount of candlesticks + Cancellation token + + + + + Get the order book for a symbol + + + The symbol to request for, for example `ETHUSDT` + The way the results will be merged together + The depth of the book + Cancellation token + + + + + Get the last trade for a symbol + + + The symbol to request for, for example `ETHUSDT` + Cancellation token + + + + + Get the last x trades for a symbol + + + The symbol to get trades for, for example `ETHUSDT` + The max number of results + Cancellation token + + + + + Get 24h stats for a symbol + + + The symbol to get the data for, for example `ETHUSDT` + Cancellation token + + + + + Get the current market status + + + Cancellation token + + + + + Get the server time + + + Cancellation token + + + + + HTX margin endpoints. + + + + + Repay a margin loan + + + Account id + Asset to repay, for example `ETH` + Quantity to repay + Loan transaction ID + Cancellation token + + + + + Transfer asset from spot account to isolated margin account + + + Trading symbol, for example `ETHUSDT` + Asset to transfer, for example `ETH` + Quantity to transfer + Cancellation token + Transfer id + + + + Transfer asset from isolated margin to spot account + + + Trading symbol, for example `ETHUSDT` + Asset to transfer, for example `ETH` + Quantity to transfer + Cancellation token + Transfer id + + + + Get isolated loan interest rate and quotas + + + Filter on symbol, for example `ETHUSDT` + Cancellation token + + + + + Request a loan on isolated margin + + + The symbol, for example `ETHUSDT` + The asset, for example `ETH` + The quantity + Cancellation token + Order id + + + + Repay an isolated margin loan + + + Id to repay + Quantity + Cancellation token + Order id + + + + Get isolated margin order history + + + The symbol to get history for, for example `ETHUSDT` + Filter by states + Filter by start date + Filter by end date + Start order id for use in combination with direction + Direction of results in combination with from parameter + Max amount of results + Sub user id + Cancellation token + + + + + Get isolated margin account balance + + + The symbol, for example `ETHUSDT` + Sub user id + Cancellation token + + + + + Transfer from spot account to cross margin account + + + The asset to transfer, for example `ETH` + Quantity to transfer + Cancellation token + + + + + Transfer from cross margin account to spot account + + + The asset to transfer, for example `ETH` + Quantity to transfer + Cancellation token + + + + + Get cross margin interest rates and quotas + + + Cancellation token + + + + + Request a loan on cross margin + + + The asset, for example `ETH` + The quantity + Cancellation token + Order id + + + + Repay a isolated margin loan + + + Id to repay + Quantity + Cancellation token + + + + + Get cross margin order history + + + Filter by asset, for example `ETH` + Filter by status + Filter by start date + Filter by end date + Start order id for use in combination with direction + Direction of results in combination with from parameter + Max amount of results + Sub user id + Cancellation token + + + + + Get cross margin account balance + + + Sub user id + Cancellation token + + + + + Get cross margin limits + + + The asset, for example `ETH` + Cancellation token + + + + Get repayment history + + + Filter by repay id + Filter by account id + Filter by asset, for example `ETH` + Only show records after this + Only show records before this + Sort direction + Result limit + Search id + Cancellation token + + + + + HTX sub-account endpoints. + + + + + Set fee deduct mode for sub accounts + + + Sub user ids + Deduct from account + Cancellation token + + + + Create new sub accounts + + + Accounts to create + Cancellation token + + + + Get a list of users associated with the apikey/secret + + + Cancellation token + + + + + Set (un)lock status on a sub account + + + Sub user id + Lock action + Cancellation token + + + + Get sub user by id + + + Sub user id + Cancellation token + + + + + Set tradable market for sub accounts + + + Sub user ids + Account type + Enabled or not + Cancellation token + + + + Set asset transfer permissions for sub accounts + + + Sub user ids + Enabled + Cancellation token + + + + Gets a list of sub-user accounts associated with the sub-user id + + + The if of the user to get accounts for + Cancellation token + + + + + Create a new API key + + + Two factor authentication code + Sub user id + Note + Permissions + Ip addresses + Cancellation token + + + + Edit an API key + + + Sub user id + Api key to edit + Note + Permissions + Ip addresses + Cancellation token + + + + Delete an API key + + + Sub user id + Api key to remove + Cancellation token + + + + Get deposit address for a sub account + + + Sub user id + The asset, for example `ETH` + Cancellation token + + + + Get deposit history + + + Sub user id + Filter by asset, for example `ETH` + Filter by start time + Filter by end time + Sort + Max number of results + Return results after this id + Cancellation token + + + + Get aggregate balances of all sub accounts + + + Cancellation token + + + + Get a list of balances for a specific sub account + + + The id of the sub account to get the balances for + Cancellation token + + + + + Transfer asset between parent and sub account + + + The target sub account id to transfer to or from + The asset to transfer, for example `ETH` + The quantity of asset to transfer + The type of transfer + Cancellation token + Unique transfer id + + + + HTX trading endpoints, placing and mananging orders. + + + + + Places an order + + + The account to place the order for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + The symbol to place the order for, for example `ETHUSDT` + The side of the order + The type of the order + The quantity of the order + The price of the order. Should be omitted for market orders + The clientOrderId the order should get + Source. defaults to SpotAPI + Stop price + Operator of the stop price + Cancellation token + + + + + Place multiple orders in a single call + + + Orders to place + Cancellation token + + + + + Place a new margin order + + + The account to place the order for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + The symbol to place the order for, for example `ETHUSDT` + The side of the order + The type of the order + Transaction purpose + The quantity of the order in base asset + The quantity of the order in quote asset + The quantity that needs to be borrowed + The price of the order. Should be omitted for market orders + Source. defaults to SpotAPI + Stop price + Operator of the stop price + Cancellation token + + + + + Get a list of open orders + + + The account id for which to get the orders for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + The symbol for which to get the orders for, for example `ETHUSDT` + Only get buy or sell orders + The max number of results + Cancellation token + + + + + Cancel an open order + + + The id of the order to cancel + Cancellation token + + + + + Cancel an open order + + + The client id of the order to cancel + Cancellation token + + + + + Cancel multiple open orders + + + The ids of the orders to cancel + The client ids of the orders to cancel + Cancellation token + + + + + Cancel multiple open orders + + + The account id used for this cancel + The trading symbol list (maximum 10 symbols, default value all symbols) + Filter on the direction of the trade + The number of orders to cancel [1, 100] + Cancellation token + + + + + Get details of an order + + + The id of the order to retrieve + Cancellation token + + + + + Get details of an order by client order id + + + The client id of the order to retrieve + Cancellation token + + + + + Get a list of trades made for a specific order + + + The id of the order to get trades for + Cancellation token + + + + + Get a list of orders + + + The symbol to get orders for, for example `ETHUSDT` + The states of orders to return + The types of orders to return + Only get orders after this date + Only get orders before this date + Only get orders with ID before or after this. Used together with the direction parameter + Direction of the results to return when using the fromId parameter + The max number of results + Cancellation token + + + + + Get a list of user trades + + + The symbol to retrieve trades for, for example `ETHUSDT` + The type of orders to return + Only get orders after this date + Only get orders before this date + Only get orders with ID before or after this. Used together with the direction parameter + Direction of the results to return when using the fromId parameter + The max number of results + Cancellation token + + + + + Get order history + + + The symbol to get orders for, for example `ETHUSDT` + Only get orders after this date + Only get orders before this date + Direction of the results to return + The max number of results + Cancellation token + + + + + Place a new conditional order + + + The account the order should be placed from, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + The symbol the order is for, for example `ETHUSDT` + Side of the order + Type of the order + Stop price of the order + Quantity of the order + Price of the order + Quote quantity of the order + Trailing rate of the order + Time in force + Client order id + Cancellation token + + + + + Cancel conditional orders + + + Client order ids of the conditional orders to cancels + Cancelation token + + + + + Get open conditional orders based on the parameters + + + Filter by account id, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + Filter by symbol, for example `ETHUSDT` + Filter by side + Filter by type + Sort direction + Max results + Ids after this + Cancelation token + + + + + Get closed conditional orders + + + Filter by account id, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + Filter by symbol, for example `ETHUSDT` + Filter by side + Filter by type + Sort direction + Max results + Ids after this + Cancelation token + Filter by status + Return only entries after this time + Return only entries before this time + + + + + Get a conditional order by id + + + Client order id + Cancelation token + + + + + Spot streams + + + + + Get kline/candlestick data for a symbol + + + The symbol to get the data for, for example `ETHUSDT` + The period of a single candlestick + + + + + Subscribes to kline/candlestick updates for a symbol + + + The symbol to subscribe to, for example `ETHUSDT` + The period of a single candlestick + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Get the current order book for a symbol + + + The symbol to get the data for, for example `ETHUSDT` + The way the results will be merged together + + + + + Get the current order book for a symbol + + + The symbol to get the data for, for example `ETHUSDT` + The amount of rows. 5, 20, 150 or 400 + + + + + Subscribes to order book updates for a symbol + + + The symbol to subscribe to, for example `ETHUSDT` + The number of price levels. 5, 10 or 20 + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribes to order book updates for a symbol + + + The symbol to subscribe to, for example `ETHUSDT` + The way the results will be merged together + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribes to order book updates for a symbol, + + + The symbol to subscribe to, for example `ETHUSDT` + The number of price levels. 5, 20, 150 or 400 + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Get a list of trades for a symbol + + + The symbol to get trades for, for example `ETHUSDT` + + + + + Subscribes to trade updates for a symbol + + + The symbol to subscribe to, for example `ETHUSDT` + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Get details for a symbol + + + The symbol to get data for, for example `ETHUSDT` + + + + + Subscribes to symbol detail updates for a symbol + + + The symbol to subscribe to, for example `ETHUSDT` + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribes to updates for a symbol + + + The symbol to subscribe, for example `ETHUSDT` + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribes to updates for all tickers + + + The handler for updates + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribe to changes of a symbol's best ask/bid + + + Symbol to subscribe to, for example `ETHUSDT` + Data handler + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribe to updates of orders + + + Subscribe on a specific symbol + Event handler for the order submitted event + Event handler for the order matched event + Event handler for the order cancelled event + Event handler for the conditional order trigger failed event + Event handler for the condition order canceled event + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribe to updates of account balances + + + Event handler + The update mode. Defaults to 1, see API docs for more info + Cancellation token for closing this subscription + A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected + + + + Subscribe to detailed order matched/canceled updates + + + Subscribe to a specific symbol, for example `ETHUSDT` + Event handler for the order matched event + Event handler for the order canceled event + 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 futures api endpoints + + + + + Endpoints related to account settings, info or actions + + + + + Endpoints related to retrieving market and system data + + + + + Endpoints related to sub accounts + + + + + Endpoints related to orders and trades + + + + + HTX usdt futures endpoints + + + + + Get asset valuation + + + The asset, for example `ETH` + Cancellation token + + + + + Get isolated margin account info + + + Optional contract code filter, for example `USDT` + Cancellation token + + + + + Get cross margin account info + + + Optional margin account filter, for example `USDT` + Cancellation token + + + + + Get cross margin assets and positions + + + Margin account, for example `USDT` + Cancellation token + + + + + Get cross margin available leverage + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Business type + Cancellation token + + + + + Get cross margin positions + + + Filter by contract code, for example `ETH-USDT` + Cancellation token + + + + + Get cross margin settlement records + + + Margin account, for example `USDT` + Filter by start time + Filter by end time + Page + Page size + Cancellation token + + + + + Get financial records + + + Margin account, for example `USDT` + Contract code, for example `ETH-USDT` + Filter by type + Filter by start time + Filter by end time + Direction + Return results after this id + Cancellation token + + + + + Get isolated margin assets and positions + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get isolated margin available leverage + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get isolated margin position info + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get isolated margin settlement records + + + Contract code, for example `ETH-USDT` + Filter by start time + Filter by end time + Page + Page size + Cancellation token + + + + + Get trading fees + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Business tpye + Cancellation token + + + + + Set cross margin position mode + + + Margin account, for example `USDT` + Position mode + Cancellation token + + + + + Set isolated margin position mode + + + Margin account, for example `USDT` + Position mode + Cancellation token + + + + + Transfer between margin accounts + + + Asset to transfer, for example `USDT` + From account + To account + Quantity to transfer + Client order id + Cancellation token + + + + + Get order limits + + + The order type + Filter by contract code, for example `ETH-USDT` + Filter by pair, for example `ETH-USDT` + Filter by contract type + Filter by businessType + Cancellation token + + + + Get isolated margin transfer limits + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + Get cross margin transfer limits + + + Margin account, for example `USDT` + Cancellation token + + + + Get isolated margin position limits + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + Get cross margin position limits + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Business type + Cancellation token + + + + Get isolated margin leverage position limits + + + Contract code, for example `ETH-USDT` + Leverage rate + Cancellation token + + + + Get cross margin leverage position limits + + + Business type + Cancellation token + + + + Get user trading status + + + Cancellation token + + + + Get isolated margin position mode + + + Margin account, for example `USDT` + Cancellation token + + + + Get cross margin position mode + + + Margin account, for example `USDT` + Cancellation token + + + + HTX usdt futures exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. + + + + + Get basis data + + + Contract code, for example `ETH-USDT` + Kline interval + Limit + Price type (open, close, high, low, average) + Cancellation token + + + + + Get the current best bid/ask values + + + Contract code, for example `ETH-USDT` + Type + Cancellation token + + + + + Get contract info + + + Contract code, for example `ETH-USDT` + Support margin mode + Pair, for example `ETH-USDT` + Contract type + Business type + Cancellation token + + + + + Get cross margin adjust factor info + + + Contract code, for example `ETH-USDT` + Asset, for example `ETH` + Type + Business type + Cancellation token + + + + + Get cross margin trade status + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Type + Business type + Cancellation token + + + + + Get cross margin transfer status + + + Margin account, for example `USDT` + Cancellation token + + + + + Get cross tiered margin info + + + Contract code, for example `ETH-USDT` + Pair + Contract type + Business type + Cancellation token + + + + + Get estimated funding rate klines + + + Contract code, for example `ETH-USDT` + Kline interval + Limit + Cancellation token + + + + + Get estimated settlement price + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Business type + Cancellation token + + + + + Get funding rate + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get funding rates + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get historical funding rates + + + Contract code, for example `ETH-USDT` + Page + Page size + Cancellation token + + + + + Get historical settlement records + + + Contract code, for example `ETH-USDT` + Filter by start time + Filter by end time + Page + Page size + Cancellation token + + + + + Get insurance fund history + + + Contract code, for example `ETH-USDT` + Page + Page size + Cancellation token + + + + + Get isolated margin adjust factor info + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get isolated margin status + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get isolated margin tier info + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get klines + + + Contract code, for example `ETH-USDT` + Kline interval + Limit + Filter by start time + Filter by end time + Cancellation token + + + + + Get last trades + + + Contract code, for example `ETH-USDT` + Business type + Cancellation token + + + + + Get liquidation orders + + + Trade type + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Filter by start time + Filter by end time + Result direction + Return results after this id + Cancellation token + + + + + Get ticker + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get tickers + + + Contract code, for example `ETH-USDT` + Business type + Cancellation token + + + + + Get open interest + + + Period + Unit + Contract code, for example `ETH-USDT` + Symbol + Type + Limit + Cancellation token + + + + + Get order book + + + Contract code, for example `ETH-USDT` + Merge step + Cancellation token + + + + + Get premium index klines + + + Contract code, for example `ETH-USDT` + Interval + Max number of results + Cancellation token + + + + + Get recent trades + + + Contract code, for example `ETH-USDT` + Max number of results to return + Cancellation token + + + + + Get server time + + + Cancellation token + + + + + Get swap index price + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get swap open interest + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Business tpye + Cancellation token + + + + + Get swap price limitation + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract tpye + Business type + Cancellation token + + + + + Get swap risk info + + + Contract code, for example `ETH-USDT` + Business type + Cancellation token + + + + + Get top trader account sentiment + + + Contract code, for example `ETH-USDT` + Period + Cancellation token + + + + Get top trader position sentiment + + + Contract code, for example `ETH-USDT` + Period + Cancellation token + + + + Get contract elements and info + + + Filter by contract code, for example `ETH-USDT` + Cancellation token + + + + Get mark price klines + + + Contract code, for example `ETH-USDT` + Kline interval + Max number of results + Cancellation token + + + + HTX usdt futures sub account endpoints + + + + + Get cross margin sub account assets + + + Margin account, for example `USDT` + Cancellation token + + + + + Get isolated margin sub account assets + + + Contract code, for example `ETH-USDT` + Cancellation token + + + + + Get master sub account transfer records + + + Margin account, for example `USDT` + Days in history + Filter by type + Page + Page size + Cancellation token + + + + + Set sub account trading permissions + + + Uids of the subaccounts + Enable trading + Cancellation token + + + + + Transfer between master and sub account + + + Sub account uid + Asset to transfer, for example `ETH` + From account + To account + Quantity to transfer + Type + Client order id + Cancellation token + + + + + Get sub accounts trade permissions + + + Filter by sub user ids + Filter by start time + Filter by end time + Filter direction + Return results after this id + Cancellation token + + + + Get isolated margin asset information + + + Contract code, for example `ETH-USDT` + Page + Page size + Cancellation token + + + + Get cross margin asset info + + + Margin account, for example `USDT` + Page + Page size + Cancellation token + + + + Get isolated margin positions + + + Sub user id + Filter by contract code, for example `ETH-USDT` + Cancellation token + + + + Get isolated margin positions + + + Sub user id + Filter by contract code, for example `ETH-USDT` + Filter by pair, for example `ETH-USDT` + Filter by contract type + Cancellation token + + + + HTX usdt futures trading endpoints, placing and managing orders. + + + + + Cancel all cross margin orders fitting the parameters + + + Contract code, for example `ETH-USDT` + Pair + Contract type + Side + Offset + Cancellation token + + + + + Cancel all isolated margin orders fitting the parameters + + + Contract code, for example `ETH-USDT` + Side + Offset + Cancellation token + + + + + Cancel a cross margin order + + + The order id + The client order id + Contract code, for example `ETH-USDT` + Pair + Contract type + Cancellation token + + + + + Cancel cross margin orders + + + Order ids + Client order ids + Contract code, for example `ETH-USDT` + Pair + Contract type + Cancellation token + + + + + Cancel an isolated margin order + + + Contract code, for example `ETH-USDT` + Order id + Client order id + Cancellation token + + + + + Cancel isolated margin orders + + + Contract code, for example `ETH-USDT` + Order ids + Client order ids + Cancellation token + + + + + Set cross margin leverage + + + Leverage rate + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Cancellation token + + + + + Set isolated margin leverage + + + Contract code, for example `ETH-USDT` + Leverage rate + Cancellation token + + + + + Get cross margin closed orders + + + Contract code, for example `ETH-USDT` + Trade type + All orders (true), or only orders in finished status (false) + Filter by pair, for example `ETH-USDT` + Filter by status + Filter by start time + Filter by end time + Direction + Return results after this id + Cancellation token + + + + Get cross margin open orders + + + Contract code, for example `ETH-USDT` + Pair + Pair, for example `ETH-USDT` + Page size + Sort by + Trade type + Cancellation token + + + + + Get cross margin order + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Order id + Client order id + Cancellation token + + + + + Get cross margin order details + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + + Get cross margin orders + + + Order ids + Client order ids + Contract code, for example `ETH-USDT` + Pair + Cancellation token + + + + + Get isolated margin user trades + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Trade type + Filter by start time + Filter by end time + Filter direction + Return results after this id + Cancellation token + + + + Get cross margin user trades + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Trade type + Filter by start time + Filter by end time + Filter direction + Return results after this id + Cancellation token + + + + Get isolated margin closed orders + + + Contract code, for example `ETH-USDT` + Trade type + All orders (true), or only orders in finished status (false) + Filter by status + Filter by start time + Filter by end time + Direction + Return results after this id + Cancellation token + + + + Get isolated margin open orders + + + Contract code, for example `ETH-USDT` + Page + Page size + Sort by + Trade type + Cancellation token + + + + + Get an isolated margin order + + + Contract code, for example `ETH-USDT` + Order id + Client order id + Cancellation token + + + + + Get isolated margin order details + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + + Get isolated margin orders + + + Contract code, for example `ETH-USDT` + Order ids + Client order ids + Cancellation token + + + + + Place a new cross margin order + + + Order quantity + Order side + Leverage rate + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Price + Offset + Order price type + Take profit trigger price + Take profit order price + Take profit order price type + Stop loss trigger price + Stop loss order price + Stop loss order price type + Reduce only + Client order id + Cancellation token + + + + + Place a new isolated margin order + + + Contract code, for example `ETH-USDT` + Quantity + Order side + Leverage rate + Price + Offset + Order price type + Take profit trigger price + Take profit order price + Take profit order price type + Stop loss trigger price + Stop loss order price + Stop loss order price type + Reduce only + Client order id + Cancellation token + + + + + Cancel all orders after the timeout elapses. Can be called again to extend the timeout. Set enable to false to disable the timeout + + + Enabled or disable cancelation + The timeout after which all order are canceled + Cancellation token + + + + Lightning close isolated margin position + + + Contract code, for example `ETH-USDT` + Direction + Client order id + Order price type + Cancellation token + + + + Lightning close cross margin position + + + Contract code, for example `ETH-USDT` + Direction + Pair, for example `ETH-USDT` + Contract type + Client order id + Order price type + Cancellation token + + + + Place a new isolated margin trigger order + + + Contract code, for example `ETH-USDT` + Trigger type + Trigger price + Order quantity + Order side + Offset + Reduce only + Order price + Order price type + Leverage rate + Cancellation token + + + + Place a new cross margin trigger order + + + Contract code, for example `ETH-USDT` + Trigger type + Trigger price + Order quantity + Order side + Pair, for example `ETH-USDT` + Contract type + Offset + Reduce only + Order price + Order price type + Leverage rate + Cancellation token + + + + Cancel isolated margin trigger order + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + Cancel cross margin trigger order + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Order id + Cancellation token + + + + Cancel all isolated margin trigger orders matching the parameters + + + Contract code, for example `ETH-USDT` + Filter by side + Filter by offset + Cancellation token + + + + Cancel all cross margin trigger orders matching the parameters + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Filter by side + Filter by offset + Cancellation token + + + + Get isolated margin open trigger orders + + + Contract code, for example `ETH-USDT` + Page + Page size + Trade type + Cancellation token + + + + Get cross margin open trigger orders + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Page + Page size + Trade type + Cancellation token + + + + Get isolated margin trigger order history + + + Contract code, for example `ETH-USDT` + Trade type + Amount of days ago. Max 90 + Status + Page + Page index + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + Get cross margin trigger order history + + + Trade type + Amount of days ago. Max 90 + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Status + Page + Page index + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + Set isolated margin order take profit / stop loss for an existing position + + + Contract code, for example `ETH-USDT` + Order side + Quantity + Take profit trigger price + Take profit order price + Take profit order price type + Stop loss trigger price + Stop loss order price + Stop loss order price type + Cancellation token + + + + Set cross margin order take profit / stop loss for an existing position + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Order side + Quantity + Take profit trigger price + Take profit order price + Take profit order price type + Stop loss trigger price + Stop loss order price + Stop loss order price type + Cancellation token + + + + Cancel isolated margin take profit / stop loss orders for an existing position + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + Cancel cross margin take profit / stop loss orders for an existing position + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Order id + Cancellation token + + + + Cancel all isolated margin take profit / stop loss orders + + + Contract code, for example `ETH-USDT` + Side + Cancellation token + + + + Cancel all cross margin take profit / stop loss orders + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Side + Cancellation token + + + + Get open isolated margin take profit / stop loss orders + + + Contract code, for example `ETH-USDT` + Page index + Page size + Trade type + Cancellation token + + + + Get open cross margin take profit / stop loss orders + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Page index + Page size + Trade type + Cancellation token + + + + Get isolated margin take profit / stop loss order history + + + Contract code, for example `ETH-USDT` + Status + Amount of days ago. Max 90 + Page + Page size + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + Get cross maring take profit / stop loss order history + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Status + Amount of days ago. Max 90 + Page + Page size + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + Get isolated margin position open info with attached tp/sl orders + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + Get cross margin position open info with attached tp/sl orders + + + Order id + Contract code, for example `ETH-USDT` + Pair + Cancellation token + + + + + Place isolated margin trailing order + + + Contract code, for example `ETH-USDT` + Reduce only + Side + Offset + Leverage rate + Quantity + Callback rate, 0.01 means 1% + Active price + Price type + Cancellation token + + + + Place cross margin trailing order + + + Side + Offset + Leverage rate + Quantity + Callback rate, 0.01 means 1% + Active price + Price type + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Reduce only + Cancellation token + + + + + Cancel an isolated margin trailing order + + + Contract code, for example `ETH-USDT` + Order id + Cancellation token + + + + Cancel a cross margin trailing order + + Order id + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Cancellation token + + + + + Cancel all open isolated margin trailing orders on a symbol + + + Contract code, for example `ETH-USDT` + Filter by side + Filter by offset + Cancellation token + + + + Cancel all open cross margin trailing orders + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Filter by side + Filter by offset + Cancellation token + + + + + Get open isolated margin trailing orders + + + Contract code, for example `ETH-USDT` + Trade type + Page + Page size + Cancellation token + + + + Get open cross margin trailing orders + + + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Trade type + Page + Page size + Cancellation token + + + + Get isolated margin trailing order history + + + Contract code, for example `ETH-USDT` + Status + Trade type + Amount of days ago. Max 90 + Page + Page size + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + + Get cross margin trailing order history + + + Status + Trade type + Amount of days ago. Max 90 + Contract code, for example `ETH-USDT` + Pair, for example `ETH-USDT` + Contract type + Page + Page size + Sort by; 'created_at' or 'update_time' + Cancellation token + + + + + Usdt futures streams + + + + + Subscribe to basis updates + + + Contract code, for example `ETH-USDT` + Period + Price type + Data handler + Cancellation token + + + + + Subscribe to best bid/ask updates + + + Contract code, for example `ETH-USDT` + Data handler + Cancellation token + + + + + Subscribe to estimated funding rate kline updates + + + Contract code, for example `ETH-USDT` + Period + Data handler + Cancellation token + + + + + Subscribe to incremental order book updates + + + Contract code, for example `ETH-USDT` + Snapshot or incremental + Depth + Data handler + Cancellation token + + + + + Subscribe to index kline updates + + + Contract code, for example `ETH-USDT` + Period + Data handler + Cancellation token + + + + + Subscribe to kline updates + + + Contract code, for example `ETH-USDT` + Period + Data handler + Cancellation token + + + + + Subscribe to mark price kline updates + + + Contract code, for example `ETH-USDT` + Period + Data handler + Cancellation token + + + + + Subscribe to order book updates + + + Contract code, for example `ETH-USDT` + Merge step + Data handler + Cancellation token + + + + + Subscribe to premium index kline updates + + + Contract code, for example `ETH-USDT` + Period + Data handler + Cancellation token + + + + + Subscribe to symbol ticker updates + + + Contract code, for example `ETH-USDT` + Data handler + Cancellation token + + + + + Subscribe to symbol trade updates + + + Contract code, for example `ETH-USDT` + Data handler + Cancellation token + + + + + Subscribe to system status updates + + + Data handler + Cancellation token + + + + + Subscribe to order updates + + + + Margin mode + Data handler + Cancellation token + + + + + Subscribe to isolated margin balance updates + + + Data handler + Cancellation token + + + + + Subscribe to cross margin balance updates + + + Data handler + Cancellation token + + + + + Subscribe to isolated margin position updates + + + Data handler + Cancellation token + + + + + Subscribe to cross margin position updates + + + Data handler + Cancellation token + + + + + Subscribe to isolated margin user trades + + + Data handler + Cancellation token + + + + + Subscribe to cross margin user trades + + + Data handler + Cancellation token + + + + + Subscribe to liquidation order updates + + + Data handler + Cancellation token + + + + + Subscribe to funding rate updates + + + Data handler + Cancellation token + + + + + Subscribe to contract info updates + + + Data handler + Cancellation token + + + + + Subscribe to contract element updates. Only changed properties are send after the initial update, other properties will be `null`. + + + Data handler + Cancellation token + + + + + Subscribe to isolated margin trigger order updates + + + Data handler + Cancellation token + + + + + Subscribe to cross margin trigger order updates + + + Data handler + Cancellation token + + + + + HTX order book factory + + + + + Spot order book factory methods + + + + + Usdt futures order book factory methods + + + + + Create a SymbolOrderBook for the Spot API + + The symbol + Order book options + + + + + Create a SymbolOrderBook for the Usdt futures API + + The symbol + Order book options + + + + + Api addresses usable for the HTX clients + + + + + The address used by the HTXRestClient for the rest spot API + + + + + The address used by the HTXSocketClient for the public socket API + + + + + The address used by the HTXRestClient for the rest usdt margin swaps API + + + + + The address used by the HTXSocketClient for the private user socket API + + + + + The default addresses to connect to the HTX.com API + + + + + The timestamp of the data + + + + + The data + + + + + The action + + + + + The name of the data channel + + + + + The timestamp of the update + + + + + The data of the update + + + + + HTX account info + + + + + The id of the account + + + + + The state of the account + + + + + The type of the account + + + + + Sub state + + + + + Account and balance info + + + + + The list of balances + + + + + Symbol + + + + + Account history data + + + + + Account ID + + + + + Asset + + + + + Quantity change (positive value if income, negative value if outcome) + + + + + Blance change types + + + + + Available balance + + + + + Account balance + + + + + Transaction time (database time) + + + + + Unique record ID in the database + + + + + Account valuation + + + + + The balance + + + + + Timestamp of the data + + + + + HTX aggregated sub account balance + + + + + The asset + + + + + The type of the balance + + + + + The balance + + + + + API key info + + + + + Access key + + + + + Status + + + + + Note + + + + + Permissions + + + + + Ip addresses + + + + + Valid days + + + + + Create time + + + + + Update time + + + + + Asset information + + + + + Tags + + + + + Asset addrress with tag + + + + + Fast confirms + + + + + Safe confirms + + + + + Minimal deposit quantity + + + + + Minimal withdrawal quantity + + + + + Fee type + + + + + White enabled + + + + + Country disabled + + + + + Is this a quote asset + + + + + Precision for displaying + + + + + Precision for withdrawing + + + + + Full asset name + + + + + Asset type + + + + + Asset code + + + + + Visible + + + + + Is deposit enabled + + + + + Is withdraw enabled + + + + + Weight + + + + + Status + + + + + Display name + + + + + Info regarding deposits + + + + + Suspend description + + + + + Suspend withdraw description + + + + + Suspend deposit description + + + + + Withdrawal description + + + + + Asset info + + + + + Networks + + + + + Asset + + + + + Status + + + + + Network info + + + + + Network + + + + + Display name + + + + + Base network + + + + + Base network protocol + + + + + Is dynamic + + + + + Deposit status + + + + + Max transact fee withdraw + + + + + Max withdraw quantity + + + + + Min deposit quantity + + + + + Fixed withdraw fee, only applicable if fee type is fixed + + + + + Ratio withdraw fee, only applicable if fee type is ratio + + + + + Min transact fee withdraw + + + + + Min withdraw quantity + + + + + Num of confirmations + + + + + Num of fast confirmations + + + + + Withdraw fee type + + + + + Withdraw precision + + + + + Withdraw quota per day + + + + + Withdraw quota per year + + + + + Withdraw quota total + + + + + Withdraw status + + + + + Balance data + + + + + The asset + + + + + The type of the balance + + + + + The balance + + + + + Sequence number of the update + + + + + Balance info + + + + + Asset + + + + + Frozen + + + + + Trade + + + + + Result of a batch cancel + + + + + Orders that were successfully canceled + + + + + Orders that failed to cancel + + + + + Cancel result + + + + + The error code + + + + + The error message + + + + + The id of the failed order + + + + + The state of the order + + + + + The id of the failed order + + + + + Batch placement result + + + + + Order id + + + + + Client order id + + + + + Whether the placement was successful + + + + + The error code + + + + + The error message + + + + + Info on a symbol's best offer + + + + + Symbol + + + + + Time of the data + + + + + Best bid price + + + + + Quantity of the best bid + + + + + Best ask price + + + + + Quantity of the best ask + + + + + Sequence number + + + + + Result of Cancel Orders by Criteria + + + + + The number of cancel request sent successfully + + + + + The number of cancel request failed + + + + + the next order id that can be canceled + + + + + Conditional order info + + + + + Acount id + + + + + Source + + + + + Order id + + + + + Client order id + + + + + Symbol + + + + + Price + + + + + Quantity + + + + + Quote quantity + + + + + Side + + + + + Time in force + + + + + Type + + + + + Stop price + + + + + Trailing rate + + + + + Creation time + + + + + Last update time + + + + + Status + + + + + Error code if the conditional order is rejected + + + + + Error message if conditional order is rejected + + + + + Conditional order cancelation result + + + + + Orders accepted for cancelation + + + + + Orders rejected for cancelation + + + + + Deduction info + + + + + Point switch + + + + + Htx switch + + + + + Asset + + + + + + + + + + Asset + + + + + Deposit address info + + + + + User id + + + + + Asset + + + + + Deposit address + + + + + Deposit address tag + + + + + Block chain name + + + + + Current transaction fee rate applied to the user + + + + + The symbol + + + + + Basic fee rate – passive side + + + + + Basic fee rate – aggressive side + + + + + Deducted fee rate – passive side + + + + + Basic fee rate – aggressive side + + + + + Ledger entry + + + + + Account id + + + + + Asset + + + + + Quantity of the transaction + + + + + Type of transaction + + + + + Type of transfer + + + + + Transaction id + + + + + Transaction time + + + + + Transferer + + + + + Transferee + + + + + Loan info + + + + + Symbol name + + + + + Currencies + + + + + Asset info + + + + + Asset + + + + + Interest rate + + + + + Minimal loan quantity + + + + + Maximal loan quantity + + + + + Remaining loanable quantity + + + + + Actual interest rate + + + + + Margin account balance + + + + + Id + + + + + Type + + + + + Symbol + + + + + Status + + + + + Risk rate + + + + + Account balance sum + + + + + Debt balance sum + + + + + The price which margin closeout was triggered + + + + + Fl type + + + + + Account details + + + + + Balance info + + + + + The asset + + + + + Balance type + + + + + Balance + + + + + Margin order info + + + + + Order id + + + + + Account id + + + + + User id + + + + + Symbol + + + + + Asset + + + + + Creation time + + + + + Accrue time + + + + + Loan quantity + + + + + Loan balance left + + + + + Interst rate + + + + + Interest quantity + + + + + Interest left + + + + + State + + + + + Paid HTX points + + + + + Paid asset + + + + + Filled HTX points + + + + + HT deduction amount + + + + + Deduct rate + + + + + Deduct asset + + + + + Deduct quantity + + + + + Last updated + + + + + Hourly interest rate + + + + + Daily interest rate + + + + + Max holdings + + + + + Asset + + + + + Max holdings + + + + + NAV info for ETP + + + + + The symbol + + + + + Latest Nav + + + + + Update time + + + + + Outstanding shares + + + + + Baskets + + + + + Actual leverage ratio + + + + + Basket + + + + + Asset + + + + + Amount + + + + + Open order + + + + + The id of the order + + + + + The order id as specified by the client + + + + + The symbol of the order + + + + + The id of the account that placed the order + + + + + The quantity of the order + + + + + The price of the order + + + + + The time the order was created + + + + + The time the order was canceled + + + + + The time the order was completed + + + + + The raw type string + + + + + The type of the order + + + + + The side of the order + + + + + The source of the order + + + + + The state of the order + + + + + The quantity of the order that is filled + + + + + Filled cash quantity + + + + + The quantity of fees paid for the filled quantity + + + + + Order info + + + + + The id of the order + + + + + The order id as specified by the client + + + + + The symbol of the order + + + + + The id of the account that placed the order + + + + + The quantity of the order + + + + + The price of the order + + + + + The time the order was created + + + + + The time the order was canceled + + + + + The time the order was finished + + + + + The raw type string + + + + + The type of the order + + + + + The side of the order + + + + + The source of the order + + + + + The state of the order + + + + + The quantity of the order that is filled + + + + + Filled cash quantity + + + + + The quantity of fees paid for the filled quantity + + + + + Source of cancelation + + + + + Order book + + + + + Timestamp + + + + + Version + + + + + List of bids + + + + + List of asks + + + + + Incremental order book update + + + + + Sequence number + + + + + Previous sequence number + + + + + List of changed bids + + + + + List of changed asks + + + + + Order id + + + + + Order id + + + + + Order request + + + + + Account id + + + + + Symbol + + + + + Order side + + + + + Order type + + + + + Order quantity. For Buy Market orders this is in quote asset. + + + + + Limit price + + + + + Order source + + + + + Client order id + + + + + Stop price + + + + + Stop operator + + + + + Orders info + + + + + Timestamp for pagination + + + + + List of ticks for symbols + + + + + Trade info + + + + + The id of the trade + + + + + The symbol of the trade + + + + + The timestamp in milliseconds when this record is created + + + + + The quantity which has been filled + + + + + Transaction fee (positive value). If maker rebate applicable, revert maker rebate value per trade (negative value). + + + + + Deduction amount (unit: in ht or hbpoint). + + + + + The id of the trade + + + + + The id of the match + + + + + The id of the order + + + + + The limit price of limit order + + + + + The source where the order was triggered, possible values: sys, web, api, app + + + + + The raw type string + + + + + The type of the order + + + + + The side of the order + + + + + The role in the transaction: taker or maker + + + + + Asset of transaction fee or transaction fee rebate (transaction fee of buy order is based on base asset, transaction fee of sell order is based on quote asset; transaction fee rebate of buy order is based on quote asset, transaction fee rebate of sell order is based on base asset) + + + + + Deduction type: ht or hbpoint. + + + + + Fee deduction status. + + + + + Placed conditional order + + + + + The id + + + + + Placed order + + + + + The id + + + + + Platform wide valuation + + + + + Updated + + + + + Today profit rate + + + + + Total balance + + + + + Todays profit + + + + + Account balance list + + + + + + + + + + Success + + + + + Last update time + + + + + + + + + + Balance type + + + + + Balance + + + + + Success + + + + + Account balance + + + + + Point balance + + + + + Account id + + + + + Group ids + + + + + Accountt balance + + + + + Account status + + + + + Group info + + + + + Group id + + + + + Expiry date + + + + + Remaining quantity + + + + + Transfer result + + + + + Transact id + + + + + Transact time + + + + + Repayment info + + + + + Repayment id + + + + + Account id + + + + + Repay time + + + + + Asset + + + + + Repay quantity + + + + + Transactions + + + + + Repayment transaction + + + + + Transact id + + + + + Principal repaid + + + + + Interest repaid + + + + + HT paid + + + + + Points paid + + + + + Repayment result + + + + + Repayment id + + + + + Repay time + + + + + Sub account info + + + + + User name + + + + + Note + + + + + User id + + + + + Error code + + + + + Error message + + + + + Sub account lock + + + + + Sub user id + + + + + User lock state + + + + + Sub account request + + + + + User name + + + + + Note + + + + + Sub account API key + + + + + Access key + + + + + Secret key + + + + + Note + + + + + Permission, comma seperated + + + + + Ip addresses, comma seperated + + + + + Edit result + + + + + Note + + + + + Permission, comma seperated + + + + + Ip addresses, comma seperated + + + + + Sub account deduct mode + + + + + Sub uid + + + + + Deduct mode + + + + + Error code + + + + + Error message + + + + + Sub account deposit + + + + + Id + + + + + Asset + + + + + Network + + + + + Quantity + + + + + Address + + + + + Status + + + + + Transaction hash + + + + + Address tag + + + + + Create time + + + + + Update time + + + + + Sub account tradable market status + + + + + Sub user id + + + + + Account type + + + + + Activation + + + + + Error code + + + + + Error message + + + + + Transfer permission + + + + + Account type + + + + + Transferrable + + + + + Sub user id + + + + + Error code + + + + + Error message + + + + + HTX sub-user account info + + + + + The type of the account + + + + + Whether the account is active of not + + + + + Whether transfers are allowed (only for spot account type) + + + + + Account ids + + + + + HTX sub-user account id and state + + + + + The id of the account + + + + + The status of the account + + + + + Sub state + + + + + HTX sub-user account info + + + + + The id of the sub-user + + + + + Deduct mode + + + + + List of accounts for the sub-user + + + + + Symbol information + + + + + Tags + + + + + State + + + + + WithdrawRisk + + + + + Symbol name + + + + + Base asset display name + + + + + Quote asset display name + + + + + Etp leverage ratio + + + + + Price precision + + + + + Quantity precision + + + + + Fee precision + + + + + Super margin leverage ratio + + + + + C2C leverage ratio + + + + + White enabled + + + + + Country disabled + + + + + Trade enabled + + + + + Symbol partition + + + + + Direction + + + + + Base asset + + + + + Quote asset + + + + + Time trading starts + + + + + trade total precision + + + + + Weight sort + + + + + Leverage ratio + + + + + DisplayName + + + + + Symbol configuration + + + + + Symbol + + + + + Status + + + + + Base asset + + + + + Quote asset + + + + + Price precision + + + + + Quantity precision + + + + + Partition + + + + + Value precision + + + + + Minimal order quantity + + + + + Max order quantity + + + + + Minimal order value + + + + + Minimal quantity of limit order + + + + + Max quantity of limit order + + + + + Max quantity of limit buy order + + + + + Max quantity of limit sell order + + + + + Minimal quantity of market sell order + + + + + Buy limit order must be less than this + + + + + Sell limit order must be less than this + + + + + Max quantity of market sell order + + + + + Max quantity of market buy order + + + + + Sell market order rate must be less than this + + + + + Buy market order rate must be less than this + + + + + Max value of a market order + + + + + Etp symbol + + + + + Mfr + + + + + ETP charge time + + + + + ETP rebal time + + + + + ETP rebal threshold + + + + + ETP initial NAV + + + + + ApiTrading + + + + + Tags + + + + + Symbol data + + + + + The highest price + + + + + The lowest price + + + + + The price at the opening + + + + + The last price + + + + + The volume in base asset + + + + + The volume in quote asset (quantity * price) + + + + + The number of trades + + + + + Version + + + + + Ticker data + + + + + The symbol + + + + + Symbol kline data + + + + + The start time of the kline + + + + + Turnover, quantity * contract value * price + + + + + Kline data + + + + + Order id + + + + + Symbol details + + + + + The id of the details + + + + + Timestamp of the data + + + + + Symbol tick + + + + + The symbol + + + + + Quantity of the best bid + + + + + Quantity of the best ask + + + + + Best bid price + + + + + Best ask price + + + + + Last trade price + + + + + Last trade quantity + + + + + Status of the symbol + + + + + The status + + + + + Start time of when market halted + + + + + Estimated end time of the halt + + + + + Reason for halting + + + + + Affected symbols, comma separated or 'all' if all symbols are affected + + + + + Symbol tick info + + + + + Timestamp of the data + + + + + The id of the tick + + + + + The current best bid for the symbol + + + + + The current best ask for the symbol + + + + + Order book entry + + + + + The price for this entry + + + + + The quantity for this entry + + + + + Symbol ticks + + + + + Timestamp of the data + + + + + List of ticks for symbols + + + + + Symbol ticks + + + + + Timestamp of the data + + + + + List of ticks for symbols + + + + + Symbol trade + + + + + The id of the trade + + + + + The timestamp of the trade + + + + + The details of the trade + + + + + Symbol trade details + + + + + The id of the update + + + + + The id of the trade + + + + + The price of the trade + + + + + The quantity of the trade + + + + + The side of the trade + + + + + The timestamp of the trade + + + + + System status info + + + + + Page + + + + + Components + + + + + Incidents + + + + + Scheduled maintenances + + + + + Status + + + + + Page info + + + + + Id + + + + + Name + + + + + Url + + + + + Time zone + + + + + Updated at + + + + + System component + + + + + Id + + + + + Name + + + + + System status + + + + + Created at + + + + + Updated at + + + + + Position + + + + + Description + + + + + Showcase + + + + + Group id + + + + + Page id + + + + + Group + + + + + Only show if degraded + + + + + System incident + + + + + Id + + + + + Name + + + + + Incident status + + + + + Created at + + + + + Updated at + + + + + Monitoring at + + + + + Resolved at + + + + + Impact + + + + + Shortlink + + + + + Started at + + + + + Page id + + + + + Incident updates + + + + + Components + + + + + System incident update + + + + + Id + + + + + Incident status + + + + + Body + + + + + Incident id + + + + + Created at + + + + + Updated at + + + + + Display at + + + + + Affected components + + + + + Deliver notifications + + + + + Custom tweet + + + + + Tweet id + + + + + System incident affacted component + + + + + Code + + + + + Name + + + + + Old status + + + + + New status + + + + + + + + + + Id + + + + + Name + + + + + Status + + + + + Created at + + + + + Updated at + + + + + Monitoring at + + + + + Resolved at + + + + + Impact + + + + + Shortlink + + + + + Started at + + + + + Page id + + + + + Incident updates + + + + + Components + + + + + Scheduled for + + + + + Scheduled until + + + + + Indicator + + + + + Indicator + + + + + Description + + + + + Transaction result + + + + + Id + + + + + Time + + + + + HTX user info + + + + + The id of the user + + + + + The status of the user + + + + + User name + + + + + User name + + + + + Withdrawal address info + + + + + Asset + + + + + Network + + + + + Note + + + + + Address tag + + + + + Address + + + + + Asset quota + + + + + Asset + + + + + Networks + + + + + Network quota + + + + + Network + + + + + Max withdraw amt + + + + + Withdraw quota per day + + + + + Remain withdraw quota per day + + + + + Withdraw quota per year + + + + + Remain withdraw quota per year + + + + + Withdraw quota total + + + + + Remain withdraw quota total + + + + + Withdraw or Deposit + + + + + Transfer id + + + + + Client order id + + + + + Define transfer type to search, possible values: [deposit, withdraw] + + + + + Sub type + + + + + The crypto asset to withdraw + + + + + The on-chain transaction hash + + + + + Block chain name + + + + + The number of crypto asset transfered in its minimum unit + + + + + The deposit or withdraw target address + + + + + The user defined address tag + + + + + The address tag of the address its from + + + + + Withdraw fee + + + + + The status of this transfer + + + + + Error code for withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". + + + + + Error description of withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". + + + + + The timestamp in milliseconds for the transfer creation + + + + + The timestamp in milliseconds for the transfer's latest update + + + + + Account update + + + + + Asset + + + + + Account id + + + + + Total balance + + + + + Available balance + + + + + Type of change + + + + + Account type + + + + + Change time + + + + + Update sequence number + + + + + Best offer update + + + + + Order id + + + + + Update id + + + + + Best bid + + + + + Best ask + + + + + Timestamp + + + + + Version + + + + + Incremental order book update + + + + + Event + + + + + Order book update + + + + + Order id + + + + + Update id + + + + + Version + + + + + List of changed bids + + + + + List of changed asks + + + + + Cancelation details + + + + + Event type + + + + + The symbol + + + + + Order id + + + + + Order side + + + + + Order type + + + + + Account id + + + + + Order source + + + + + Order price + + + + + Order quantity + + + + + Client order id + + + + + Stop price + + + + + Operator + + + + + Order creation time + + + + + Order status + + + + + Remaining quantity + + + + + Order update + + + + + Event type + + + + + The symbol + + + + + Client order id + + + + + Order status + + + + + Timestamp + + + + + Submitted order update + + + + + Account id + + + + + Order id + + + + + Price of the order + + + + + Quantity of the order + + + + + Value of the order + + + + + The raw type string + + + + + The type of the order + + + + + The type of the order + + + + + Creation time + + + + + Order source + + + + + Matched order update + + + + + Trade price + + + + + Trade volume + + + + + Order id + + + + + The raw type string + + + + + The type of the order + + + + + The type of the order + + + + + Trade id + + + + + Timestamp of trade + + + + + Is the taker + + + + + Remaining quantity + + + + + Executed quantity + + + + + Price of the order + + + + + Quantity of the order + + + + + Order source + + + + + Canceled order update + + + + + Order id + + + + + The raw type string + + + + + The type of the order + + + + + The type of the order + + + + + Remaining quantity + + + + + Executed quantity + + + + + Price of the order + + + + + Quantity of the order + + + + + Order source + + + + + Info on a failed trigger for a conditional order + + + + + Side of the order + + + + + The error code + + + + + The error message + + + + + System status update + + + + + Timestamp + + + + + Event, init (initial) status or update + + + + + Data + + + + + System status update + + + + + Is system available + + + + + Estimated recovery time + + + + + Symbol update + + + + + Id + + + + + Order id + + + + + Turnover + + + + + Best bid + + + + + Best ask + + + + + Trade update + + + + + Event type + + + + + The symbol + + + + + Order id + + + + + Price of this trade + + + + + Volume of this trade + + + + + Order side + + + + + Order type + + + + + Is the taker + + + + + Trade id + + + + + Time of trade + + + + + Transaction fee + + + + + Asset of the fee + + + + + Fee deduction quantity + + + + + Fee deduction type + + + + + Account id + + + + + Order source + + + + + Order price + + + + + Order quantity + + + + + Client order id + + + + + Stop price + + + + + Operator + + + + + Order creation time + + + + + Order status + + + + + Basis update + + + + + Id + + + + + Index price + + + + + Contract price + + + + + Basis + + + + + Basis rate + + + + + Timestamp + + + + + Event + + + + + Data + + + + + Contract element info + + + + + Contract code + + + + + Funding rate cap + + + + + Funding rate floor + + + + + Mode type + + + + + Swap delivery type + + + + + Settle period + + + + + Instrument index code + + + + + Price ticks + + + + + Instrument values + + + + + Min level + + + + + Max level + + + + + Order limits + + + + + Normal limits + + + + + Open limits + + + + + Trade limits + + + + + Instrument types + + + + + Real time settlement + + + + + Transfer profit ratio + + + + + Cross transfer profit ratio + + + + + Price tick + + + + + Instrument value + + + + + Trade partition + + + + + Open order limit + + + + + Offset order limit + + + + + Long position limit + + + + + Short position limit + + + + + Contract infos + + + + + + + + + + Timestamp + + + + + Event + + + + + Data + + + + + Contract update + + + + + Symbol + + + + + Contract code + + + + + Contract quantity + + + + + Price tick + + + + + Settlement date + + + + + Create date + + + + + Contract status + + + + + Support margin mode + + + + + Delivery time + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Delivery date + + + + + Cross margin balance update + + + + + Timestamp + + + + + Event + + + + + Data + + + + + User id + + + + + + + + + + Margin mode + + + + + Margin account + + + + + Margin asset + + + + + Margin balance + + + + + Static margin + + + + + Margin position + + + + + Margin frozen + + + + + Realized profit and loss + + + + + Unrealized profit and loss + + + + + Withdraw available + + + + + Risk rate + + + + + Position mode + + + + + Contract detail + + + + + Futures contract detail + + + + + Contract info + + + + + Symbol + + + + + Contract code + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Unrealized profit and loss + + + + + Liquidation price + + + + + Leverage rate + + + + + Adjust factor + + + + + Contract type + + + + + Pair + + + + + Business type + + + + + Futures contract + + + + + Symbol + + + + + Contract code + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Unrealized profit and loss + + + + + Liquidation price + + + + + Leverage rate + + + + + Adjust factor + + + + + Contract type + + + + + Pair + + + + + Business type + + + + + Cross margin position update + + + + + Data timestamp + + + + + Event + + + + + Data + + + + + User id + + + + + Cross margin position data + + + + + Pair + + + + + Business type + + + + + Contract type + + + + + Cross margin trade update + + + + + Pair + + + + + Business type + + + + + Contract type + + + + + Trigger order update + + + + + Timestamp + + + + + Event + + + + + User id + + + + + Data + + + + + Trigger update + + + + + Pair + + + + + Business type + + + + + Contract type + + + + + + + + + + Timestamp + + + + + Data + + + + + Funding rate update + + + + + Symbol + + + + + Contract code + + + + + Fee asset + + + + + Funding time + + + + + Funding rate + + + + + Settlement time + + + + + Estimated rate + + + + + Isolated balance update + + + + + Timestamp + + + + + Event trigger + + + + + Data + + + + + User id + + + + + Isolated margin balance update + + + + + Asset + + + + + Contract code + + + + + Margin balance + + + + + Static equity + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Realized profit and loss + + + + + Unrealized proft and loss + + + + + Withdraw available + + + + + Risk rate + + + + + Liquidation price + + + + + Leverage rate + + + + + Adjust factor + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Position mode + + + + + Position data update + + + + + Data timestamp + + + + + Event + + + + + Data + + + + + User id + + + + + Position data + + + + + Symbol + + + + + Contract code + + + + + Quantity + + + + + Available + + + + + Frozen + + + + + Open price + + + + + Position price + + + + + Unrealized profit and loss + + + + + Profit / loss ratio + + + + + Profit and loss + + + + + Position margin + + + + + Leverage rate + + + + + Side + + + + + Last price + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Position mode + + + + + Adl risk percent + + + + + Order trade update + + + + + Timestamp + + + + + Symbol + + + + + Contract code + + + + + Status + + + + + Order id + + + + + Order id string + + + + + Client order id + + + + + Order type + + + + + Creation time + + + + + Trades + + + + + User id + + + + + Quantity + + + + + Quantity filled + + + + + Order side + + + + + Offset + + + + + Leverage rate + + + + + Price + + + + + Order source + + + + + Order price type + + + + + Margin mode + + + + + Margin account + + + + + Is take profit / stop loss + + + + + Reduce only + + + + + + + + + + Trade id + + + + + Id + + + + + Quantity + + + + + Price + + + + + Value + + + + + Creation time + + + + + Role + + + + + Trigger order update + + + + + Timestamp + + + + + Event + + + + + User id + + + + + Data + + + + + + + + + + Symbol + + + + + Contract code + + + + + Trigger type + + + + + Quantity + + + + + Order type + + + + + Side + + + + + Offset + + + + + Leverage rate + + + + + Order id + + + + + Order id string + + + + + Relation order id + + + + + Order price type + + + + + Status + + + + + Order source + + + + + Trigger price + + + + + Triggered price + + + + + Order price + + + + + Creation time + + + + + Triggered time + + + + + Order insert time + + + + + Cancel time + + + + + Margin mode + + + + + Margin account + + + + + Fail code + + + + + Fail reason + + + + + Reduce only + + + + + Liquidation update + + + + + Timestamp + + + + + Data + + + + + + + + + + Symbol + + + + + Contract code + + + + + Side + + + + + Offset + + + + + Volume + + + + + Price + + + + + Creation time + + + + + Liquidation quantity + + + + + Trade turnover + + + + + Contract type + + + + + Pair + + + + + Business type + + + + + Order update + + + + + Update timestamp + + + + + User id + + + + + Symbol + + + + + Contract code + + + + + Quantity + + + + + Price + + + + + Order price type + + + + + Order side + + + + + Offset + + + + + Status + + + + + Leverage rate + + + + + Order id + + + + + Order id string + + + + + Client order id + + + + + Order source + + + + + Order type + + + + + Created at + + + + + Quantity filled + + + + + Value filled in quote asset + + + + + Fee + + + + + Liquidation type + + + + + Average trade price + + + + + Margin asset + + + + + Margin frozen + + + + + Profit + + + + + Canceled at + + + + + Fee asset + + + + + Margin mode + + + + + Margin account + + + + + Is take profit / stop loss + + + + + Profit and loss + + + + + Reduce only + + + + + Canceled source + + + + + Trade info + + + + + Trade info + + + + + Trade id + + + + + Id + + + + + Trade quantity + + + + + Trade price + + + + + Fee + + + + + Fee asset + + + + + Deduction asset price + + + + + Trade value + + + + + Created at + + + + + Role + + + + + Profit + + + + + Real profit + + + + + Trade info + + + + + Update id + + + + + Update timestamp + + + + + Trades + + + + + Trade info + + + + + Amount of trades + + + + + Timestamp + + + + + Trade id + + + + + Price + + + + + Side + + + + + Quantity + + + + + Turnover + + + + + Account sentiment + + + + + List + + + + + Symbol + + + + + Contract code + + + + + Business type + + + + + Pair + + + + + Sentiment value + + + + + Buy ratio + + + + + Sell ratio + + + + + Locked ratio + + + + + Timestamp + + + + + Asset valuation + + + + + Asset name + + + + + Balance + + + + + Basis data + + + + + Basis + + + + + Basis rate + + + + + Contract price + + + + + Index price + + + + + Unique id + + + + + Batch result + + + + + Errors in the batch + + + + + Success + + + + + Batch operation error + + + + + Order id + + + + + Error code + + + + + Error message + + + + + Cancel after status + + + + + Current time + + + + + Trigger time + + + + + Trigger order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trigger order + + + + + Cancel time + + + + + Trigger time + + + + + Order insert time + + + + + Update time + + + + + Error code + + + + + Error reason + + + + + Triggered price + + + + + Relation order id + + + + + Trigger order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trigger order + + + + + Cancel time + + + + + Trigger time + + + + + Order insert time + + + + + Update time + + + + + Error code + + + + + Error reason + + + + + Triggered price + + + + + Relation order id + + + + + Close position result + + + + + Order id + + + + + Order id str + + + + + Client order id + + + + + Contract element info + + + + + Contract code + + + + + Funding rate cap + + + + + Funding rate floor + + + + + Mode type + + + + + Swap delivery type + + + + + Settle period + + + + + Instrument index code + + + + + Price ticks + + + + + Instrument values + + + + + Min level + + + + + Max level + + + + + Order limits + + + + + Normal limits + + + + + Open limits + + + + + Trade limits + + + + + Real time settlement + + + + + Transfer profit ratio + + + + + Cross transfer profit ratio + + + + + Instrument types + + + + + Price tick + + + + + Instrument value + + + + + Trade partition + + + + + Open order limit + + + + + Offset order limit + + + + + Long position limit + + + + + Short position limit + + + + + Contract infos + + + + + Price info + + + + + Business type + + + + + Price + + + + + Limit info + + + + + Instrument type + + + + + Open + + + + + Close + + + + + Order limit + + + + + Open after closing + + + + + Contract info + + + + + Contract code + + + + + Instrument type + + + + + Settlement date + + + + + Delivery time + + + + + Create date + + + + + Contract status + + + + + Delivery date + + + + + Contract info + + + + + The asset + + + + + Contract code + + + + + Contract size + + + + + Price tick + + + + + Deliverty date + + + + + Delivery time + + + + + Created date + + + + + Status + + + + + Settlement date + + + + + Margin mode + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Contract status + + + + + Asset + + + + + Contract code + + + + + Margin account + + + + + Margin mode + + + + + Open order access + + + + + Close order access + + + + + Cancel order access + + + + + Deposit access + + + + + Withdrawal access + + + + + Transfer from master to sub + + + + + Transfer from sub to master + + + + + Master transfer sub inner in + + + + + Master transfer sub inner out + + + + + Sub transfer master inner in + + + + + Sub transfer master inner out + + + + + Transfer inner in + + + + + Tranfer inner out + + + + + Levearege position limits + + + + + Business type + + + + + Contract type + + + + + Pair + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + List + + + + + Limits + + + + + Leverage rate + + + + + Buy limit value + + + + + Sell limit value + + + + + Cross margin account contract details + + + + + Asset + + + + + Contract type + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Unrealized profit and loss + + + + + Liquidation price + + + + + Leverage rate + + + + + Cross max available + + + + + Adjust factor + + + + + Contract type + + + + + Symbol + + + + + Business type + + + + + Trade partition + + + + + Account info + + + + + Margin balance + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Realized profit and loss + + + + + Unrealized profit and loss + + + + + Risk rate + + + + + New risk rate + + + + + Withdraw available + + + + + Money in + + + + + Money out + + + + + Margin static + + + + + Cross max available + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Position mode + + + + + ADL risk percentage + + + + + Contract details + + + + + Futures contract details + + + + + Cross margin assets and positions info + + + + + Positions + + + + + Available leverage info + + + + + Contract type + + + + + Symbol + + + + + Business type + + + + + Order page + + + + + Orders + + + + + Positions limits + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + Buy limit + + + + + Sell limit + + + + + Business type + + + + + Contract type + + + + + Pair + + + + + Lever rate + + + + + Buy limit value + + + + + Sell limit value + + + + + Mark price + + + + + Sub account assets info + + + + + Sub account uid + + + + + Assets + + + + + Sub account asset info + + + + + Margin balance + + + + + Risk rate + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Cross margin trade status + + + + + Asset + + + + + Contract code + + + + + Margin mode + + + + + Margin account + + + + + Open order access + + + + + Close order access + + + + + Cancel order access + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Cross margin transfer status + + + + + Margin mode + + + + + Margin account + + + + + Deposit access + + + + + Withdrawal access + + + + + Transfer from master to sub + + + + + Transfer from sub to master + + + + + Master transfer sub inner in + + + + + Master transfer sub inner out + + + + + Sub transfer master inner in + + + + + Sub transfer master inner out + + + + + Transfer inner in + + + + + Tranfer inner out + + + + + User settlement record page + + + + + Total pages + + + + + Current pages + + + + + Total amount of records + + + + + Records + + + + + User settlement record + + + + + Margin account + + + + + Margin mode + + + + + Margin balance init + + + + + Margin balance + + + + + Settlement profit realized + + + + + Settlement time + + + + + Clawback + + + + + Funding fee + + + + + Offset profit loss + + + + + Fee + + + + + Fee asset + + + + + Contract details + + + + + Settlement contract details + + + + + Asset + + + + + Contract code + + + + + Offset profit loss + + + + + Fee + + + + + Fee asset + + + + + Positions + + + + + Settlement position + + + + + Asset + + + + + Contract code + + + + + Direction + + + + + Volume + + + + + Cost open + + + + + Cost hold before settlement + + + + + Cost hold after settlement + + + + + Settlement profit unrealized + + + + + Settlement price + + + + + Settlement type + + + + + User trade info + + + + + Position open and tp/sl info + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Take profit / stop loss order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Tp/Sl order + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Take profit / stop loss order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Tp/Sl order + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Trailing order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trailing order info + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Trailing order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trailing order info + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Cross margin transfer limit + + + + + Transfer in max per transfer + + + + + Transfer in min per transfer + + + + + Transfer out max per transfer + + + + + Transfer out min per transfer + + + + + Transfer in max daily + + + + + Transfer out max daily + + + + + Net transfer in max daily + + + + + Net transfer out max daily + + + + + Margin account + + + + + Margin mode + + + + + Trigger cross margin order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trigger order + + + + + Contract type + + + + + Business type + + + + + Symbol + + + + + Estimated settlement price + + + + + Contract code + + + + + Estimated settlement price + + + + + Settlement type + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Financial records + + + + + Query id + + + + + Record id + + + + + Record type + + + + + Amount + + + + + Timestamp + + + + + Contract code + + + + + Asset + + + + + Margin account + + + + + Face margin account + + + + + Funding rate + + + + + Funding rate + + + + + Contract code + + + + + Symbol + + + + + Fee asset + + + + + Funding rate + + + + + Funding rates page + + + + + Total pages + + + + + Current page + + + + + Total results + + + + + Rates + + + + + Historical funding rate + + + + + Average premium index + + + + + Funding rate + + + + + Realized rate + + + + + Funding time + + + + + Contract code + + + + + Symbol + + + + + Fee asset + + + + + Insurance info + + + + + Total amount of pages + + + + + Current page + + + + + Total amount of results + + + + + The asset + + + + + Contract code + + + + + Business type + + + + + Symbol + + + + + The history data + + + + + Insurance value + + + + + Insurance fund + + + + + Timestamp + + + + + Account info + + + + + Asset info + + + + + Margin balance + + + + + Margin position + + + + + Margin frozen + + + + + Margin available + + + + + Profit real + + + + + Unrealized profit and loss + + + + + Risk rate + + + + + Risk rate + + + + + Withdraw available + + + + + Liquidation price + + + + + Leverage rate + + + + + Adjust factor + + + + + Margin static + + + + + Contract code + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Position mode + + + + + Trade partition + + + + + ADL risk percentage + + + + + Isolated margin assets and positions info + + + + + Positions + + + + + Available leverage info + + + + + Contract code + + + + + Margin mode + + + + + Available rates + + + + + Isolated margin order info + + + + + Asset + + + + + Contract code + + + + + Quantity of contract + + + + + Price + + + + + Order price type + + + + + Order type + + + + + Direction + + + + + Offset + + + + + Leverage rate + + + + + Order id + + + + + Order id string + + + + + Client order id + + + + + Creation time + + + + + Cancel time + + + + + Quantity filled + + + + + Value of the quantity filled + + + + + Fee + + + + + Average fill price + + + + + Margin frozen + + + + + Margin asset + + + + + Profit + + + + + Order status + + + + + Source + + + + + Fee asset + + + + + Liquidation type + + + + + Margin mode + + + + + Margin account + + + + + Is take profit/stop loss + + + + + Realized profit and loss + + + + + Reduce only + + + + + HTX fee quantity + + + + + HTX fee quote quantity + + + + + Cancel source + + + + + Update time + + + + + Trades + + + + + Cross margin order info + + + + + Business type + + + + + Contract type + + + + + Symbol + + + + + Order page + + + + + Orders + + + + + Sub account assets info + + + + + Sub account uid + + + + + Assets + + + + + Sub account asset info + + + + + Asset + + + + + Margin balance + + + + + Liquidation price + + + + + Risk rate + + + + + Contract code + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + User settlement record page + + + + + Total pages + + + + + Current pages + + + + + Total amount of records + + + + + Records + + + + + User settlement record + + + + + Asset + + + + + Contract code + + + + + Margin mode + + + + + Margin account + + + + + Margin balance init + + + + + Margin balance + + + + + Settlement profit realized + + + + + Settlement time + + + + + Clawback + + + + + Funding fee + + + + + Offset profit loss + + + + + Fee + + + + + Fee asset + + + + + Positions + + + + + Settlement position + + + + + Asset + + + + + Contract code + + + + + Direction + + + + + Volume + + + + + Cost open + + + + + Cost hold before settlement + + + + + Cost hold after settlement + + + + + Settlement unrealized profit and loss + + + + + Settlement price + + + + + Settlement type + + + + + + + + + + Query id + + + + + Contract type + + + + + Pair + + + + + Business type + + + + + Match id + + + + + Order id + + + + + Symbol + + + + + Contract code + + + + + Side + + + + + Offset + + + + + Quantity + + + + + Price + + + + + Value + + + + + Fee + + + + + Offset profit loss + + + + + Create time + + + + + Role + + + + + Order source + + + + + Order id str + + + + + Id + + + + + Fee asset + + + + + Margin mode + + + + + Margin account + + + + + Real profit + + + + + Reduce only + + + + + Last trade data + + + + + Amount of contracts + + + + + Quantity + + + + + Price + + + + + Timestamp + + + + + Id + + + + + Direction + + + + + Value + + + + + Last trade info + + + + + Contract code + + + + + Business type + + + + + Leverage position limit info + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + Limits + + + + + Leverage position limit + + + + + Leverage rate + + + + + Buy limit value + + + + + Sell limit value + + + + + Leverage rate + + + + + Contract code + + + + + Margin mode + + + + + Leverage rate + + + + + Leverage rate + + + + + Symbol + + + + + Business type + + + + + Contract type + + + + + Liquidation order + + + + + Query id + + + + + Contract code + + + + + Asset + + + + + Direction + + + + + Offset + + + + + Volume + + + + + Price + + + + + Creation time + + + + + Amount + + + + + Turnover + + + + + Business type + + + + + Symbol + + + + + Isolated margin order info + + + + + Instrument price + + + + + Final interest + + + + + Adjust value + + + + + Total pages + + + + + Current page + + + + + Total amount of records + + + + + Trades + + + + + Trade info + + + + + Id + + + + + Trade id + + + + + Trade price + + + + + Trade quantity + + + + + Trade value + + + + + Fee + + + + + Creation time + + + + + Trade role + + + + + Fee asset + + + + + Profit + + + + + Real pnl + + + + + Sub transfer page + + + + + Transfers + + + + + Transfer between master and sub account + + + + + Id + + + + + Creation time + + + + + Asset name + + + + + Margin account + + + + + From margin account + + + + + To margin account + + + + + Sub uid + + + + + Sub account name + + + + + Transfer type + + + + + Quantity + + + + + Open interest + + + + + The asset + + + + + Amount + + + + + Volume + + + + + Value + + + + + Contract code + + + + + Trade amount + + + + + Trade volume + + + + + Trade turnover + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Open interest value + + + + + Asset + + + + + Contract code + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Tick + + + + + Open interest value tick + + + + + Volume + + + + + Unit + + + + + Value + + + + + Timestamp + + + + + Order id + + + + + Order id + + + + + Order id + + + + + Order id string + + + + + Client order id + + + + + Order id + + + + + Order limit info + + + + + Order price type + + + + + Limits + + + + + Limit info + + + + + Asset + + + + + Contract code + + + + + Max open order limit + + + + + Max close order limit + + + + + Business type + + + + + Contract type + + + + + Pair + + + + + Page of data + + + + + Total amount of pages + + + + + Current page + + + + + Total amount of records + + + + + Placed order id + + + + + Order id + + + + + Client order id + + + + + Isolated margin position info + + + + + Asset + + + + + Contract code + + + + + Quantity + + + + + Available + + + + + Frozen + + + + + Opening average price + + + + + Average price of position + + + + + Unrealized profit and loss + + + + + Profit rate + + + + + Leverage rate + + + + + Position margin + + + + + Order direction + + + + + Profit + + + + + Last price + + + + + New risk rate + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Position mode + + + + + ADL risk percentage + + + + + Trade partition + + + + + Cross margin position + + + + + Contract type + + + + + Business type + + + + + Pair + + + + + Position limit + + + + + Symbol + + + + + Contract code + + + + + Buy limit + + + + + Sell limit + + + + + Margin mode + + + + + Leverage rate + + + + + Buy limit value + + + + + Sell limit value + + + + + Mark price + + + + + Position mode + + + + + Margin account + + + + + Position mode + + + + + Position open and tp/sl info + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + Margin account + + + + + Quantity + + + + + Price + + + + + Order price type + + + + + Side + + + + + Offset + + + + + Leverage rate + + + + + Order id + + + + + Order id string + + + + + Client order id + + + + + Creation time + + + + + Filled quantity + + + + + Value filled + + + + + Fee + + + + + Average trade price + + + + + Margin frozen + + + + + Profit + + + + + Status + + + + + Order type + + + + + Order source + + + + + Fee asset + + + + + Cancelation time + + + + + Tpsl order info + + + + + + + + + + Quantity + + + + + Side + + + + + Tpsl order type + + + + + Order id + + + + + Order id string + + + + + Trigger type + + + + + Trigger price + + + + + Order price + + + + + Creation time + + + + + Order price type + + + + + Relation tpsl order id + + + + + Status + + + + + Cancelation time + + + + + Fail code + + + + + Fail reason + + + + + Triggered price + + + + + Relation order id + + + + + Price limitation + + + + + The asset + + + + + Contract code + + + + + High limit + + + + + Low limit + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Settlement page + + + + + Total pages + + + + + Current page + + + + + Total size + + + + + Records + + + + + Settlement info + + + + + Asset + + + + + Contract code + + + + + Settlement time + + + + + Clawback ratio + + + + + Settlement price + + + + + Settlement type + + + + + Business type + + + + + Symbol + + + + + Sub account asset info page + + + + + Total page + + + + + Current page + + + + + Total items + + + + + Sub accounts + + + + + Sub account asset info + + + + + Sub user id + + + + + Assets + + + + + Sub account asset + + + + + Symbol + + + + + Margin balance + + + + + Liquidation price + + + + + Risk rate + + + + + Contract code + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + Sub account asset info page + + + + + Total page + + + + + Current page + + + + + Total items + + + + + Sub accounts + + + + + Sub account asset info + + + + + Sub user id + + + + + Assets + + + + + Sub account asset + + + + + Margin balance + + + + + Risk rate + + + + + Margin asset + + + + + Margin mode + + + + + Margin account + + + + + sub account results + + + + + Successfully updated ids + + + + + Errors + + + + + Sub account error info + + + + + Sub uid + + + + + Error code + + + + + Error message + + + + + Trade permissions result + + + + + Errors + + + + + Successes + + + + + Error + + + + + Sub user id + + + + + Error code + + + + + Error msg + + + + + Status + + + + + Query id + + + + + Sub uid + + + + + Sub auth + + + + + Adjust factor info + + + + + Asset + + + + + Contract code + + + + + Margin mode + + + + + list + + + + + Cross margin adjust factor info + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Factor info + + + + + Lever rate + + + + + Ladders + + + + + Factor info + + + + + Ladder + + + + + Min size + + + + + Max size + + + + + Adjust factor + + + + + Best offer + + + + + Business type + + + + + Contract code + + + + + Best ask + + + + + Best bid + + + + + Order id + + + + + Timestamp + + + + + Swap index + + + + + Contract code + + + + + Index price + + + + + Timestamp + + + + + Swap risk info + + + + + Contract code + + + + + Insurance fund + + + + + Estimated clawback + + + + + Business type + + + + + Symbol + + + + + Market data + + + + + Open time + + + + + Timestamp + + + + + Turnover, quantity * contract value * price + + + + + Best ask + + + + + Best bid + + + + + Ticker info + + + + + Contract code + + + + + Business type + + + + + Number of buys and sells in last 24h + + + + + Tiered margin info + + + + + Margin account + + + + + Asset + + + + + Contract code + + + + + Margin mode + + + + + List + + + + + Tiered cross margin info + + + + + Business type + + + + + Symbol + + + + + Contract type + + + + + Margin rate + + + + + Lever rate + + + + + Ladders + + + + + Ladder info + + + + + Min marging balance + + + + + Max margin balance + + + + + Min margin available + + + + + Max margin available + + + + + Take profit / stop loss order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Tp/Sl order + + + + + Cancel time + + + + + Update time + + + + + Error code + + + + + Error reason + + + + + Triggered price + + + + + Relation order id + + + + + Take profit / stop loss order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Tp/Sl order + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + Margin account + + + + + Quantity + + + + + Order type + + + + + Side + + + + + Order id + + + + + Order id string + + + + + Order source + + + + + Trigger type + + + + + Trigger price + + + + + Order price + + + + + Creation time + + + + + Order price type + + + + + Status + + + + + Tpsl order type + + + + + Source order id + + + + + Relation tpsl order id + + + + + Tp/sl set result + + + + + Take profit order + + + + + Stop loss order + + + + + Order info + + + + + Order id + + + + + Order id string + + + + + Trading fee info + + + + + Asset + + + + + Contract code + + + + + Open position maker fee + + + + + Open position taker fee + + + + + Close position maker fee + + + + + Close position taker fee + + + + + Fee asset + + + + + Delivery fee + + + + + Business type + + + + + Contract type + + + + + Symbol + + + + + Trading status + + + + + Is disable + + + + + Order price types + + + + + Disable reason + + + + + Disable interval + + + + + Recovery time + + + + + Cancel order ratio info + + + + + Total disables info + + + + + Cancel order ratio + + + + + Orders threshold + + + + + Orders + + + + + Invalid cancel orders + + + + + Cancel ratio threshold + + + + + Cancel ratio + + + + + Is trigger + + + + + Is active + + + + + Total disables + + + + + Disables threshold + + + + + Disables + + + + + Is trigger + + + + + Is active + + + + + Trailing order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trailing order info + + + + + Triggered price + + + + + Update time + + + + + Cancel time + + + + + Error code + + + + + Error reason + + + + + Relation order id + + + + + Lowest/highest market price (use the lowest price when buy. use the highest when sell) + + + + + Real volume + + + + + Formula price(the lowest (highest) market price* (1 ± callback rate)) + + + + + Trailing order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trailing order info + + + + + Symbol + + + + + Contract code + + + + + Quantity + + + + + Order type + + + + + Side + + + + + Offset + + + + + Leverage rate + + + + + Order id + + + + + Order id str + + + + + Order source + + + + + Creation time + + + + + Order price type + + + + + Status + + + + + Callback rate + + + + + Active price + + + + + Is active + + + + + Margin mode + + + + + Margin account + + + + + Reduce only + + + + + Transfer limit + + + + + Symbol + + + + + Contract code + + + + + Margin mode + + + + + Margin account + + + + + Transfer in max per transfer + + + + + Transfer in min per transfer + + + + + Transfer out max per transfer + + + + + Transfer out min per transfer + + + + + Transfer in max daily + + + + + Transfer out max daily + + + + + Net transfer in max daily + + + + + Net transfer out max daily + + + + + Trigger order page + + + + + Orders + + + + + Total page + + + + + Current page + + + + + Total results + + + + + Trigger order + + + + + Symbol + + + + + Contract code + + + + + Trigger type + + + + + Quantity + + + + + Order type + + + + + Side + + + + + Offset + + + + + Leverage rate + + + + + Order id + + + + + Order id str + + + + + Order source + + + + + Trigger price + + + + + Order price + + + + + Create time + + + + + Order price type + + + + + Status + + + + + Margin mode + + + + + Margin account + + + + + Reduce only + + + + + Trigger order operation result + + + + + Errors + + + + + Successful operations, comma seperated + + + + + Error info + + + + + Order id + + + + + Err code + + + + + Err msg + + + + + Options for the HTX SymbolOrderBook + + + + + Default options for the HTX SymbolOrderBook + + + + + The way the entries are merged. 0 is no merge, 2 means to combine the entries on 2 decimal places + + + + + The amount of entries to maintain. Either 5, 20 or 150. Level 5 and 20 are currently only supported for the following symbols: btcusdt, ethusdt, xrpusdt, eosusdt, ltcusdt, etcusdt, adausdt, dashusdt, bsvusdt. + + + + + After how much time we should consider the connection dropped if no data is received for this time after the initial subscriptions + + + + + Options for the HTXRestClient + + + + + Default options for the HTXRestClient + + + + + Whether public requests should be signed if ApiCredentials are provided. Needed for accurate rate limiting. + + + + + Broker id + + + + + Spot API options + + + + + USDT margin swap API options + + + + + Options for the HTXSocketClient + + + + + Default options for the HTXSocketClient + + + + + Spot API options + + + + + Usdt Margin Swap API options + + + + + Message + + + + + Operation + + + + + Request id + + + + + Topic + + + + + + + + + + + + + + ctor + + Service provider for resolving logging and clients + + + + + + + + + + HTX order book implementation + + + + + Create a new order book instance + + The symbol the order book is for + Option configuration delegate + + + + Create a new order book instance + + The symbol the order book is for + Option configuration delegate + Logger + Socket client instance + + + + + + + + + + + + + HTX order book implementation + + + + + Create a new order book instance + + The symbol the order book is for + Option configuration delegate + + + + Create a new order book instance + + The symbol the order book is for + Option configuration delegate + Logger + Socket client instance + + + + + + + + + + + + + Extensions for the ICryptoRestClient and ICryptoSocketClient interfaces + + + + + Get the HTX REST Api client + + + + + + + Get the HTX Websocket Api client + + + + + + + Extensions for DI + + + + + Add the IRestHTXClient and IHTXSocketClient to the sevice collection so they can be injected + + The service collection + Set default options for the rest client + Set default options for the socket client + The lifetime of the IHTXSocketClient for the service collection. Defaults to Singleton. + + + + diff --git a/Huobi.Net/HuobiEnvironment.cs b/HTX.Net/HTXEnvironment.cs similarity index 69% rename from Huobi.Net/HuobiEnvironment.cs rename to HTX.Net/HTXEnvironment.cs index 3448a7ae..405bcc03 100644 --- a/Huobi.Net/HuobiEnvironment.cs +++ b/HTX.Net/HTXEnvironment.cs @@ -1,12 +1,11 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Objects; +using HTX.Net.Objects; -namespace Huobi.Net +namespace HTX.Net { /// - /// Huobi environments + /// HTX environments /// - public class HuobiEnvironment : TradeEnvironment + public class HTXEnvironment : TradeEnvironment { /// /// Spot Rest client address @@ -28,7 +27,7 @@ public class HuobiEnvironment : TradeEnvironment /// public string UsdtMarginSwapSocketBaseAddress { get; } - internal HuobiEnvironment(string name, + internal HTXEnvironment(string name, string restBaseAddress, string socketBaseAddress, string marginSwapRestBaseAddress, @@ -43,12 +42,12 @@ internal HuobiEnvironment(string name, /// /// Live environment /// - public static HuobiEnvironment Live { get; } - = new HuobiEnvironment(TradeEnvironmentNames.Live, - HuobiApiAddresses.Default.RestClientAddress, - HuobiApiAddresses.Default.SocketClientAddress, - HuobiApiAddresses.Default.UsdtMarginSwapRestClientAddress, - HuobiApiAddresses.Default.UsdtMarginSwapSocketClientAddress); + public static HTXEnvironment Live { get; } + = new HTXEnvironment(TradeEnvironmentNames.Live, + HTXApiAddresses.Default.RestClientAddress, + HTXApiAddresses.Default.SocketClientAddress, + HTXApiAddresses.Default.UsdtMarginSwapRestClientAddress, + HTXApiAddresses.Default.UsdtMarginSwapSocketClientAddress); /// /// Create a custom environment @@ -59,12 +58,12 @@ internal HuobiEnvironment(string name, /// /// /// - public static HuobiEnvironment CreateCustom( + public static HTXEnvironment CreateCustom( string name, string restAddress, string socketAddress, string usdtMarginSwapRestAddress, string usdtMarginSwapSocketAddress) - => new HuobiEnvironment(name, restAddress, socketAddress, usdtMarginSwapRestAddress, usdtMarginSwapSocketAddress); + => new HTXEnvironment(name, restAddress, socketAddress, usdtMarginSwapRestAddress, usdtMarginSwapSocketAddress); } } diff --git a/HTX.Net/HTXExchange.cs b/HTX.Net/HTXExchange.cs new file mode 100644 index 00000000..66eb3b5d --- /dev/null +++ b/HTX.Net/HTXExchange.cs @@ -0,0 +1,92 @@ +using CryptoExchange.Net.RateLimiting; +using CryptoExchange.Net.RateLimiting.Guards; +using CryptoExchange.Net.RateLimiting.Interfaces; + +namespace HTX.Net +{ + /// + /// HTX exchange information and configuration + /// + public static class HTXExchange + { + /// + /// Exchange name + /// + public static string ExchangeName => "HTX"; + + /// + /// Url to the main website + /// + public static string Url { get; } = "https://www.htx.com/"; + + /// + /// Urls to the API documentation + /// + public static string[] ApiDocsUrl { get; } = new[] { + "https://www.htx.com/en-us/opend/newApiPages/" + }; + + /// + /// Rate limiter configuration for the HTX API + /// + public static HTXRateLimiters RateLimiter { get; } = new HTXRateLimiters(); + } + + /// + /// Rate limiter configuration for the HTX API + /// + public class HTXRateLimiters + { + /// + /// Event for when a rate limit is triggered + /// + public event Action RateLimitTriggered; + +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + internal HTXRateLimiters() +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + { + Initialize(); + } + + private void Initialize() + { + EndpointLimit = new RateLimitGate("Endpoint Limit"); + SpotMarketLimit = new RateLimitGate("Spot Market Limit") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { }, 10, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding)); + SpotConnection = new RateLimitGate("Spot Connection Messages") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { }, 50, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)) // 50 requests per second per connection + .AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new IGuardFilter[] { }, 100, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)); // 100 requests per second per IP + + UsdtTrade = new RateLimitGate("USDT-M Trade") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerApiKeyPerEndpoint, new IGuardFilter[] { }, 72, TimeSpan.FromSeconds(3), RateLimitWindowType.Fixed)); + UsdtRead = new RateLimitGate("USDT-M Read") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerApiKeyPerEndpoint, new IGuardFilter[] { }, 72, TimeSpan.FromSeconds(3), RateLimitWindowType.Fixed)); + PublicMarket = new RateLimitGate("Public Market") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new IGuardFilter[] { }, 800, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)); + UsdtPublicReference = new RateLimitGate("USDT-M Public Reference") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new IGuardFilter[] { }, 240, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)); + UsdtConnection = new RateLimitGate("USDT-M Connection Messages") + .AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new IGuardFilter[] { }, 40, TimeSpan.FromSeconds(1), RateLimitWindowType.Fixed)); // 40 requests per second per connection + + EndpointLimit.RateLimitTriggered += RateLimitTriggered; + SpotMarketLimit.RateLimitTriggered += RateLimitTriggered; + SpotConnection.RateLimitTriggered += RateLimitTriggered; + UsdtTrade.RateLimitTriggered += RateLimitTriggered; + UsdtRead.RateLimitTriggered += RateLimitTriggered; + PublicMarket.RateLimitTriggered += RateLimitTriggered; + UsdtPublicReference.RateLimitTriggered += RateLimitTriggered; + UsdtConnection.RateLimitTriggered += RateLimitTriggered; + } + + internal IRateLimitGate EndpointLimit { get; private set; } + internal IRateLimitGate SpotMarketLimit { get; private set; } + internal IRateLimitGate SpotConnection { get; private set; } + internal IRateLimitGate UsdtTrade { get; private set; } + internal IRateLimitGate UsdtRead { get; private set; } + internal IRateLimitGate PublicMarket { get; private set; } + internal IRateLimitGate UsdtPublicReference { get; private set; } + internal IRateLimitGate UsdtConnection { get; private set; } + + } +} diff --git a/Huobi.Net/HuobiAuthenticationProvider.cs b/HTX.Net/HuobiAuthenticationProvider.cs similarity index 77% rename from Huobi.Net/HuobiAuthenticationProvider.cs rename to HTX.Net/HuobiAuthenticationProvider.cs index d18bb263..6a9122d6 100644 --- a/Huobi.Net/HuobiAuthenticationProvider.cs +++ b/HTX.Net/HuobiAuthenticationProvider.cs @@ -1,24 +1,17 @@ -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Clients; -using CryptoExchange.Net.Objects; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Sockets; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; +using CryptoExchange.Net.Clients; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Sockets; using System.Net; -using System.Net.Http; using System.Text; using System.Text.RegularExpressions; -namespace Huobi.Net +namespace HTX.Net { - internal class HuobiAuthenticationProvider : AuthenticationProvider + internal class HTXAuthenticationProvider : AuthenticationProvider { private readonly bool _signPublicRequests; - public HuobiAuthenticationProvider(ApiCredentials credentials, bool signPublicRequests) : base(credentials) + public HTXAuthenticationProvider(ApiCredentials credentials, bool signPublicRequests) : base(credentials) { if (credentials.CredentialType != ApiCredentialsType.Hmac) throw new Exception("Only Hmac authentication is supported"); @@ -42,7 +35,7 @@ public override void AuthenticateRequest( return; // These are always in the uri - uriParameters ??= new Dictionary(); + uriParameters ??= new ParameterCollection(); uriParameters.Add("AccessKeyId", _credentials.Key); uriParameters.Add("SignatureMethod", "HmacSHA256"); uriParameters.Add("SignatureVersion", 2); @@ -60,9 +53,9 @@ public override void AuthenticateRequest( uriParameters.Add("Signature", SignHMACSHA256(signData, SignOutputType.Base64)); } - public HuobiAuthParams GetWebsocketAuthentication(Uri uri) + public HTXAuthParams GetWebsocketAuthentication(Uri uri) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.Add("accessKey", _credentials.Key); parameters.Add("signatureMethod", "HmacSHA256"); parameters.Add("signatureVersion", 2.1); @@ -74,12 +67,12 @@ public HuobiAuthParams GetWebsocketAuthentication(Uri uri) var signData = $"GET\n{uri.Host}\n{uri.AbsolutePath}\n{paramString}"; var signature = SignHMACSHA256(signData, SignOutputType.Base64); - return new HuobiAuthParams { AccessKey = _credentials.Key, Timestamp = (string)parameters["timestamp"], Signature = signature }; + return new HTXAuthParams { AccessKey = _credentials.Key, Timestamp = (string)parameters["timestamp"], Signature = signature }; } - public HuobiAuthenticationRequest2 GetWebsocketAuthentication2(Uri uri) + public HTXAuthenticationRequest2 GetWebsocketAuthentication2(Uri uri) { - var parameters = new Dictionary(); + var parameters = new ParameterCollection(); parameters.Add("AccessKeyId", _credentials.Key); parameters.Add("SignatureMethod", "HmacSHA256"); parameters.Add("SignatureVersion", 2); @@ -91,7 +84,7 @@ public HuobiAuthenticationRequest2 GetWebsocketAuthentication2(Uri uri) var signData = $"GET\n{uri.Host}\n{uri.AbsolutePath}\n{paramString}"; var signature = SignHMACSHA256(signData, SignOutputType.Base64); - return new HuobiAuthenticationRequest2(_credentials.Key, (string)parameters["Timestamp"], signature); + return new HTXAuthenticationRequest2(_credentials.Key, (string)parameters["Timestamp"], signature); } } } diff --git a/Huobi.Net/Icon/icon.png b/HTX.Net/Icon/icon.png similarity index 100% rename from Huobi.Net/Icon/icon.png rename to HTX.Net/Icon/icon.png diff --git a/Huobi.Net/Interfaces/Clients/IHuobiClient.cs b/HTX.Net/Interfaces/Clients/IHTXRestClient.cs similarity index 51% rename from Huobi.Net/Interfaces/Clients/IHuobiClient.cs rename to HTX.Net/Interfaces/Clients/IHTXRestClient.cs index aa328060..cf83f85f 100644 --- a/Huobi.Net/Interfaces/Clients/IHuobiClient.cs +++ b/HTX.Net/Interfaces/Clients/IHTXRestClient.cs @@ -1,23 +1,21 @@ -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; -namespace Huobi.Net.Interfaces.Clients +namespace HTX.Net.Interfaces.Clients { /// - /// Client for accessing the Huobi API. + /// Client for accessing the HTX API. /// - public interface IHuobiRestClient : IRestClient + public interface IHTXRestClient : IRestClient { /// /// Spot endpoints /// - IHuobiRestClientSpotApi SpotApi { get; } + IHTXRestClientSpotApi SpotApi { get; } /// - /// Usdt margin swap endpoints + /// Usdt futures endpoints /// - IHuobiRestClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } + IHTXRestClientUsdtFuturesApi UsdtFuturesApi { 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/HTX.Net/Interfaces/Clients/IHTXSocketClient.cs b/HTX.Net/Interfaces/Clients/IHTXSocketClient.cs new file mode 100644 index 00000000..dfc42f2e --- /dev/null +++ b/HTX.Net/Interfaces/Clients/IHTXSocketClient.cs @@ -0,0 +1,26 @@ +using HTX.Net.Interfaces.Clients.SpotApi; +using HTX.Net.Interfaces.Clients.UsdtFuturesApi; + +namespace HTX.Net.Interfaces.Clients +{ + /// + /// Client for accessing the HTX websocket API. + /// + public interface IHTXSocketClient : ISocketClient + { + /// + /// Spot streams + /// + public IHTXSocketClientSpotApi SpotApi { get; } + /// + /// Usdt futures streams + /// + public IHTXSocketClientUsdtFuturesApi UsdtFuturesApi { get; } + + /// + /// Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. + /// + /// The credentials to set + void SetApiCredentials(ApiCredentials credentials); + } +} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApi.cs similarity index 52% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs rename to HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApi.cs index f917be93..0b25ddd3 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApi.cs +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApi.cs @@ -1,28 +1,34 @@ -using CryptoExchange.Net.Interfaces; -using CryptoExchange.Net.Interfaces.CommonClients; -using System; +using CryptoExchange.Net.Interfaces.CommonClients; -namespace Huobi.Net.Interfaces.Clients.SpotApi +namespace HTX.Net.Interfaces.Clients.SpotApi { /// /// Spot API endpoints /// - public interface IHuobiRestClientSpotApi : IRestApiClient, IDisposable + public interface IHTXRestClientSpotApi : IRestApiClient, IDisposable { /// /// Endpoints related to account settings, info or actions /// - IHuobiRestClientSpotApiAccount Account { get; } + IHTXRestClientSpotApiAccount Account { get; } /// /// Endpoints related to retrieving market and system data /// - IHuobiRestClientSpotApiExchangeData ExchangeData { get; } + IHTXRestClientSpotApiExchangeData ExchangeData { get; } + /// + /// Endpoints related to margin + /// + IHTXRestClientSpotApiMargin Margin { get; } + /// + /// Endpoints related to sub-accounts + /// + IHTXRestClientSpotApiSubAccount SubAccount { get; } /// /// Endpoints related to orders and trades /// - IHuobiRestClientSpotApiTrading Trading { get; } + IHTXRestClientSpotApiTrading 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/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiAccount.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiAccount.cs new file mode 100644 index 00000000..3299e713 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiAccount.cs @@ -0,0 +1,252 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; + +namespace HTX.Net.Interfaces.Clients.SpotApi +{ + /// + /// HTX account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings + /// + public interface IHTXRestClientSpotApiAccount + { + /// + /// Get the user id associated with the apikey/secret + /// + /// + /// Cancellation token + /// + Task> GetUserIdAsync(CancellationToken ct = default); + + /// + /// Get a list of accounts associated with the apikey/secret + /// + /// + /// Cancellation token + /// + Task>> GetAccountsAsync(CancellationToken ct = default); + + /// + /// Get a list of balances for a specific account + /// + /// + /// The id of the account to get the balances for, account ids can be retrieved with GetAccountsAsync. + /// Cancellation token + /// + Task>> GetBalancesAsync(long accountId, CancellationToken ct = default); + + /// + /// Get platform asset valuation + /// + /// + /// Filter by account type + /// Valuation asset, only BTC supported at the moment + /// + /// + Task> GetPlatformValuationAsync(AccountType? accountType = null, string? valuationAsset = null, CancellationToken ct = default); + + /// + /// Get the valuation of all assets + /// + /// + /// Type of account to valuate + /// The asset to get the value in + /// The id of the sub user + /// Cancellation token + /// + Task> GetAssetValuationAsync(AccountType accountType, string? valuationAsset = null, long? subUserId = null, CancellationToken ct = default); + + /// + /// Get a list of balance changes of specified user's account + /// + /// + /// The id of the account to get the account history for, account ids can be retrieved with GetAccountsAsync. + /// Asset name, for example `ETH` + /// Blance change types + /// Far point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days + /// Near point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days + /// Sorting order (Ascending by default) + /// Maximum number of items in each response (from 1 to 500, default is 100) + /// Cancellation token + /// + Task>> GetAccountHistoryAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, CancellationToken ct = default); + + /// + /// Get the balance changes of specified user's account. + /// + /// + /// The id of the account to get the ledger for, account ids can be retrieved with GetAccountsAsync. + /// Asset name, for example `ETH` + /// Blanace change types + /// Far point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days + /// Near point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days + /// Sorting order (Ascending by default) + /// Maximum number of items in each response (from 1 to 500, default is 100) + /// Only get orders with ID before or after this. Used together with the direction parameter + /// Cancellation token + /// + Task>> GetAccountLedgerAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Transfer asset between accounts + /// + /// + /// Source account type + /// Target account type + /// The asset, for example `ETH` + /// Quantity + /// Margin account. Use `USDT` for cross margin + /// Cancellation token + Task> TransferAsync(TransferAccount fromAccount, TransferAccount toAccount, string asset, decimal quantity, string marginAccount, CancellationToken ct = default); + + /// + /// Get the deposit addresses for an asset + /// + /// + /// Asset, for example `ETH` + /// Cancellation token + /// + Task>> GetDepositAddressesAsync(string asset, CancellationToken ct = default); + + /// + /// Withdraw an asset from the account to an address + /// + /// + /// The desination address of this withdraw + /// Asset, for example `ETH` + /// The quantity of asset to withdraw + /// The fee to pay with this withdraw + /// Set as "usdt" to withdraw USDT to OMNI, set as "trc20usdt" to withdraw USDT to TRX + /// A tag specified for this address + /// Client order id + /// Cancellation token + /// + Task> WithdrawAsync(string address, string asset, decimal quantity, decimal fee, string? network = null, string? addressTag = null, string? clientOrderId = null, CancellationToken ct = default); + + /// + /// Get withdrawal/deposit history + /// + /// + /// Transfer type to search + /// The asset to withdraw, for example `ETH` + /// The transfer id to begin search + /// The number of items to return + /// the order of response + /// Cancellation token + /// + Task>> GetWithdrawDepositHistoryAsync(WithdrawDepositType type, string? asset = null, int? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default); + + /// + /// Get current trading fees for symbols + /// + /// + /// Filter on symbol, for example `ETHUSDT` + /// Cancellation token + /// + Task>> GetTradingFeesAsync(IEnumerable symbols, + CancellationToken ct = default); + + /// + /// Get point balance + /// + /// + /// Sub user id to request for + /// Cancellation token + Task> GetPointBalanceAsync(string? subUserId = null, CancellationToken ct = default); + + /// + /// Transfer points to another user + /// + /// + /// From user id + /// To user id + /// Group id + /// Quantity + /// Cancellation token + Task> TransferPointsAsync(string fromUserId, string toUserId, string groupId, decimal quantity, CancellationToken ct = default); + + /// + /// Get user deduction info + /// + /// + /// Cancellation token + Task> GetUserDeductionInfoAsync(CancellationToken ct = default); + + /// + /// Get deduction assets + /// + /// + /// Cancellation token + Task> GetDeductAssetsAsync(CancellationToken ct = default); + + /// + /// Set deduction switch + /// + /// + /// Deduction switch type + /// Asset + /// Cancellation token + Task SetDeductionSwitchAsync(DeductionSwitchType switchType, string? deductionAsset = null, CancellationToken ct = default); + + /// + /// Get withdrawal quota + /// + /// + /// Filter by asset, for example `ETH` + /// Cancellation token + Task> GetWithdrawalQuotasAsync(string? asset = null, CancellationToken ct = default); + + /// + /// Get withdrawal addresses + /// + /// + /// The asset, for example `ETH` + /// Filter by network + /// Filter by note + /// Max number of results + /// Return results after this id + /// Cancellation token + Task>> GetWithdrawalAddressesAsync(string asset, string? network = null, string? note = null, int? limit = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get a withdrawal by client order id + /// + /// + /// The client order id + /// Cancellation token + Task> GetWithdrawalByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default); + + /// + /// Cancel a pending withdrawal + /// + /// + /// The withdrawal id + /// Cancellation token + Task> CancelWithdrawalAsync(long id, CancellationToken ct = default); + + /// + /// Get API key info + /// + /// + /// User id + /// The API key + /// Cancellation token + Task>> GetApiKeyInfoAsync(long userId, string? apiKey = null, CancellationToken ct = default); + + /// + /// Transfer assets between accounts + /// + /// + /// From user id + /// From account type + /// From account id + /// To user id + /// To account type + /// To account id + /// Asset to transfer, for example `ETH` + /// Amount to transfer + /// Cancellation token + /// + Task> InternalTransferAsync(long fromUserId, AccountType fromAccountType, long fromAccountId, + long toUserId, AccountType toAccountType, long toAccountId, string asset, decimal quantity, CancellationToken ct = default); + + } +} diff --git a/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiExchangeData.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiExchangeData.cs new file mode 100644 index 00000000..5bd97f07 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiExchangeData.cs @@ -0,0 +1,131 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; + +namespace HTX.Net.Interfaces.Clients.SpotApi +{ + /// + /// HTX exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. + /// + public interface IHTXRestClientSpotApiExchangeData + { + /// + /// Get current system status and announcements + /// + /// + /// Cancellation token + Task> GetSystemStatusAsync(CancellationToken ct = default); + + /// + /// Get supported symbols + /// + /// + /// Cancellation token + Task>> GetSymbolsAsync(CancellationToken ct = default); + + /// + /// Get supported assets + /// + /// + /// Cancellation token + Task>> GetAssetsAsync(CancellationToken ct = default); + + /// + /// Get symbol trading configuration + /// + /// + /// Filter by symbols, for example `ETHUSDT` + /// Cancellation token + Task>> GetSymbolConfigAsync(IEnumerable? symbols = null, CancellationToken ct = default); + + /// + /// Get assets and network information + /// + /// + /// Filter by asset, for example `ETH` + /// Cancellation token + Task>> GetAssetsAndNetworksAsync(string? asset = null, CancellationToken ct = default); + + /// + /// Gets the latest ticker for all symbols + /// + /// + /// Cancellation token + /// + Task> GetTickersAsync(CancellationToken ct = default); + + /// + /// Gets the ticker, including the best bid / best ask for a symbol + /// + /// + /// The symbol to get the ticker for, for example `ETHUSDT` + /// Cancellation token + /// + Task> GetTickerAsync(string symbol, CancellationToken ct = default); + + /// + /// Get kline/candlestick data for a symbol + /// + /// + /// The symbol to get the data for, for example `ETHUSDT` + /// The period of a single candlestick + /// The amount of candlesticks + /// Cancellation token + /// + Task>> GetKlinesAsync(string symbol, KlineInterval period, int? limit = null, CancellationToken ct = default); + + /// + /// Get the order book for a symbol + /// + /// + /// The symbol to request for, for example `ETHUSDT` + /// The way the results will be merged together + /// The depth of the book + /// Cancellation token + /// + Task> GetOrderBookAsync(string symbol, int mergeStep, int? limit = null, CancellationToken ct = default); + + /// + /// Get the last trade for a symbol + /// + /// + /// The symbol to request for, for example `ETHUSDT` + /// Cancellation token + /// + Task> GetLastTradeAsync(string symbol, CancellationToken ct = default); + + /// + /// Get the last x trades for a symbol + /// + /// + /// The symbol to get trades for, for example `ETHUSDT` + /// The max number of results + /// Cancellation token + /// + Task>> GetTradeHistoryAsync(string symbol, int? limit = null, CancellationToken ct = default); + + /// + /// Get 24h stats for a symbol + /// + /// + /// The symbol to get the data for, for example `ETHUSDT` + /// Cancellation token + /// + Task> GetSymbolDetails24HAsync(string symbol, CancellationToken ct = default); + + /// + /// Get the current market status + /// + /// + /// Cancellation token + /// + Task> GetSymbolStatusAsync(CancellationToken ct = default); + + /// + /// Get the server time + /// + /// + /// Cancellation token + /// + Task> GetServerTimeAsync(CancellationToken ct = default); + } +} diff --git a/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiMargin.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiMargin.cs new file mode 100644 index 00000000..5ef7e49e --- /dev/null +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiMargin.cs @@ -0,0 +1,217 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; + +namespace HTX.Net.Interfaces.Clients.SpotApi +{ + /// + /// HTX margin endpoints. + /// + public interface IHTXRestClientSpotApiMargin + { + /// + /// Repay a margin loan + /// + /// + /// Account id + /// Asset to repay, for example `ETH` + /// Quantity to repay + /// Loan transaction ID + /// Cancellation token + /// + Task>> RepayLoanAsync(string accountId, string asset, decimal quantity, string? transactionId = null, CancellationToken ct = default); + + /// + /// Transfer asset from spot account to isolated margin account + /// + /// + /// Trading symbol, for example `ETHUSDT` + /// Asset to transfer, for example `ETH` + /// Quantity to transfer + /// Cancellation token + /// Transfer id + Task> TransferSpotToIsolatedMarginAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Transfer asset from isolated margin to spot account + /// + /// + /// Trading symbol, for example `ETHUSDT` + /// Asset to transfer, for example `ETH` + /// Quantity to transfer + /// Cancellation token + /// Transfer id + Task> TransferIsolatedMarginToSpotAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Get isolated loan interest rate and quotas + /// + /// + /// Filter on symbol, for example `ETHUSDT` + /// Cancellation token + /// + Task>> GetIsolatedLoanInterestRateAndQuotaAsync(IEnumerable? symbols = null, CancellationToken ct = default); + + /// + /// Request a loan on isolated margin + /// + /// + /// The symbol, for example `ETHUSDT` + /// The asset, for example `ETH` + /// The quantity + /// Cancellation token + /// Order id + Task> RequestIsolatedMarginLoanAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Repay an isolated margin loan + /// + /// + /// Id to repay + /// Quantity + /// Cancellation token + /// Order id + Task> RepayIsolatedMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default); + + /// + /// Get isolated margin order history + /// + /// + /// The symbol to get history for, for example `ETHUSDT` + /// Filter by states + /// Filter by start date + /// Filter by end date + /// Start order id for use in combination with direction + /// Direction of results in combination with from parameter + /// Max amount of results + /// Sub user id + /// Cancellation token + /// + Task>> GetIsolatedMarginClosedOrdersAsync( + string symbol, + IEnumerable? states = null, + DateTime? startDate = null, + DateTime? endDate = null, + string? from = null, + FilterDirection? direction = null, + int? limit = null, + int? subUserId = null, + CancellationToken ct = default); + + /// + /// Get isolated margin account balance + /// + /// + /// The symbol, for example `ETHUSDT` + /// Sub user id + /// Cancellation token + /// + Task>> GetIsolatedMarginBalanceAsync(string symbol, int? subUserId = null, CancellationToken ct = default); + + /// + /// Transfer from spot account to cross margin account + /// + /// + /// The asset to transfer, for example `ETH` + /// Quantity to transfer + /// Cancellation token + /// + Task> TransferSpotToCrossMarginAsync(string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Transfer from cross margin account to spot account + /// + /// + /// The asset to transfer, for example `ETH` + /// Quantity to transfer + /// Cancellation token + /// + Task> TransferCrossMarginToSpotAsync(string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Get cross margin interest rates and quotas + /// + /// + /// Cancellation token + /// + Task>> GetCrossLoanInterestRateAndQuotaAsync(CancellationToken ct = default); + + /// + /// Request a loan on cross margin + /// + /// + /// The asset, for example `ETH` + /// The quantity + /// Cancellation token + /// Order id + Task> RequestCrossMarginLoanAsync(string asset, decimal quantity, CancellationToken ct = default); + + /// + /// Repay a isolated margin loan + /// + /// + /// Id to repay + /// Quantity + /// Cancellation token + /// + Task RepayCrossMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default); + + /// + /// Get cross margin order history + /// + /// + /// Filter by asset, for example `ETH` + /// Filter by status + /// Filter by start date + /// Filter by end date + /// Start order id for use in combination with direction + /// Direction of results in combination with from parameter + /// Max amount of results + /// Sub user id + /// Cancellation token + /// + Task>> GetCrossMarginClosedOrdersAsync( + string? asset = null, + MarginOrderStatus? status = null, + DateTime? startDate = null, + DateTime? endDate = null, + string? from = null, + FilterDirection? direction = null, + int? limit = null, + int? subUserId = null, + CancellationToken ct = default); + + /// + /// Get cross margin account balance + /// + /// + /// Sub user id + /// Cancellation token + /// + Task> GetCrossMarginBalanceAsync(int? subUserId = null, CancellationToken ct = default); + + /// + /// Get cross margin limits + /// + /// + /// The asset, for example `ETH` + /// Cancellation token + Task>> GetCrossMarginLimitAsync(string? asset = null, CancellationToken ct = default); + + /// + /// Get repayment history + /// + /// + /// Filter by repay id + /// Filter by account id + /// Filter by asset, for example `ETH` + /// Only show records after this + /// Only show records before this + /// Sort direction + /// Result limit + /// Search id + /// Cancellation token + /// + Task>> GetRepaymentHistoryAsync(long? repayId = null, long? accountId = null, string? asset = null, DateTime? startTime = null, DateTime? endTime = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); + + } +} diff --git a/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiSubAccount.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiSubAccount.cs new file mode 100644 index 00000000..5beb97f5 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiSubAccount.cs @@ -0,0 +1,167 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; + +namespace HTX.Net.Interfaces.Clients.SpotApi +{ + /// + /// HTX sub-account endpoints. + /// + public interface IHTXRestClientSpotApiSubAccount + { + /// + /// Set fee deduct mode for sub accounts + /// + /// + /// Sub user ids + /// Deduct from account + /// Cancellation token + Task>> SetDeductModeAsync(IEnumerable subUserIds, DeductMode deductMode, CancellationToken ct = default); + + /// + /// Create new sub accounts + /// + /// + /// Accounts to create + /// Cancellation token + Task>> CreateSubAccountsAsync(IEnumerable accounts, CancellationToken ct = default); + + /// + /// Get a list of users associated with the apikey/secret + /// + /// + /// Cancellation token + /// + Task>> GetSubUserListAsync(CancellationToken ct = default); + + /// + /// Set (un)lock status on a sub account + /// + /// + /// Sub user id + /// Lock action + /// Cancellation token + Task> SetLockAsync(long subUserId, LockAction lockAction, CancellationToken ct = default); + + /// + /// Get sub user by id + /// + /// + /// Sub user id + /// Cancellation token + /// + Task> GetSubUserAsync(long subUserId, CancellationToken ct = default); + + /// + /// Set tradable market for sub accounts + /// + /// + /// Sub user ids + /// Account type + /// Enabled or not + /// Cancellation token + Task>> SetTradableMarketAsync(IEnumerable subUserIds, SubAccountMarketType accountType, bool enabled, CancellationToken ct = default); + + /// + /// Set asset transfer permissions for sub accounts + /// + /// + /// Sub user ids + /// Enabled + /// Cancellation token + Task>> SetAssetTransferPermissionsAsync(IEnumerable subUserIds, bool enabled, CancellationToken ct = default); + + /// + /// Gets a list of sub-user accounts associated with the sub-user id + /// + /// + /// The if of the user to get accounts for + /// Cancellation token + /// + Task> GetSubUserAccountsAsync(long subUserId, CancellationToken ct = default); + + /// + /// Create a new API key + /// + /// + /// Two factor authentication code + /// Sub user id + /// Note + /// Permissions + /// Ip addresses + /// Cancellation token + Task> CreateApiKeyAsync(string otpToken, long subUserId, string note, IEnumerable permissions, IEnumerable ipAddresses, CancellationToken ct = default); + + /// + /// Edit an API key + /// + /// + /// Sub user id + /// Api key to edit + /// Note + /// Permissions + /// Ip addresses + /// Cancellation token + Task> EditApiKeyAsync(long subUserId, string apiKey, string note, IEnumerable permissions, IEnumerable ipAddresses, CancellationToken ct = default); + + /// + /// Delete an API key + /// + /// + /// Sub user id + /// Api key to remove + /// Cancellation token + Task DeleteApiKeyAsync(long subUserId, string apiKey, CancellationToken ct = default); + + /// + /// Get deposit address for a sub account + /// + /// + /// Sub user id + /// The asset, for example `ETH` + /// Cancellation token + Task>> GetDepositAddressAsync(long subUserId, string asset, CancellationToken ct = default); + + /// + /// Get deposit history + /// + /// + /// Sub user id + /// Filter by asset, for example `ETH` + /// Filter by start time + /// Filter by end time + /// Sort + /// Max number of results + /// Return results after this id + /// Cancellation token + Task>> GetDepositHistoryAsync(long subUserId, string? asset = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get aggregate balances of all sub accounts + /// + /// + /// Cancellation token + Task>> GetAggregateBalancesAsync(CancellationToken ct = default); + + /// + /// Get a list of balances for a specific sub account + /// + /// + /// The id of the sub account to get the balances for + /// Cancellation token + /// + Task>> GetBalancesAsync(long subAccountId, CancellationToken ct = default); + + /// + /// Transfer asset between parent and sub account + /// + /// + /// The target sub account id to transfer to or from + /// The asset to transfer, for example `ETH` + /// The quantity of asset to transfer + /// The type of transfer + /// Cancellation token + /// Unique transfer id + Task> TransferWithSubAccountAsync(long subAccountId, string asset, decimal quantity, TransferType transferType, CancellationToken ct = default); + + } +} diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiTrading.cs similarity index 50% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs rename to HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiTrading.cs index 5f09e63d..b8b8dd0a 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiTrading.cs +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXRestClientSpotApiTrading.cs @@ -1,24 +1,19 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; - -namespace Huobi.Net.Interfaces.Clients.SpotApi +using HTX.Net.Enums; +using HTX.Net.Objects.Models; + +namespace HTX.Net.Interfaces.Clients.SpotApi { /// - /// Huobi trading endpoints, placing and mananging orders. + /// HTX trading endpoints, placing and mananging orders. /// - public interface IHuobiRestClientSpotApiTrading + public interface IHTXRestClientSpotApiTrading { /// /// Places an order - /// + /// /// - /// The account to place the order for - /// The symbol to place the order for + /// The account to place the order for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// The symbol to place the order for, for example `ETHUSDT` /// The side of the order /// The type of the order /// The quantity of the order @@ -32,20 +27,64 @@ public interface IHuobiRestClientSpotApiTrading Task> PlaceOrderAsync(long accountId, string symbol, OrderSide side, OrderType type, decimal quantity, decimal? price = null, string? clientOrderId = null, SourceType? source = null, decimal? stopPrice = null, Operator? stopOperator = null, CancellationToken ct = default); /// - /// Gets a list of open orders - /// + /// Place multiple orders in a single call + /// + /// + /// Orders to place + /// Cancellation token + /// + Task>> PlaceMultipleOrderAsync( + IEnumerable orders, + CancellationToken ct = default); + + /// + /// Place a new margin order + /// + /// + /// The account to place the order for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// The symbol to place the order for, for example `ETHUSDT` + /// The side of the order + /// The type of the order + /// Transaction purpose + /// The quantity of the order in base asset + /// The quantity of the order in quote asset + /// The quantity that needs to be borrowed + /// The price of the order. Should be omitted for market orders + /// Source. defaults to SpotAPI + /// Stop price + /// Operator of the stop price + /// Cancellation token + /// + Task> PlaceMarginOrderAsync( + long accountId, + string symbol, + Enums.OrderSide side, + Enums.OrderType type, + Enums.MarginPurpose purpose, + SourceType source, + decimal? quantity = null, + decimal? quoteQuantity = null, + decimal? borrowQuantity = null, + decimal? price = null, + decimal? stopPrice = null, + Operator? stopOperator = null, + CancellationToken ct = default); + + /// + /// Get a list of open orders + /// /// - /// The account id for which to get the orders for - /// The symbol for which to get the orders for + /// The account id for which to get the orders for, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// The symbol for which to get the orders for, for example `ETHUSDT` /// Only get buy or sell orders /// The max number of results /// Cancellation token /// - Task>> GetOpenOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, int? limit = null, CancellationToken ct = default); + Task>> GetOpenOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, int? limit = null, CancellationToken ct = default); /// - /// Cancels an open order - /// + /// Cancel an open order + /// /// /// The id of the order to cancel /// Cancellation token @@ -53,8 +92,8 @@ public interface IHuobiRestClientSpotApiTrading Task> CancelOrderAsync(long orderId, CancellationToken ct = default); /// - /// Cancels an open order - /// + /// Cancel an open order + /// /// /// The client id of the order to cancel /// Cancellation token @@ -63,17 +102,17 @@ public interface IHuobiRestClientSpotApiTrading /// /// Cancel multiple open orders - /// + /// /// /// The ids of the orders to cancel /// The client ids of the orders to cancel /// Cancellation token /// - Task> CancelOrdersAsync(IEnumerable? orderIds = null, IEnumerable? clientOrderIds = null, CancellationToken ct = default); + Task> CancelOrdersAsync(IEnumerable? orderIds = null, IEnumerable? clientOrderIds = null, CancellationToken ct = default); /// /// Cancel multiple open orders - /// + /// /// /// The account id used for this cancel /// The trading symbol list (maximum 10 symbols, default value all symbols) @@ -81,40 +120,40 @@ public interface IHuobiRestClientSpotApiTrading /// The number of orders to cancel [1, 100] /// Cancellation token /// - Task> CancelOrdersByCriteriaAsync(long? accountId = null, IEnumerable? symbols = null, OrderSide? side = null, int? limit = null, CancellationToken ct = default); + Task> CancelOrdersByCriteriaAsync(long? accountId = null, IEnumerable? symbols = null, OrderSide? side = null, int? limit = null, CancellationToken ct = default); /// /// Get details of an order - /// + /// /// /// The id of the order to retrieve /// Cancellation token /// - Task> GetOrderAsync(long orderId, CancellationToken ct = default); + Task> GetOrderAsync(long orderId, CancellationToken ct = default); /// /// Get details of an order by client order id - /// + /// /// /// The client id of the order to retrieve /// Cancellation token /// - Task> GetOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default); + Task> GetOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default); /// - /// Gets a list of trades made for a specific order - /// + /// Get a list of trades made for a specific order + /// /// /// The id of the order to get trades for /// Cancellation token /// - Task>> GetOrderTradesAsync(long orderId, CancellationToken ct = default); + Task>> GetOrderTradesAsync(long orderId, CancellationToken ct = default); /// - /// Gets a list of orders - /// + /// Get a list of orders + /// /// - /// The symbol to get orders for + /// The symbol to get orders for, for example `ETHUSDT` /// The states of orders to return /// The types of orders to return /// Only get orders after this date @@ -124,14 +163,13 @@ public interface IHuobiRestClientSpotApiTrading /// The max number of results /// Cancellation token /// - Task>> GetClosedOrdersAsync(string symbol, IEnumerable? states = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); + Task>> GetClosedOrdersAsync(string symbol, IEnumerable? states = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); /// - /// Gets a list of trades for a specific symbol - /// + /// Get a list of user trades + /// /// - /// Only return trades with specific states - /// The symbol to retrieve trades for + /// The symbol to retrieve trades for, for example `ETHUSDT` /// The type of orders to return /// Only get orders after this date /// Only get orders before this date @@ -140,27 +178,27 @@ public interface IHuobiRestClientSpotApiTrading /// The max number of results /// Cancellation token /// - Task>> GetUserTradesAsync(IEnumerable? states = null, string? symbol = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); + Task>> GetUserTradesAsync(string? symbol = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); /// - /// Gets a list of history orders - /// + /// Get order history + /// /// - /// The symbol to get orders for + /// The symbol to get orders for, for example `ETHUSDT` /// Only get orders after this date /// Only get orders before this date /// Direction of the results to return /// The max number of results /// Cancellation token /// - Task>> GetHistoricalOrdersAsync(string? symbol = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); + Task>> GetHistoricalOrdersAsync(string? symbol = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default); /// /// Place a new conditional order - /// + /// /// - /// The account the order should be placed from - /// The symbol the order is for + /// The account the order should be placed from, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// The symbol the order is for, for example `ETHUSDT` /// Side of the order /// Type of the order /// Stop price of the order @@ -172,7 +210,7 @@ public interface IHuobiRestClientSpotApiTrading /// Client order id /// Cancellation token /// - Task> PlaceConditionalOrderAsync( + Task> PlaceConditionalOrderAsync( long accountId, string symbol, OrderSide side, @@ -188,19 +226,19 @@ Task> PlaceConditionalOrderAsync( /// /// Cancel conditional orders - /// + /// /// /// Client order ids of the conditional orders to cancels /// Cancelation token /// - Task> CancelConditionalOrdersAsync(IEnumerable clientOrderIds, CancellationToken ct = default); + Task> CancelConditionalOrdersAsync(IEnumerable clientOrderIds, CancellationToken ct = default); /// /// Get open conditional orders based on the parameters - /// + /// /// - /// Filter by account id - /// Filter by symbol + /// Filter by account id, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// Filter by symbol, for example `ETHUSDT` /// Filter by side /// Filter by type /// Sort direction @@ -208,14 +246,14 @@ Task> PlaceConditionalOrderAsync( /// Ids after this /// Cancelation token /// - Task>> GetOpenConditionalOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, ConditionalOrderType? type = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); + Task>> GetOpenConditionalOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, ConditionalOrderType? type = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); /// /// Get closed conditional orders - /// + /// /// - /// Filter by account id - /// Filter by symbol + /// Filter by account id, account ids can be retrieved with SpotApi.Account.GetAccountsAsync. + /// Filter by symbol, for example `ETHUSDT` /// Filter by side /// Filter by type /// Sort direction @@ -226,7 +264,7 @@ Task> PlaceConditionalOrderAsync( /// Return only entries after this time /// Return only entries before this time /// - Task>> GetClosedConditionalOrdersAsync( + Task>> GetClosedConditionalOrdersAsync( string symbol, ConditionalOrderStatus status, long? accountId = null, @@ -241,11 +279,11 @@ Task>> GetClosedConditionalOrde /// /// Get a conditional order by id - /// + /// /// /// Client order id /// Cancelation token /// - Task> GetConditionalOrderAsync(string clientOrderId, CancellationToken ct = default); + Task> GetConditionalOrderAsync(string clientOrderId, CancellationToken ct = default); } } diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiSocketClientSpotApi.cs b/HTX.Net/Interfaces/Clients/SpotApi/IHTXSocketClientSpotApi.cs similarity index 60% rename from Huobi.Net/Interfaces/Clients/SpotApi/IHuobiSocketClientSpotApi.cs rename to HTX.Net/Interfaces/Clients/SpotApi/IHTXSocketClientSpotApi.cs index 69947298..92459ae6 100644 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiSocketClientSpotApi.cs +++ b/HTX.Net/Interfaces/Clients/SpotApi/IHTXSocketClientSpotApi.cs @@ -1,159 +1,154 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using CryptoExchange.Net.Interfaces; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using Huobi.Net.Enums; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; - -namespace Huobi.Net.Interfaces.Clients.SpotApi +using CryptoExchange.Net.Objects.Sockets; +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.Socket; + +namespace HTX.Net.Interfaces.Clients.SpotApi { /// /// Spot streams /// - public interface IHuobiSocketClientSpotApi : ISocketApiClient, IDisposable + public interface IHTXSocketClientSpotApi : ISocketApiClient, IDisposable { /// - /// Gets candlestick data for a symbol + /// Get kline/candlestick data for a symbol /// /// - /// The symbol to get the data for + /// The symbol to get the data for, for example `ETHUSDT` /// The period of a single candlestick /// - Task>> GetKlinesAsync(string symbol, KlineInterval period); + Task>> GetKlinesAsync(string symbol, KlineInterval period); /// - /// Subscribes to candlestick updates for a symbol + /// Subscribes to kline/candlestick updates for a symbol + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The period of a single candlestick /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval period, Action> onData, CancellationToken ct = default); + Task> SubscribeToKlineUpdatesAsync(string symbol, KlineInterval period, Action> onData, CancellationToken ct = default); /// - /// Gets the current order book for a symbol + /// Get the current order book for a symbol /// /// - /// The symbol to get the data for + /// The symbol to get the data for, for example `ETHUSDT` /// The way the results will be merged together /// - Task> GetOrderBookWithMergeStepAsync(string symbol, int mergeStep); + Task> GetOrderBookWithMergeStepAsync(string symbol, int mergeStep); /// - /// Gets the current order book for a symbol + /// Get the current order book for a symbol /// /// - /// The symbol to get the data for + /// The symbol to get the data for, for example `ETHUSDT` /// The amount of rows. 5, 20, 150 or 400 /// - Task> GetOrderBookAsync(string symbol, int levels); + Task> GetOrderBookAsync(string symbol, int levels); /// /// Subscribes to order book updates for a symbol - /// + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The number of price levels. 5, 10 or 20 /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToPartialOrderBookUpdates100MilisecondAsync(string symbol, int levels, Action> onData, CancellationToken ct = default); + Task> SubscribeToPartialOrderBookUpdates100MilisecondAsync(string symbol, int levels, Action> onData, CancellationToken ct = default); /// /// Subscribes to order book updates for a symbol - /// + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The way the results will be merged together /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToPartialOrderBookUpdates1SecondAsync(string symbol, int mergeStep, Action> onData, CancellationToken ct = default); + Task> SubscribeToPartialOrderBookUpdates1SecondAsync(string symbol, int mergeStep, Action> onData, CancellationToken ct = default); /// /// Subscribes to order book updates for a symbol, - /// + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The number of price levels. 5, 20, 150 or 400 /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToOrderBookChangeUpdatesAsync(string symbol, int levels, Action> onData, CancellationToken ct = default); + Task> SubscribeToOrderBookChangeUpdatesAsync(string symbol, int levels, Action> onData, CancellationToken ct = default); /// - /// Gets a list of trades for a symbol + /// Get a list of trades for a symbol /// /// - /// The symbol to get trades for + /// The symbol to get trades for, for example `ETHUSDT` /// - Task>> GetTradeHistoryAsync(string symbol); + Task>> GetTradeHistoryAsync(string symbol); /// /// Subscribes to trade updates for a symbol - /// + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToTradeUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); + Task> SubscribeToTradeUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); /// - /// Gets details for a symbol + /// Get details for a symbol /// /// - /// The symbol to get data for + /// The symbol to get data for, for example `ETHUSDT` /// - Task> GetSymbolDetailsAsync(string symbol); + Task> GetSymbolDetailsAsync(string symbol); /// /// Subscribes to symbol detail updates for a symbol - /// + /// /// - /// The symbol to subscribe to + /// The symbol to subscribe to, for example `ETHUSDT` /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToSymbolDetailUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); + Task> SubscribeToSymbolDetailUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); /// /// Subscribes to updates for a symbol - /// + /// /// - /// The symbol to subscribe + /// The symbol to subscribe, for example `ETHUSDT` /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); + Task> SubscribeToTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); /// /// Subscribes to updates for all tickers - /// + /// /// /// The handler for updates /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToTickerUpdatesAsync(Action>> onData, CancellationToken ct = default); + Task> SubscribeToTickerUpdatesAsync(Action>> onData, CancellationToken ct = default); /// /// Subscribe to changes of a symbol's best ask/bid - /// + /// /// - /// Symbol to subscribe to + /// Symbol to subscribe to, for example `ETHUSDT` /// Data handler /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToBestOfferUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); + Task> SubscribeToBookTickerUpdatesAsync(string symbol, Action> onData, CancellationToken ct = default); /// /// Subscribe to updates of orders - /// + /// /// /// Subscribe on a specific symbol /// Event handler for the order submitted event @@ -165,33 +160,33 @@ public interface IHuobiSocketClientSpotApi : ISocketApiClient, IDisposable /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected Task> SubscribeToOrderUpdatesAsync( string? symbol = null, - Action>? onOrderSubmitted = null, - Action>? onOrderMatched = null, - Action>? onOrderCancelation = null, - Action>? onConditionalOrderTriggerFailure = null, - Action>? onConditionalOrderCanceled = null, + Action>? onOrderSubmitted = null, + Action>? onOrderMatched = null, + Action>? onOrderCancelation = null, + Action>? onConditionalOrderTriggerFailure = null, + Action>? onConditionalOrderCanceled = null, CancellationToken ct = default); /// /// Subscribe to updates of account balances - /// + /// /// /// Event handler /// The update mode. Defaults to 1, see API docs for more info /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - Task> SubscribeToAccountUpdatesAsync(Action> onAccountUpdate, int? updateMode = null, CancellationToken ct = default); + Task> SubscribeToAccountUpdatesAsync(Action> onAccountUpdate, int? updateMode = null, CancellationToken ct = default); /// /// Subscribe to detailed order matched/canceled updates - /// + /// /// - /// Subscribe to a specific symbol + /// Subscribe to a specific symbol, for example `ETHUSDT` /// Event handler for the order matched event /// Event handler for the order canceled event /// Cancellation token for closing this subscription /// A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected Task> SubscribeToOrderDetailsUpdatesAsync(string? symbol = null, - Action>? onOrderMatch = null, Action>? onOrderCancel = null, CancellationToken ct = default); + Action>? onOrderMatch = null, Action>? onOrderCancel = null, CancellationToken ct = default); } } \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApi.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApi.cs new file mode 100644 index 00000000..e230d8c9 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApi.cs @@ -0,0 +1,25 @@ +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// Usdt futures api endpoints + /// + public interface IHTXRestClientUsdtFuturesApi : IRestApiClient + { + /// + /// Endpoints related to account settings, info or actions + /// + IHTXRestClientUsdtFuturesApiAccount Account { get; } + /// + /// Endpoints related to retrieving market and system data + /// + IHTXRestClientUsdtFuturesApiExchangeData ExchangeData { get; } + /// + /// Endpoints related to sub accounts + /// + IHTXRestClientUsdtFuturesApiSubAccount SubAccount { get; } + /// + /// Endpoints related to orders and trades + /// + IHTXRestClientUsdtFuturesApiTrading Trading { get; } + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiAccount.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiAccount.cs new file mode 100644 index 00000000..e3b88b0b --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiAccount.cs @@ -0,0 +1,256 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// HTX usdt futures endpoints + /// + public interface IHTXRestClientUsdtFuturesApiAccount + { + /// + /// Get asset valuation + /// + /// + /// The asset, for example `ETH` + /// Cancellation token + /// + Task>> GetAssetValuationAsync(string? asset = null, CancellationToken ct = default); + /// + /// Get isolated margin account info + /// + /// + /// Optional contract code filter, for example `USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginAccountInfoAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get cross margin account info + /// + /// + /// Optional margin account filter, for example `USDT` + /// Cancellation token + /// + Task>> GetCrossMarginAccountInfoAsync(string? marginAccount = null, CancellationToken ct = default); + /// + /// Get cross margin assets and positions + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + /// + Task> GetCrossMarginAssetsAndPositionsAsync(string marginAccount, CancellationToken ct = default); + /// + /// Get cross margin available leverage + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business type + /// Cancellation token + /// + Task>> GetCrossMarginAvailableLeverageAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get cross margin positions + /// + /// + /// Filter by contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetCrossMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get cross margin settlement records + /// + /// + /// Margin account, for example `USDT` + /// Filter by start time + /// Filter by end time + /// Page + /// Page size + /// Cancellation token + /// + Task> GetCrossMarginSettlementRecordsAsync(string marginAccount, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Get financial records + /// + /// + /// Margin account, for example `USDT` + /// Contract code, for example `ETH-USDT` + /// Filter by type + /// Filter by start time + /// Filter by end time + /// Direction + /// Return results after this id + /// Cancellation token + /// + Task>> GetFinancialRecordsAsync(string marginAccount, string? contractCode = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get isolated margin assets and positions + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginAssetsAndPositionsAsync(string contractCode, CancellationToken ct = default); + /// + /// Get isolated margin available leverage + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginAvailableLeverageAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get isolated margin position info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get isolated margin settlement records + /// + /// + /// Contract code, for example `ETH-USDT` + /// Filter by start time + /// Filter by end time + /// Page + /// Page size + /// Cancellation token + /// + Task> GetIsolatedMarginSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + /// + /// Get trading fees + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business tpye + /// Cancellation token + /// + Task>> GetTradingFeesAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Set cross margin position mode + /// + /// + /// Margin account, for example `USDT` + /// Position mode + /// Cancellation token + /// + Task> SetCrossMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default); + /// + /// Set isolated margin position mode + /// + /// + /// Margin account, for example `USDT` + /// Position mode + /// Cancellation token + /// + Task> SetIsolatedMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default); + /// + /// Transfer between margin accounts + /// + /// + /// Asset to transfer, for example `USDT` + /// From account + /// To account + /// Quantity to transfer + /// Client order id + /// Cancellation token + /// + Task> TransferMarginAccountsAsync(string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, long? clientOrderId = null, CancellationToken ct = default); + + /// + /// Get order limits + /// + /// + /// The order type + /// Filter by contract code, for example `ETH-USDT` + /// Filter by pair, for example `ETH-USDT` + /// Filter by contract type + /// Filter by businessType + /// Cancellation token + Task> GetOrderLimitsAsync(OrderPriceType orderType, string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + + /// + /// Get isolated margin transfer limits + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + Task>> GetIsolatedMarginTransferLimitsAsync(string? contractCode = null, CancellationToken ct = default); + + /// + /// Get cross margin transfer limits + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + Task>> GetCrossMarginTransferLimitsAsync(string? marginAccount = null, CancellationToken ct = default); + + /// + /// Get isolated margin position limits + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + Task>> GetIsolatedMarginPositionLimitAsync(string contractCode, CancellationToken ct = default); + + /// + /// Get cross margin position limits + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business type + /// Cancellation token + Task>> GetCrossMarginPositionLimitsAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, string? businessType = null, CancellationToken ct = default); + + /// + /// Get isolated margin leverage position limits + /// + /// + /// Contract code, for example `ETH-USDT` + /// Leverage rate + /// Cancellation token + Task>> GetIsolatedMarginLeveragePositionLimitsAsync(string? contractCode = null, int? leverageRate = null, CancellationToken ct = default); + + /// + /// Get cross margin leverage position limits + /// + /// + /// Business type + /// Cancellation token + Task>> GetCrossMarginLeveragePositionLimitsAsync(BusinessType businessType, CancellationToken ct = default); + + /// + /// Get user trading status + /// + /// + /// Cancellation token + Task>> GetTradingStatusAsync(CancellationToken ct = default); + + /// + /// Get isolated margin position mode + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + Task>> GetIsolatedMarginPositionModeAsync(string marginAccount, CancellationToken ct = default); + + /// + /// Get cross margin position mode + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + Task>> GetCrossMarginPositionModeAsync(string marginAccount, CancellationToken ct = default); + + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiExchangeData.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiExchangeData.cs new file mode 100644 index 00000000..6d47dfd3 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiExchangeData.cs @@ -0,0 +1,362 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// HTX usdt futures exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. + /// + public interface IHTXRestClientUsdtFuturesApiExchangeData + { + /// + /// Get basis data + /// + /// + /// Contract code, for example `ETH-USDT` + /// Kline interval + /// Limit + /// Price type (open, close, high, low, average) + /// Cancellation token + /// + Task>> GetBasisDataAsync(string contractCode, KlineInterval interval, int limit, string? basisPriceType = null, CancellationToken ct = default); + /// + /// Get the current best bid/ask values + /// + /// + /// Contract code, for example `ETH-USDT` + /// Type + /// Cancellation token + /// + Task>> GetBookTickerAsync(string? contractCode = null, BusinessType? type = null, CancellationToken ct = default); + /// + /// Get contract info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Support margin mode + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business type + /// Cancellation token + /// + Task>> GetContractsAsync(string? contractCode = null, MarginMode? supportMarginMode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get cross margin adjust factor info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Asset, for example `ETH` + /// Type + /// Business type + /// Cancellation token + /// + Task>> GetCrossMarginAdjustFactorInfoAsync(string? contractCode = null, string? asset = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get cross margin trade status + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Type + /// Business type + /// Cancellation token + /// + Task>> GetCrossMarginTradeStatusAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get cross margin transfer status + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + /// + Task>> GetCrossMarginTransferStatusAsync(string? marginAccount = null, CancellationToken ct = default); + /// + /// Get cross tiered margin info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair + /// Contract type + /// Business type + /// Cancellation token + /// + Task>> GetCrossTieredMarginInfoAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get estimated funding rate klines + /// + /// + /// Contract code, for example `ETH-USDT` + /// Kline interval + /// Limit + /// Cancellation token + /// + Task>> GetEstimatedFundingRateKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default); + /// + /// Get estimated settlement price + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business type + /// Cancellation token + /// + Task>> GetEstimatedSettlementPriceAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get funding rate + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task> GetFundingRateAsync(string contractCode, CancellationToken ct = default); + /// + /// Get funding rates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetFundingRatesAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get historical funding rates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page + /// Page size + /// Cancellation token + /// + Task> GetHistoricalFundingRatesAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default); + /// + /// Get historical settlement records + /// + /// + /// Contract code, for example `ETH-USDT` + /// Filter by start time + /// Filter by end time + /// Page + /// Page size + /// Cancellation token + /// + Task> GetHistoricalSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + /// + /// Get insurance fund history + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page + /// Page size + /// Cancellation token + /// + Task> GetInsuranceFundHistoryAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default); + /// + /// Get isolated margin adjust factor info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginAdjustFactorInfoAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get isolated margin status + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginStatusAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get isolated margin tier info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginTieredInfoAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get klines + /// + /// + /// Contract code, for example `ETH-USDT` + /// Kline interval + /// Limit + /// Filter by start time + /// Filter by end time + /// Cancellation token + /// + Task>> GetKlinesAsync(string contractCode, KlineInterval interval, DateTime? startTime = null, DateTime? endTime = null, int? limit = null, CancellationToken ct = default); + /// + /// Get last trades + /// + /// + /// Contract code, for example `ETH-USDT` + /// Business type + /// Cancellation token + /// + Task> GetLastTradesAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get liquidation orders + /// + /// + /// Trade type + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Filter by start time + /// Filter by end time + /// Result direction + /// Return results after this id + /// Cancellation token + /// + Task>> GetLiquidationOrdersAsync(string contractCode, + LiquidationTradeType tradeType, + string? pair = null, + DateTime? startTime = null, + DateTime? endTime = null, + FilterDirection? direction = null, + long? fromId = null, + CancellationToken ct = default); + /// + /// Get ticker + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task> GetTickerAsync(string contractCode, CancellationToken ct = default); + /// + /// Get tickers + /// + /// + /// Contract code, for example `ETH-USDT` + /// Business type + /// Cancellation token + /// + Task>> GetTickersAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get open interest + /// + /// + /// Period + /// Unit + /// Contract code, for example `ETH-USDT` + /// Symbol + /// Type + /// Limit + /// Cancellation token + /// + Task> GetOpenInterestHistoryAsync(InterestPeriod period, Unit unit, string? contractCode = null, string? symbol = null, ContractType? type = null, int? limit = null, CancellationToken ct = default); + /// + /// Get order book + /// + /// + /// Contract code, for example `ETH-USDT` + /// Merge step + /// Cancellation token + /// + Task> GetOrderBookAsync(string contractCode, int? mergeStep = null, CancellationToken ct = default); + /// + /// Get premium index klines + /// + /// + /// Contract code, for example `ETH-USDT` + /// Interval + /// Max number of results + /// Cancellation token + /// + Task>> GetPremiumIndexKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default); + /// + /// Get recent trades + /// + /// + /// Contract code, for example `ETH-USDT` + /// Max number of results to return + /// Cancellation token + /// + Task>> GetRecentTradesAsync(string contractCode, int limit, CancellationToken ct = default); + /// + /// Get server time + /// + /// + /// Cancellation token + /// + Task> GetServerTimeAsync(CancellationToken ct = default); + /// + /// Get swap index price + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetSwapIndexPriceAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get swap open interest + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Business tpye + /// Cancellation token + /// + Task>> GetSwapOpenInterestAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get swap price limitation + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract tpye + /// Business type + /// Cancellation token + /// + Task>> GetSwapPriceLimitationAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); + /// + /// Get swap risk info + /// + /// + /// Contract code, for example `ETH-USDT` + /// Business type + /// Cancellation token + /// + Task>> GetSwapRiskInfoAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); + + /// + /// Get top trader account sentiment + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Cancellation token + Task> GetTopTraderAccountSentimentAsync(string contractCode, Period period, CancellationToken ct = default); + + /// + /// Get top trader position sentiment + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Cancellation token + Task> GetTopTraderPositionSentimentAsync(string contractCode, Period period, CancellationToken ct = default); + + /// + /// Get contract elements and info + /// + /// + /// Filter by contract code, for example `ETH-USDT` + /// Cancellation token + Task>> GetContractElementsAsync(string contractCode, CancellationToken ct = default); + + /// + /// Get mark price klines + /// + /// + /// Contract code, for example `ETH-USDT` + /// Kline interval + /// Max number of results + /// Cancellation token + Task>> GetMarkPriceKlinesAsync(string contractCode, KlineInterval klineInterval, int limit, CancellationToken ct = default); + + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiSubAccount.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiSubAccount.cs new file mode 100644 index 00000000..699e8201 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiSubAccount.cs @@ -0,0 +1,119 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// HTX usdt futures sub account endpoints + /// + public interface IHTXRestClientUsdtFuturesApiSubAccount + { + /// + /// Get cross margin sub account assets + /// + /// + /// Margin account, for example `USDT` + /// Cancellation token + /// + Task>> GetCrossMarginAssetsAsync(string? marginAccount = null, CancellationToken ct = default); + + /// + /// Get isolated margin sub account assets + /// + /// + /// Contract code, for example `ETH-USDT` + /// Cancellation token + /// + Task>> GetIsolatedMarginAssetsAsync(string? contractCode = null, CancellationToken ct = default); + /// + /// Get master sub account transfer records + /// + /// + /// Margin account, for example `USDT` + /// Days in history + /// Filter by type + /// Page + /// Page size + /// Cancellation token + /// + Task> GetMasterSubTransferRecordsAsync(string marginAccount, int daysInHistory, MasterSubTransferType? type = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Set sub account trading permissions + /// + /// + /// Uids of the subaccounts + /// Enable trading + /// Cancellation token + /// + Task> SetTradingPermissionsAsync(IEnumerable subAccountUids, bool enabled, CancellationToken ct = default); + + /// + /// Transfer between master and sub account + /// + /// + /// Sub account uid + /// Asset to transfer, for example `ETH` + /// From account + /// To account + /// Quantity to transfer + /// Type + /// Client order id + /// Cancellation token + /// + Task> TransferMasterSubAsync(string subUid, string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, MasterSubTransferType type, long? clientOrderId = null, CancellationToken ct = default); + + /// + /// Get sub accounts trade permissions + /// + /// + /// Filter by sub user ids + /// Filter by start time + /// Filter by end time + /// Filter direction + /// Return results after this id + /// Cancellation token + Task> GetTradePermissionsAsync(IEnumerable? subAccountUids = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get isolated margin asset information + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page + /// Page size + /// Cancellation token + Task> GetIsolatedMarginAssetInfoAsync(string? contractCode = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Get cross margin asset info + /// + /// + /// Margin account, for example `USDT` + /// Page + /// Page size + /// Cancellation token + Task> GetCrossMarginAssetInfoAsync(string? marginAccount = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Get isolated margin positions + /// + /// + /// Sub user id + /// Filter by contract code, for example `ETH-USDT` + /// Cancellation token + Task>> GetIsolatedMarginPositionsAsync(long subUserId, string? contractCode = null, CancellationToken ct = default); + + /// + /// Get isolated margin positions + /// + /// + /// Sub user id + /// Filter by contract code, for example `ETH-USDT` + /// Filter by pair, for example `ETH-USDT` + /// Filter by contract type + /// Cancellation token + Task>> GetCrossMarginPositionsAsync(long subUserId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiTrading.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiTrading.cs new file mode 100644 index 00000000..009bbdf7 --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXRestClientUsdtFuturesApiTrading.cs @@ -0,0 +1,728 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models.UsdtMarginSwap; + +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// HTX usdt futures trading endpoints, placing and managing orders. + /// + public interface IHTXRestClientUsdtFuturesApiTrading + { + /// + /// Cancel all cross margin orders fitting the parameters + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair + /// Contract type + /// Side + /// Offset + /// Cancellation token + /// + Task> CancelAllCrossMarginOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + /// + /// Cancel all isolated margin orders fitting the parameters + /// + /// + /// Contract code, for example `ETH-USDT` + /// Side + /// Offset + /// Cancellation token + /// + Task> CancelAllIsolatedMarginOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + /// + /// Cancel a cross margin order + /// + /// + /// The order id + /// The client order id + /// Contract code, for example `ETH-USDT` + /// Pair + /// Contract type + /// Cancellation token + /// + Task> CancelCrossMarginOrderAsync(long? orderId = null, long? clientOrderId = null, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + /// + /// Cancel cross margin orders + /// + /// + /// Order ids + /// Client order ids + /// Contract code, for example `ETH-USDT` + /// Pair + /// Contract type + /// Cancellation token + /// + Task> CancelCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + /// + /// Cancel an isolated margin order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Client order id + /// Cancellation token + /// + Task> CancelIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); + /// + /// Cancel isolated margin orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order ids + /// Client order ids + /// Cancellation token + /// + Task> CancelIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderId, IEnumerable clientOrderId, CancellationToken ct = default); + /// + /// Set cross margin leverage + /// + /// + /// Leverage rate + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Cancellation token + /// + Task> SetCrossMarginLeverageAsync(int leverageRate, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + /// + /// Set isolated margin leverage + /// + /// + /// Contract code, for example `ETH-USDT` + /// Leverage rate + /// Cancellation token + /// + Task> SetIsolatedMarginLeverageAsync(string contractCode, int leverageRate, CancellationToken ct = default); + /// + /// Get cross margin closed orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trade type + /// All orders (true), or only orders in finished status (false) + /// Filter by pair, for example `ETH-USDT` + /// Filter by status + /// Filter by start time + /// Filter by end time + /// Direction + /// Return results after this id + /// Cancellation token + Task>> GetCrossMarginClosedOrdersAsync(string contractCode, MarginTradeType tradeType, bool allOrders, IEnumerable status, string? pair = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, long? fromId = null, CancellationToken ct = default); + /// + /// Get cross margin open orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair + /// Pair, for example `ETH-USDT` + /// Page size + /// Sort by + /// Trade type + /// Cancellation token + /// + Task> GetCrossMarginOpenOrdersAsync(string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + /// + /// Get cross margin order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Order id + /// Client order id + /// Cancellation token + /// + Task>> GetCrossMarginOrderAsync(string? contractCode = null, string? pair = null, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); + /// + /// Get cross margin order details + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + /// + Task> GetCrossMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default); + /// + /// Get cross margin orders + /// + /// + /// Order ids + /// Client order ids + /// Contract code, for example `ETH-USDT` + /// Pair + /// Cancellation token + /// + Task>> GetCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? pair = null, CancellationToken ct = default); + /// + /// Get isolated margin user trades + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Trade type + /// Filter by start time + /// Filter by end time + /// Filter direction + /// Return results after this id + /// Cancellation token + Task>> GetIsolatedMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, string? pair = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get cross margin user trades + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Trade type + /// Filter by start time + /// Filter by end time + /// Filter direction + /// Return results after this id + /// Cancellation token + Task>> GetCrossMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, string? pair = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? filterDirection = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get isolated margin closed orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trade type + /// All orders (true), or only orders in finished status (false) + /// Filter by status + /// Filter by start time + /// Filter by end time + /// Direction + /// Return results after this id + /// Cancellation token + Task>> GetIsolatedMarginClosedOrdersAsync(string contractCode, MarginTradeType tradeType, bool allOrders, IEnumerable status, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, long? fromId = null, CancellationToken ct = default); + + /// + /// Get isolated margin open orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page + /// Page size + /// Sort by + /// Trade type + /// Cancellation token + /// + Task> GetIsolatedMarginOpenOrdersAsync(string contractCode, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + /// + /// Get an isolated margin order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Client order id + /// Cancellation token + /// + Task>> GetIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); + /// + /// Get isolated margin order details + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + /// + Task> GetIsolatedMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default); + /// + /// Get isolated margin orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order ids + /// Client order ids + /// Cancellation token + /// + Task>> GetIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderIds, IEnumerable clientOrderIds, CancellationToken ct = default); + /// + /// Place a new cross margin order + /// + /// + /// Order quantity + /// Order side + /// Leverage rate + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Price + /// Offset + /// Order price type + /// Take profit trigger price + /// Take profit order price + /// Take profit order price type + /// Stop loss trigger price + /// Stop loss order price + /// Stop loss order price type + /// Reduce only + /// Client order id + /// Cancellation token + /// + Task> PlaceCrossMarginOrderAsync(long quantity, OrderSide side, int leverageRate, OrderPriceType orderPriceType, string? contractCode = null, string? pair = null, ContractType? contractType = null, decimal? price = null, Offset? offset = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, bool? reduceOnly = null, long? clientOrderId = null, CancellationToken ct = default); + /// + /// Place a new isolated margin order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Quantity + /// Order side + /// Leverage rate + /// Price + /// Offset + /// Order price type + /// Take profit trigger price + /// Take profit order price + /// Take profit order price type + /// Stop loss trigger price + /// Stop loss order price + /// Stop loss order price type + /// Reduce only + /// Client order id + /// Cancellation token + /// + Task> PlaceIsolatedMarginOrderAsync(string contractCode, long quantity, OrderSide side, int leverageRate, OrderPriceType orderPriceType, decimal? price = null, Offset? offset = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, bool? reduceOnly = null, long? clientOrderId = null, CancellationToken ct = default); + + /// + /// Cancel all orders after the timeout elapses. Can be called again to extend the timeout. Set enable to false to disable the timeout + /// + /// + /// Enabled or disable cancelation + /// The timeout after which all order are canceled + /// Cancellation token + Task> CancelOrdersAfterAsync(bool enable, TimeSpan? timeout = null, CancellationToken ct = default); + + /// + /// Lightning close isolated margin position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Direction + /// Client order id + /// Order price type + /// Cancellation token + Task> CloseIsolatedMarginPositionAsync(string contractCode, OrderSide direction, long? clientOrderId = null, LightningPriceType? orderPriceType = null, CancellationToken ct = default); + + /// + /// Lightning close cross margin position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Direction + /// Pair, for example `ETH-USDT` + /// Contract type + /// Client order id + /// Order price type + /// Cancellation token + Task> CloseCrossMarginPositionAsync(OrderSide direction, string? contractCode = null, string? pair = null, ContractType? contractType = null, long? clientOrderId = null, LightningPriceType? orderPriceType = null, CancellationToken ct = default); + + /// + /// Place a new isolated margin trigger order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trigger type + /// Trigger price + /// Order quantity + /// Order side + /// Offset + /// Reduce only + /// Order price + /// Order price type + /// Leverage rate + /// Cancellation token + Task> PlaceIsolatedMarginTriggerOrderAsync(string contractCode, TriggerType triggerType, decimal triggerPrice, decimal quantity, OrderSide side, Offset? offset = null, bool? reduceOnly = null, decimal? orderPrice = null, OrderPriceType? orderPriceType = null, int? leverageRate = null, CancellationToken ct = default); + + /// + /// Place a new cross margin trigger order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trigger type + /// Trigger price + /// Order quantity + /// Order side + /// Pair, for example `ETH-USDT` + /// Contract type + /// Offset + /// Reduce only + /// Order price + /// Order price type + /// Leverage rate + /// Cancellation token + Task> PlaceCrossMarginTriggerOrderAsync(TriggerType triggerType, decimal triggerPrice, decimal quantity, OrderSide side, string? contractCode = null, string? pair = null, ContractType? contractType = null, Offset? offset = null, bool? reduceOnly = null, decimal? orderPrice = null, OrderPriceType? orderPriceType = null, int? leverageRate = null, CancellationToken ct = default); + + /// + /// Cancel isolated margin trigger order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + Task> CancelIsolatedMarginTriggerOrderAsync(string contractCode, string orderId, CancellationToken ct = default); + + /// + /// Cancel cross margin trigger order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Order id + /// Cancellation token + Task> CancelCrossMarginTriggerOrderAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + + /// + /// Cancel all isolated margin trigger orders matching the parameters + /// + /// + /// Contract code, for example `ETH-USDT` + /// Filter by side + /// Filter by offset + /// Cancellation token + Task> CancelAllIsolatedMarginTriggerOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + + /// + /// Cancel all cross margin trigger orders matching the parameters + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Filter by side + /// Filter by offset + /// Cancellation token + Task> CancelAllCrossMarginTriggerOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + + /// + /// Get isolated margin open trigger orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page + /// Page size + /// Trade type + /// Cancellation token + Task> GetIsolatedMarginOpenTriggerOrdersAsync(string contractCode, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + + /// + /// Get cross margin open trigger orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Page + /// Page size + /// Trade type + /// Cancellation token + Task> GetCrossMarginOpenTriggerOrdersAsync(string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + + /// + /// Get isolated margin trigger order history + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trade type + /// Amount of days ago. Max 90 + /// Status + /// Page + /// Page index + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + Task> GetIsolatedMarginTriggerOrderHistoryAsync(string contractCode, MarginTradeType tradeType, int daysPast, OrderStatusFilter status, int? page = null, int? pageIndex = null, string? sortBy = null, CancellationToken ct = default); + + /// + /// Get cross margin trigger order history + /// + /// + /// Trade type + /// Amount of days ago. Max 90 + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Status + /// Page + /// Page index + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + Task> GetCrossMarginTriggerOrderHistoryAsync(MarginTradeType tradeType, int daysPast, OrderStatusFilter status, string? contractCode = null, string? pair = null, ContractType? contractType = null, int? page = null, int? pageIndex = null, string? sortBy = null, CancellationToken ct = default); + + /// + /// Set isolated margin order take profit / stop loss for an existing position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order side + /// Quantity + /// Take profit trigger price + /// Take profit order price + /// Take profit order price type + /// Stop loss trigger price + /// Stop loss order price + /// Stop loss order price type + /// Cancellation token + Task> SetIsolatedMarginTpSlAsync(string contractCode, OrderSide side, decimal quantity, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, CancellationToken ct = default); + + /// + /// Set cross margin order take profit / stop loss for an existing position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Order side + /// Quantity + /// Take profit trigger price + /// Take profit order price + /// Take profit order price type + /// Stop loss trigger price + /// Stop loss order price + /// Stop loss order price type + /// Cancellation token + Task> SetCrossMarginTpSlAsync(OrderSide side, decimal quantity, string? contractCode = null, string? pair = null, ContractType? contractType = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, CancellationToken ct = default); + + /// + /// Cancel isolated margin take profit / stop loss orders for an existing position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + Task> CancelIsolatedMarginTpSlAsync(string contractCode, string orderId, CancellationToken ct = default); + + /// + /// Cancel cross margin take profit / stop loss orders for an existing position + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Order id + /// Cancellation token + Task> CancelCrossMarginTpSlAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + + /// + /// Cancel all isolated margin take profit / stop loss orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Side + /// Cancellation token + Task> CancelAllIsolatedMarginTpSlAsync(string contractCode, OrderSide? side = null, CancellationToken ct = default); + + /// + /// Cancel all cross margin take profit / stop loss orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Side + /// Cancellation token + Task> CancelAllCrossMarginTpSlAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, CancellationToken ct = default); + + /// + /// Get open isolated margin take profit / stop loss orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Page index + /// Page size + /// Trade type + /// Cancellation token + Task> GetIsolatedMarginOpenTpSlOrdersAsync(string? contractCode = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + + /// + /// Get open cross margin take profit / stop loss orders + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Page index + /// Page size + /// Trade type + /// Cancellation token + Task> GetCrossMarginOpenTpSlOrdersAsync(string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, MarginTradeType? tradeType = null, CancellationToken ct = default); + + /// + /// Get isolated margin take profit / stop loss order history + /// + /// + /// Contract code, for example `ETH-USDT` + /// Status + /// Amount of days ago. Max 90 + /// Page + /// Page size + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + Task> GetIsolatedMarginTpSlHistoryAsync(string contractCode, IEnumerable tpSlOrderStatus, int daysPast, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); + + /// + /// Get cross maring take profit / stop loss order history + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Status + /// Amount of days ago. Max 90 + /// Page + /// Page size + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + Task> GetCrossMarginTpSlHistoryAsync(IEnumerable tpSlOrderStatus, int daysPast, string? contractCode = null, string? pair = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); + + /// + /// Get isolated margin position open info with attached tp/sl orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + Task> GetIsolatedMarginPositionOpenTpSlInfoAsync(string contractCode, long orderId, CancellationToken ct = default); + + /// + /// Get cross margin position open info with attached tp/sl orders + /// + /// + /// Order id + /// Contract code, for example `ETH-USDT` + /// Pair + /// Cancellation token + /// + Task> GetCrossMarginPositionOpenTpSlInfoAsync(long orderId, string? contractCode = null, string? pair = null, CancellationToken ct = default); + + /// + /// Place isolated margin trailing order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Reduce only + /// Side + /// Offset + /// Leverage rate + /// Quantity + /// Callback rate, 0.01 means 1% + /// Active price + /// Price type + /// Cancellation token + Task> PlaceIsolatedMarginTrailingOrderAsync(string contractCode, bool reduceOnly, OrderSide side, Offset offset, int leverageRate, decimal quantity, decimal callbackRate, decimal activePrice, OrderPriceType orderPriceType, CancellationToken ct = default); + + /// + /// Place cross margin trailing order + /// + /// + /// Side + /// Offset + /// Leverage rate + /// Quantity + /// Callback rate, 0.01 means 1% + /// Active price + /// Price type + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Reduce only + /// Cancellation token + /// + Task> PlaceCrossMarginTrailingOrderAsync(OrderSide side, Offset offset, int leverageRate, decimal quantity, decimal callbackRate, decimal activePrice, OrderPriceType orderPriceType, string? contractCode = null, string? pair = null, ContractType? contractType = null, bool? reduceOnly = null, CancellationToken ct = default); + + /// + /// Cancel an isolated margin trailing order + /// + /// + /// Contract code, for example `ETH-USDT` + /// Order id + /// Cancellation token + Task> CancelIsolatedMarginTrailingOrderAsync(string contractCode, string orderId, CancellationToken ct = default); + + /// + /// Cancel a cross margin trailing order + /// + /// Order id + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Cancellation token + /// + Task> CancelCrossMarginTrailingOrderAsync(string orderId, string? contractCode = null, string? pair = null, ContractType? contractType = null, CancellationToken ct = default); + + /// + /// Cancel all open isolated margin trailing orders on a symbol + /// + /// + /// Contract code, for example `ETH-USDT` + /// Filter by side + /// Filter by offset + /// Cancellation token + Task> CancelAllIsolatedMarginTrailingOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + + /// + /// Cancel all open cross margin trailing orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Filter by side + /// Filter by offset + /// Cancellation token + /// + Task> CancelAllCrossMarginTrailingOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); + + /// + /// Get open isolated margin trailing orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Trade type + /// Page + /// Page size + /// Cancellation token + Task> GetOpenIsolatedMarginTrailingOrdersAsync(string contractCode, MarginTradeType? tradeType = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Get open cross margin trailing orders + /// + /// + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Trade type + /// Page + /// Page size + /// Cancellation token + Task> GetOpenCrossMarginTrailingOrdersAsync(string? contractCode = null, string? pair = null, ContractType? contractType = null, MarginTradeType? tradeType = null, int? page = null, int? pageSize = null, CancellationToken ct = default); + + /// + /// Get isolated margin trailing order history + /// + /// + /// Contract code, for example `ETH-USDT` + /// Status + /// Trade type + /// Amount of days ago. Max 90 + /// Page + /// Page size + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + /// + Task> GetClosedIsolatedMarginTrailingOrdersAsync(string contractCode, IEnumerable tpSlOrderStatus, MarginTradeType tradeType, int daysPast, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); + + /// + /// Get cross margin trailing order history + /// + /// + /// Status + /// Trade type + /// Amount of days ago. Max 90 + /// Contract code, for example `ETH-USDT` + /// Pair, for example `ETH-USDT` + /// Contract type + /// Page + /// Page size + /// Sort by; 'created_at' or 'update_time' + /// Cancellation token + /// + Task> GetClosedCrossMarginTrailingOrdersAsync(IEnumerable tpSlOrderStatus, MarginTradeType tradeType, int daysPast, string? contractCode = null, string? pair = null, ContractType? contractType = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXSocketClientUsdtFuturesApi.cs b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXSocketClientUsdtFuturesApi.cs new file mode 100644 index 00000000..fa16e61e --- /dev/null +++ b/HTX.Net/Interfaces/Clients/UsdtFuturesApi/IHTXSocketClientUsdtFuturesApi.cs @@ -0,0 +1,251 @@ +using CryptoExchange.Net.Objects.Sockets; +using HTX.Net.Enums; +using HTX.Net.Objects.Models; +using HTX.Net.Objects.Models.Socket; + +namespace HTX.Net.Interfaces.Clients.UsdtFuturesApi +{ + /// + /// Usdt futures streams + /// + public interface IHTXSocketClientUsdtFuturesApi : ISocketApiClient + { + /// + /// Subscribe to basis updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Price type + /// Data handler + /// Cancellation token + /// + Task> SubscribeToBasisUpdatesAsync(string contractCode, KlineInterval period, string priceType, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to best bid/ask updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Data handler + /// Cancellation token + /// + Task> SubscribeToBookTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to estimated funding rate kline updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Data handler + /// Cancellation token + /// + Task> SubscribeToEstimatedFundingRateKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to incremental order book updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Snapshot or incremental + /// Depth + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIncrementalOrderBookUpdatesAsync(string contractCode, bool snapshot, int limit, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to index kline updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to kline updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Data handler + /// Cancellation token + /// + Task> SubscribeToKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to mark price kline updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Data handler + /// Cancellation token + /// + Task> SubscribeToMarkPriceKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to order book updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Merge step + /// Data handler + /// Cancellation token + /// + Task> SubscribeToOrderBookUpdatesAsync(string contractCode, int mergeStep, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to premium index kline updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Period + /// Data handler + /// Cancellation token + /// + Task> SubscribeToPremiumIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to symbol ticker updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Data handler + /// Cancellation token + /// + Task> SubscribeToTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); + /// + /// Subscribe to symbol trade updates + /// + /// + /// Contract code, for example `ETH-USDT` + /// Data handler + /// Cancellation token + /// + Task> SubscribeToTradeUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to system status updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToSystemStatusUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to order updates + /// + /// + /// + /// Margin mode + /// Data handler + /// Cancellation token + /// + Task> SubscribeToOrderUpdatesAsync(MarginMode mode, Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to isolated margin balance updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIsolatedMarginBalanceUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to cross margin balance updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToCrossMarginBalanceUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to isolated margin position updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIsolatedMarginPositionUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to cross margin position updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToCrossMarginPositionUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to isolated margin user trades + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIsolatedMarginUserTradeUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to cross margin user trades + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToCrossMarginUserTradeUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to liquidation order updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToLiquidationUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to funding rate updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToFundingRateUpdatesAsync(Action>> onData, CancellationToken ct = default); + + /// + /// Subscribe to contract info updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToContractUpdatesAsync(Action>> onData, CancellationToken ct = default); + + /// + /// Subscribe to contract element updates. Only changed properties are send after the initial update, other properties will be `null`. + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToContractElementsUpdatesAsync(Action>> onData, CancellationToken ct = default); + + /// + /// Subscribe to isolated margin trigger order updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToIsolatedMarginTriggerOrderUpdatesAsync(Action> onData, CancellationToken ct = default); + + /// + /// Subscribe to cross margin trigger order updates + /// + /// + /// Data handler + /// Cancellation token + /// + Task> SubscribeToCrossMarginTriggerOrderUpdatesAsync(Action> onData, CancellationToken ct = default); + } +} \ No newline at end of file diff --git a/HTX.Net/Interfaces/IHTXOrderBookFactory.cs b/HTX.Net/Interfaces/IHTXOrderBookFactory.cs new file mode 100644 index 00000000..10ca9870 --- /dev/null +++ b/HTX.Net/Interfaces/IHTXOrderBookFactory.cs @@ -0,0 +1,35 @@ +using HTX.Net.Objects.Options; + +namespace HTX.Net.Interfaces +{ + /// + /// HTX order book factory + /// + public interface IHTXOrderBookFactory + { + /// + /// Spot order book factory methods + /// + public IOrderBookFactory Spot { get; } + /// + /// Usdt futures order book factory methods + /// + public IOrderBookFactory UsdtFutures { get; } + + /// + /// Create a SymbolOrderBook for the Spot API + /// + /// The symbol + /// Order book options + /// + ISymbolOrderBook CreateSpot(string symbol, Action? options = null); + + /// + /// Create a SymbolOrderBook for the Usdt futures API + /// + /// The symbol + /// Order book options + /// + ISymbolOrderBook CreateUsdtFutures(string symbol, Action? options = null); + } +} diff --git a/Huobi.Net/Objects/HuobiApiAddresses.cs b/HTX.Net/Objects/HTXApiAddresses.cs similarity index 59% rename from Huobi.Net/Objects/HuobiApiAddresses.cs rename to HTX.Net/Objects/HTXApiAddresses.cs index 62f078b5..479f3d05 100644 --- a/Huobi.Net/Objects/HuobiApiAddresses.cs +++ b/HTX.Net/Objects/HTXApiAddresses.cs @@ -1,32 +1,32 @@ -namespace Huobi.Net.Objects +namespace HTX.Net.Objects { /// - /// Api addresses usable for the Huobi clients + /// Api addresses usable for the HTX clients /// - public class HuobiApiAddresses + public class HTXApiAddresses { /// - /// The address used by the HuobiClient for the rest spot API + /// The address used by the HTXRestClient for the rest spot API /// public string RestClientAddress { get; set; } = ""; /// - /// The address used by the HuobiSocketClient for the public socket API + /// The address used by the HTXSocketClient for the public socket API /// public string SocketClientAddress { get; set; } = ""; /// - /// The address used by the HuobiClient for the rest usdt margin swaps API + /// The address used by the HTXRestClient for the rest usdt margin swaps API /// public string UsdtMarginSwapRestClientAddress { get; set; } = ""; /// - /// The address used by the HuobiSocketClient for the private user socket API + /// The address used by the HTXSocketClient for the private user socket API /// public string UsdtMarginSwapSocketClientAddress { get; set; } = ""; /// - /// The default addresses to connect to the Huobi.com API + /// The default addresses to connect to the HTX.com API /// - public static HuobiApiAddresses Default = new HuobiApiAddresses + public static HTXApiAddresses Default = new HTXApiAddresses { RestClientAddress = "https://api.huobi.pro", SocketClientAddress = "wss://api.huobi.pro", diff --git a/HTX.Net/Objects/Internal/HTXApiResponse.cs b/HTX.Net/Objects/Internal/HTXApiResponse.cs new file mode 100644 index 00000000..b548ddba --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXApiResponse.cs @@ -0,0 +1,52 @@ +namespace HTX.Net.Objects.Internal +{ + internal abstract class HTXApiResponse + { + [JsonInclude, JsonPropertyName("status")] + internal string? Status { get; set; } + + + [JsonInclude, JsonPropertyName("err-msg")] + internal string? ErrorMessage { get; set; } + [JsonInclude, JsonPropertyName("err_msg")] + private string? ErrorMessageInternal + { + get => ErrorMessage; + set => ErrorMessage = value; + } + [JsonInclude, JsonPropertyName("err-code"), JsonConverter(typeof(NumberStringConverter))] + internal string? ErrorCode { get; set; } + [JsonInclude, JsonPropertyName("err_code"), JsonConverter(typeof(NumberStringConverter))] + private string? ErrorCodeInternal + { + get => ErrorCode; + set => ErrorCode = value; + } + [JsonInclude, JsonPropertyName("code"), JsonConverter(typeof(NumberStringConverter))] + private string? ErrorCodeInternal2 + { + get => ErrorCode; + set => ErrorCode = value; + } + } + + internal class HTXBasicResponse : HTXApiResponse + { + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] + public DateTime Timestamp { get; set; } + [JsonPropertyName("ch")] + public string Channel { get; set; } = string.Empty; + [JsonInclude, JsonPropertyName("next-time"), JsonConverter(typeof(DateTimeConverter))] + private DateTime NextTime { get => Timestamp; set => Timestamp = value; } + } + + internal class HTXBasicResponse : HTXBasicResponse + { + [JsonPropertyName("data")] + public T Data { get; set; } = default!; + [JsonInclude, JsonPropertyName("tick")] + private T Tick { set => Data = value; get => Data; } + [JsonInclude, JsonPropertyName("ticks")] + private T Ticks { set => Data = value; get => Data; } + } +} diff --git a/Huobi.Net/Objects/Internal/HuobiApiResponseV2.cs b/HTX.Net/Objects/Internal/HTXApiResponseV2.cs similarity index 53% rename from Huobi.Net/Objects/Internal/HuobiApiResponseV2.cs rename to HTX.Net/Objects/Internal/HTXApiResponseV2.cs index 641b7f65..1557e2f3 100644 --- a/Huobi.Net/Objects/Internal/HuobiApiResponseV2.cs +++ b/HTX.Net/Objects/Internal/HTXApiResponseV2.cs @@ -1,10 +1,13 @@ -namespace Huobi.Net.Objects.Internal +namespace HTX.Net.Objects.Internal { - internal class HuobiApiResponseV2 + internal class HTXApiResponseV2 { + [JsonPropertyName("code")] public int Code { get; set; } + [JsonPropertyName("msg")] public string Message { get; set; } = string.Empty; #pragma warning disable 8618 + [JsonPropertyName("data")] public T Data { get; set; } #pragma warning restore 8618 } diff --git a/HTX.Net/Objects/Internal/HTXAuthenticationRequest2.cs b/HTX.Net/Objects/Internal/HTXAuthenticationRequest2.cs new file mode 100644 index 00000000..84849555 --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXAuthenticationRequest2.cs @@ -0,0 +1,22 @@ + + +namespace HTX.Net.Objects.Internal +{ + internal class HTXAuthenticationRequest2 + { + [JsonPropertyName("op")] public string Operation { get; set; } = "auth"; + [JsonPropertyName("type")] public string AuthType { get; set; } = "api"; + [JsonPropertyName("AccessKeyId")] public string AccessKey { get; set; } = string.Empty; + [JsonPropertyName("SignatureMethod")] public string SignatureMethod { get; set; } = "HmacSHA256"; + [JsonPropertyName("SignatureVersion")] public string SignatureVersion { get; set; } = "2"; + [JsonPropertyName("Timestamp")] public string Timestamp { get; set; } = string.Empty; + [JsonPropertyName("Signature")] public string Signature { get; set; } = string.Empty; + + public HTXAuthenticationRequest2(string accessKey, string timestamp, string signature) + { + AccessKey = accessKey; + Timestamp = timestamp; + Signature = signature; + } + } +} diff --git a/HTX.Net/Objects/Internal/HTXPingRequest.cs b/HTX.Net/Objects/Internal/HTXPingRequest.cs new file mode 100644 index 00000000..6375a7f3 --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXPingRequest.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Internal +{ + internal class HTXPingRequest + { + [JsonPropertyName("ping")] + public long Ping { get; set; } + } + + internal class HTXPingResponse + { + [JsonPropertyName("pong")] + public long Pong { get; set; } + + public HTXPingResponse(long id) + { + Pong = id; + } + } + + internal class HTXPingAuthResponse + { + [JsonPropertyName("action")] + public string Action { get; set; } + [JsonPropertyName("data")] + public Dictionary Data { get; set; } + + public HTXPingAuthResponse(long id) + { + Action = "pong"; + Data = new ParameterCollection() + { + { "ts", id} + }; + } + } +} diff --git a/HTX.Net/Objects/Internal/HTXSocketRequest.cs b/HTX.Net/Objects/Internal/HTXSocketRequest.cs new file mode 100644 index 00000000..9aeb0865 --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXSocketRequest.cs @@ -0,0 +1,24 @@ +namespace HTX.Net.Objects.Internal +{ + internal class HTXRequest + { + [JsonIgnore] + public string? Id { get; set; } + } + + internal class HTXSocketRequest: HTXRequest + { + [JsonPropertyName("req")] + public string Request { get; set; } + + [JsonPropertyName("id")] + public new string Id { get; set; } + + + public HTXSocketRequest(string id, string topic) + { + Id = id; + Request = topic; + } + } +} diff --git a/HTX.Net/Objects/Internal/HTXSocketRequestOp.cs b/HTX.Net/Objects/Internal/HTXSocketRequestOp.cs new file mode 100644 index 00000000..71fb479c --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXSocketRequestOp.cs @@ -0,0 +1,21 @@ + + +namespace HTX.Net.Objects.Internal +{ + internal class HTXSocketRequestOp + { + [JsonPropertyName("op")] + public string Operation { get; set; } + [JsonPropertyName("cid")] + public string ClientId { get; set; } + [JsonPropertyName("topic")] + public string Topic { get; set; } + + public HTXSocketRequestOp(string operation, string clientId, string topic) + { + Operation = operation; + ClientId = clientId; + Topic = topic; + } + } +} diff --git a/HTX.Net/Objects/Internal/HTXSocketResponse.cs b/HTX.Net/Objects/Internal/HTXSocketResponse.cs new file mode 100644 index 00000000..95a9ca06 --- /dev/null +++ b/HTX.Net/Objects/Internal/HTXSocketResponse.cs @@ -0,0 +1,34 @@ + +namespace HTX.Net.Objects.Internal +{ + internal abstract class HTXResponse + { + internal abstract bool IsSuccessful { get; } + [JsonPropertyName("id")] + public string? Id { get; set; } + [JsonPropertyName("err-code")] + public string? ErrorCode { get; set; } + [JsonPropertyName("err-msg")] + public string? ErrorMessage { get; set; } + } + + internal class HTXSocketResponse: HTXResponse + { + internal override bool IsSuccessful => string.Equals(Status, "ok", StringComparison.Ordinal); + [JsonPropertyName("status")] internal string Status { get; set; } = string.Empty; + + /// + /// The timestamp of the data + /// + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] + public DateTime Timestamp { get; set; } + + /// + /// The data + /// + [JsonPropertyName("data")] + public T Data { get; set; } = default!; + [JsonPropertyName("tick")] + private T Tick { set => Data = value; get => Data; } + } +} diff --git a/Huobi.Net/Objects/Internal/HuobiSocketUpdate.cs b/HTX.Net/Objects/Internal/HTXSocketUpdate.cs similarity index 65% rename from Huobi.Net/Objects/Internal/HuobiSocketUpdate.cs rename to HTX.Net/Objects/Internal/HTXSocketUpdate.cs index b27f38b6..ebdd9423 100644 --- a/Huobi.Net/Objects/Internal/HuobiSocketUpdate.cs +++ b/HTX.Net/Objects/Internal/HTXSocketUpdate.cs @@ -1,32 +1,29 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal +namespace HTX.Net.Objects.Internal { - internal class HuobiDataEvent + internal class HTXDataEvent { /// /// The action /// - [JsonProperty("action")] + [JsonPropertyName("action")] public string Action { get; set; } = string.Empty; /// /// The name of the data channel /// - [JsonProperty("ch")] + [JsonPropertyName("ch")] public string Channel { get; set; } = string.Empty; /// /// The timestamp of the update /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// The data of the update /// + [JsonPropertyName("data")] public T Data { get; set; } = default!; - [JsonProperty("tick")] + [JsonInclude, JsonPropertyName("tick")] private T Tick { set => Data = value; get => Data; } } } diff --git a/Huobi.Net/Objects/Models/HuobiAccount.cs b/HTX.Net/Objects/Models/HTXAccount.cs similarity index 55% rename from Huobi.Net/Objects/Models/HuobiAccount.cs rename to HTX.Net/Objects/Models/HTXAccount.cs index 9b2358da..75a32ad8 100644 --- a/Huobi.Net/Objects/Models/HuobiAccount.cs +++ b/HTX.Net/Objects/Models/HTXAccount.cs @@ -1,31 +1,33 @@ -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// - /// Huobi account info + /// HTX account info /// - public record HuobiAccount + public record HTXAccount { /// /// The id of the account /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// The state of the account /// - [JsonConverter(typeof(AccountStateConverter))] - public AccountState State { get; set; } + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("state")] + public AccountStatus Status { get; set; } /// /// The type of the account /// - [JsonConverter(typeof(AccountTypeConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("type")] public AccountType Type { get; set; } /// /// Sub state /// + [JsonPropertyName("subtype")] public string? SubType { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXAccountBalances.cs b/HTX.Net/Objects/Models/HTXAccountBalances.cs new file mode 100644 index 00000000..74f22699 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXAccountBalances.cs @@ -0,0 +1,20 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Account and balance info + /// + public record HTXAccountBalances: HTXAccount + { + /// + /// The list of balances + /// + [JsonPropertyName("list")] + public IEnumerable Data { get; set; } = Array.Empty(); + + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string? Symbol { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/HuobiAccountHistory.cs b/HTX.Net/Objects/Models/HTXAccountHistory.cs similarity index 62% rename from Huobi.Net/Objects/Models/HuobiAccountHistory.cs rename to HTX.Net/Objects/Models/HTXAccountHistory.cs index 42b87a90..c1151334 100644 --- a/Huobi.Net/Objects/Models/HuobiAccountHistory.cs +++ b/HTX.Net/Objects/Models/HTXAccountHistory.cs @@ -1,62 +1,58 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Account history data /// - public record HuobiAccountHistory + public record HTXAccountHistory { /// /// Account ID /// - [JsonProperty("account-id")] + [JsonPropertyName("account-id")] public long AccountId { get; set; } /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Quantity change (positive value if income, negative value if outcome) /// - [JsonProperty("transact-amt")] + [JsonPropertyName("transact-amt")] public decimal Quantity { get; set; } /// /// Blance change types /// - [JsonProperty("transact-type"), JsonConverter(typeof(TransactionTypeConverter))] + [JsonPropertyName("transact-type"), JsonConverter(typeof(EnumConverter))] public TransactionType Type { get; set; } /// /// Available balance /// - [JsonProperty("avail-balance")] + [JsonPropertyName("avail-balance")] public decimal Available { get; set; } /// /// Account balance /// - [JsonProperty("acct-balance")] + [JsonPropertyName("acct-balance")] public decimal Total { get; set; } /// /// Transaction time (database time) /// - [JsonProperty("transact-time"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("transact-time"), JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// Unique record ID in the database /// - [JsonProperty("record-id")] - public string RecordId { get; set; } = string.Empty; + [JsonPropertyName("record-id")] + public long RecordId { get; set; } } } \ No newline at end of file diff --git a/Huobi.Net/Objects/Models/HuobiAccountValuation.cs b/HTX.Net/Objects/Models/HTXAccountValuation.cs similarity index 70% rename from Huobi.Net/Objects/Models/HuobiAccountValuation.cs rename to HTX.Net/Objects/Models/HTXAccountValuation.cs index 50311493..0b322aaf 100644 --- a/Huobi.Net/Objects/Models/HuobiAccountValuation.cs +++ b/HTX.Net/Objects/Models/HTXAccountValuation.cs @@ -1,22 +1,20 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Account valuation /// - public record HuobiAccountValuation + public record HTXAccountValuation { /// /// The balance /// + [JsonPropertyName("balance")] public decimal Balance { get; set; } /// /// Timestamp of the data /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXAggBalance.cs b/HTX.Net/Objects/Models/HTXAggBalance.cs new file mode 100644 index 00000000..7c0cc521 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXAggBalance.cs @@ -0,0 +1,27 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// HTX aggregated sub account balance + /// + public record HTXAggBalance + { + /// + /// The asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// The type of the balance + /// + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("type")] + public AccountType Type { get; set; } + /// + /// The balance + /// + [JsonPropertyName("balance")] + public decimal Balance { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/HTXApiKeyInfo.cs b/HTX.Net/Objects/Models/HTXApiKeyInfo.cs new file mode 100644 index 00000000..40eb7220 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXApiKeyInfo.cs @@ -0,0 +1,53 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// API key info + /// + public record HTXApiKeyInfo + { + /// + /// Access key + /// + [JsonPropertyName("accessKey")] + public string AccessKey { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("status")] + public ApiKeyStatus Status { get; set; } + /// + /// Note + /// + [JsonPropertyName("note")] + public string? Note { get; set; } + /// + /// Permissions + /// + [JsonPropertyName("permission")] + public string Permissions { get; set; } = string.Empty; + /// + /// Ip addresses + /// + [JsonPropertyName("ipAddresses")] + public string IpAddresses { get; set; } = string.Empty; + /// + /// Valid days + /// + [JsonPropertyName("validDays")] + public int ValidDays { get; set; } + /// + /// Create time + /// + [JsonPropertyName("createTime")] + public DateTime CreateTime { get; set; } + /// + /// Update time + /// + [JsonPropertyName("updateTime")] + public DateTime? UpdateTime { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXAsset.cs b/HTX.Net/Objects/Models/HTXAsset.cs new file mode 100644 index 00000000..d99b73eb --- /dev/null +++ b/HTX.Net/Objects/Models/HTXAsset.cs @@ -0,0 +1,143 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Asset information + /// + public record HTXAsset + { + /// + /// Tags + /// + [JsonPropertyName("tags")] + public string? Tags { get; set; } + /// + /// Asset addrress with tag + /// + [JsonPropertyName("cawt")] + public bool AssetAddressTag { get; set; } + /// + /// Fast confirms + /// + [JsonPropertyName("fc")] + public int FastConfirms { get; set; } + /// + /// Safe confirms + /// + [JsonPropertyName("sc")] + public int SafeConfirms { get; set; } + /// + /// Minimal deposit quantity + /// + [JsonPropertyName("dma")] + public decimal DepositMinQuantity { get; set; } + /// + /// Minimal withdrawal quantity + /// + [JsonPropertyName("wma")] + public decimal WithdrawMinQuantity { get; set; } + /// + /// Fee type + /// + [JsonPropertyName("ft")] + public string FeeType { get; set; } = string.Empty; + /// + /// White enabled + /// + [JsonPropertyName("whe")] + public bool WhiteEnabled { get; set; } + /// + /// Country disabled + /// + [JsonPropertyName("cd")] + public bool CountryDisabled { get; set; } + /// + /// Is this a quote asset + /// + [JsonPropertyName("qc")] + public bool IsQuoteAsset { get; set; } + /// + /// Precision for displaying + /// + [JsonPropertyName("sp")] + public decimal DisplayPrecision { get; set; } + /// + /// Precision for withdrawing + /// + [JsonPropertyName("wp")] + public decimal WithdrawPrecision { get; set; } + /// + /// Full asset name + /// + [JsonPropertyName("fn")] + public string FullName { get; set; } = string.Empty; + /// + /// Asset type + /// + [JsonPropertyName("at")] + public AssetType AssetType { get; set; } + /// + /// Asset code + /// + [JsonPropertyName("cc")] + public string AssetCode { get; set; } = string.Empty; + /// + /// Visible + /// + [JsonPropertyName("v")] + public bool Visible { get; set; } + /// + /// Is deposit enabled + /// + [JsonPropertyName("de")] + public bool DepositEnabled { get; set; } + /// + /// Is withdraw enabled + /// + [JsonPropertyName("wed")] + public bool WithdrawEnabled { get; set; } + /// + /// Weight + /// + [JsonPropertyName("w")] + public long Weight { get; set; } + /// + /// Status + /// + [JsonPropertyName("state")] + public string AssetStatus { get; set; } = string.Empty; + /// + /// Display name + /// + [JsonPropertyName("dn")] + public string DisplayName { get; set; } = string.Empty; + /// + /// Info regarding deposits + /// + [JsonPropertyName("dd")] + public string DepositDescription { get; set; } = string.Empty; + /// + /// Suspend description + /// + [JsonPropertyName("svd")] + public string? SuspendDescription { get; set; } + /// + /// Suspend withdraw description + /// + [JsonPropertyName("swd")] + public string? SuspendWithdrawDescription { get; set; } + /// + /// Suspend deposit description + /// + [JsonPropertyName("sdd")] + public string? SuspendDepositDescription { get; set; } + /// + /// Withdrawal description + /// + [JsonPropertyName("wd")] + public string WithdrawDescription { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/HTXAssetNetworks.cs b/HTX.Net/Objects/Models/HTXAssetNetworks.cs new file mode 100644 index 00000000..0877c682 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXAssetNetworks.cs @@ -0,0 +1,140 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Asset info + /// + public record HTXAssetNetworks + { + /// + /// Networks + /// + [JsonPropertyName("chains")] + public IEnumerable Networks { get; set; } = Array.Empty(); + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("instStatus")] + public AssetStatus Status { get; set; } + } + + /// + /// Network info + /// + public record HTXAssetNetwork + { + /// + /// Network + /// + [JsonPropertyName("chain")] + public string Network { get; set; } = string.Empty; + /// + /// Display name + /// + [JsonPropertyName("displayName")] + public string? DisplayName { get; set; } + /// + /// Base network + /// + [JsonPropertyName("baseChain")] + public string BaseNetwork { get; set; } = string.Empty; + /// + /// Base network protocol + /// + [JsonPropertyName("baseChainProtocol")] + public string BaseNetworkProtocol { get; set; } = string.Empty; + /// + /// Is dynamic + /// + [JsonPropertyName("isDynamic")] + public bool IsDynamic { get; set; } + /// + /// Deposit status + /// + [JsonPropertyName("depositStatus")] + public NetworkStatus? DepositStatus { get; set; } + /// + /// Max transact fee withdraw + /// + [JsonPropertyName("maxTransactFeeWithdraw")] + public decimal MaxTransactFeeWithdraw { get; set; } + /// + /// Max withdraw quantity + /// + [JsonPropertyName("maxWithdrawAmt")] + public decimal MaxWithdrawQuantity { get; set; } + /// + /// Min deposit quantity + /// + [JsonPropertyName("minDepositAmt")] + public decimal MinDepositQuantity { get; set; } + /// + /// Fixed withdraw fee, only applicable if fee type is fixed + /// + [JsonPropertyName("transactFeeWithdraw")] + public decimal? FixedWithdrawFee { get; set; } + /// + /// Ratio withdraw fee, only applicable if fee type is ratio + /// + [JsonPropertyName("transactFeeRateWithdraw")] + public decimal? RatioWithdrawFee { get; set; } + /// + /// Min transact fee withdraw + /// + [JsonPropertyName("minTransactFeeWithdraw")] + public decimal MinTransactFeeWithdraw { get; set; } + /// + /// Min withdraw quantity + /// + [JsonPropertyName("minWithdrawAmt")] + public decimal MinWithdrawQuantity { get; set; } + /// + /// Num of confirmations + /// + [JsonPropertyName("numOfConfirmations")] + public int NumOfConfirmations { get; set; } + /// + /// Num of fast confirmations + /// + [JsonPropertyName("numOfFastConfirmations")] + public int NumOfFastConfirmations { get; set; } + /// + /// Withdraw fee type + /// + [JsonPropertyName("withdrawFeeType")] + public FeeType? WithdrawFeeType { get; set; } + /// + /// Withdraw precision + /// + [JsonPropertyName("withdrawPrecision")] + public decimal WithdrawPrecision { get; set; } + /// + /// Withdraw quota per day + /// + [JsonPropertyName("withdrawQuotaPerDay")] + public decimal? WithdrawQuotaPerDay { get; set; } + /// + /// Withdraw quota per year + /// + [JsonPropertyName("withdrawQuotaPerYear")] + public decimal? WithdrawQuotaPerYear { get; set; } + /// + /// Withdraw quota total + /// + [JsonPropertyName("withdrawQuotaTotal")] + public decimal? WithdrawQuotaTotal { get; set; } + /// + /// Withdraw status + /// + [JsonPropertyName("withdrawStatus")] + public NetworkStatus? WithdrawStatus { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/HuobiBalance.cs b/HTX.Net/Objects/Models/HTXBalance.cs similarity index 67% rename from Huobi.Net/Objects/Models/HuobiBalance.cs rename to HTX.Net/Objects/Models/HTXBalance.cs index 6adf4fa9..e90a75a3 100644 --- a/Huobi.Net/Objects/Models/HuobiBalance.cs +++ b/HTX.Net/Objects/Models/HTXBalance.cs @@ -1,32 +1,34 @@ -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; + +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Balance data /// - public record HuobiBalance + public record HTXBalance { /// /// The asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// The type of the balance /// - [JsonConverter(typeof(BalanceTypeConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("type")] public BalanceType Type { get; set; } /// /// The balance /// + [JsonPropertyName("balance")] public decimal Balance { get; set; } /// /// Sequence number of the update /// - [JsonProperty("seq-num")] + [JsonPropertyName("seq-num")] public string SequenceNumber { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/HuobiBalanceWrapper.cs b/HTX.Net/Objects/Models/HTXBalanceWrapper.cs similarity index 69% rename from Huobi.Net/Objects/Models/HuobiBalanceWrapper.cs rename to HTX.Net/Objects/Models/HTXBalanceWrapper.cs index 3b9688e0..e11670c4 100644 --- a/Huobi.Net/Objects/Models/HuobiBalanceWrapper.cs +++ b/HTX.Net/Objects/Models/HTXBalanceWrapper.cs @@ -1,21 +1,24 @@ -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Balance info /// - public record HuobiBalanceWrapper + public record HTXBalanceWrapper { /// /// Asset /// + [JsonPropertyName("asset")] public string Asset { get; set; } = string.Empty; /// /// Frozen /// + [JsonPropertyName("frozen")] public decimal Frozen { get; set; } /// /// Trade /// + [JsonPropertyName("trade")] public decimal Trade { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiBatchCancelResult.cs b/HTX.Net/Objects/Models/HTXBatchCancelResult.cs similarity index 55% rename from Huobi.Net/Objects/Models/HuobiBatchCancelResult.cs rename to HTX.Net/Objects/Models/HTXBatchCancelResult.cs index 446e78e7..75609474 100644 --- a/Huobi.Net/Objects/Models/HuobiBatchCancelResult.cs +++ b/HTX.Net/Objects/Models/HTXBatchCancelResult.cs @@ -1,54 +1,51 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Result of a batch cancel /// - public record HuobiBatchCancelResult + public record HTXBatchCancelResult { /// /// Orders that were successfully canceled /// - [JsonProperty("success")] - public IEnumerable Successful { get; set; } = Array.Empty(); + [JsonPropertyName("success")] + public IEnumerable Successful { get; set; } = Array.Empty(); /// /// Orders that failed to cancel /// - public IEnumerable Failed { get; set; } = Array.Empty(); + [JsonPropertyName("failed")] + public IEnumerable Failed { get; set; } = Array.Empty(); } /// /// Cancel result /// - public record HuobiFailedCancelResult + public record HTXFailedCancelResult { /// /// The error code /// - [JsonProperty("err-code")] + [JsonPropertyName("err-code")] public string? ErrorCode { get; set; } /// /// The error message /// - [JsonProperty("err-msg")] + [JsonPropertyName("err-msg")] public string? ErrorMessage { get; set; } /// /// The id of the failed order /// - [JsonProperty("order-id")] - public long OrderId { get; set; } + [JsonPropertyName("order-id")] + public string OrderId { get; set; } = string.Empty; /// /// The state of the order /// - [JsonProperty("order-state")] - public string? OrderState { get; set; } + [JsonPropertyName("order-state")] + public int? OrderStatus { get; set; } /// /// The id of the failed order /// - [JsonProperty("client-order-id")] + [JsonPropertyName("client-order-id")] public string? ClientOrderId { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXBatchPlaceResult.cs b/HTX.Net/Objects/Models/HTXBatchPlaceResult.cs new file mode 100644 index 00000000..acd8c7b4 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXBatchPlaceResult.cs @@ -0,0 +1,33 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Batch placement result + /// + public record HTXBatchPlaceResult + { + /// + /// Order id + /// + [JsonPropertyName("order-id")] + public long? OrderId { get; set; } + /// + /// Client order id + /// + [JsonPropertyName("client-order-id")] + public string? ClientOrderId { get; set; } + /// + /// Whether the placement was successful + /// + public bool Success => ErrorCode == null; + /// + /// The error code + /// + [JsonPropertyName("err-code")] + public string? ErrorCode { get; set; } + /// + /// The error message + /// + [JsonPropertyName("err-msg")] + public string? ErrorMessage { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/HuobiBestOffer.cs b/HTX.Net/Objects/Models/HTXBestOffer.cs similarity index 75% rename from Huobi.Net/Objects/Models/HuobiBestOffer.cs rename to HTX.Net/Objects/Models/HTXBestOffer.cs index d63e5a41..5a31d632 100644 --- a/Huobi.Net/Objects/Models/HuobiBestOffer.cs +++ b/HTX.Net/Objects/Models/HTXBestOffer.cs @@ -1,47 +1,45 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Info on a symbol's best offer /// - public record HuobiBestOffer + public record HTXBestOffer { /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Time of the data /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("quoteTime")] public DateTime QuoteTime { get; set; } /// /// Best bid price /// - [JsonProperty("bid")] + [JsonPropertyName("bid")] public decimal BestBidPrice { get; set; } /// /// Quantity of the best bid /// - [JsonProperty("bidSize")] + [JsonPropertyName("bidSize")] public decimal BestBidQuantity { get; set; } /// /// Best ask price /// - [JsonProperty("ask")] + [JsonPropertyName("ask")] public decimal BestAskPrice { get; set; } /// /// Quantity of the best ask /// - [JsonProperty("askSize")] + [JsonPropertyName("askSize")] public decimal BestAskQuantity { get; set; } /// /// Sequence number /// - [JsonProperty("seqId")] + [JsonPropertyName("seqId")] public long Sequence { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiByCriteriaCancelResult.cs b/HTX.Net/Objects/Models/HTXByCriteriaCancelResult.cs similarity index 68% rename from Huobi.Net/Objects/Models/HuobiByCriteriaCancelResult.cs rename to HTX.Net/Objects/Models/HTXByCriteriaCancelResult.cs index 6f608e5a..319d88ca 100644 --- a/Huobi.Net/Objects/Models/HuobiByCriteriaCancelResult.cs +++ b/HTX.Net/Objects/Models/HTXByCriteriaCancelResult.cs @@ -1,26 +1,26 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Result of Cancel Orders by Criteria /// - public record HuobiByCriteriaCancelResult + public record HTXByCriteriaCancelResult { /// /// The number of cancel request sent successfully /// - [JsonProperty("success-count")] + [JsonPropertyName("success-count")] public long Successful { get; set; } /// /// The number of cancel request failed /// - [JsonProperty("failed-count")] + [JsonPropertyName("failed-count")] public long Failed { get; set; } /// /// the next order id that can be canceled /// - [JsonProperty("next-id")] + [JsonPropertyName("next-id")] public long NextId { get; set; } } } \ No newline at end of file diff --git a/Huobi.Net/Objects/Models/HuobiConditionalOrder.cs b/HTX.Net/Objects/Models/HTXConditionalOrder.cs similarity index 75% rename from Huobi.Net/Objects/Models/HuobiConditionalOrder.cs rename to HTX.Net/Objects/Models/HTXConditionalOrder.cs index 26bd1c22..7c0f1e6f 100644 --- a/Huobi.Net/Objects/Models/HuobiConditionalOrder.cs +++ b/HTX.Net/Objects/Models/HTXConditionalOrder.cs @@ -1,102 +1,107 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Conditional order info /// - public record HuobiConditionalOrder + public record HTXConditionalOrder { /// /// Acount id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Source /// + [JsonPropertyName("source")] public string Source { get; set; } = string.Empty; /// /// Order id /// + [JsonPropertyName("orderId")] public string? OrderId { get; set; } /// /// Client order id /// + [JsonPropertyName("clientOrderId")] public string ClientOrderId { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Price /// - [JsonProperty("orderPrice")] + [JsonPropertyName("orderPrice")] public decimal? Price { get; set; } /// /// Quantity /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal? Quantity { get; set; } /// /// Quote quantity /// - [JsonProperty("orderValue")] + [JsonPropertyName("orderValue")] public decimal? QuoteQuantity { get; set; } /// /// Side /// - [JsonProperty("orderSide")] + [JsonPropertyName("orderSide")] [JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// Time in force /// [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("timeInForce")] public TimeInForce TimeInForce { get; set; } /// /// Type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("orderType")] + [JsonPropertyName("orderType")] public ConditionalOrderType Type { get; set; } /// /// Stop price /// + [JsonPropertyName("stopPrice")] public decimal StopPrice { get; set; } /// /// Trailing rate /// + [JsonPropertyName("trailingRate")] public decimal? TrailingRate { get; set; } /// /// Creation time /// - [JsonProperty("orderOrigTime")] + [JsonPropertyName("orderOrigTime")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Last update time /// - [JsonProperty("lastActTime")] + [JsonPropertyName("lastActTime")] [JsonConverter(typeof(DateTimeConverter))] public DateTime UpdateTime { get; set; } /// /// Status /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("orderStatus")] + [JsonPropertyName("orderStatus")] public ConditionalOrderStatus Status { get; set; } /// /// Error code if the conditional order is rejected /// - [JsonProperty("errCode")] + [JsonPropertyName("errCode")] public int? ErrorCode { get; set; } /// /// Error message if conditional order is rejected /// - [JsonProperty("errMessage")] + [JsonPropertyName("errMessage")] public string? ErrorMessage { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiConditionalOrderCancelResult.cs b/HTX.Net/Objects/Models/HTXConditionalOrderCancelResult.cs similarity index 72% rename from Huobi.Net/Objects/Models/HuobiConditionalOrderCancelResult.cs rename to HTX.Net/Objects/Models/HTXConditionalOrderCancelResult.cs index e901ca25..cb1f7bbb 100644 --- a/Huobi.Net/Objects/Models/HuobiConditionalOrderCancelResult.cs +++ b/HTX.Net/Objects/Models/HTXConditionalOrderCancelResult.cs @@ -1,20 +1,19 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Conditional order cancelation result /// - public record HuobiConditionalOrderCancelResult + public record HTXConditionalOrderCancelResult { /// /// Orders accepted for cancelation /// + [JsonPropertyName("accepted")] public IEnumerable Accepted { get; set; } = Array.Empty(); /// /// Orders rejected for cancelation /// + [JsonPropertyName("rejected")] public IEnumerable Rejected { get; set; } = Array.Empty(); } } diff --git a/HTX.Net/Objects/Models/HTXDeductInfo.cs b/HTX.Net/Objects/Models/HTXDeductInfo.cs new file mode 100644 index 00000000..0c9e9647 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXDeductInfo.cs @@ -0,0 +1,26 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Deduction info + /// + public record HTXDeductInfo + { + /// + /// Point switch + /// + [JsonPropertyName("pointSwitch")] + public bool PointSwitch { get; set; } + /// + /// Htx switch + /// + [JsonPropertyName("htxSwitch")] + public bool HtxSwitch { get; set; } + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/HTXDeductionAssets.cs b/HTX.Net/Objects/Models/HTXDeductionAssets.cs new file mode 100644 index 00000000..e3d72805 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXDeductionAssets.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// + /// + public record HTXDeductionAssets + { + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Assets { get; set; } = string.Empty; + } +} diff --git a/Huobi.Net/Objects/Models/HuobiDepositAddress.cs b/HTX.Net/Objects/Models/HTXDepositAddress.cs similarity index 73% rename from Huobi.Net/Objects/Models/HuobiDepositAddress.cs rename to HTX.Net/Objects/Models/HTXDepositAddress.cs index 82976193..3d61bb56 100644 --- a/Huobi.Net/Objects/Models/HuobiDepositAddress.cs +++ b/HTX.Net/Objects/Models/HTXDepositAddress.cs @@ -1,33 +1,36 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Deposit address info /// - public record HuobiDepositAddress + public record HTXDepositAddress { /// /// User id /// + [JsonPropertyName("userId")] public long UserId { get; set; } /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Deposit address /// + [JsonPropertyName("address")] public string Address { get; set; } = string.Empty; /// /// Deposit address tag /// + [JsonPropertyName("addressTag")] public string AddressTag { get; set; } = string.Empty; /// /// Block chain name /// - [JsonProperty("chain")] + [JsonPropertyName("chain")] public string Network { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/HuobiFeeRate.cs b/HTX.Net/Objects/Models/HTXFeeRate.cs similarity index 73% rename from Huobi.Net/Objects/Models/HuobiFeeRate.cs rename to HTX.Net/Objects/Models/HTXFeeRate.cs index d1a1357a..1a383cbf 100644 --- a/Huobi.Net/Objects/Models/HuobiFeeRate.cs +++ b/HTX.Net/Objects/Models/HTXFeeRate.cs @@ -1,33 +1,38 @@ -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Current transaction fee rate applied to the user /// - public record HuobiFeeRate + public record HTXFeeRate { /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; - + /// /// Basic fee rate – passive side /// + [JsonPropertyName("actualMakerRate")] public decimal ActualMakerRate { get; set; } - + /// /// Basic fee rate – aggressive side /// + [JsonPropertyName("actualTakerRate")] public decimal ActualTakerRate { get; set; } - + /// /// Deducted fee rate – passive side /// + [JsonPropertyName("makerFeeRate")] public decimal MakerFeeRate { get; set; } - + /// /// Basic fee rate – aggressive side /// + [JsonPropertyName("takerFeeRate")] public decimal TakerFeeRate { get; set; } } } \ No newline at end of file diff --git a/Huobi.Net/Objects/Models/HuobiLedgerEntry.cs b/HTX.Net/Objects/Models/HTXLedgerEntry.cs similarity index 72% rename from Huobi.Net/Objects/Models/HuobiLedgerEntry.cs rename to HTX.Net/Objects/Models/HTXLedgerEntry.cs index cc67f4aa..ca56f4e3 100644 --- a/Huobi.Net/Objects/Models/HuobiLedgerEntry.cs +++ b/HTX.Net/Objects/Models/HTXLedgerEntry.cs @@ -1,58 +1,60 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Ledger entry /// - public record HuobiLedgerEntry + public record HTXLedgerEntry { /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Quantity of the transaction /// - [JsonProperty("transactAmt")] + [JsonPropertyName("transactAmt")] public decimal TransactionQuantity { get; set; } /// /// Type of transaction /// - [JsonProperty("transactType")] + [JsonPropertyName("transactType")] public TransactionType TransactionType { get; set; } /// /// Type of transfer /// + [JsonPropertyName("transferType")] public string TransferType { get; set; } = string.Empty; /// /// Transaction id /// - [JsonProperty("transactId")] + [JsonPropertyName("transactId")] public long TransactionId { get; set; } /// /// Transaction time /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("transactTime")] + [JsonPropertyName("transactTime")] public DateTime TransactionTime { get; set; } /// /// Transferer /// + [JsonPropertyName("transferer")] public long Transferer { get; set; } /// /// Transferee /// + [JsonPropertyName("transferee")] public long Transferee { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiLoanInfo.cs b/HTX.Net/Objects/Models/HTXLoanInfo.cs similarity index 66% rename from Huobi.Net/Objects/Models/HuobiLoanInfo.cs rename to HTX.Net/Objects/Models/HTXLoanInfo.cs index 20dfc924..bec70cd2 100644 --- a/Huobi.Net/Objects/Models/HuobiLoanInfo.cs +++ b/HTX.Net/Objects/Models/HTXLoanInfo.cs @@ -1,59 +1,56 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Loan info /// - public record HuobiLoanInfo + public record HTXLoanInfo { /// /// Symbol name /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Currencies /// - [JsonProperty("currencies")] - public IEnumerable Assets { get; set; } = Array.Empty(); + [JsonPropertyName("currencies")] + public IEnumerable Assets { get; set; } = Array.Empty(); } /// /// Asset info /// - public record HuobiLoanInfoAsset + public record HTXLoanInfoAsset { /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Interest rate /// - [JsonProperty("interest-rate")] + [JsonPropertyName("interest-rate")] public decimal InterestRate { get; set; } /// /// Minimal loan quantity /// - [JsonProperty("min-loan-amt")] + [JsonPropertyName("min-loan-amt")] public decimal MinLoanQuantity { get; set; } /// /// Maximal loan quantity /// - [JsonProperty("max-loan-amt")] + [JsonPropertyName("max-loan-amt")] public decimal MaxLoanQuantity { get; set; } /// /// Remaining loanable quantity /// - [JsonProperty("loanable-amt")] + [JsonPropertyName("loanable-amt")] public decimal LoanableQuantity { get; set; } /// /// Actual interest rate /// - [JsonProperty("actual-rate")] + [JsonPropertyName("actual-rate")] public decimal ActualRate { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiMarginBalances.cs b/HTX.Net/Objects/Models/HTXMarginBalances.cs similarity index 65% rename from Huobi.Net/Objects/Models/HuobiMarginBalances.cs rename to HTX.Net/Objects/Models/HTXMarginBalances.cs index e57fe29d..e88ef432 100644 --- a/Huobi.Net/Objects/Models/HuobiMarginBalances.cs +++ b/HTX.Net/Objects/Models/HTXMarginBalances.cs @@ -1,81 +1,84 @@ -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Margin account balance /// - public record HuobiMarginBalances + public record HTXMarginBalances { /// /// Id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Type /// + [JsonPropertyName("type")] public string Type { get; set; } = string.Empty; /// /// Symbol /// + [JsonPropertyName("symbol")] public string? Symbol { get; set; } /// - /// State + /// Status /// - public string State { get; set; } = string.Empty; + [JsonPropertyName("state")] + public string Status { get; set; } = string.Empty; /// /// Risk rate /// - [JsonProperty("risk-rate")] + [JsonPropertyName("risk-rate")] public decimal RiskRate { get; set; } /// /// Account balance sum /// - [JsonProperty("acct-balance-sum")] + [JsonPropertyName("acct-balance-sum")] public decimal? AccountBalanceSum { get; set; } /// /// Debt balance sum /// - [JsonProperty("debt-balance-sum")] + [JsonPropertyName("debt-balance-sum")] public decimal? DebtBalanceSum { get; set; } /// /// The price which margin closeout was triggered /// - [JsonProperty("fl-price")] + [JsonPropertyName("fl-price")] public decimal? FlPrice { get; set; } /// /// Fl type /// - [JsonProperty("fl-type")] + [JsonPropertyName("fl-type")] public string? FlType { get; set; } = string.Empty; /// /// Account details /// - public IEnumerable List { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable List { get; set; } = Array.Empty(); } /// /// Balance info /// - public record HuobiIsolatedBalance + public record HTXIsolatedBalance { /// /// The asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Balance type /// - [JsonConverter(typeof(BalanceTypeConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("type")] public BalanceType Type { get; set; } /// /// Balance /// + [JsonPropertyName("balance")] public decimal Balance { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiMarginOrder.cs b/HTX.Net/Objects/Models/HTXMarginOrder.cs similarity index 71% rename from Huobi.Net/Objects/Models/HuobiMarginOrder.cs rename to HTX.Net/Objects/Models/HTXMarginOrder.cs index 5fc3cb7f..d5d510b0 100644 --- a/Huobi.Net/Objects/Models/HuobiMarginOrder.cs +++ b/HTX.Net/Objects/Models/HTXMarginOrder.cs @@ -1,130 +1,130 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Margin order info /// - public record HuobiMarginOrder + public record HTXMarginOrder { /// /// Order id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Account id /// - [JsonProperty("account-id")] + [JsonPropertyName("account-id")] public long AccountId { get; set; } /// /// User id /// - [JsonProperty("user-id")] + [JsonPropertyName("user-id")] public long UserId { get; set; } /// /// Symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Creation time /// - [JsonProperty("created-at")] + [JsonPropertyName("created-at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Accrue time /// - [JsonProperty("accrued-at")] + [JsonPropertyName("accrued-at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? AccrueTime { get; set; } /// /// Loan quantity /// - [JsonProperty("loan-amount")] + [JsonPropertyName("loan-amount")] public decimal LoanQuantity { get; set; } /// /// Loan balance left /// - [JsonProperty("loan-balance")] + [JsonPropertyName("loan-balance")] public decimal LoanBalance { get; set; } /// /// Interst rate /// - [JsonProperty("interest-rate")] + [JsonPropertyName("interest-rate")] public decimal? InterestRate { get; set; } /// /// Interest quantity /// - [JsonProperty("interest-amount")] + [JsonPropertyName("interest-amount")] public decimal InterestQuantity { get; set; } /// /// Interest left /// - [JsonProperty("interest-balance")] + [JsonPropertyName("interest-balance")] public decimal InterestBalance { get; set; } /// /// State /// [JsonConverter(typeof(EnumConverter))] - public MarginOrderStatus State { get; set; } + [JsonPropertyName("state")] + public MarginOrderStatus Status { get; set; } /// - /// Paid Huobi points + /// Paid HTX points /// - [JsonProperty("paid-point")] + [JsonPropertyName("paid-point")] public decimal PaidPoints { get; set; } /// /// Paid asset /// - [JsonProperty("paid-coin")] + [JsonPropertyName("paid-coin")] public decimal PaidAsset { get; set; } /// - /// Filled Huobi points + /// Filled HTX points /// - [JsonProperty("filled-points")] + [JsonPropertyName("filled-points")] public decimal FilledPoints { get; set; } /// /// HT deduction amount /// - [JsonProperty("filled-ht")] + [JsonPropertyName("filled-ht")] public decimal FilledHt { get; set; } /// /// Deduct rate /// - [JsonProperty("deduct-rate")] + [JsonPropertyName("deduct-rate")] public decimal? DeductRate { get; set; } /// /// Deduct asset /// - [JsonProperty("deduct-currency")] + [JsonPropertyName("deduct-currency")] public string? DeductAsset { get; set; } /// /// Deduct quantity /// - [JsonProperty("deduct-amount")] + [JsonPropertyName("deduct-amount")] public decimal? DeductQuantity { get; set; } /// /// Last updated /// - [JsonProperty("updated-at")] + [JsonPropertyName("updated-at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? UpdateTime { get; set; } /// /// Hourly interest rate /// - [JsonProperty("hour-interest-rate")] + [JsonPropertyName("hour-interest-rate")] public decimal? HourInterestRate { get; set; } /// /// Daily interest rate /// - [JsonProperty("day-interest-rate")] + [JsonPropertyName("day-interest-rate")] public decimal? DayInterestRate { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXMaxHolding.cs b/HTX.Net/Objects/Models/HTXMaxHolding.cs new file mode 100644 index 00000000..40d5bac6 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXMaxHolding.cs @@ -0,0 +1,21 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Max holdings + /// + public record HTXMaxHolding + { + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// Max holdings + /// + [JsonPropertyName("max-holdings")] + public decimal MaxHoldings { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/HuobiNav.cs b/HTX.Net/Objects/Models/HTXNav.cs similarity index 69% rename from Huobi.Net/Objects/Models/HuobiNav.cs rename to HTX.Net/Objects/Models/HTXNav.cs index cdfe380c..013fdb3e 100644 --- a/Huobi.Net/Objects/Models/HuobiNav.cs +++ b/HTX.Net/Objects/Models/HTXNav.cs @@ -1,55 +1,57 @@ -using System; -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// NAV info for ETP /// - public record HuobiNav + public record HTXNav { /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Latest Nav /// + [JsonPropertyName("nav")] public decimal Nav { get; set; } /// /// Update time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("navTime")] public DateTime NavTime { get; set; } /// /// Outstanding shares /// + [JsonPropertyName("outstanding")] public decimal Outstanding { get; set; } /// /// Baskets /// - public IEnumerable Basket { get; set; } = Array.Empty(); + [JsonPropertyName("basket")] + public IEnumerable Basket { get; set; } = Array.Empty(); /// /// Actual leverage ratio /// + [JsonPropertyName("actualLeverage")] public decimal ActualLeverage { get; set; } } /// /// Basket /// - public record HuobiBasket + public record HTXBasket { /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Amount /// + [JsonPropertyName("amount")] public decimal Amount { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiOpenOrder.cs b/HTX.Net/Objects/Models/HTXOpenOrder.cs similarity index 59% rename from Huobi.Net/Objects/Models/HuobiOpenOrder.cs rename to HTX.Net/Objects/Models/HTXOpenOrder.cs index 95358259..9e7d4786 100644 --- a/Huobi.Net/Objects/Models/HuobiOpenOrder.cs +++ b/HTX.Net/Objects/Models/HTXOpenOrder.cs @@ -1,108 +1,109 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Open order /// - public record HuobiOpenOrder + public record HTXOpenOrder { /// /// The id of the order /// - [JsonProperty("id")] + [JsonPropertyName("id")] public long Id { get; set; } /// /// The order id as specified by the client /// - [JsonProperty("client-order-id")] - public string ClientOrderId { get; set; } = string.Empty; + [JsonPropertyName("client-order-id")] + public string? ClientOrderId { get; set; } /// /// The symbol of the order /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// The id of the account that placed the order /// - [JsonProperty("account-id")] + [JsonPropertyName("account-id")] public long AccountId { get; set; } /// /// The quantity of the order /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Quantity { get; set; } /// /// The price of the order /// - [JsonProperty("price")] + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// The time the order was created /// - [JsonProperty("created-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("created-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// The time the order was canceled /// - [JsonProperty("canceled-at"), JsonConverter(typeof(DateTimeConverter))] - public DateTime CancelTime { get; set; } + [JsonPropertyName("canceled-at"), JsonConverter(typeof(DateTimeConverter))] + public DateTime? CancelTime { get; set; } /// /// The time the order was completed /// - [JsonProperty("finished-at"), JsonConverter(typeof(DateTimeConverter))] - public DateTime CompleteTime { get; set; } + [JsonPropertyName("finished-at"), JsonConverter(typeof(DateTimeConverter))] + public DateTime? CompleteTime { get; set; } - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); /// - /// The type of the order + /// The side of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// The source of the order /// - [JsonProperty("source")] + [JsonPropertyName("source")] public string Source { get; set; } = string.Empty; /// /// The state of the order /// - [JsonProperty("state"), JsonConverter(typeof(OrderStateConverter))] - public OrderState State { get; set; } + [JsonPropertyName("state"), JsonConverter(typeof(EnumConverter))] + public OrderStatus Status { get; set; } /// /// The quantity of the order that is filled /// - [JsonProperty("filled-amount")] + [JsonPropertyName("filled-amount")] public decimal QuantityFilled { get; set; } /// /// Filled cash quantity /// - [JsonProperty("filled-cash-amount")] + [JsonPropertyName("filled-cash-amount")] public decimal QuoteQuantityFilled { get; set; } /// /// The quantity of fees paid for the filled quantity /// - [JsonProperty("filled-fees")] + [JsonPropertyName("filled-fees")] public decimal Fee { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiOrder.cs b/HTX.Net/Objects/Models/HTXOrder.cs similarity index 62% rename from Huobi.Net/Objects/Models/HuobiOrder.cs rename to HTX.Net/Objects/Models/HTXOrder.cs index 2e00ae4a..4c8734bf 100644 --- a/Huobi.Net/Objects/Models/HuobiOrder.cs +++ b/HTX.Net/Objects/Models/HTXOrder.cs @@ -1,108 +1,114 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Order info /// - public record HuobiOrder + public record HTXOrder { /// /// The id of the order /// - [JsonProperty("id")] + [JsonPropertyName("id")] public long Id { get; set; } /// /// The order id as specified by the client /// - [JsonProperty("client-order-id")] + [JsonPropertyName("client-order-id")] public string ClientOrderId { get; set; } = string.Empty; /// /// The symbol of the order /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// The id of the account that placed the order /// - [JsonProperty("account-id")] + [JsonPropertyName("account-id")] public long AccountId { get; set; } /// /// The quantity of the order /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Quantity { get; set; } /// /// The price of the order /// - [JsonProperty("price")] + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// The time the order was created /// - [JsonProperty("created-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("created-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// The time the order was canceled /// - [JsonProperty("canceled-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("canceled-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime CancelTime { get; set; } /// /// The time the order was finished /// - [JsonProperty("finished-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("finished-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime CompleteTime { get; set; } - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); /// /// The side of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// The source of the order /// - [JsonProperty("source")] + [JsonPropertyName("source")] public string Source { get; set; } = string.Empty; /// /// The state of the order /// - [JsonProperty("state"), JsonConverter(typeof(OrderStateConverter))] - public OrderState State { get; set; } + [JsonPropertyName("state"), JsonConverter(typeof(EnumConverter))] + public OrderStatus Status { get; set; } /// /// The quantity of the order that is filled /// - [JsonProperty("field-amount")] + [JsonPropertyName("field-amount")] public decimal QuantityFilled { get; set; } /// /// Filled cash quantity /// - [JsonProperty("field-cash-amount")] + [JsonPropertyName("field-cash-amount")] public decimal QuoteQuantityFilled { get; set; } /// /// The quantity of fees paid for the filled quantity /// - [JsonProperty("field-fees")] + [JsonPropertyName("field-fees")] public decimal Fee { get; set; } + + /// + /// Source of cancelation + /// + [JsonPropertyName("canceled-source")] + public string? CancelSource { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXOrderBook.cs b/HTX.Net/Objects/Models/HTXOrderBook.cs new file mode 100644 index 00000000..c3baa466 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXOrderBook.cs @@ -0,0 +1,63 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Order book + /// + public record HTXOrderBook + { + /// + /// Timestamp + /// + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] + public DateTime Timestamp { get; set; } + /// + /// Version + /// + [JsonPropertyName("version")] + public long Version { get; set; } + [JsonInclude, JsonPropertyName("seqNum")] + internal long SequenceNumber + { + get => Version; + set => Version = value; + } + + /// + /// List of bids + /// + [JsonPropertyName("bids")] + public IEnumerable Bids { get; set; } = Array.Empty(); + /// + /// List of asks + /// + [JsonPropertyName("asks")] + public IEnumerable Asks { get; set; } = Array.Empty(); + } + + /// + /// Incremental order book update + /// + public record HTXIncementalOrderBook + { + /// + /// Sequence number + /// + [JsonPropertyName("seqNum")] + public long SequenceNumber { get; set; } + /// + /// Previous sequence number + /// + [JsonPropertyName("prevSeqNum")] + public long? PreviousSequenceNumber { get; set; } + /// + /// List of changed bids + /// + [JsonPropertyName("bids")] + public IEnumerable Bids { get; set; } = Array.Empty(); + /// + /// List of changed asks + /// + [JsonPropertyName("asks")] + public IEnumerable Asks { get; set; } = Array.Empty(); + } +} diff --git a/HTX.Net/Objects/Models/HTXOrderId.cs b/HTX.Net/Objects/Models/HTXOrderId.cs new file mode 100644 index 00000000..294ba3dd --- /dev/null +++ b/HTX.Net/Objects/Models/HTXOrderId.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Order id + /// + public record HTXOrderId + { + /// + /// Order id + /// + [JsonPropertyName("order-id")] + public long OrderId { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/HTXOrderRequest.cs b/HTX.Net/Objects/Models/HTXOrderRequest.cs new file mode 100644 index 00000000..54901126 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXOrderRequest.cs @@ -0,0 +1,51 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Order request + /// + public record HTXOrderRequest + { + /// + /// Account id + /// + public string AccountId { get; set; } = string.Empty; + /// + /// Symbol + /// + public string Symbol { get; set; } = string.Empty; + /// + /// Order side + /// + public OrderSide Side { get; set; } + /// + /// Order type + /// + public OrderType Type { get; set; } + /// + /// Order quantity. For Buy Market orders this is in quote asset. + /// + public decimal Quantity { get; set; } + /// + /// Limit price + /// + public decimal? Price { get; set; } + /// + /// Order source + /// + public SourceType? Source { get; set; } + /// + /// Client order id + /// + public string? ClientOrderId { get; set; } + /// + /// Stop price + /// + public decimal? StopPrice { get; set; } + /// + /// Stop operator + /// + public Operator? StopOperator { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/HuobiOrderTrade.cs b/HTX.Net/Objects/Models/HTXOrderTrade.cs similarity index 68% rename from Huobi.Net/Objects/Models/HuobiOrderTrade.cs rename to HTX.Net/Objects/Models/HTXOrderTrade.cs index 1ae73a19..5a9aafbe 100644 --- a/Huobi.Net/Objects/Models/HuobiOrderTrade.cs +++ b/HTX.Net/Objects/Models/HTXOrderTrade.cs @@ -1,98 +1,105 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Trade info /// - public record HuobiOrderTrade + public record HTXOrderTrade { /// /// The id of the trade /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// The symbol of the trade /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// The timestamp in milliseconds when this record is created /// - [JsonProperty("created-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("created-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// The quantity which has been filled /// - [JsonProperty("filled-amount")] + [JsonPropertyName("filled-amount")] public decimal Quantity { get; set; } /// /// Transaction fee (positive value). If maker rebate applicable, revert maker rebate value per trade (negative value). /// - [JsonProperty("filled-fees")] + [JsonPropertyName("filled-fees")] public decimal Fee { get; set; } /// /// Deduction amount (unit: in ht or hbpoint). /// - [JsonProperty("filled-points")] + [JsonPropertyName("filled-points")] public decimal FilledPoints { get; set; } /// /// The id of the trade /// - [JsonProperty("trade-id")] + [JsonPropertyName("trade-id")] public long TradeId { get; set; } /// /// The id of the match /// - [JsonProperty("match-id")] + [JsonPropertyName("match-id")] public long MatchId { get; set; } /// /// The id of the order /// - [JsonProperty("order-id")] + [JsonPropertyName("order-id")] public long OrderId { get; set; } /// /// The limit price of limit order /// + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// The source where the order was triggered, possible values: sys, web, api, app /// + [JsonPropertyName("source")] public string Source { get; set; } = string.Empty; - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; + /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); + /// /// The side of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// The role in the transaction: taker or maker /// - [JsonProperty("role"), JsonConverter(typeof(OrderRoleConverter))] + [JsonPropertyName("role"), JsonConverter(typeof(EnumConverter))] public OrderRole Role { get; set; } /// /// Asset of transaction fee or transaction fee rebate (transaction fee of buy order is based on base asset, transaction fee of sell order is based on quote asset; transaction fee rebate of buy order is based on quote asset, transaction fee rebate of sell order is based on base asset) /// - [JsonProperty("fee-currency")] + [JsonPropertyName("fee-currency")] public string FeeAsset { get; set; } = string.Empty; /// /// Deduction type: ht or hbpoint. /// - [JsonProperty("fee-deduct-currency")] + [JsonPropertyName("fee-deduct-currency")] public string FeeDeductAsset { get; set; } = string.Empty; /// /// Fee deduction status. /// - [JsonProperty("fee-deduct-state"), JsonConverter(typeof(FeeDeductStateConverter))] - public FeeDeductState FeeDeductState { get; set; } + [JsonPropertyName("fee-deduct-state"), JsonConverter(typeof(EnumConverter))] + public FeeDeductStatus FeeDeductStatus { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiOrders.cs b/HTX.Net/Objects/Models/HTXOrders.cs similarity index 55% rename from Huobi.Net/Objects/Models/HuobiOrders.cs rename to HTX.Net/Objects/Models/HTXOrders.cs index 72c9898c..f4775437 100644 --- a/Huobi.Net/Objects/Models/HuobiOrders.cs +++ b/HTX.Net/Objects/Models/HTXOrders.cs @@ -1,20 +1,19 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Orders info /// - public record HuobiOrders + public record HTXOrders { /// /// Timestamp for pagination /// + [JsonPropertyName("nextTime")] public DateTime NextTime { get; set; } /// /// List of ticks for symbols /// - public IEnumerable Orders { get; set; } = Array.Empty(); + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); } } diff --git a/Huobi.Net/Objects/Models/HuobiPlacedConditionalOrder.cs b/HTX.Net/Objects/Models/HTXPlacedConditionalOrder.cs similarity index 63% rename from Huobi.Net/Objects/Models/HuobiPlacedConditionalOrder.cs rename to HTX.Net/Objects/Models/HTXPlacedConditionalOrder.cs index 39a8b6d6..e3a18551 100644 --- a/Huobi.Net/Objects/Models/HuobiPlacedConditionalOrder.cs +++ b/HTX.Net/Objects/Models/HTXPlacedConditionalOrder.cs @@ -1,13 +1,14 @@ -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Placed conditional order /// - public record HuobiPlacedConditionalOrder + public record HTXPlacedConditionalOrder { /// /// The id /// + [JsonPropertyName("clientOrderId")] public string ClientOrderId { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/HuobiPlacedOrder.cs b/HTX.Net/Objects/Models/HTXPlacedOrder.cs similarity index 63% rename from Huobi.Net/Objects/Models/HuobiPlacedOrder.cs rename to HTX.Net/Objects/Models/HTXPlacedOrder.cs index af9181cf..7402af1b 100644 --- a/Huobi.Net/Objects/Models/HuobiPlacedOrder.cs +++ b/HTX.Net/Objects/Models/HTXPlacedOrder.cs @@ -1,13 +1,14 @@ -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Placed order /// - public record HuobiPlacedOrder + public record HTXPlacedOrder { /// /// The id /// + [JsonPropertyName("id")] public long Id { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXPlatformValuation.cs b/HTX.Net/Objects/Models/HTXPlatformValuation.cs new file mode 100644 index 00000000..27c28ef4 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXPlatformValuation.cs @@ -0,0 +1,82 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Platform wide valuation + /// + public record HTXPlatformValuation + { + /// + /// Updated + /// + [JsonPropertyName("updated")] + public HTXPlatformValuationUpdate Updated { get; set; } = null!; + /// + /// Today profit rate + /// + [JsonPropertyName("todayProfitRate")] + public decimal? TodayProfitRate { get; set; } + /// + /// Total balance + /// + [JsonPropertyName("totalBalance")] + public decimal TotalBalance { get; set; } + /// + /// Todays profit + /// + [JsonPropertyName("todayProfit")] + public decimal? TodayProfit { get; set; } + /// + /// Account balance list + /// + [JsonPropertyName("profitAccountBalanceList")] + public IEnumerable Balances { get; set; } = Array.Empty(); + } + + /// + /// + /// + public record HTXPlatformValuationUpdate + { + /// + /// Success + /// + [JsonPropertyName("success")] + public bool Success { get; set; } + /// + /// Last update time + /// + [JsonPropertyName("time")] + public DateTime? UpdateTime { get; set; } + } + + /// + /// + /// + public record HTXPlatformValuationBalance + { + /// + /// Balance type + /// + [JsonPropertyName("distributionType")] + public ValuationBalanceType? BalanceType { get; set; } + /// + /// Balance + /// + [JsonPropertyName("balance")] + public decimal Balance { get; set; } + /// + /// Success + /// + [JsonPropertyName("success")] + public bool Success { get; set; } + /// + /// Account balance + /// + [JsonPropertyName("accountBalance")] + public decimal AccountBalance { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXPointBalance.cs b/HTX.Net/Objects/Models/HTXPointBalance.cs new file mode 100644 index 00000000..cb3bf657 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXPointBalance.cs @@ -0,0 +1,55 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Point balance + /// + public record HTXPointBalance + { + /// + /// Account id + /// + [JsonPropertyName("accountId")] + public string AccountId { get; set; } = string.Empty; + /// + /// Group ids + /// + [JsonPropertyName("groupIds")] + public IEnumerable GroupIds { get; set; } = Array.Empty(); + /// + /// Accountt balance + /// + [JsonPropertyName("acctBalance")] + public decimal AccountBalance { get; set; } + /// + /// Account status + /// + [JsonPropertyName("accountStatus")] + public PointAccountStatus AccountStatus { get; set; } + } + + /// + /// Group info + /// + public record HTXPointBalanceGroup + { + /// + /// Group id + /// + [JsonPropertyName("groupId")] + public long GroupId { get; set; } + /// + /// Expiry date + /// + [JsonPropertyName("expiryDate")] + public DateTime? ExpiryDate { get; set; } + /// + /// Remaining quantity + /// + [JsonPropertyName("remainAmt")] + public decimal RemainingQuantity { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXPointTransfer.cs b/HTX.Net/Objects/Models/HTXPointTransfer.cs new file mode 100644 index 00000000..2d69c9cc --- /dev/null +++ b/HTX.Net/Objects/Models/HTXPointTransfer.cs @@ -0,0 +1,21 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Transfer result + /// + public record HTXPointTransfer + { + /// + /// Transact id + /// + [JsonPropertyName("transactId")] + public string TransactId { get; set; } = string.Empty; + /// + /// Transact time + /// + [JsonPropertyName("transactTime")] + public DateTime? TransactTime { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/HuobiRepayment.cs b/HTX.Net/Objects/Models/HTXRepayment.cs similarity index 69% rename from Huobi.Net/Objects/Models/HuobiRepayment.cs rename to HTX.Net/Objects/Models/HTXRepayment.cs index d2d5b092..0e3fb185 100644 --- a/Huobi.Net/Objects/Models/HuobiRepayment.cs +++ b/HTX.Net/Objects/Models/HTXRepayment.cs @@ -1,68 +1,72 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Repayment info /// - public record HuobiRepayment + public record HTXRepayment { /// /// Repayment id /// + [JsonPropertyName("repayId")] public long RepayId { get; set; } /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Repay time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("repayTime")] public DateTime RepayTime { get; set; } /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Repay quantity /// - [JsonProperty("repaidAmount")] + [JsonPropertyName("repaidAmount")] public decimal RepaidQuantity { get; set; } /// /// Transactions /// - [JsonProperty("transactIds")] - public HuobiRepayTransaction Transactions { get; set; } = null!; + [JsonPropertyName("transactIds")] + public HTXRepayTransaction Transactions { get; set; } = null!; } /// /// Repayment transaction /// - public record HuobiRepayTransaction + public record HTXRepayTransaction { /// /// Transact id /// + [JsonPropertyName("transactId")] public long TransactId { get; set; } /// /// Principal repaid /// + [JsonPropertyName("repaidprincipal")] public decimal RepaidPrincipal { get; set; } /// /// Interest repaid /// + [JsonPropertyName("repaidInterest")] public decimal RepaidInterest { get; set; } /// /// HT paid /// + [JsonPropertyName("paidHt")] public decimal PaidHt { get; set; } /// /// Points paid /// + [JsonPropertyName("paidPoint")] public decimal PaidPoint { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiRepaymentResult.cs b/HTX.Net/Objects/Models/HTXRepaymentResult.cs similarity index 59% rename from Huobi.Net/Objects/Models/HuobiRepaymentResult.cs rename to HTX.Net/Objects/Models/HTXRepaymentResult.cs index 76ca15bc..a659fcda 100644 --- a/Huobi.Net/Objects/Models/HuobiRepaymentResult.cs +++ b/HTX.Net/Objects/Models/HTXRepaymentResult.cs @@ -1,22 +1,20 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Repayment result /// - public record HuobiRepaymentResult + public record HTXRepaymentResult { /// /// Repayment id /// - public string RepayId { get; set; } = string.Empty; + [JsonPropertyName("repayId")] + public long RepayId { get; set; } /// /// Repay time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("repayTime")] public DateTime RepayTime { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXSubAccountInfo.cs b/HTX.Net/Objects/Models/HTXSubAccountInfo.cs new file mode 100644 index 00000000..30b33c35 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubAccountInfo.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account info + /// + public record HTXSubAccountInfo + { + /// + /// User name + /// + [JsonPropertyName("userName")] + public string UserName { get; set; } = string.Empty; + /// + /// Note + /// + [JsonPropertyName("note")] + public string Note { get; set; } = string.Empty; + /// + /// User id + /// + [JsonPropertyName("uid")] + public long? UserId { get; set; } + /// + /// Error code + /// + [JsonPropertyName("errCode")] + public string? ErrorCode { get; set; } + /// + /// Error message + /// + [JsonPropertyName("errMessage")] + public string? ErrorMessage { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubAccountLock.cs b/HTX.Net/Objects/Models/HTXSubAccountLock.cs new file mode 100644 index 00000000..eaa7b6cd --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubAccountLock.cs @@ -0,0 +1,23 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account lock + /// + public record HTXSubAccountLock + { + /// + /// Sub user id + /// + [JsonPropertyName("subUid")] + public long SubUserId { get; set; } + /// + /// User lock state + /// + [JsonPropertyName("userState")] + public LockAction UserState { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubAccountRequest.cs b/HTX.Net/Objects/Models/HTXSubAccountRequest.cs new file mode 100644 index 00000000..d3158e5a --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubAccountRequest.cs @@ -0,0 +1,19 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account request + /// + public record HTXSubAccountRequest + { + /// + /// User name + /// + [JsonPropertyName("userName")] + public string UserName { get; set; } = string.Empty; + /// + /// Note + /// + [JsonPropertyName("note")] + public string? Note { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/HTXSubApiKey.cs b/HTX.Net/Objects/Models/HTXSubApiKey.cs new file mode 100644 index 00000000..e49b68dc --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubApiKey.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account API key + /// + public record HTXSubApiKey + { + /// + /// Access key + /// + [JsonPropertyName("accessKey")] + public string AccessKey { get; set; } = string.Empty; + /// + /// Secret key + /// + [JsonPropertyName("secretKey")] + public string SecretKey { get; set; } = string.Empty; + /// + /// Note + /// + [JsonPropertyName("note")] + public string? Note { get; set; } + /// + /// Permission, comma seperated + /// + [JsonPropertyName("permission")] + public string Permission { get; set; } = string.Empty; + /// + /// Ip addresses, comma seperated + /// + [JsonPropertyName("ipAddresses")] + public string IpAddresses { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubApiKeyEdit.cs b/HTX.Net/Objects/Models/HTXSubApiKeyEdit.cs new file mode 100644 index 00000000..d8eeeec5 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubApiKeyEdit.cs @@ -0,0 +1,26 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Edit result + /// + public record HTXSubApiKeyEdit + { + /// + /// Note + /// + [JsonPropertyName("note")] + public string Note { get; set; } = string.Empty; + /// + /// Permission, comma seperated + /// + [JsonPropertyName("permission")] + public string Permission { get; set; } = string.Empty; + /// + /// Ip addresses, comma seperated + /// + [JsonPropertyName("ipAddresses")] + public string IpAddresses { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubDeductMode.cs b/HTX.Net/Objects/Models/HTXSubDeductMode.cs new file mode 100644 index 00000000..84607111 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubDeductMode.cs @@ -0,0 +1,33 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account deduct mode + /// + public record HTXSubDeductMode + { + /// + /// Sub uid + /// + [JsonPropertyName("subUid")] + public string SubUid { get; set; } = string.Empty; + /// + /// Deduct mode + /// + [JsonPropertyName("deductMode")] + public DeductMode? DeductMode { get; set; } + /// + /// Error code + /// + [JsonPropertyName("errCode")] + public int? ErrorCode { get; set; } + /// + /// Error message + /// + [JsonPropertyName("errMessage")] + public string? ErrorMessage { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubDeposit.cs b/HTX.Net/Objects/Models/HTXSubDeposit.cs new file mode 100644 index 00000000..9d7a1361 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubDeposit.cs @@ -0,0 +1,61 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account deposit + /// + public record HTXSubDeposit + { + /// + /// Id + /// + [JsonPropertyName("id")] + public long Id { get; set; } + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// Network + /// + [JsonPropertyName("chain")] + public string Network { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("amount")] + public decimal Quantity { get; set; } + /// + /// Address + /// + [JsonPropertyName("address")] + public string Address { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("state")] + public string DepositStatus { get; set; } = string.Empty; + /// + /// Transaction hash + /// + [JsonPropertyName("txHash")] + public string TransactionHash { get; set; } = string.Empty; + /// + /// Address tag + /// + [JsonPropertyName("addressTag")] + public string? AddressTag { get; set; } + /// + /// Create time + /// + [JsonPropertyName("createTime")] + public DateTime CreateTime { get; set; } + /// + /// Update time + /// + [JsonPropertyName("updateTime")] + public DateTime? UpdateTime { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubMarketTradable.cs b/HTX.Net/Objects/Models/HTXSubMarketTradable.cs new file mode 100644 index 00000000..532959b6 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubMarketTradable.cs @@ -0,0 +1,39 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Sub account tradable market status + /// + public record HTXSubMarketTradable + { + /// + /// Sub user id + /// + [JsonPropertyName("subUid")] + public string SubUserId { get; set; } = string.Empty; + /// + /// Account type + /// + [JsonPropertyName("accountType")] + public SubAccountMarketType AccountType { get; set; } + /// + /// Activation + /// + [JsonPropertyName("activation")] + public string Activation { get; set; } = string.Empty; + + /// + /// Error code + /// + [JsonPropertyName("errCode")] + public int? ErrorCode { get; set; } + /// + /// Error message + /// + [JsonPropertyName("errMessage")] + public string? ErrorMessage { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubTransferPermission.cs b/HTX.Net/Objects/Models/HTXSubTransferPermission.cs new file mode 100644 index 00000000..3c3b753d --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubTransferPermission.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Transfer permission + /// + public record HTXSubTransferPermission + { + /// + /// Account type + /// + [JsonPropertyName("accountType")] + public string AccountType { get; set; } = string.Empty; + /// + /// Transferrable + /// + [JsonPropertyName("transferrable")] + public bool? Transferrable { get; set; } + /// + /// Sub user id + /// + [JsonPropertyName("subUid")] + public long SubUserId { get; set; } + /// + /// Error code + /// + [JsonPropertyName("errCode")] + public int? ErrorCode { get; set; } + /// + /// Error message + /// + [JsonPropertyName("errMessage")] + public string? ErrorMessage { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/HTXSubUserAccount.cs b/HTX.Net/Objects/Models/HTXSubUserAccount.cs new file mode 100644 index 00000000..0da29975 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubUserAccount.cs @@ -0,0 +1,32 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// HTX sub-user account info + /// + public record HTXSubUserAccount + { + /// + /// The type of the account + /// + [JsonPropertyName("accountType"), JsonConverter(typeof(EnumConverter))] + public SubAccountMarketType Type { get; set; } + /// + /// Whether the account is active of not + /// + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("activation")] + public AccountActivation Activation { get; set; } + /// + /// Whether transfers are allowed (only for spot account type) + /// + [JsonPropertyName("transferrable")] + public bool? Transferrable { get; set; } + /// + /// Account ids + /// + [JsonPropertyName("accountIds")] + public IEnumerable AccountIds { get; set; } = Array.Empty(); + } +} diff --git a/HTX.Net/Objects/Models/HTXSubUserAccountId.cs b/HTX.Net/Objects/Models/HTXSubUserAccountId.cs new file mode 100644 index 00000000..8a748a40 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSubUserAccountId.cs @@ -0,0 +1,28 @@ + +using HTX.Net.Enums; + + +namespace HTX.Net.Objects.Models +{ + /// + /// HTX sub-user account id and state + /// + public record HTXSubUserAccountId + { + /// + /// The id of the account + /// + [JsonPropertyName("accountId")] + public long Id { get; set; } + /// + /// The status of the account + /// + [JsonPropertyName("accountStatus"), JsonConverter(typeof(EnumConverter))] + public AccountStatus Status { get; set; } + /// + /// Sub state + /// + [JsonPropertyName("subtype")] + public string? SubType { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/HuobiSubUserAccounts.cs b/HTX.Net/Objects/Models/HTXSubUserAccounts.cs similarity index 52% rename from Huobi.Net/Objects/Models/HuobiSubUserAccounts.cs rename to HTX.Net/Objects/Models/HTXSubUserAccounts.cs index 32cc2be7..bf2ad645 100644 --- a/Huobi.Net/Objects/Models/HuobiSubUserAccounts.cs +++ b/HTX.Net/Objects/Models/HTXSubUserAccounts.cs @@ -1,29 +1,26 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// - /// Huobi sub-user account info + /// HTX sub-user account info /// - public record HuobiSubUserAccounts + public record HTXSubUserAccounts { /// /// The id of the sub-user /// - [JsonProperty("uid")] + [JsonPropertyName("uid")] public long UserId { get; set; } /// /// Deduct mode /// + [JsonPropertyName("deductMode")] public string DeductMode { get; set; } = string.Empty; /// /// List of accounts for the sub-user /// - [JsonProperty("list")] - public IEnumerable Accounts { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable Accounts { get; set; } = Array.Empty(); } } diff --git a/HTX.Net/Objects/Models/HTXSymbol.cs b/HTX.Net/Objects/Models/HTXSymbol.cs new file mode 100644 index 00000000..56e11160 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSymbol.cs @@ -0,0 +1,131 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// Symbol information + /// + public record HTXSymbol + { + /// + /// Tags + /// + [JsonPropertyName("tags")] + public string? Tags { get; set; } + /// + /// State + /// + [JsonPropertyName("state")] + public SymbolStatus SymbolStatus { get; set; } + /// + /// WithdrawRisk + /// + [JsonPropertyName("wr")] + public decimal? WithdrawRisk { get; set; } + /// + /// Symbol name + /// + [JsonPropertyName("sc")] + public string Name { get; set; } = string.Empty; + /// + /// Base asset display name + /// + [JsonPropertyName("bcdn")] + public string BaseAssetName { get; set; } = string.Empty; + /// + /// Quote asset display name + /// + [JsonPropertyName("qcdn")] + public string QuoteAssetName { get; set; } = string.Empty; + /// + /// Etp leverage ratio + /// + [JsonPropertyName("elr")] + public string? EtpLeverageRatio { get; set; } + /// + /// Price precision + /// + [JsonPropertyName("tpp")] + public decimal PricePrecision { get; set; } + /// + /// Quantity precision + /// + [JsonPropertyName("tap")] + public decimal QuantityPrecision { get; set; } + /// + /// Fee precision + /// + [JsonPropertyName("fp")] + public decimal FeePrecision { get; set; } + /// + /// Super margin leverage ratio + /// + [JsonPropertyName("smlr")] + public string? SuperMarginLeverageRatio { get; set; } + /// + /// C2C leverage ratio + /// + [JsonPropertyName("flr")] + public string? C2CLeverageRatio { get; set; } + /// + /// White enabled + /// + [JsonPropertyName("whe")] + public bool WhiteEnabled { get; set; } + /// + /// Country disabled + /// + [JsonPropertyName("cd")] + public bool CountryDisabled { get; set; } + /// + /// Trade enabled + /// + [JsonPropertyName("te")] + public bool TradeEnabled { get; set; } + /// + /// Symbol partition + /// + [JsonPropertyName("sp")] + public string Partition { get; set; } = string.Empty; + /// + /// Direction + /// + [JsonPropertyName("d")] + public string? Direction { get; set; } + /// + /// Base asset + /// + [JsonPropertyName("bc")] + public string BaseAsset { get; set; } = string.Empty; + /// + /// Quote asset + /// + [JsonPropertyName("qc")] + public string QuoteAsset { get; set; } = string.Empty; + /// + /// Time trading starts + /// + [JsonPropertyName("toa")] + public DateTime TradeOpenTime { get; set; } + /// + /// trade total precision + /// + [JsonPropertyName("ttp")] + public decimal TradeTotalPrecision { get; set; } + /// + /// Weight sort + /// + [JsonPropertyName("w")] + public long WeightSort { get; set; } + /// + /// Leverage ratio + /// + [JsonPropertyName("lr")] + public decimal? LeverageRatio { get; set; } + /// + /// DisplayName + /// + [JsonPropertyName("dn")] + public string DisplayName { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Models/HTXSymbolConfig.cs b/HTX.Net/Objects/Models/HTXSymbolConfig.cs new file mode 100644 index 00000000..b1b81a83 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSymbolConfig.cs @@ -0,0 +1,166 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Symbol configuration + /// + public record HTXSymbolConfig + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("state")] + public string Status { get; set; } = string.Empty; + /// + /// Base asset + /// + [JsonPropertyName("bc")] + public string BaseAsset { get; set; } = string.Empty; + /// + /// Quote asset + /// + [JsonPropertyName("qc")] + public string QuoteAsset { get; set; } = string.Empty; + /// + /// Price precision + /// + [JsonPropertyName("pp")] + public int PricePrecision { get; set; } + /// + /// Quantity precision + /// + [JsonPropertyName("ap")] + public int QuantityPrecision { get; set; } + /// + /// Partition + /// + [JsonPropertyName("sp")] + public string Partition { get; set; } = string.Empty; + /// + /// Value precision + /// + [JsonPropertyName("vp")] + public int ValuePrecision { get; set; } + /// + /// Minimal order quantity + /// + [JsonPropertyName("minoa")] + public decimal? MinOrderQuantity { get; set; } + /// + /// Max order quantity + /// + [JsonPropertyName("maxoa")] + public decimal? MaxOrderQuantity { get; set; } + /// + /// Minimal order value + /// + [JsonPropertyName("minov")] + public decimal? MinOrderValue { get; set; } + /// + /// Minimal quantity of limit order + /// + [JsonPropertyName("lominoa")] + public decimal? MinQuantityLimitOrder { get; set; } + /// + /// Max quantity of limit order + /// + [JsonPropertyName("lomaxoa")] + public decimal? MaxQuantityLimitOrder { get; set; } + /// + /// Max quantity of limit buy order + /// + [JsonPropertyName("lomaxba")] + public decimal? MaxQuantityLimitBuyOrder { get; set; } + /// + /// Max quantity of limit sell order + /// + [JsonPropertyName("lomaxsa")] + public decimal? MaxQuantityLimitSellOrder { get; set; } + /// + /// Minimal quantity of market sell order + /// + [JsonPropertyName("smminoa")] + public decimal? MinQuantityMarketSellOrder { get; set; } + /// + /// Buy limit order must be less than this + /// + [JsonPropertyName("blmlt")] + public decimal? BuyLimitLessThan { get; set; } + /// + /// Sell limit order must be less than this + /// + [JsonPropertyName("slmgt")] + public decimal? SellLimitLessThan { get; set; } + /// + /// Max quantity of market sell order + /// + [JsonPropertyName("smmaxoa")] + public decimal? MaxQuantityMarketSellOrder { get; set; } + /// + /// Max quantity of market buy order + /// + [JsonPropertyName("bmmaxov")] + public decimal? MaxQuantityMarketBuyOrder { get; set; } + /// + /// Sell market order rate must be less than this + /// + [JsonPropertyName("msormlt")] + public decimal? SellMarketLessThan { get; set; } + /// + /// Buy market order rate must be less than this + /// + [JsonPropertyName("mbormlt")] + public decimal? BuyMarketLessThan { get; set; } + /// + /// Max value of a market order + /// + [JsonPropertyName("maxov")] + public decimal? MaxValueMarketOrder { get; set; } + /// + /// Etp symbol + /// + [JsonPropertyName("u")] + public string? EtpSymbol { get; set; } = string.Empty; + /// + /// Mfr + /// + [JsonPropertyName("mfr")] + public decimal? Mfr { get; set; } + /// + /// ETP charge time + /// + [JsonPropertyName("ct")] + public string? ChareTime { get; set; } + /// + /// ETP rebal time + /// + [JsonPropertyName("rt")] + public string? RebalTime { get; set; } + /// + /// ETP rebal threshold + /// + [JsonPropertyName("rthr")] + public decimal? RebalThreshold { get; set; } + /// + /// ETP initial NAV + /// + [JsonPropertyName("in")] + public decimal InitialNav { get; set; } + /// + /// ApiTrading + /// + [JsonPropertyName("at")] + public string ApiTrading { get; set; } = string.Empty; + /// + /// Tags + /// + [JsonPropertyName("tags")] + public string Tags { get; set; } = string.Empty; + } + + +} diff --git a/Huobi.Net/Objects/Models/HuobiSymbolData.cs b/HTX.Net/Objects/Models/HTXSymbolData.cs similarity index 66% rename from Huobi.Net/Objects/Models/HuobiSymbolData.cs rename to HTX.Net/Objects/Models/HTXSymbolData.cs index d713c0d9..4234462b 100644 --- a/Huobi.Net/Objects/Models/HuobiSymbolData.cs +++ b/HTX.Net/Objects/Models/HTXSymbolData.cs @@ -1,134 +1,153 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Symbol data /// - public record HuobiSymbolData + public record HTXSymbolData { /// /// The highest price /// - [JsonProperty("high")] + [JsonPropertyName("high")] public decimal? HighPrice { get; set; } /// /// The lowest price /// - [JsonProperty("low")] + [JsonPropertyName("low")] public decimal? LowPrice { get; set; } /// /// The price at the opening /// - [JsonProperty("open")] + [JsonPropertyName("open")] public decimal? OpenPrice { get; set; } /// /// The last price /// - [JsonProperty("close")] + [JsonPropertyName("close")] public decimal? ClosePrice { get; set; } /// /// The volume in base asset /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal? Volume { get; set; } /// /// The volume in quote asset (quantity * price) /// - [JsonProperty("vol")] + [JsonPropertyName("vol")] public decimal? QuoteVolume { get; set; } /// /// The number of trades /// - [JsonProperty("count")] + [JsonPropertyName("count")] public int? TradeCount { get; set; } /// /// Version /// + [JsonPropertyName("version")] public long? Version { get; set; } } /// /// Ticker data /// - public record HuobiSymbolTicker : HuobiSymbolData + public record HTXSymbolTicker : HTXSymbolData { /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; } /// /// Symbol kline data /// - public record HuobiKline : HuobiSymbolData + public record HTXKline : HTXSymbolData { /// /// The start time of the kline /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("id")] + [JsonPropertyName("id")] public DateTime OpenTime { get; set; } + + /// + /// Turnover, quantity * contract value * price + /// + [JsonPropertyName("trade_turnover")] + public decimal? Value { get; set; } + } + + /// + /// Kline data + /// + public record HTXSwapKline : HTXKline + { + /// + /// Order id + /// + [JsonPropertyName("mrid")] + public long OrderId { get; set; } } /// /// Symbol details /// - public record HuobiSymbolDetails : HuobiSymbolData + public record HTXSymbolDetails : HTXSymbolData { /// /// The id of the details /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Timestamp of the data /// + [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } } /// /// Symbol tick /// - public record HuobiSymbolTick : HuobiSymbolData + public record HTXSymbolTick : HTXSymbolData { /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Quantity of the best bid /// - [JsonProperty("bidSize")] + [JsonPropertyName("bidSize")] public decimal BestBidQuantity { get; set; } /// /// Quantity of the best ask /// - [JsonProperty("askSize")] + [JsonPropertyName("askSize")] public decimal BestAskQuantity { get; set; } /// /// Best bid price /// - [JsonProperty("bid")] + [JsonPropertyName("bid")] public decimal BestBidPrice { get; set; } /// /// Best ask price /// - [JsonProperty("ask")] + [JsonPropertyName("ask")] public decimal BestAskPrice { get; set; } /// /// Last trade price /// - [JsonProperty("lastPrice")] + [JsonPropertyName("lastPrice")] public decimal LastTradePrice { get; set; } /// /// Last trade quantity /// - [JsonProperty("lastSize")] + [JsonPropertyName("lastSize")] public decimal LastTradeQuantity { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiSymbolStatus.cs b/HTX.Net/Objects/Models/HTXSymbolStatus.cs similarity index 74% rename from Huobi.Net/Objects/Models/HuobiSymbolStatus.cs rename to HTX.Net/Objects/Models/HTXSymbolStatus.cs index f070a1b0..27b5840b 100644 --- a/Huobi.Net/Objects/Models/HuobiSymbolStatus.cs +++ b/HTX.Net/Objects/Models/HTXSymbolStatus.cs @@ -1,38 +1,39 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Status of the symbol /// - public record HuobiSymbolStatus + public record HTXSymbolStatus { /// /// The status /// - [JsonProperty("marketStatus")] + [JsonPropertyName("marketStatus")] public MarketStatus Status { get; set; } /// /// Start time of when market halted /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("haltStartTime")] public DateTime? HaltStartTime { get; set; } /// /// Estimated end time of the halt /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("haltEndTime")] public DateTime? HaltEndTime { get; set; } /// /// Reason for halting /// + [JsonPropertyName("haltReason")] public string? HaltReason { get; set; } /// /// Affected symbols, comma separated or 'all' if all symbols are affected /// + [JsonPropertyName("affectedSymbols")] public string? AffectedSymbols { get; set; } } } diff --git a/Huobi.Net/Objects/Models/HuobiSymbolTickMerged.cs b/HTX.Net/Objects/Models/HTXSymbolTickMerged.cs similarity index 67% rename from Huobi.Net/Objects/Models/HuobiSymbolTickMerged.cs rename to HTX.Net/Objects/Models/HTXSymbolTickMerged.cs index ed23b433..c4317a7e 100644 --- a/Huobi.Net/Objects/Models/HuobiSymbolTickMerged.cs +++ b/HTX.Net/Objects/Models/HTXSymbolTickMerged.cs @@ -1,42 +1,42 @@ -using System; -using CryptoExchange.Net.Converters; -using CryptoExchange.Net.Interfaces; -using Newtonsoft.Json; +using CryptoExchange.Net.Converters; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Symbol tick info /// - public record HuobiSymbolTickMerged: HuobiSymbolData + public record HTXSymbolTickMerged: HTXSymbolData { /// /// Timestamp of the data /// + [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } /// /// The id of the tick /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// The current best bid for the symbol /// - [JsonProperty("bid")] - public HuobiOrderBookEntry? BestBid { get; set; } + [JsonPropertyName("bid")] + public HTXOrderBookEntry? BestBid { get; set; } /// /// The current best ask for the symbol /// - [JsonProperty("ask")] - public HuobiOrderBookEntry? BestAsk { get; set; } + [JsonPropertyName("ask")] + public HTXOrderBookEntry? BestAsk { get; set; } } /// /// Order book entry /// [JsonConverter(typeof(ArrayConverter))] - public record HuobiOrderBookEntry: ISymbolOrderBookEntry + public record HTXOrderBookEntry: ISymbolOrderBookEntry { /// /// The price for this entry diff --git a/Huobi.Net/Objects/Models/HuobiSymbolTicks.cs b/HTX.Net/Objects/Models/HTXSymbolTicks.cs similarity index 55% rename from Huobi.Net/Objects/Models/HuobiSymbolTicks.cs rename to HTX.Net/Objects/Models/HTXSymbolTicks.cs index 8f0654f6..9c565d4b 100644 --- a/Huobi.Net/Objects/Models/HuobiSymbolTicks.cs +++ b/HTX.Net/Objects/Models/HTXSymbolTicks.cs @@ -1,35 +1,36 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Symbol ticks /// - public record HuobiSymbolDatas + public record HTXSymbolDatas { /// /// Timestamp of the data /// + [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } /// /// List of ticks for symbols /// - public IEnumerable Ticks { get; set; } = Array.Empty(); + [JsonPropertyName("ticks")] + public IEnumerable Ticks { get; set; } = Array.Empty(); } /// /// Symbol ticks /// - public record HuobiSymbolTicks + public record HTXSymbolTicks { /// /// Timestamp of the data /// + [JsonPropertyName("timestamp")] public DateTime Timestamp { get; set; } /// /// List of ticks for symbols /// - public IEnumerable Ticks { get; set; } = Array.Empty(); + [JsonPropertyName("ticks")] + public IEnumerable Ticks { get; set; } = Array.Empty(); } } diff --git a/Huobi.Net/Objects/Models/HuobiSymbolTrade.cs b/HTX.Net/Objects/Models/HTXSymbolTrade.cs similarity index 63% rename from Huobi.Net/Objects/Models/HuobiSymbolTrade.cs rename to HTX.Net/Objects/Models/HTXSymbolTrade.cs index dd27ccea..15ba26bb 100644 --- a/Huobi.Net/Objects/Models/HuobiSymbolTrade.cs +++ b/HTX.Net/Objects/Models/HTXSymbolTrade.cs @@ -1,68 +1,68 @@ -using System; -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models + +namespace HTX.Net.Objects.Models { /// /// Symbol trade /// - public record HuobiSymbolTrade + public record HTXSymbolTrade { /// /// The id of the trade /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// The timestamp of the trade /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// The details of the trade /// - [JsonProperty("data")] - public IEnumerable Details { get; set; } = Array.Empty(); + [JsonPropertyName("data")] + public IEnumerable Details { get; set; } = Array.Empty(); } /// /// Symbol trade details /// - public record HuobiSymbolTradeDetails + public record HTXSymbolTradeDetails { /// /// The id of the update /// + [JsonPropertyName("id")] + [JsonConverter(typeof(NumberStringConverter))] public string Id { get; set; } = string.Empty; /// /// The id of the trade /// - [JsonProperty("trade-id")] + [JsonPropertyName("trade-id")] public long TradeId { get; set; } // Rest uses trade-id, socket uses tradeId - [JsonProperty("tradeId")] + [JsonInclude, JsonPropertyName("tradeId")] private long TradeIdInternal { get => TradeId; set => TradeId = value; } /// /// The price of the trade /// + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// The quantity of the trade /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Quantity { get; set; } /// /// The side of the trade /// - [JsonProperty("direction"), JsonConverter(typeof(OrderSideConverter))] + [JsonPropertyName("direction"), JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// The timestamp of the trade /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("ts"), JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXSystemStatus.cs b/HTX.Net/Objects/Models/HTXSystemStatus.cs new file mode 100644 index 00000000..d780800c --- /dev/null +++ b/HTX.Net/Objects/Models/HTXSystemStatus.cs @@ -0,0 +1,397 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models +{ + /// + /// System status info + /// + public record HTXSystemStatus + { + /// + /// Page + /// + [JsonPropertyName("page")] + public HTXPageInfo Page { get; set; } = null!; + /// + /// Components + /// + [JsonPropertyName("components")] + public IEnumerable Components { get; set; } = Array.Empty(); + /// + /// Incidents + /// + [JsonPropertyName("incidents")] + public IEnumerable Incidents { get; set; } = Array.Empty(); + /// + /// Scheduled maintenances + /// + [JsonPropertyName("scheduled_maintenances")] + public IEnumerable ScheduledMaintenances { get; set; } = Array.Empty(); + /// + /// Status + /// + [JsonPropertyName("status")] + public HTXSystemStatusIndicator? Status { get; set; } + } + + /// + /// Page info + /// + public record HTXPageInfo + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Url + /// + [JsonPropertyName("url")] + public string Url { get; set; } = string.Empty; + /// + /// Time zone + /// + [JsonPropertyName("time_zone")] + public string TimeZone { get; set; } = string.Empty; + /// + /// Updated at + /// + [JsonPropertyName("updated_at")] + public DateTime UpdatedAt { get; set; } + } + + /// + /// System component + /// + public record HTXSystemComponent + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// System status + /// + [JsonPropertyName("status")] + public ComponentStatus SystemStatus { get; set; } + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Updated at + /// + [JsonPropertyName("updated_at")] + public DateTime UpdatedAt { get; set; } + /// + /// Position + /// + [JsonPropertyName("position")] + public int Position { get; set; } + /// + /// Description + /// + [JsonPropertyName("description")] + public string? Description { get; set; } + /// + /// Showcase + /// + [JsonPropertyName("showcase")] + public bool Showcase { get; set; } + /// + /// Group id + /// + [JsonPropertyName("group_id")] + public string GroupId { get; set; } = string.Empty; + /// + /// Page id + /// + [JsonPropertyName("page_id")] + public string PageId { get; set; } = string.Empty; + /// + /// Group + /// + [JsonPropertyName("group")] + public bool Group { get; set; } + /// + /// Only show if degraded + /// + [JsonPropertyName("only_show_if_degraded")] + public bool OnlyShowIfDegraded { get; set; } + } + + /// + /// System incident + /// + public record HTXSystemIncident + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Incident status + /// + [JsonPropertyName("status")] + public IncidentStatus IncidentStatus { get; set; } + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Updated at + /// + [JsonPropertyName("updated_at")] + public DateTime UpdatedAt { get; set; } + /// + /// Monitoring at + /// + [JsonPropertyName("monitoring_at")] + public DateTime? MonitoringAt { get; set; } + /// + /// Resolved at + /// + [JsonPropertyName("resolved_at")] + public DateTime? ResolvedAt { get; set; } + /// + /// Impact + /// + [JsonPropertyName("impact")] + public string Impact { get; set; } = string.Empty; + /// + /// Shortlink + /// + [JsonPropertyName("shortlink")] + public string Shortlink { get; set; } = string.Empty; + /// + /// Started at + /// + [JsonPropertyName("started_at")] + public DateTime StartedAt { get; set; } + /// + /// Page id + /// + [JsonPropertyName("page_id")] + public string PageId { get; set; } = string.Empty; + /// + /// Incident updates + /// + [JsonPropertyName("incident_updates")] + public IEnumerable IncidentUpdates { get; set; } = Array.Empty(); + /// + /// Components + /// + [JsonPropertyName("components")] + public IEnumerable Components { get; set; } = Array.Empty(); + } + + /// + /// System incident update + /// + public record HTXSystemIncidentUpdate + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Incident status + /// + [JsonPropertyName("status")] + public IncidentStatus? IncidentStatus { get; set; } + /// + /// Body + /// + [JsonPropertyName("body")] + public string Body { get; set; } = string.Empty; + /// + /// Incident id + /// + [JsonPropertyName("incident_id")] + public string IncidentId { get; set; } = string.Empty; + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Updated at + /// + [JsonPropertyName("updated_at")] + public DateTime UpdatedAt { get; set; } + /// + /// Display at + /// + [JsonPropertyName("display_at")] + public DateTime DisplayAt { get; set; } + /// + /// Affected components + /// + [JsonPropertyName("affected_components")] + public IEnumerable AffectedComponents { get; set; } = Array.Empty(); + /// + /// Deliver notifications + /// + [JsonPropertyName("deliver_notifications")] + public bool DeliverNotifications { get; set; } + /// + /// Custom tweet + /// + [JsonPropertyName("custom_tweet")] + public string? CustomTweet { get; set; } + /// + /// Tweet id + /// + [JsonPropertyName("tweet_id")] + public string? TweetId { get; set; } + } + + /// + /// System incident affacted component + /// + public record HTXSystemIncidentComponent + { + /// + /// Code + /// + [JsonPropertyName("code")] + public string Code { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Old status + /// + [JsonPropertyName("old_status")] + public ComponentStatus OldStatus { get; set; } + /// + /// New status + /// + [JsonPropertyName("new_status")] + public ComponentStatus NewStatus { get; set; } + } + + /// + /// + /// + public record HTXSystemMaintenance + { + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Name + /// + [JsonPropertyName("name")] + public string Name { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("status")] + public MaintenanceStatus Status { get; set; } + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Updated at + /// + [JsonPropertyName("updated_at")] + public DateTime UpdatedAt { get; set; } + /// + /// Monitoring at + /// + [JsonPropertyName("monitoring_at")] + public DateTime? MonitoringAt { get; set; } + /// + /// Resolved at + /// + [JsonPropertyName("resolved_at")] + public DateTime? ResolvedAt { get; set; } + /// + /// Impact + /// + [JsonPropertyName("impact")] + public string Impact { get; set; } = string.Empty; + /// + /// Shortlink + /// + [JsonPropertyName("shortlink")] + public string Shortlink { get; set; } = string.Empty; + /// + /// Started at + /// + [JsonPropertyName("started_at")] + public string StartedAt { get; set; } = string.Empty; + /// + /// Page id + /// + [JsonPropertyName("page_id")] + public string PageId { get; set; } = string.Empty; + /// + /// Incident updates + /// + [JsonPropertyName("incident_updates")] + public IEnumerable IncidentUpdates { get; set; } = Array.Empty(); + /// + /// Components + /// + [JsonPropertyName("components")] + public IEnumerable Components { get; set; } = Array.Empty(); + /// + /// Scheduled for + /// + [JsonPropertyName("scheduled_for")] + public DateTime ScheduledFor { get; set; } + /// + /// Scheduled until + /// + [JsonPropertyName("scheduled_until")] + public DateTime ScheduledUntil { get; set; } + } + + /// + /// Indicator + /// + public record HTXSystemStatusIndicator + { + /// + /// Indicator + /// + [JsonPropertyName("indicator")] + public SystemStatusIndicator Indicator { get; set; } + /// + /// Description + /// + [JsonPropertyName("description")] + public string Description { get; set; } = string.Empty; + } + + +} diff --git a/Huobi.Net/Objects/Models/HuobiTransactionResult.cs b/HTX.Net/Objects/Models/HTXTransactionResult.cs similarity index 62% rename from Huobi.Net/Objects/Models/HuobiTransactionResult.cs rename to HTX.Net/Objects/Models/HTXTransactionResult.cs index 8b0aac91..16914f33 100644 --- a/Huobi.Net/Objects/Models/HuobiTransactionResult.cs +++ b/HTX.Net/Objects/Models/HTXTransactionResult.cs @@ -1,21 +1,21 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Transaction result /// - public record HuobiTransactionResult + public record HTXTransactionResult { /// /// Id /// - [JsonProperty("transact-id")] + [JsonPropertyName("transact-id")] public long TransactionId { get; set; } /// /// Time /// - [JsonProperty("transact-time")] + [JsonPropertyName("transact-time")] public long TransactionTime { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXUser.cs b/HTX.Net/Objects/Models/HTXUser.cs new file mode 100644 index 00000000..fbe4d219 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXUser.cs @@ -0,0 +1,33 @@ + +using HTX.Net.Enums; + + +namespace HTX.Net.Objects.Models +{ + /// + /// HTX user info + /// + public record HTXUser + { + /// + /// The id of the user + /// + [JsonPropertyName("uid")] + public long Id { get; set; } + /// + /// The status of the user + /// + [JsonPropertyName("userState"), JsonConverter(typeof(EnumConverter))] + public UserStatus Status { get; set; } + /// + /// User name + /// + [JsonPropertyName("subUserName")] + public string UserName { get; set; } = string.Empty; + /// + /// User name + /// + [JsonPropertyName("note")] + public string? Note { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/HuobiWithdrawDeposit.cs b/HTX.Net/Objects/Models/HTXWithdrawDeposit.cs similarity index 59% rename from Huobi.Net/Objects/Models/HuobiWithdrawDeposit.cs rename to HTX.Net/Objects/Models/HTXWithdrawDeposit.cs index d31e86e8..a7275bd0 100644 --- a/Huobi.Net/Objects/Models/HuobiWithdrawDeposit.cs +++ b/HTX.Net/Objects/Models/HTXWithdrawDeposit.cs @@ -1,92 +1,96 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models +namespace HTX.Net.Objects.Models { /// /// Withdraw or Deposit /// - public record HuobiWithdrawDeposit + public record HTXWithdrawDeposit { /// /// Transfer id /// - public int Id { get; set; } - /// - /// Define transfer type to search, possible values: [deposit, withdraw] - /// - [JsonProperty("type"), JsonConverter(typeof(WithdrawDepositTypeConverter))] + [JsonPropertyName("id")] + public long Id { get; set; } + /// + /// Client order id + /// + [JsonPropertyName("client-order-id")] + public string? ClientOrderId { get; set; } + /// + /// Define transfer type to search, possible values: [deposit, withdraw] + /// + [JsonPropertyName("type"), JsonConverter(typeof(EnumConverter))] public WithdrawDepositType Type { get; set; } /// /// Sub type /// - [JsonProperty("sub-type")] + [JsonPropertyName("sub-type")] public string SubType { get; set; } = string.Empty; /// /// The crypto asset to withdraw /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string? Asset { get; set; } /// /// The on-chain transaction hash /// - [JsonProperty("tx-hash")] + [JsonPropertyName("tx-hash")] public string? TransactionHash { get; set; } /// /// Block chain name /// - [JsonProperty("chain")] + [JsonPropertyName("chain")] public string? Network { get; set; } /// /// The number of crypto asset transfered in its minimum unit /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Quantity { get; set; } /// /// The deposit or withdraw target address /// + [JsonPropertyName("address")] public string? Address { get; set; } /// /// The user defined address tag /// - [JsonProperty("address-tag")] + [JsonPropertyName("address-tag")] public string? AddressTag { get; set; } /// /// The address tag of the address its from /// - [JsonProperty("from-addr-tag")] + [JsonPropertyName("from-addr-tag")] public string? FromAddressTag { get; set; } /// /// Withdraw fee /// + [JsonPropertyName("fee")] public decimal Fee { get; set; } - /// - /// The state of this transfer - /// - [JsonProperty("state"), JsonConverter(typeof(WithdrawDepositStateConverter))] - public WithdrawDepositState State { get; set; } + /// + /// The status of this transfer + /// + [JsonPropertyName("state"), JsonConverter(typeof(EnumConverter))] + public WithdrawDepositStatus Status { get; set; } /// /// Error code for withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". /// - [JsonProperty("error-code")] + [JsonPropertyName("error-code")] public string? ErrorCode { get; set; } /// /// Error description of withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". /// - [JsonProperty("error-msg")] + [JsonPropertyName("error-msg")] public string? ErrorMessage { get; set; } /// /// The timestamp in milliseconds for the transfer creation /// - [JsonProperty("created-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("created-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// The timestamp in milliseconds for the transfer's latest update /// - [JsonProperty("updated-at"), JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("updated-at"), JsonConverter(typeof(DateTimeConverter))] public DateTime UpdateTime { get; set; } } } diff --git a/HTX.Net/Objects/Models/HTXWithdrawalAddress.cs b/HTX.Net/Objects/Models/HTXWithdrawalAddress.cs new file mode 100644 index 00000000..740d9279 --- /dev/null +++ b/HTX.Net/Objects/Models/HTXWithdrawalAddress.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Withdrawal address info + /// + public record HTXWithdrawalAddress + { + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// Network + /// + [JsonPropertyName("chain")] + public string Network { get; set; } = string.Empty; + /// + /// Note + /// + [JsonPropertyName("note")] + public string Note { get; set; } = string.Empty; + /// + /// Address tag + /// + [JsonPropertyName("addressTag")] + public string? AddressTag { get; set; } + /// + /// Address + /// + [JsonPropertyName("address")] + public string Address { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/HTXWithdrawalQuota.cs b/HTX.Net/Objects/Models/HTXWithdrawalQuota.cs new file mode 100644 index 00000000..f39fb3ce --- /dev/null +++ b/HTX.Net/Objects/Models/HTXWithdrawalQuota.cs @@ -0,0 +1,66 @@ +namespace HTX.Net.Objects.Models +{ + /// + /// Asset quota + /// + public record HTXWithdrawalQuota + { + /// + /// Asset + /// + [JsonPropertyName("currency")] + public string Asset { get; set; } = string.Empty; + /// + /// Networks + /// + [JsonPropertyName("chains")] + public IEnumerable Networks { get; set; } = Array.Empty(); + } + + /// + /// Network quota + /// + public record HTXWithdrawalNetworkQuota + { + /// + /// Network + /// + [JsonPropertyName("chain")] + public string Network { get; set; } = string.Empty; + /// + /// Max withdraw amt + /// + [JsonPropertyName("maxWithdrawAmt")] + public decimal MaxWithdrawAmt { get; set; } + /// + /// Withdraw quota per day + /// + [JsonPropertyName("withdrawQuotaPerDay")] + public decimal WithdrawQuotaPerDay { get; set; } + /// + /// Remain withdraw quota per day + /// + [JsonPropertyName("remainWithdrawQuotaPerDay")] + public decimal RemainWithdrawQuotaPerDay { get; set; } + /// + /// Withdraw quota per year + /// + [JsonPropertyName("withdrawQuotaPerYear")] + public decimal WithdrawQuotaPerYear { get; set; } + /// + /// Remain withdraw quota per year + /// + [JsonPropertyName("remainWithdrawQuotaPerYear")] + public decimal RemainWithdrawQuotaPerYear { get; set; } + /// + /// Withdraw quota total + /// + [JsonPropertyName("withdrawQuotaTotal")] + public decimal WithdrawQuotaTotal { get; set; } + /// + /// Remain withdraw quota total + /// + [JsonPropertyName("remainWithdrawQuotaTotal")] + public decimal RemainWithdrawQuotaTotal { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiAccountUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXAccountUpdate.cs similarity index 68% rename from Huobi.Net/Objects/Models/Socket/HuobiAccountUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXAccountUpdate.cs index 2b67ea9a..bd394864 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiAccountUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXAccountUpdate.cs @@ -1,52 +1,55 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.Socket + +namespace HTX.Net.Objects.Models.Socket { /// /// Account update /// - public record HuobiAccountUpdate + public record HTXAccountUpdate { /// /// Asset /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public string Asset { get; set; } = string.Empty; /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Total balance /// + [JsonPropertyName("balance")] public decimal? Balance { get; set; } /// /// Available balance /// + [JsonPropertyName("available")] public decimal? Available { get; set; } /// /// Type of change /// - [JsonConverter(typeof(AccountEventConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("changeType")] public AccountEventType? ChangeType { get; set; } /// /// Account type /// - [JsonConverter(typeof(BalanceTypeConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("accountType")] public BalanceType AccountType { get; set; } /// /// Change time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("changeTime")] public DateTime? ChangeTime { get; set; } /// /// Update sequence number /// - [JsonProperty("seqNum")] + [JsonPropertyName("seqNum")] public long SequenceNumber { get; set; } } } diff --git a/HTX.Net/Objects/Models/Socket/HTXBestOfferUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXBestOfferUpdate.cs new file mode 100644 index 00000000..ff111214 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXBestOfferUpdate.cs @@ -0,0 +1,41 @@ + + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Best offer update + /// + public record HTXBestOfferUpdate + { + /// + /// Order id + /// + [JsonPropertyName("mrid")] + public long OrderId { get; set; } + /// + /// Update id + /// + [JsonPropertyName("id")] + public long Id { get; set; } + /// + /// Best bid + /// + [JsonPropertyName("bid")] + public HTXOrderBookEntry Bid { get; set; } = null!; + /// + /// Best ask + /// + [JsonPropertyName("ask")] + public HTXOrderBookEntry Ask { get; set; } = null!; + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Version + /// + [JsonPropertyName("version")] + public long Version { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXIncrementalOrderBookUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXIncrementalOrderBookUpdate.cs new file mode 100644 index 00000000..ba0b510b --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXIncrementalOrderBookUpdate.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Incremental order book update + /// + public record HTXIncrementalOrderBookUpdate : HTXOrderBookUpdate + { + /// + /// Event + /// + [JsonPropertyName("event")] + public string Event { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXOrderBookUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXOrderBookUpdate.cs new file mode 100644 index 00000000..ea790afe --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXOrderBookUpdate.cs @@ -0,0 +1,34 @@ +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Order book update + /// + public record HTXOrderBookUpdate + { + /// + /// Order id + /// + [JsonPropertyName("mrid")] + public long OrderId { get; set; } + /// + /// Update id + /// + [JsonPropertyName("id")] + public long Id { get; set; } + /// + /// Version + /// + [JsonPropertyName("version")] + public long? Version { get; set; } + /// + /// List of changed bids + /// + [JsonPropertyName("bids")] + public IEnumerable Bids { get; set; } = Array.Empty(); + /// + /// List of changed asks + /// + [JsonPropertyName("asks")] + public IEnumerable Asks { get; set; } = Array.Empty(); + } +} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiOrderCancelationUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXOrderCancelationUpdate.cs similarity index 68% rename from Huobi.Net/Objects/Models/Socket/HuobiOrderCancelationUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXOrderCancelationUpdate.cs index 8f4d282a..d27c4d6d 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiOrderCancelationUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXOrderCancelationUpdate.cs @@ -1,85 +1,92 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.Socket + +namespace HTX.Net.Objects.Models.Socket { /// /// Cancelation details /// - public record HuobiOrderCancelationUpdate + public record HTXOrderCancelationUpdate { /// /// Event type /// + [JsonPropertyName("eventType")] public string EventType { get; set; } = string.Empty; /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Order id /// + [JsonPropertyName("orderId")] public long OrderId { get; set; } /// /// Order side /// - [JsonProperty("orderSide"), JsonConverter(typeof(OrderSideConverter))] + [JsonPropertyName("orderSide"), JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// Order type /// - [JsonProperty("orderType"), JsonConverter(typeof(OrderTypeConverter))] + [JsonPropertyName("orderType"), JsonConverter(typeof(EnumConverter))] public OrderType Type { get; set; } /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Order source /// - [JsonProperty("source")] + [JsonPropertyName("source")] public string OrderSource { get; set; } = string.Empty; /// /// Order price /// + [JsonPropertyName("orderPrice")] public decimal OrderPrice { get; set; } /// /// Order quantity /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal OrderQuantity { get; set; } /// /// Client order id /// + [JsonPropertyName("clientOrderId")] public string? ClientOrderId { get; set; } /// /// Stop price /// + [JsonPropertyName("stopPrice")] public decimal? StopPrice { get; set; } /// /// Operator /// + [JsonPropertyName("operator")] public string? Operator { get; set; } /// /// Order creation time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("orderCreateTime")] public DateTime OrderCreateTime { get; set; } /// /// Order status /// - [JsonConverter(typeof(OrderStateConverter))] - public OrderState OrderStatus { get; set; } + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("orderStatus")] + public OrderStatus OrderStatus { get; set; } /// /// Remaining quantity /// - [JsonProperty("remainAmt")] + [JsonPropertyName("remainAmt")] public decimal QuantityRemaining { get; set; } } } diff --git a/Huobi.Net/Objects/Models/Socket/HuobiOrderUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXOrderUpdate.cs similarity index 64% rename from Huobi.Net/Objects/Models/Socket/HuobiOrderUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXOrderUpdate.cs index 79b0afea..c81e3eef 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiOrderUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXOrderUpdate.cs @@ -1,237 +1,258 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.Socket + +namespace HTX.Net.Objects.Models.Socket { /// /// Order update /// - public record HuobiOrderUpdate + public record HTXOrderUpdate { /// /// Event type /// + [JsonPropertyName("eventType")] public string EventType { get; set; } = string.Empty; /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Client order id /// + [JsonPropertyName("clientOrderId")] public string? ClientOrderId { get; set; } /// /// Order status /// - [JsonProperty("orderStatus"), JsonConverter(typeof(OrderStateConverter))] - public OrderState Status { get; set; } + [JsonPropertyName("orderStatus"), JsonConverter(typeof(EnumConverter))] + public OrderStatus Status { get; set; } /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("lastActTime")] + [JsonPropertyName("lastActTime")] public DateTime? UpdateTime { get; set; } } /// /// Submitted order update /// - public record HuobiSubmittedOrderUpdate : HuobiOrderUpdate + public record HTXSubmittedOrderUpdate : HTXOrderUpdate { /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Order id /// + [JsonPropertyName("orderId")] public long OrderId { get; set; } /// /// Price of the order /// - [JsonProperty("orderPrice")] + [JsonPropertyName("orderPrice")] public decimal Price { get; set; } /// /// Quantity of the order /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal? Quantity { get; set; } /// /// Value of the order /// - [JsonProperty("orderValue")] + [JsonPropertyName("orderValue")] public decimal? QuoteQuantity { get; set; } - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; + /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); /// /// The type of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// Creation time /// - [JsonProperty("orderCreateTime")] + [JsonPropertyName("orderCreateTime")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Order source /// + [JsonPropertyName("orderSource")] public string OrderSource { get; set; } = string.Empty; } /// /// Matched order update /// - public record HuobiMatchedOrderUpdate : HuobiOrderUpdate + public record HTXMatchedOrderUpdate : HTXOrderUpdate { /// /// Trade price /// + [JsonPropertyName("tradePrice")] public decimal TradePrice { get; set; } /// /// Trade volume /// - [JsonProperty("tradeVolume")] + [JsonPropertyName("tradeVolume")] public decimal TradeQuantity { get; set; } /// /// Order id /// + [JsonPropertyName("orderId")] public long OrderId { get; set; } - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); /// /// The type of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// Trade id /// + [JsonPropertyName("tradeId")] public long TradeId { get; set; } /// /// Timestamp of trade /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("tradeTime")] public DateTime TradeTime { get; set; } /// /// Is the taker /// - [JsonProperty("aggressor")] + [JsonPropertyName("aggressor")] public bool IsTaker { get; set; } /// /// Remaining quantity /// - [JsonProperty("remainAmt")] + [JsonPropertyName("remainAmt")] public decimal QuantityRemaining { get; set; } /// /// Executed quantity /// - [JsonProperty("execAmt")] + [JsonPropertyName("execAmt")] public decimal QuantityFilled { get; set; } /// /// Price of the order /// - [JsonProperty("orderPrice")] + [JsonPropertyName("orderPrice")] public decimal Price { get; set; } /// /// Quantity of the order /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal? Quantity { get; set; } /// /// Order source /// + [JsonPropertyName("orderSource")] public string OrderSource { get; set; } = string.Empty; } /// /// Canceled order update /// - public record HuobiCanceledOrderUpdate : HuobiOrderUpdate + public record HTXCanceledOrderUpdate : HTXOrderUpdate { /// /// Order id /// + [JsonPropertyName("orderId")] public long OrderId { get; set; } - [JsonProperty("type")] - internal string TypeInternal { get; set; } = string.Empty; + + /// + /// The raw type string + /// + [JsonPropertyName("type")] + public string RawType { get; set; } = string.Empty; /// /// The type of the order /// [JsonIgnore] - public OrderType Type => new OrderTypeConverter(false).ReadString(TypeInternal); + public OrderType Type => EnumConverter.ParseString(RawType); /// /// The type of the order /// [JsonIgnore] - public OrderSide Side => new OrderSideConverter(false).ReadString(TypeInternal); + public OrderSide Side => EnumConverter.ParseString(RawType); /// /// Remaining quantity /// - [JsonProperty("remainAmt")] + [JsonPropertyName("remainAmt")] public decimal QuantityRemaining { get; set; } /// /// Executed quantity /// - [JsonProperty("execAmt")] + [JsonPropertyName("execAmt")] public decimal QuantityFilled { get; set; } /// /// Price of the order /// - [JsonProperty("orderPrice")] + [JsonPropertyName("orderPrice")] public decimal Price { get; set; } /// /// Quantity of the order /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal? Quantity { get; set; } /// /// Order source /// + [JsonPropertyName("orderSource")] public string OrderSource { get; set; } = string.Empty; } /// /// Info on a failed trigger for a conditional order /// - public record HuobiTriggerFailureOrderUpdate : HuobiOrderUpdate + public record HTXTriggerFailureOrderUpdate : HTXOrderUpdate { /// /// Side of the order /// - [JsonProperty("orderSide"), JsonConverter(typeof(OrderSideConverter))] + [JsonPropertyName("orderSide"), JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// The error code /// - [JsonProperty("errCode")] + [JsonPropertyName("errCode")] public int ErrorCode { get; set; } /// /// The error message /// - [JsonProperty("errMessage")] + [JsonPropertyName("errMessage")] public string ErrorMessage { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/Socket/HTXStatusUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXStatusUpdate.cs new file mode 100644 index 00000000..1e06b806 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXStatusUpdate.cs @@ -0,0 +1,45 @@ +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// System status update + /// + public record HTXStatusUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + + /// + /// Event, init (initial) status or update + /// + [JsonPropertyName("event")] + public string Event { get; set; } = string.Empty; + /// + /// Data + /// + [JsonPropertyName("data")] + public HTXStatus Data { get; set; } = null!; + } + + /// + /// System status update + /// + public record HTXStatus + { + /// + /// Is system available + /// + [JsonPropertyName("heartbeat")] + public bool Available { get; set; } + + /// + /// Estimated recovery time + /// + [JsonPropertyName("estimated_recovery_time")] + public DateTime? EstimatedRecoveryTime { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiSymbolTickUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXSymbolTickUpdate.cs similarity index 51% rename from Huobi.Net/Objects/Models/Socket/HuobiSymbolTickUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXSymbolTickUpdate.cs index 1c9adf14..27f34c84 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiSymbolTickUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXSymbolTickUpdate.cs @@ -1,35 +1,36 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.Socket +namespace HTX.Net.Objects.Models.Socket { /// /// Symbol update /// - public record HuobiSymbolTickUpdate: HuobiSymbolData + public record HTXSymbolTickUpdate: HTXSymbolData { /// /// Id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Order id /// - [JsonProperty("mrid")] + [JsonPropertyName("mrid")] public long OrderId { get; set; } /// /// Turnover /// - [JsonProperty("trade_turnover")] - public long TradeTurnover { get; set; } + [JsonPropertyName("trade_turnover")] + public decimal TradeTurnover { get; set; } /// /// Best bid /// - [JsonProperty("bid")] - public HuobiOrderBookEntry BestBid { get; set; } = null!; + [JsonPropertyName("bid")] + public HTXOrderBookEntry BestBid { get; set; } = null!; /// /// Best ask /// - [JsonProperty("ask")] - public HuobiOrderBookEntry BestAsk { get; set; } = null!; + [JsonPropertyName("ask")] + public HTXOrderBookEntry BestAsk { get; set; } = null!; } } diff --git a/Huobi.Net/Objects/Models/Socket/HuobiTradeUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXTradeUpdate.cs similarity index 70% rename from Huobi.Net/Objects/Models/Socket/HuobiTradeUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXTradeUpdate.cs index d84aac4a..71120829 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiTradeUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXTradeUpdate.cs @@ -1,125 +1,133 @@ -using System; -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.Socket +namespace HTX.Net.Objects.Models.Socket { /// /// Trade update /// - public record HuobiTradeUpdate + public record HTXTradeUpdate { /// /// Event type /// + [JsonPropertyName("eventType")] public string EventType { get; set; } = string.Empty; /// /// The symbol /// + [JsonPropertyName("symbol")] public string Symbol { get; set; } = string.Empty; /// /// Order id /// + [JsonPropertyName("orderId")] public long OrderId { get; set; } /// /// Price of this trade /// - [JsonProperty("tradePrice")] + [JsonPropertyName("tradePrice")] public decimal Price { get; set; } /// /// Volume of this trade /// - [JsonProperty("tradeVolume")] + [JsonPropertyName("tradeVolume")] public decimal Quantity { get; set; } /// /// Order side /// - [JsonProperty("orderSide"), JsonConverter(typeof(OrderSideConverter))] + [JsonPropertyName("orderSide"), JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// Order type /// - [JsonProperty("orderType"), JsonConverter(typeof(OrderTypeConverter))] + [JsonPropertyName("orderType"), JsonConverter(typeof(EnumConverter))] public OrderType Type { get; set; } /// /// Is the taker /// - [JsonProperty("aggressor")] + [JsonPropertyName("aggressor")] public bool IsTaker { get; set; } /// /// Trade id /// - [JsonProperty("tradeId")] + [JsonPropertyName("tradeId")] public long Id { get; set; } /// /// Time of trade /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("tradeTime")] + [JsonPropertyName("tradeTime")] public DateTime Timestamp { get; set; } /// /// Transaction fee /// - [JsonProperty("transactFee")] + [JsonPropertyName("transactFee")] public decimal TransactionFee { get; set; } /// /// Asset of the fee /// - [JsonProperty("feeCurrency")] + [JsonPropertyName("feeCurrency")] public string FeeAsset { get; set; } = string.Empty; /// /// Fee deduction quantity /// + [JsonPropertyName("feeDeduct")] public decimal FeeDeduct { get; set; } /// /// Fee deduction type /// + [JsonPropertyName("feeDeductType")] public string FeeDeductType { get; set; } = string.Empty; /// /// Account id /// + [JsonPropertyName("accountId")] public long AccountId { get; set; } /// /// Order source /// - [JsonProperty("source")] + [JsonPropertyName("source")] public string OrderSource { get; set; } = string.Empty; /// /// Order price /// + [JsonPropertyName("orderPrice")] public decimal OrderPrice { get; set; } /// /// Order quantity /// - [JsonProperty("orderSize")] + [JsonPropertyName("orderSize")] public decimal OrderQuantity { get; set; } /// /// Client order id /// + [JsonPropertyName("clientOrderId")] public string? ClientOrderId { get; set; } /// /// Stop price /// + [JsonPropertyName("stopPrice")] public decimal? StopPrice { get; set; } /// /// Operator /// + [JsonPropertyName("operator")] public string? Operator { get; set; } /// /// Order creation time /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("orderCreateTime")] public DateTime OrderCreateTime { get; set; } /// /// Order status /// - [JsonConverter(typeof(OrderStateConverter))] - public OrderState OrderStatus { get; set; } + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("orderStatus")] + public OrderStatus OrderStatus { get; set; } } } diff --git a/Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapBasisUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapBasisUpdate.cs similarity index 68% rename from Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapBasisUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapBasisUpdate.cs index 6d81a901..5dcb7442 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapBasisUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapBasisUpdate.cs @@ -1,33 +1,35 @@ -using Newtonsoft.Json; -namespace Huobi.Net.Objects.Models.Socket + +namespace HTX.Net.Objects.Models.Socket { /// /// Basis update /// - public record HuobiUsdtMarginSwapBasisUpdate + public record HTXUsdtMarginSwapBasisUpdate { /// /// Id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Index price /// - [JsonProperty("index_price")] + [JsonPropertyName("index_price")] public decimal IndexPrice { get; set; } /// /// Contract price /// - [JsonProperty("contract_price")] + [JsonPropertyName("contract_price")] public decimal ContractPrice { get; set; } /// /// Basis /// + [JsonPropertyName("basis")] public decimal Basis { get; set; } /// /// Basis rate /// - [JsonProperty("basis_rate")] + [JsonPropertyName("basis_rate")] public decimal BasisRate { get; set; } } } diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractElementsUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractElementsUpdate.cs new file mode 100644 index 00000000..5cca006a --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractElementsUpdate.cs @@ -0,0 +1,168 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Models.UsdtMarginSwap; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + internal record HTXUsdtMarginSwapContractElementsUpdateWrapper : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public string Event { get; set; } = string.Empty; + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// Contract element info + /// + public record HTXUsdtMarginSwapContractElementsUpdate + { + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Funding rate cap + /// + [JsonPropertyName("funding_rate_cap")] + public decimal? FundingRateCap { get; set; } + /// + /// Funding rate floor + /// + [JsonPropertyName("funding_rate_floor")] + public decimal? FundingRateFloor { get; set; } + /// + /// Mode type + /// + [JsonPropertyName("mode_type")] + public ElementModeType? ModeType { get; set; } + /// + /// Swap delivery type + /// + [JsonPropertyName("swap_delivery_type")] + public SwapDeliveryType? SwapDeliveryType { get; set; } + /// + /// Settle period + /// + [JsonPropertyName("settle_period")] + public int? SettlePeriod { get; set; } + /// + /// Instrument index code + /// + [JsonPropertyName("instrument_index_code")] + public string? InstrumentIndexCode { get; set; } = string.Empty; + /// + /// Price ticks + /// + [JsonPropertyName("price_ticks")] + public IEnumerable? PriceTicks { get; set; } + /// + /// Instrument values + /// + [JsonPropertyName("instrument_values")] + public IEnumerable? InstrumentValues { get; set; } + /// + /// Min level + /// + [JsonPropertyName("min_level")] + public decimal? MinLevel { get; set; } + /// + /// Max level + /// + [JsonPropertyName("max_level")] + public decimal? MaxLevel { get; set; } + /// + /// Order limits + /// + [JsonPropertyName("order_limits")] + public IEnumerable? OrderLimits { get; set; } + /// + /// Normal limits + /// + [JsonPropertyName("normal_limits")] + public IEnumerable? NormalLimits { get; set; } + /// + /// Open limits + /// + [JsonPropertyName("open_limits")] + public IEnumerable? OpenLimits { get; set; } + /// + /// Trade limits + /// + [JsonPropertyName("trade_limits")] + public IEnumerable? TradeLimits { get; set; } + + /// + /// Instrument types + /// + [JsonPropertyName("instrument_type")] + public IEnumerable InstrumentTypes { get; set; } = Array.Empty(); + /// + /// Real time settlement + /// + [JsonPropertyName("real_time_settlement")] + public bool? RealTimeSettlement { get; set; } + /// + /// Transfer profit ratio + /// + [JsonPropertyName("transfer_profit_ratio")] + public decimal? TransferProfitRatio { get; set; } + /// + /// Cross transfer profit ratio + /// + [JsonPropertyName("cross_transfer_profit_ratio")] + public decimal? CrossTransferProfitRatio { get; set; } + /// + /// Price tick + /// + [JsonPropertyName("price_tick")] + public decimal? PriceTick { get; set; } + /// + /// Instrument value + /// + [JsonPropertyName("instrument_value")] + public decimal? InstrumentValue { get; set; } + /// + /// Trade partition + /// + [JsonPropertyName("trade_partition")] + public string? TradePartition { get; set; } = string.Empty; + /// + /// Open order limit + /// + [JsonPropertyName("open_order_limit")] + public decimal? OpenOrderLimit { get; set; } + /// + /// Offset order limit + /// + [JsonPropertyName("offset_order_limit")] + public decimal? OffsetOrderLimit { get; set; } + /// + /// Long position limit + /// + [JsonPropertyName("long_position_limit")] + public decimal? LongPositionLimit { get; set; } + /// + /// Short position limit + /// + [JsonPropertyName("short_position_limit")] + public decimal? ShortPositionLimit { get; set; } + /// + /// Contract infos + /// + [JsonPropertyName("contract_infos")] + public IEnumerable? ContractInfos { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractUpdate.cs new file mode 100644 index 00000000..e2c7f0a0 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapContractUpdate.cs @@ -0,0 +1,101 @@ +using HTX.Net.Objects.Sockets; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// + /// + internal record HTXUsdtMarginSwapContractUpdateWrapper : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public string Event { get; set; } = string.Empty; + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// Contract update + /// + public record HTXUsdtMarginSwapContractUpdate + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Contract quantity + /// + [JsonPropertyName("contract_size")] + public decimal ContractQuantity { get; set; } + /// + /// Price tick + /// + [JsonPropertyName("price_tick")] + public decimal PriceTick { get; set; } + /// + /// Settlement date + /// + [JsonPropertyName("settlement_date")] + public DateTime SettlementDate { get; set; } + /// + /// Create date + /// + [JsonPropertyName("create_date")] + public DateTime CreateDate { get; set; } + /// + /// Contract status + /// + [JsonPropertyName("contract_status")] + public ContractStatus ContractStatus { get; set; } + /// + /// Support margin mode + /// + [JsonPropertyName("support_margin_mode")] + public MarginMode SupportMarginMode { get; set; } + /// + /// Delivery time + /// + [JsonPropertyName("delivery_time")] + public DateTime? DeliveryTime { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType? BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Delivery date + /// + [JsonPropertyName("delivery_date")] + public DateTime? DeliveryDate { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossBalanceUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossBalanceUpdate.cs new file mode 100644 index 00000000..9701e38d --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossBalanceUpdate.cs @@ -0,0 +1,245 @@ +using HTX.Net.Objects.Sockets; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Cross margin balance update + /// + public record HTXUsdtMarginSwapCrossBalanceUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public EventTrigger Event { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + /// + /// User id + /// + [JsonPropertyName("uid")] + public decimal UserId { get; set; } + } + + /// + /// + /// + public record HTXUsdtMarginSwapCrossBalanceUpdateData + { + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin balance + /// + [JsonPropertyName("margin_balance")] + public decimal MarginBalance { get; set; } + /// + /// Static margin + /// + [JsonPropertyName("margin_static")] + public decimal MarginStatic { get; set; } + /// + /// Margin position + /// + [JsonPropertyName("margin_position")] + public decimal MarginPosition { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Realized profit and loss + /// + [JsonPropertyName("profit_real")] + public decimal RealizedPnl { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Withdraw available + /// + [JsonPropertyName("withdraw_available")] + public decimal WithdrawAvailable { get; set; } + /// + /// Risk rate + /// + [JsonPropertyName("risk_rate")] + public decimal? RiskRate { get; set; } + /// + /// Position mode + /// + [JsonPropertyName("position_mode")] + public PositionMode PositionMode { get; set; } + /// + /// Contract detail + /// + [JsonPropertyName("contract_detail")] + public IEnumerable ContractDetail { get; set; } = Array.Empty(); + /// + /// Futures contract detail + /// + [JsonPropertyName("futures_contract_detail")] + public IEnumerable FuturesContractDetail { get; set; } = Array.Empty(); + } + + /// + /// Contract info + /// + public record HTXUsdtMarginSwapCrossBalanceUpdateContract + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin position + /// + [JsonPropertyName("margin_position")] + public decimal MarginPosition { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Margin available + /// + [JsonPropertyName("margin_available")] + public decimal MarginAvailable { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Liquidation price + /// + [JsonPropertyName("liquidation_price")] + public decimal? LiquidationPrice { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } + /// + /// Adjust factor + /// + [JsonPropertyName("adjust_factor")] + public decimal AdjustFactor { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + } + + /// + /// Futures contract + /// + public record HTXUsdtMarginSwapCrossBalanceUpdateFutures + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin position + /// + [JsonPropertyName("margin_position")] + public decimal MarginPosition { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Margin available + /// + [JsonPropertyName("margin_available")] + public decimal MarginAvailable { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Liquidation price + /// + [JsonPropertyName("liquidation_price")] + public decimal? LiquidationPrice { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } + /// + /// Adjust factor + /// + [JsonPropertyName("adjust_factor")] + public decimal AdjustFactor { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossPositionUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossPositionUpdate.cs new file mode 100644 index 00000000..313a8e54 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossPositionUpdate.cs @@ -0,0 +1,54 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Cross margin position update + /// + public record HTXUsdtMarginSwapCrossPositionUpdate : HTXOpMessage + { + /// + /// Data timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public EventTrigger Event { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + } + + /// + /// Cross margin position data + /// + public record HTXUsdtMarginSwapCrossPositionUpdateData : HTXUsdtMarginSwapIsolatedPositionUpdateData + { + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTradeUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTradeUpdate.cs new file mode 100644 index 00000000..0ec3078d --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTradeUpdate.cs @@ -0,0 +1,26 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Cross margin trade update + /// + public record HTXUsdtMarginSwapCrossTradeUpdate : HTXUsdtMarginSwapIsolatedTradeUpdate + { + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTriggerOrderUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTriggerOrderUpdate.cs new file mode 100644 index 00000000..9a132771 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapCrossTriggerOrderUpdate.cs @@ -0,0 +1,54 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Trigger order update + /// + public record HTXUsdtMarginSwapCrossTriggerOrderUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime? Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public EventOrderTrigger EventOrderTrigger { get; set; } + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// Trigger update + /// + public record HTXUsdtMarginSwapCrossTriggerOrderUpdateData : HTXUsdtMarginSwapIsolatedTriggerOrderUpdateData + { + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapFundingRateUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapFundingRateUpdate.cs new file mode 100644 index 00000000..0f15f044 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapFundingRateUpdate.cs @@ -0,0 +1,65 @@ +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// + /// + internal record HTXUsdtMarginSwapFundingRateUpdateWrapper : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// Funding rate update + /// + public record HTXUsdtMarginSwapFundingRateUpdate + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Fee asset + /// + [JsonPropertyName("fee_asset")] + public string FeeAsset { get; set; } = string.Empty; + /// + /// Funding time + /// + [JsonPropertyName("funding_time")] + public DateTime FundingTime { get; set; } + /// + /// Funding rate + /// + [JsonPropertyName("funding_rate")] + public decimal FundingRate { get; set; } + /// + /// Settlement time + /// + [JsonPropertyName("settlement_time")] + public DateTime SettlementTime { get; set; } + /// + /// Estimated rate + /// + [JsonPropertyName("estimated_rate")] + public decimal? EstimatedRate { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedBalanceUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedBalanceUpdate.cs new file mode 100644 index 00000000..472baf9b --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedBalanceUpdate.cs @@ -0,0 +1,131 @@ +using HTX.Net.Objects.Sockets; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Isolated balance update + /// + public record HTXUsdtMarginSwapIsolatedBalanceUpdate: HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event trigger + /// + [JsonPropertyName("event")] + public EventTrigger Event { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + } + + /// + /// Isolated margin balance update + /// + public record HTXUsdtMarginSwapIsolatedBalanceUpdateData + { + /// + /// Asset + /// + [JsonPropertyName("symbol")] + public string Asset { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin balance + /// + [JsonPropertyName("margin_balance")] + public decimal MarginBalance { get; set; } + /// + /// Static equity + /// + [JsonPropertyName("margin_static")] + public decimal MarginStatic { get; set; } + /// + /// Margin position + /// + [JsonPropertyName("margin_position")] + public decimal MarginPosition { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Margin available + /// + [JsonPropertyName("margin_available")] + public decimal MarginAvailable { get; set; } + /// + /// Realized profit and loss + /// + [JsonPropertyName("profit_real")] + public decimal RealizedPnl { get; set; } + /// + /// Unrealized proft and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Withdraw available + /// + [JsonPropertyName("withdraw_available")] + public decimal WithdrawAvailable { get; set; } + /// + /// Risk rate + /// + [JsonPropertyName("risk_rate")] + public decimal? RiskRate { get; set; } + /// + /// Liquidation price + /// + [JsonPropertyName("liquidation_price")] + public decimal? LiquidationPrice { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } + /// + /// Adjust factor + /// + [JsonPropertyName("adjust_factor")] + public decimal AdjustFactor { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Position mode + /// + [JsonPropertyName("position_mode")] + public PositionMode PositionMode { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedPositionUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedPositionUpdate.cs new file mode 100644 index 00000000..7b4710ef --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedPositionUpdate.cs @@ -0,0 +1,136 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Position data update + /// + public record HTXUsdtMarginSwapIsolatedPositionUpdate : HTXOpMessage + { + /// + /// Data timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public EventTrigger Event { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + } + + /// + /// Position data + /// + public record HTXUsdtMarginSwapIsolatedPositionUpdateData + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Available + /// + [JsonPropertyName("available")] + public decimal Available { get; set; } + /// + /// Frozen + /// + [JsonPropertyName("frozen")] + public decimal Frozen { get; set; } + /// + /// Open price + /// + [JsonPropertyName("cost_open")] + public decimal OpenPrice { get; set; } + /// + /// Position price + /// + [JsonPropertyName("cost_hold")] + public decimal PositionPrice { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Profit / loss ratio + /// + [JsonPropertyName("profit_rate")] + public decimal ProfitRate { get; set; } + /// + /// Profit and loss + /// + [JsonPropertyName("profit")] + public decimal Pnl { get; set; } + /// + /// Position margin + /// + [JsonPropertyName("position_margin")] + public decimal PositionMargin { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Last price + /// + [JsonPropertyName("last_price")] + public decimal LastPrice { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Position mode + /// + [JsonPropertyName("position_mode")] + public PositionMode PositionMode { get; set; } + /// + /// Adl risk percent + /// + [JsonPropertyName("adl_risk_percent")] + public decimal? AdlRiskPercent { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTradeUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTradeUpdate.cs new file mode 100644 index 00000000..19040ada --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTradeUpdate.cs @@ -0,0 +1,171 @@ +using HTX.Net.Objects.Sockets; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Order trade update + /// + public record HTXUsdtMarginSwapIsolatedTradeUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Status + /// + [JsonPropertyName("status")] + public OrderStatusFilter Status { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Client order id + /// + [JsonPropertyName("client_order_id")] + public string? ClientOrderId { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public MarginOrderType OrderType { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Trades + /// + [JsonPropertyName("trade")] + public IEnumerable Trades { get; set; } = Array.Empty(); + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Quantity filled + /// + [JsonPropertyName("trade_volume")] + public decimal QuantityFilled { get; set; } + /// + /// Order side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Is take profit / stop loss + /// + [JsonPropertyName("is_tpsl")] + public bool IsTpsl { get; set; } + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + } + + /// + /// + /// + public record HTXUsdtMarginSwapIsolatedTradeUpdateTrade + { + /// + /// Trade id + /// + [JsonPropertyName("trade_id")] + public long TradeId { get; set; } + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("trade_volume")] + public decimal Quantity { get; set; } + /// + /// Price + /// + [JsonPropertyName("trade_price")] + public decimal Price { get; set; } + /// + /// Value + /// + [JsonPropertyName("trade_turnover")] + public decimal Value { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Role + /// + [JsonPropertyName("role")] + public OrderRole Role { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTriggerOrderUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTriggerOrderUpdate.cs new file mode 100644 index 00000000..f92f6bc7 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapIsolatedTriggerOrderUpdate.cs @@ -0,0 +1,171 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Trigger order update + /// + public record HTXUsdtMarginSwapIsolatedTriggerOrderUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime? Timestamp { get; set; } + /// + /// Event + /// + [JsonPropertyName("event")] + public EventOrderTrigger EventOrderTrigger { get; set; } + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// + /// + public record HTXUsdtMarginSwapIsolatedTriggerOrderUpdateData + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Trigger type + /// + [JsonPropertyName("trigger_type")] + public TriggerType? TriggerType { get; set; } + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public int? OrderType { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string RelationOrderId { get; set; } = string.Empty; + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType? OrderPriceType { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public OrderStatusFilter? OrderStatus { get; set; } + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Trigger price + /// + [JsonPropertyName("trigger_price")] + public decimal TriggerPrice { get; set; } + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public decimal? TriggeredPrice { get; set; } + /// + /// Order price + /// + [JsonPropertyName("order_price")] + public decimal? OrderPrice { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Triggered time + /// + [JsonPropertyName("triggered_at")] + public DateTime? TriggerTime { get; set; } + /// + /// Order insert time + /// + [JsonPropertyName("order_insert_at")] + public DateTime? OrderInsertTime { get; set; } + /// + /// Cancel time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Fail code + /// + [JsonPropertyName("fail_code")] + public string? FailCode { get; set; } + /// + /// Fail reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapLiquidationUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapLiquidationUpdate.cs new file mode 100644 index 00000000..b6df71f7 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapLiquidationUpdate.cs @@ -0,0 +1,91 @@ +using HTX.Net.Objects.Sockets; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Liquidation update + /// + public record HTXUsdtMarginSwapLiquidationUpdate : HTXOpMessage + { + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime? Timestamp { get; set; } + /// + /// Data + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = Array.Empty(); + } + + /// + /// + /// + public record HTXUsdtMarginSwapLiquidationUpdateData + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Volume + /// + [JsonPropertyName("volume")] + public decimal Volume { get; set; } + /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Liquidation quantity + /// + [JsonPropertyName("amount")] + public decimal Quantity { get; set; } + /// + /// Trade turnover + /// + [JsonPropertyName("trade_turnover")] + public decimal TradeTurnover { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapOrderUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapOrderUpdate.cs new file mode 100644 index 00000000..3c5efdd6 --- /dev/null +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapOrderUpdate.cs @@ -0,0 +1,251 @@ +using HTX.Net.Enums; +using HTX.Net.Objects.Sockets; + +namespace HTX.Net.Objects.Models.Socket +{ + /// + /// Order update + /// + public record HTXUsdtMarginSwapOrderUpdate : HTXOpMessage + { + /// + /// Update timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// User id + /// + [JsonPropertyName("uid")] + public long UserId { get; set; } + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Order side + /// + [JsonPropertyName("direction")] + public string OrderSide { get; set; } = string.Empty; + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public OrderStatusFilter OrderStatus { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Client order id + /// + [JsonPropertyName("client_order_id")] + public long? ClientOrderId { get; set; } + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public int OrderType { get; set; } + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Quantity filled + /// + [JsonPropertyName("trade_volume")] + public decimal QuantityFilled { get; set; } + /// + /// Value filled in quote asset + /// + [JsonPropertyName("trade_turnover")] + public decimal ValueFilled { get; set; } + /// + /// Fee + /// + [JsonPropertyName("fee")] + public decimal Fee { get; set; } + /// + /// Liquidation type + /// + [JsonPropertyName("liquidation_type")] + public LiquidationType? LiquidationType { get; set; } + /// + /// Average trade price + /// + [JsonPropertyName("trade_avg_price")] + public decimal AveragePrice { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Profit + /// + [JsonPropertyName("profit")] + public decimal Profit { get; set; } + /// + /// Canceled at + /// + [JsonPropertyName("canceled_at")] + public DateTime? CanceledAt { get; set; } + /// + /// Fee asset + /// + [JsonPropertyName("fee_asset")] + public string FeeAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Is take profit / stop loss + /// + [JsonPropertyName("is_tpsl")] + public bool IsTpsl { get; set; } + /// + /// Profit and loss + /// + [JsonPropertyName("real_profit")] + public decimal RealizedPnl { get; set; } + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + /// + /// Canceled source + /// + [JsonPropertyName("canceled_source")] + public string? CanceledSource { get; set; } + /// + /// Trade info + /// + [JsonPropertyName("trade")] + public IEnumerable Trade { get; set; } = Array.Empty(); + } + + /// + /// Trade info + /// + public record HTXUsdtMarginSwapOrderUpdateTrade + { + /// + /// Trade id + /// + [JsonPropertyName("trade_id")] + public long TradeId { get; set; } + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Trade quantity + /// + [JsonPropertyName("trade_volume")] + public decimal Quantity { get; set; } + /// + /// Trade price + /// + [JsonPropertyName("trade_price")] + public decimal Price { get; set; } + /// + /// Fee + /// + [JsonPropertyName("trade_fee")] + public decimal Fee { get; set; } + /// + /// Fee asset + /// + [JsonPropertyName("fee_asset")] + public string FeeAsset { get; set; } = string.Empty; + /// + /// Deduction asset price + /// + [JsonPropertyName("price")] + public decimal? DeductionAssetPrice { get; set; } + /// + /// Trade value + /// + [JsonPropertyName("trade_turnover")] + public decimal Value { get; set; } + /// + /// Created at + /// + [JsonPropertyName("created_at")] + public DateTime CreatedAt { get; set; } + /// + /// Role + /// + [JsonPropertyName("role")] + public OrderRole Role { get; set; } + /// + /// Profit + /// + [JsonPropertyName("profit")] + public decimal Profit { get; set; } + /// + /// Real profit + /// + [JsonPropertyName("real_profit")] + public decimal RealProfit { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapTradeUpdate.cs b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapTradeUpdate.cs similarity index 67% rename from Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapTradeUpdate.cs rename to HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapTradeUpdate.cs index 986242a0..6870b893 100644 --- a/Huobi.Net/Objects/Models/Socket/HuobiUsdtMarginSwapTradeUpdate.cs +++ b/HTX.Net/Objects/Models/Socket/HTXUsdtMarginSwapTradeUpdate.cs @@ -1,70 +1,71 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.Socket +namespace HTX.Net.Objects.Models.Socket { /// /// Trade info /// - public record HuobiUsdtMarginSwapTradesUpdate + public record HTXUsdtMarginSwapTradesUpdate { /// /// Update id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Update timestamp /// - [JsonProperty("ts")] + [JsonPropertyName("ts")] [JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// Trades /// - [JsonProperty("data")] - public IEnumerable Trades { get; set; } = Array.Empty(); + [JsonPropertyName("data")] + public IEnumerable Trades { get; set; } = Array.Empty(); } /// /// Trade info /// - public record HuobiUsdtMarginSwapTradeUpdate + public record HTXUsdtMarginSwapTradeUpdate { /// /// Amount of trades /// + [JsonPropertyName("amount")] public int Amount { get; set; } /// /// Timestamp /// - [JsonProperty("ts")] + [JsonPropertyName("ts")] [JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } /// /// Trade id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Price /// + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// Side /// - [JsonProperty("direction")] + [JsonPropertyName("direction")] [JsonConverter(typeof(EnumConverter))] public OrderSide Side { get; set; } /// /// Quantity /// + [JsonPropertyName("quantity")] public decimal Quantity { get; set; } /// /// Turnover /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal TradeTurnover { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXAccountSentiment.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXAccountSentiment.cs new file mode 100644 index 00000000..26914bac --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXAccountSentiment.cs @@ -0,0 +1,65 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Account sentiment + /// + public record HTXAccountSentiment + { + /// + /// List + /// + [JsonPropertyName("list")] + public IEnumerable List { get; set; } = Array.Empty(); + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + /// + /// Sentiment value + /// + public record HTXAccountSentimentValue + { + /// + /// Buy ratio + /// + [JsonPropertyName("buy_ratio")] + public decimal BuyRatio { get; set; } + /// + /// Sell ratio + /// + [JsonPropertyName("sell_ratio")] + public decimal SellRatio { get; set; } + /// + /// Locked ratio + /// + [JsonPropertyName("locked_ratio")] + public decimal LockedRatio { get; set; } + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiAssetValue.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXAssetValue.cs similarity index 65% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiAssetValue.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXAssetValue.cs index b1897872..a5fb0551 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiAssetValue.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXAssetValue.cs @@ -1,20 +1,21 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Asset valuation /// - public record HuobiAssetValue + public record HTXAssetValue { /// /// Asset name /// - [JsonProperty("valuation_asset")] + [JsonPropertyName("valuation_asset")] public string Asset { get; set; } = string.Empty; /// /// Balance /// + [JsonPropertyName("balance")] public decimal Balance { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBasisData.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXBasisData.cs similarity index 69% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBasisData.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXBasisData.cs index 4332fc3e..e1d3a960 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBasisData.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXBasisData.cs @@ -1,34 +1,36 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Basis data /// - public record HuobiBasisData + public record HTXBasisData { /// /// Basis /// + [JsonPropertyName("basis")] public decimal Basis { get; set; } /// /// Basis rate /// - [JsonProperty("basis_rate")] + [JsonPropertyName("basis_rate")] public decimal BasisRate { get; set; } /// /// Contract price /// - [JsonProperty("contract_price")] + [JsonPropertyName("contract_price")] public decimal ContractPrice { get; set; } /// /// Index price /// - [JsonProperty("index_price")] + [JsonPropertyName("index_price")] public decimal IndexPrice { get; set; } /// /// Unique id /// + [JsonPropertyName("id")] public long Id { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBatchResult.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXBatchResult.cs similarity index 64% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBatchResult.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXBatchResult.cs index aca9ac91..9d5a0cde 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiBatchResult.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXBatchResult.cs @@ -1,42 +1,41 @@ -using Newtonsoft.Json; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Batch result /// - public record HuobiBatchResult + public record HTXBatchResult { /// /// Errors in the batch /// - public IEnumerable Errors { get; set; } = new List(); + [JsonPropertyName("errors")] + public IEnumerable Errors { get; set; } = new List(); /// /// Success /// + [JsonPropertyName("successes")] public string Successes { get; set; } = string.Empty; } /// /// Batch operation error /// - public record HuobiBatchError + public record HTXBatchError { /// /// Order id /// - [JsonProperty("order_id")] + [JsonPropertyName("order_id")] public string OrderId { get; set; } = string.Empty; /// /// Error code /// - [JsonProperty("err_code")] + [JsonPropertyName("err_code")] public int ErrorCode { get; set; } /// /// Error message /// - [JsonProperty("err_msg")] + [JsonPropertyName("err_msg")] public string ErrorMessage { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCancelAfter.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCancelAfter.cs new file mode 100644 index 00000000..6f44b488 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCancelAfter.cs @@ -0,0 +1,19 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Cancel after status + /// + public record HTXCancelAfter + { + /// + /// Current time + /// + [JsonPropertyName("current_time")] + public DateTime CurrentTime { get; set; } + /// + /// Trigger time + /// + [JsonPropertyName("trigger_time")] + public DateTime? TriggerTime { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosePositionResult.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosePositionResult.cs new file mode 100644 index 00000000..5ff9b860 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosePositionResult.cs @@ -0,0 +1,26 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Close position result + /// + public record HTXClosePositionResult + { + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long? OrderId { get; set; } + /// + /// Order id str + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Client order id + /// + [JsonPropertyName("client_order_id")] + public long? ClientOrderId { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedCrossTriggerOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedCrossTriggerOrderPage.cs new file mode 100644 index 00000000..3f54eecd --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedCrossTriggerOrderPage.cs @@ -0,0 +1,78 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trigger order page + /// + public record HTXClosedCrossTriggerOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trigger order + /// + public record HTXClosedCrossTriggerOrder : HTXCrossTriggerOrder + { + /// + /// Cancel time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Trigger time + /// + [JsonPropertyName("triggered_at")] + public DateTime? TriggerTime { get; set; } + /// + /// Order insert time + /// + [JsonPropertyName("order_insert_at")] + public DateTime? OrderInsertTime { get; set; } + /// + /// Update time + /// + [JsonPropertyName("update_time")] + public DateTime? UpdateTime { get; set; } + /// + /// Error code + /// + [JsonPropertyName("fail_code")] + public int? FailCode { get; set; } + /// + /// Error reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public int? TriggeredPrice { get; set; } + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string? RelationOrderId { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedTriggerOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedTriggerOrderPage.cs new file mode 100644 index 00000000..7b0f8245 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXClosedTriggerOrderPage.cs @@ -0,0 +1,78 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trigger order page + /// + public record HTXClosedTriggerOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trigger order + /// + public record HTXClosedTriggerOrder : HTXTriggerOrder + { + /// + /// Cancel time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Trigger time + /// + [JsonPropertyName("triggered_at")] + public DateTime? TriggerTime { get; set; } + /// + /// Order insert time + /// + [JsonPropertyName("order_insert_at")] + public DateTime? OrderInsertTime { get; set; } + /// + /// Update time + /// + [JsonPropertyName("update_time")] + public DateTime? UpdateTime { get; set; } + /// + /// Error code + /// + [JsonPropertyName("fail_code")] + public int? FailCode { get; set; } + /// + /// Error reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public int? TriggeredPrice { get; set; } + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string? RelationOrderId { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractElements.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractElements.cs new file mode 100644 index 00000000..740a31d1 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractElements.cs @@ -0,0 +1,241 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Contract element info + /// + public record HTXContractElements + { + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Funding rate cap + /// + [JsonPropertyName("funding_rate_cap")] + public decimal FundingRateCap { get; set; } + /// + /// Funding rate floor + /// + [JsonPropertyName("funding_rate_floor")] + public decimal FundingRateFloor { get; set; } + /// + /// Mode type + /// + [JsonPropertyName("mode_type")] + public ElementModeType ModeType { get; set; } + /// + /// Swap delivery type + /// + [JsonPropertyName("swap_delivery_type")] + public SwapDeliveryType SwapDeliveryType { get; set; } + /// + /// Settle period + /// + [JsonPropertyName("settle_period")] + public int SettlePeriod { get; set; } + /// + /// Instrument index code + /// + [JsonPropertyName("instrument_index_code")] + public string InstrumentIndexCode { get; set; } = string.Empty; + /// + /// Price ticks + /// + [JsonPropertyName("price_ticks")] + public IEnumerable PriceTicks { get; set; } = Array.Empty(); + /// + /// Instrument values + /// + [JsonPropertyName("instrument_values")] + public IEnumerable InstrumentValues { get; set; } = Array.Empty(); + /// + /// Min level + /// + [JsonPropertyName("min_level")] + public decimal MinLevel { get; set; } + /// + /// Max level + /// + [JsonPropertyName("max_level")] + public decimal MaxLevel { get; set; } + /// + /// Order limits + /// + [JsonPropertyName("order_limits")] + public IEnumerable OrderLimits { get; set; } = Array.Empty(); + /// + /// Normal limits + /// + [JsonPropertyName("normal_limits")] + public IEnumerable NormalLimits { get; set; } = Array.Empty(); + /// + /// Open limits + /// + [JsonPropertyName("open_limits")] + public IEnumerable OpenLimits { get; set; } = Array.Empty(); + /// + /// Trade limits + /// + [JsonPropertyName("trade_limits")] + public IEnumerable TradeLimits { get; set; } = Array.Empty(); + /// + /// Real time settlement + /// + [JsonPropertyName("real_time_settlement")] + public bool RealTimeSettlement { get; set; } + /// + /// Transfer profit ratio + /// + [JsonPropertyName("transfer_profit_ratio")] + public decimal TransferProfitRatio { get; set; } + /// + /// Cross transfer profit ratio + /// + [JsonPropertyName("cross_transfer_profit_ratio")] + public decimal CrossTransferProfitRatio { get; set; } + /// + /// Instrument types + /// + [JsonPropertyName("instrument_type")] + public IEnumerable InstrumentTypes { get; set; } = Array.Empty(); + /// + /// Price tick + /// + [JsonPropertyName("price_tick")] + public decimal PriceTick { get; set; } + /// + /// Instrument value + /// + [JsonPropertyName("instrument_value")] + public decimal InstrumentValue { get; set; } + /// + /// Trade partition + /// + [JsonPropertyName("trade_partition")] + public string TradePartition { get; set; } = string.Empty; + /// + /// Open order limit + /// + [JsonPropertyName("open_order_limit")] + public decimal OpenOrderLimit { get; set; } + /// + /// Offset order limit + /// + [JsonPropertyName("offset_order_limit")] + public decimal OffsetOrderLimit { get; set; } + /// + /// Long position limit + /// + [JsonPropertyName("long_position_limit")] + public decimal LongPositionLimit { get; set; } + /// + /// Short position limit + /// + [JsonPropertyName("short_position_limit")] + public decimal ShortPositionLimit { get; set; } + /// + /// Contract infos + /// + [JsonPropertyName("contract_infos")] + public IEnumerable ContractInfos { get; set; } = Array.Empty(); + } + + /// + /// Price info + /// + public record HTXContractElementsPriceTick + { + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public ElementBusinessType BusinessType { get; set; } + /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + } + + /// + /// Limit info + /// + public record HTXContractElementsLimit + { + /// + /// Instrument type + /// + [JsonPropertyName("instrument_type")] + public ElementInstrumentType InstrumentType { get; set; } + /// + /// Open + /// + [JsonPropertyName("open")] + public decimal Open { get; set; } + /// + /// Close + /// + [JsonPropertyName("close")] + public decimal Close { get; set; } + } + + /// + /// Order limit + /// + public record HTXContractElementsOrderLimit: HTXContractElementsLimit + { + /// + /// Open after closing + /// + [JsonPropertyName("open_after_closing")] + public decimal OpenAfterClosing { get; set; } + } + + /// + /// Contract info + /// + public record HTXContractElementsContractInfo + { + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Instrument type + /// + [JsonPropertyName("instrument_type")] + public ElementInstrumentType InstrumentType { get; set; } + /// + /// Settlement date + /// + [JsonPropertyName("settlement_date")] + public DateTime SettlementDate { get; set; } + /// + /// Delivery time + /// + [JsonPropertyName("delivery_time")] + public DateTime? DeliveryTime { get; set; } + /// + /// Create date + /// + [JsonPropertyName("create_date")] + public DateTime CreateDate { get; set; } + /// + /// Contract status + /// + [JsonPropertyName("contract_status")] + public ContractStatus ContractStatus { get; set; } + /// + /// Delivery date + /// + [JsonPropertyName("delivery_date")] + public DateTime? DeliveryDate { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractInfo.cs similarity index 74% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractInfo.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractInfo.cs index 534f4851..76ca4e06 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractInfo.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractInfo.cs @@ -1,87 +1,84 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Contract info /// - public record HuobiContractInfo + public record HTXContractInfo { /// /// The asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Contract size /// - [JsonProperty("contract_size")] + [JsonPropertyName("contract_size")] public decimal ContractSize { get; set; } /// /// Price tick /// - [JsonProperty("price_tick")] + [JsonPropertyName("price_tick")] public decimal PriceTick { get; set; } /// /// Deliverty date /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("delivery_date")] + [JsonPropertyName("delivery_date")] public DateTime? DeliveryDate { get; set; } /// /// Delivery time /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("delivery_time")] + [JsonPropertyName("delivery_time")] public DateTime? DeliveryTime { get; set; } /// /// Created date /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("create_date")] + [JsonPropertyName("create_date")] public DateTime CreateDate { get; set; } /// /// Status /// - [JsonProperty("contract_status")] + [JsonPropertyName("contract_status")] [JsonConverter(typeof(EnumConverter))] public ContractStatus Status { get; set; } /// /// Settlement date /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("settlement_date")] + [JsonPropertyName("settlement_date")] public DateTime SettlementDate { get; set; } /// /// Margin mode /// - [JsonProperty("support_margin_mode")] + [JsonPropertyName("support_margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] public ContractType ContractType { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractStatus.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractStatus.cs similarity index 72% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractStatus.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractStatus.cs index 084d1533..289b00e9 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiContractStatus.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXContractStatus.cs @@ -1,96 +1,98 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Contract status /// - public record HuobiContractStatus + public record HTXContractStatus { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Open order access /// + [JsonPropertyName("open")] public bool Open { get; set; } /// /// Close order access /// + [JsonPropertyName("close")] public bool Close { get; set; } /// /// Cancel order access /// + [JsonPropertyName("cancel")] public bool Cancel { get; set; } /// /// Deposit access /// - [JsonProperty("transfer_in")] + [JsonPropertyName("transfer_in")] public bool TranferIn { get; set; } /// /// Withdrawal access /// - [JsonProperty("transfer_out")] + [JsonPropertyName("transfer_out")] public bool TransferOut { get; set; } /// /// Transfer from master to sub /// - [JsonProperty("master_transfer_sub")] + [JsonPropertyName("master_transfer_sub")] public bool MasterTransferSub { get; set; } /// /// Transfer from sub to master /// - [JsonProperty("sub_transfer_master")] + [JsonPropertyName("sub_transfer_master")] public bool SubTransferMaster { get; set; } /// /// Master transfer sub inner in /// - [JsonProperty("master_transfer_sub_inner_in")] + [JsonPropertyName("master_transfer_sub_inner_in")] public bool MasterTransferSubInnerIn { get; set; } /// /// Master transfer sub inner out /// - [JsonProperty("master_transfer_sub_inner_out")] + [JsonPropertyName("master_transfer_sub_inner_out")] public bool MasterTransferSubInnerOut { get; set; } /// /// Sub transfer master inner in /// - [JsonProperty("sub_transfer_master_inner_in")] + [JsonPropertyName("sub_transfer_master_inner_in")] public bool SubTransferMasterInnerIn { get; set; } /// /// Sub transfer master inner out /// - [JsonProperty("sub_transfer_master_inner_out")] + [JsonPropertyName("sub_transfer_master_inner_out")] public bool SubTransferMasterInnerOut { get; set; } /// /// Transfer inner in /// - [JsonProperty("transfer_inner_in")] + [JsonPropertyName("transfer_inner_in")] public bool TransferInnerIn { get; set; } /// /// Tranfer inner out /// - [JsonProperty("transfer_inner_out")] + [JsonPropertyName("transfer_inner_out")] public bool TransferInnerOut { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossLeveragePositionLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossLeveragePositionLimit.cs new file mode 100644 index 00000000..6ab45d7d --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossLeveragePositionLimit.cs @@ -0,0 +1,70 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Levearege position limits + /// + public record HTXCrossLeveragePositionLimit + { + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// List + /// + [JsonPropertyName("list")] + public IEnumerable List { get; set; } = Array.Empty(); + } + + /// + /// Limits + /// + public record HTXCrossLeveragePositionLimitLeverage + { + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Buy limit value + /// + [JsonPropertyName("buy_limit_value")] + public decimal BuyLimitValue { get; set; } + /// + /// Sell limit value + /// + [JsonPropertyName("sell_limit_value")] + public decimal SellLimitValue { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountContract.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountContract.cs similarity index 61% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountContract.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountContract.cs index 9322d848..fe2a300f 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountContract.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountContract.cs @@ -1,80 +1,84 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Cross margin account contract details /// - public record HuobiCrossMarginAccountContract + public record HTXCrossMarginAccountContract { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin position /// - [JsonProperty("margin_position")] + [JsonPropertyName("margin_position")] public decimal MarginPosition { get; set; } /// /// Margin frozen /// - [JsonProperty("margin_frozen")] + [JsonPropertyName("margin_frozen")] public decimal MarginFrozen { get; set; } /// /// Margin available /// - [JsonProperty("margin_available")] + [JsonPropertyName("margin_available")] public decimal MarginAvailable { get; set; } /// - /// Profit unreal + /// Unrealized profit and loss /// - [JsonProperty("profit_unreal")] - public decimal ProfitUnreal { get; set; } + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } /// /// Liquidation price /// - [JsonProperty("liquidation_price")] + [JsonPropertyName("liquidation_price")] public decimal? LiquidationPrice { get; set; } /// - /// Lever rate + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } + /// + /// Cross max available /// - [JsonProperty("lever_rate")] - public decimal LeverRate { get; set; } + [JsonPropertyName("cross_max_available")] + public decimal? CrossMaxAvaialble { get; set; } /// /// Adjust factor /// - [JsonProperty("adjust_factor")] + [JsonPropertyName("adjust_factor")] public decimal AdjustFactor { get; set; } /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Trade partition /// - [JsonProperty("trade_partition")] + [JsonPropertyName("trade_partition")] public string TradePartition { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountInfo.cs new file mode 100644 index 00000000..9a0318b0 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAccountInfo.cs @@ -0,0 +1,113 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Account info + /// + public record HTXCrossMarginAccountInfo + { + /// + /// Margin balance + /// + [JsonPropertyName("margin_balance")] + public decimal MarginBalance { get; set; } + /// + /// Margin position + /// + [JsonPropertyName("margin_position")] + public decimal MarginPosition { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Margin available + /// + [JsonPropertyName("margin_available")] + public decimal MarginAvailable { get; set; } + /// + /// Realized profit and loss + /// + [JsonPropertyName("profit_real")] + public decimal RealizedPnl { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Risk rate + /// + [JsonPropertyName("risk_rate")] + public decimal? RiskRate { get; set; } + /// + /// New risk rate + /// + [JsonPropertyName("new_risk_rate")] + public decimal? NewRiskRate { get; set; } + /// + /// Withdraw available + /// + [JsonPropertyName("withdraw_available")] + public decimal WithdrawAvailable { get; set; } + /// + /// Money in + /// + [JsonPropertyName("money_in")] + public decimal? MoneyIn { get; set; } + /// + /// Money out + /// + [JsonPropertyName("money_out")] + public decimal? MoneyOut { get; set; } + /// + /// Margin static + /// + [JsonPropertyName("margin_static")] + public decimal MarginStatic { get; set; } + /// + /// Cross max available + /// + [JsonPropertyName("cross_max_available")] + public decimal CrossMaxAvailable { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Position mode + /// + [JsonPropertyName("position_mode")] + [JsonConverter(typeof(EnumConverter))] + public PositionMode PositionMode { get; set; } + /// + /// ADL risk percentage + /// + [JsonPropertyName("adl_risk_percent")] + public decimal? AdlRiskPercentage { get; set; } + /// + /// Contract details + /// + [JsonPropertyName("contract_detail")] + public IEnumerable ContractDetails { get; set; } = Array.Empty(); + /// + /// Futures contract details + /// + [JsonPropertyName("futures_contract_detail")] + public IEnumerable FuturesContractDetails { get; set; } = Array.Empty(); + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAssetsAndPositions.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAssetsAndPositions.cs new file mode 100644 index 00000000..ea69d0f5 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginAssetsAndPositions.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Cross margin assets and positions info + /// + public record HTXCrossMarginAssetsAndPositions : HTXCrossMarginAccountInfo + { + /// + /// Positions + /// + [JsonPropertyName("positions")] + public IEnumerable? Positions { get; set; } = Array.Empty(); + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginLeverageAvailable.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginLeverageAvailable.cs similarity index 62% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginLeverageAvailable.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginLeverageAvailable.cs index 60db32d7..bd3e79a3 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginLeverageAvailable.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginLeverageAvailable.cs @@ -1,29 +1,28 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Available leverage info /// - public record HuobiCrossMarginLeverageAvailable: HuobiIsolatedMarginLeverageAvailable + public record HTXCrossMarginLeverageAvailable: HTXIsolatedMarginLeverageAvailable { /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginOrderPage.cs new file mode 100644 index 00000000..aabab42e --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginOrderPage.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Order page + /// + public record HTXCrossMarginOrderPage : HTXPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginPositionLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginPositionLimit.cs new file mode 100644 index 00000000..3dd12e71 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginPositionLimit.cs @@ -0,0 +1,73 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Positions limits + /// + public record HTXCrossMarginPositionLimit + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public string MarginMode { get; set; } = string.Empty; + /// + /// Buy limit + /// + [JsonPropertyName("buy_limit")] + public decimal BuyLimit { get; set; } + /// + /// Sell limit + /// + [JsonPropertyName("sell_limit")] + public decimal SellLimit { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType? BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType? ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Lever rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverRate { get; set; } + /// + /// Buy limit value + /// + [JsonPropertyName("buy_limit_value")] + public decimal BuyLimitValue { get; set; } + /// + /// Sell limit value + /// + [JsonPropertyName("sell_limit_value")] + public decimal SellLimitValue { get; set; } + /// + /// Mark price + /// + [JsonPropertyName("mark_price")] + public decimal MarkPrice { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginSubAccountAssets.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginSubAccountAssets.cs similarity index 60% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginSubAccountAssets.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginSubAccountAssets.cs index 3b0e92bf..51bfa2a3 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginSubAccountAssets.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginSubAccountAssets.cs @@ -1,58 +1,54 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Sub account assets info /// - public record HuobiCrossMarginSubAccountAssets + public record HTXCrossMarginSubAccountAssets { /// /// Sub account uid /// - [JsonProperty("sub_uid")] + [JsonPropertyName("sub_uid")] public long SubUid { get; set; } /// /// Assets /// - [JsonProperty("list")] - public IEnumerable Assets { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable Assets { get; set; } = Array.Empty(); } /// /// Sub account asset info /// - public record HuobiCrossMarginSubAccountAsset + public record HTXCrossMarginSubAccountAsset { /// /// Margin balance /// - [JsonProperty("margin_balance")] + [JsonPropertyName("margin_balance")] public decimal MarginBalance { get; set; } /// /// Risk rate /// - [JsonProperty("risk_rate")] + [JsonPropertyName("risk_rate")] public decimal? RiskRate { get; set; } /// /// Margin asset /// - [JsonProperty("margin_asset")] + [JsonPropertyName("margin_asset")] public string MarginAsset { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTradeStatus.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTradeStatus.cs similarity index 73% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTradeStatus.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTradeStatus.cs index 060fb644..1df3f9a5 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTradeStatus.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTradeStatus.cs @@ -1,63 +1,65 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Cross margin trade status /// - public record HuobiCrossMarginTradeStatus + public record HTXCrossMarginTradeStatus { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Open order access /// + [JsonPropertyName("open")] public bool Open { get; set; } /// /// Close order access /// + [JsonPropertyName("close")] public bool Close { get; set; } /// /// Cancel order access /// + [JsonPropertyName("cancel")] public bool Cancel { get; set; } /// /// Business type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] public ContractType ContractType { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTransferStatus.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTransferStatus.cs similarity index 70% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTransferStatus.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTransferStatus.cs index b01feba5..808f40dc 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginTransferStatus.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginTransferStatus.cs @@ -1,74 +1,73 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Cross margin transfer status /// - public record HuobiCrossMarginTransferStatus + public record HTXCrossMarginTransferStatus { /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Deposit access /// - [JsonProperty("transfer_in")] + [JsonPropertyName("transfer_in")] public bool TranferIn { get; set; } /// /// Withdrawal access /// - [JsonProperty("transfer_out")] + [JsonPropertyName("transfer_out")] public bool TransferOut { get; set; } /// /// Transfer from master to sub /// - [JsonProperty("master_transfer_sub")] + [JsonPropertyName("master_transfer_sub")] public bool MasterTransferSub { get; set; } /// /// Transfer from sub to master /// - [JsonProperty("sub_transfer_master")] + [JsonPropertyName("sub_transfer_master")] public bool SubTransferMaster { get; set; } /// /// Master transfer sub inner in /// - [JsonProperty("master_transfer_sub_inner_in")] + [JsonPropertyName("master_transfer_sub_inner_in")] public bool MasterTransferSubInnerIn { get; set; } /// /// Master transfer sub inner out /// - [JsonProperty("master_transfer_sub_inner_out")] + [JsonPropertyName("master_transfer_sub_inner_out")] public bool MasterTransferSubInnerOut { get; set; } /// /// Sub transfer master inner in /// - [JsonProperty("sub_transfer_master_inner_in")] + [JsonPropertyName("sub_transfer_master_inner_in")] public bool SubTransferMasterInnerIn { get; set; } /// /// Sub transfer master inner out /// - [JsonProperty("sub_transfer_master_inner_out")] + [JsonPropertyName("sub_transfer_master_inner_out")] public bool SubTransferMasterInnerOut { get; set; } /// /// Transfer inner in /// - [JsonProperty("transfer_inner_in")] + [JsonPropertyName("transfer_inner_in")] public bool TransferInnerIn { get; set; } /// /// Tranfer inner out /// - [JsonProperty("transfer_inner_out")] + [JsonPropertyName("transfer_inner_out")] public bool TransferInnerOut { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserSettlementRecord.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserSettlementRecord.cs similarity index 65% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserSettlementRecord.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserSettlementRecord.cs index 0c921af5..0e8a79fa 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserSettlementRecord.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserSettlementRecord.cs @@ -1,193 +1,195 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// User settlement record page /// - public record HuobiCrossMarginUserSettlementRecordPage + public record HTXCrossMarginUserSettlementRecordPage { /// /// Total pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current pages /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total amount of records /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalRecords { get; set; } /// /// Records /// - [JsonProperty("settlement_records")] - public IEnumerable Records { get; set; } = Array.Empty(); + [JsonPropertyName("settlement_records")] + public IEnumerable Records { get; set; } = Array.Empty(); } /// /// User settlement record /// - public record HuobiCrossMarginUserSettlementRecord + public record HTXCrossMarginUserSettlementRecord { /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Margin balance init /// - [JsonProperty("margin_balance_init")] + [JsonPropertyName("margin_balance_init")] public decimal MarginBalanceInit { get; set; } /// /// Margin balance /// - [JsonProperty("margin_balance")] + [JsonPropertyName("margin_balance")] public decimal MarginBalance { get; set; } /// /// Settlement profit realized /// - [JsonProperty("settlement_profit_real")] - public decimal SettlementProfitReal { get; set; } + [JsonPropertyName("settlement_profit_real")] + public decimal SettlementRealizedPnl { get; set; } /// /// Settlement time /// - [JsonProperty("settlement_time")] + [JsonPropertyName("settlement_time")] [JsonConverter(typeof(DateTimeConverter))] public DateTime SettlementTime { get; set; } /// /// Clawback /// + [JsonPropertyName("clawback")] public decimal Clawback { get; set; } /// /// Funding fee /// - [JsonProperty("funding_fee")] + [JsonPropertyName("funding_fee")] public decimal FundingFee { get; set; } /// /// Offset profit loss /// - [JsonProperty("offset_profitloss")] + [JsonPropertyName("offset_profitloss")] public decimal OffsetProfitLoss { get; set; } /// /// Fee /// + [JsonPropertyName("fee")] public decimal Fee { get; set; } /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Contract details /// - [JsonProperty("contract_detail")] - public IEnumerable ContractDetails { get; set; } = Array.Empty(); + [JsonPropertyName("contract_detail")] + public IEnumerable ContractDetails { get; set; } = Array.Empty(); } /// /// Settlement contract details /// - public record HuobiCrossMarginSettlementAccountContract + public record HTXCrossMarginSettlementAccountContract { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Offset profit loss /// - [JsonProperty("offset_profitloss")] + [JsonPropertyName("offset_profitloss")] public decimal OffsetProfitLoss { get; set; } /// /// Fee /// + [JsonPropertyName("fee")] public decimal Fee { get; set; } /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Positions /// - public IEnumerable Positions { get; set; } = Array.Empty(); + [JsonPropertyName("positions")] + public IEnumerable Positions { get; set; } = Array.Empty(); } /// /// Settlement position /// - public record HuobiSettlementPosition + public record HTXSettlementPosition { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Direction /// + [JsonPropertyName("direction")] public OrderSide Direction { get; set; } /// /// Volume /// + [JsonPropertyName("volume")] public decimal Volume { get; set; } /// /// Cost open /// - [JsonProperty("cost_open")] + [JsonPropertyName("cost_open")] public decimal CostOpen { get; set; } /// /// Cost hold before settlement /// - [JsonProperty("cost_hold_pre")] + [JsonPropertyName("cost_hold_pre")] public decimal CostHoldPre { get; set; } /// /// Cost hold after settlement /// - [JsonProperty("cost_hold")] + [JsonPropertyName("cost_hold")] public decimal ColdHold { get; set; } /// - /// Settlement profit unreal + /// Settlement profit unrealized /// - [JsonProperty("settlement_profit_unreal")] - public decimal SettlementProfitUnreal { get; set; } + [JsonPropertyName("settlement_profit_unreal")] + public decimal SettlementUnrealizedPnl { get; set; } /// /// Settlement price /// - [JsonProperty("settlement_price")] + [JsonPropertyName("settlement_price")] public decimal SettlementPrice { get; set; } /// /// Settlement type /// - [JsonProperty("settlement_type")] + [JsonPropertyName("settlement_type")] [JsonConverter(typeof(EnumConverter))] public SettlementType SettlementType { get; set; } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserTrade.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserTrade.cs new file mode 100644 index 00000000..55921220 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossMarginUserTrade.cs @@ -0,0 +1,9 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// User trade info + /// + public record HTXCrossMarginUserTrade : HTXIsolatedMarginUserTrade + { + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossPositionOpenTpSlOrders.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossPositionOpenTpSlOrders.cs new file mode 100644 index 00000000..1873d795 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossPositionOpenTpSlOrders.cs @@ -0,0 +1,28 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Position open and tp/sl info + /// + public record HTXCrossPositionOpenTpSlOrders : HTXPositionOpenTpSlOrders + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlClosedOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlClosedOrderPage.cs new file mode 100644 index 00000000..485c0f16 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlClosedOrderPage.cs @@ -0,0 +1,57 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Take profit / stop loss order page + /// + public record HTXCrossTpSlClosedOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Tp/Sl order + /// + public record HTXCrossTpSlClosedOrder: HTXTpSlClosedOrder + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlOrderPage.cs new file mode 100644 index 00000000..70c8dc27 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTpSlOrderPage.cs @@ -0,0 +1,57 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Take profit / stop loss order page + /// + public record HTXCrossTpSlOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Tp/Sl order + /// + public record HTXCrossTpSlOrder : HTXTpSlOrder + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingClosedOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingClosedOrderPage.cs new file mode 100644 index 00000000..b0fa9c4a --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingClosedOrderPage.cs @@ -0,0 +1,57 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trailing order page + /// + public record HTXCrossTrailingClosedOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trailing order info + /// + public record HTXCrossTrailingClosedOrder : HTXTrailingClosedOrder + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingOrderPage.cs new file mode 100644 index 00000000..6298ba24 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTrailingOrderPage.cs @@ -0,0 +1,57 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trailing order page + /// + public record HTXCrossTrailingOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trailing order info + /// + public record HTXCrossTrailingOrder : HTXTrailingOrder + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTransferLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTransferLimit.cs new file mode 100644 index 00000000..8fb566dd --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTransferLimit.cs @@ -0,0 +1,63 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Cross margin transfer limit + /// + public record HTXCrossTransferLimit + { + /// + /// Transfer in max per transfer + /// + [JsonPropertyName("transfer_in_max_each")] + public decimal TransferInMaxEach { get; set; } + /// + /// Transfer in min per transfer + /// + [JsonPropertyName("transfer_in_min_each")] + public decimal TransferInMinEach { get; set; } + /// + /// Transfer out max per transfer + /// + [JsonPropertyName("transfer_out_max_each")] + public decimal TransferOutMaxEach { get; set; } + /// + /// Transfer out min per transfer + /// + [JsonPropertyName("transfer_out_min_each")] + public decimal TransferOutMinEach { get; set; } + /// + /// Transfer in max daily + /// + [JsonPropertyName("transfer_in_max_daily")] + public decimal TransferInMaxDaily { get; set; } + /// + /// Transfer out max daily + /// + [JsonPropertyName("transfer_out_max_daily")] + public decimal TransferOutMaxDaily { get; set; } + /// + /// Net transfer in max daily + /// + [JsonPropertyName("net_transfer_in_max_daily")] + public decimal NetTransferInMaxDaily { get; set; } + /// + /// Net transfer out max daily + /// + [JsonPropertyName("net_transfer_out_max_daily")] + public decimal NetTransferOutMaxDaily { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTriggerOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTriggerOrderPage.cs new file mode 100644 index 00000000..8463b422 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXCrossTriggerOrderPage.cs @@ -0,0 +1,55 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trigger cross margin order page + /// + public record HTXCrossTriggerOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trigger order + /// + public record HTXCrossTriggerOrder: HTXTriggerOrder + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + [JsonConverter(typeof(EnumConverter))] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + [JsonConverter(typeof(EnumConverter))] + public BusinessType BusinessType { get; set; } + /// + /// Symbol + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiEstimatedSettlementPrice.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXEstimatedSettlementPrice.cs similarity index 70% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiEstimatedSettlementPrice.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXEstimatedSettlementPrice.cs index b1478d53..f45605e0 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiEstimatedSettlementPrice.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXEstimatedSettlementPrice.cs @@ -1,45 +1,44 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Estimated settlement price /// - public record HuobiEstimatedSettlementPrice + public record HTXEstimatedSettlementPrice { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Estimated settlement price /// - [JsonProperty("estimated_settlement_price")] + [JsonPropertyName("estimated_settlement_price")] public decimal? EstimatedSettlementPrice { get; set; } /// /// Settlement type /// - [JsonProperty("settlement_type")] + [JsonPropertyName("settlement_type")] [JsonConverter(typeof(EnumConverter))] public SettlementType SettlementType { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFinancialRecord.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXFinancialRecord.cs similarity index 50% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFinancialRecord.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXFinancialRecord.cs index 61ead781..14c33046 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFinancialRecord.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXFinancialRecord.cs @@ -1,79 +1,58 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// - /// Financial records page + /// Financial records /// - public record HuobiFinancialRecordsPage + public record HTXFinancialRecord { /// - /// Total amount of pages - /// - [JsonProperty("total_page")] - public int TotalPages { get; set; } - /// - /// Current page - /// - [JsonProperty("current_page")] - public int CurrentPage { get; set; } - /// - /// Total amount of records - /// - [JsonProperty("total_size")] - public int TotalRecords { get; set; } - /// - /// Data + /// Query id /// - [JsonProperty("financial_record")] - public IEnumerable Records { get; set; } = Array.Empty(); - } - - /// - /// Financial records - /// - public record HuobiFinancialRecord - { + [JsonPropertyName("query_id")] + public long QueryId { get; set; } /// /// Record id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Record type /// [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("type")] public FinancialRecordType Type { get; set; } /// /// Amount /// - public decimal Amount { get; set; } + [JsonPropertyName("amount")] + public decimal Quantity { get; set; } /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] + [JsonPropertyName("ts")] public DateTime Timestamp { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Asset /// + [JsonPropertyName("asset")] public string Asset { get; set; } = string.Empty; /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Face margin account /// - [JsonProperty("face_margin_account")] + [JsonPropertyName("face_margin_account")] public string FaceMarginAccount { get; set; } = string.Empty; } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFundingRate.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXFundingRate.cs similarity index 50% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFundingRate.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXFundingRate.cs index c04df872..734ad39c 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiFundingRate.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXFundingRate.cs @@ -1,50 +1,35 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Funding rate /// - public record HuobiFundingRate + public record HTXFundingRate { - /// - /// Estimated rate - /// - [JsonProperty("estimated_rate")] - public decimal? EstimatedRate { get; set; } /// /// Funding rate /// - [JsonProperty("funding_rate")] + [JsonPropertyName("funding_rate")] public decimal? FundingRate { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Symbol /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Funding rate /// - [JsonProperty("funding_time")] + [JsonPropertyName("funding_time")] [JsonConverter(typeof(DateTimeConverter))] public DateTime FundingTime { get; set; } - /// - /// Next funding time - /// - [JsonProperty("next_funding_time")] - [JsonConverter(typeof(DateTimeConverter))] - public DateTime NextFundingTime { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiHistoricalFundingRate.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXHistoricalFundingRate.cs similarity index 63% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiHistoricalFundingRate.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXHistoricalFundingRate.cs index e23dc3c7..f8862def 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiHistoricalFundingRate.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXHistoricalFundingRate.cs @@ -1,77 +1,72 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Funding rates page /// - public record HuobiFundingRatePage + public record HTXFundingRatePage { /// /// Total pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current page /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total results /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalResults { get; set; } /// /// Rates /// - [JsonProperty("data")] - public IEnumerable Rates { get; set; } = Array.Empty(); + [JsonPropertyName("data")] + public IEnumerable Rates { get; set; } = Array.Empty(); } /// /// Historical funding rate /// - public record HuobiHistoricalFundingRate + public record HTXHistoricalFundingRate { /// /// Average premium index /// - [JsonProperty("avg_premium_index")] + [JsonPropertyName("avg_premium_index")] public decimal AveragePremiumIndex { get; set; } /// /// Funding rate /// - [JsonProperty("funding_rate")] + [JsonPropertyName("funding_rate")] public decimal FundingRate { get; set; } /// /// Realized rate /// - [JsonProperty("realized_rate")] - public decimal RealizedRate { get; set; } + [JsonPropertyName("realized_rate")] + public decimal? RealizedRate { get; set; } /// /// Funding time /// - [JsonProperty("funding_time")] + [JsonPropertyName("funding_time")] [JsonConverter(typeof(DateTimeConverter))] public DateTime FundingTime { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Symbol /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiInsuranceValue.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXInsuranceValue.cs similarity index 65% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiInsuranceValue.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXInsuranceValue.cs index bcdea996..cf947043 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiInsuranceValue.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXInsuranceValue.cs @@ -1,72 +1,68 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Insurance info /// - public record HuobiInsuranceInfo + public record HTXInsuranceInfo { /// /// Total amount of pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPage { get; set; } /// /// Current page /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total amount of results /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalSize { get; set; } /// /// The asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// The history data /// - [JsonProperty("tick")] - public IEnumerable History { get; set; } = Array.Empty(); + [JsonPropertyName("tick")] + public IEnumerable History { get; set; } = Array.Empty(); } /// /// Insurance value /// - public record HuobiInsuranceValue + public record HTXInsuranceValue { /// /// Insurance fund /// - [JsonProperty("insurance_fund")] + [JsonPropertyName("insurance_fund")] public decimal InsuranceFund { get; set; } /// /// Timestamp /// - [JsonProperty("ts")] + [JsonPropertyName("ts")] [JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAccountInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAccountInfo.cs similarity index 57% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAccountInfo.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAccountInfo.cs index cfe32774..868cd013 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAccountInfo.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAccountInfo.cs @@ -1,105 +1,119 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Account info /// - public record HuobiIsolatedMarginAccountInfo + public record HTXIsolatedMarginAccountInfo { /// /// Asset info /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Margin balance /// - [JsonProperty("margin_balance")] + [JsonPropertyName("margin_balance")] public decimal MarginBalance { get; set; } /// /// Margin position /// - [JsonProperty("margin_position")] + [JsonPropertyName("margin_position")] public decimal MarginPosition { get; set; } /// /// Margin frozen /// - [JsonProperty("margin_frozen")] + [JsonPropertyName("margin_frozen")] public decimal MarginFrozen { get; set; } /// /// Margin available /// - [JsonProperty("margin_available")] + [JsonPropertyName("margin_available")] public decimal MarginAvailable { get; set; } /// /// Profit real /// - [JsonProperty("profit_real")] - public decimal ProfitReal { get; set; } + [JsonPropertyName("profit_real")] + public decimal RealizedProfit { get; set; } /// - /// Profit unreal + /// Unrealized profit and loss /// - [JsonProperty("profit_unreal")] - public decimal ProfitUnreal { get; set; } + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } /// /// Risk rate /// - [JsonProperty("risk_rate")] + [JsonPropertyName("risk_rate")] public decimal? RiskRate { get; set; } /// + /// Risk rate + /// + [JsonPropertyName("new_risk_rate")] + public decimal? NewRiskRate { get; set; } + /// /// Withdraw available /// - [JsonProperty("withdraw_available")] + [JsonPropertyName("withdraw_available")] public decimal WithdrawAvailable { get; set; } /// /// Liquidation price /// - [JsonProperty("liquidation_price")] + [JsonPropertyName("liquidation_price")] public decimal? LiquidationPrice { get; set; } /// - /// Lever rate + /// Leverage rate /// - [JsonProperty("level_rate")] - public decimal LeverRate { get; set; } + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } /// /// Adjust factor /// - [JsonProperty("adjust_factor")] + [JsonPropertyName("adjust_factor")] public decimal AdjustFactor { get; set; } /// /// Margin static /// - [JsonProperty("margin_static")] + [JsonPropertyName("margin_static")] public decimal MarginStatic { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin asset /// - [JsonProperty("margin_asset")] + [JsonPropertyName("margin_asset")] public string MarginAsset { get; set; } = string.Empty; /// /// Margin mode /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Position mode /// - [JsonProperty("position_mode")] + [JsonPropertyName("position_mode")] [JsonConverter(typeof(EnumConverter))] public PositionMode PositionMode { get; set; } + /// + /// Trade partition + /// + [JsonPropertyName("trade_partition")] + public string TradePartition { get; set; } = string.Empty; + /// + /// ADL risk percentage + /// + [JsonPropertyName("adl_risk_percent")] + public decimal? AdlRiskPercentage { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAssetsAndPositions.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAssetsAndPositions.cs new file mode 100644 index 00000000..d45598d7 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginAssetsAndPositions.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Isolated margin assets and positions info + /// + public record HTXIsolatedMarginAssetsAndPositions: HTXIsolatedMarginAccountInfo + { + /// + /// Positions + /// + [JsonPropertyName("positions")] + public IEnumerable? Positions { get; set; } = Array.Empty(); + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginLeverageAvailable.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginLeverageAvailable.cs similarity index 62% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginLeverageAvailable.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginLeverageAvailable.cs index 0c3cabfd..a4c4cdf7 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginLeverageAvailable.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginLeverageAvailable.cs @@ -1,29 +1,28 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Available leverage info /// - public record HuobiIsolatedMarginLeverageAvailable + public record HTXIsolatedMarginLeverageAvailable { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Available rates /// - [JsonProperty("available_level_rate")] + [JsonPropertyName("available_level_rate")] public string AvailableLevelRate { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrder.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrder.cs similarity index 59% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrder.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrder.cs index 0a2b5266..8d622519 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrder.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrder.cs @@ -1,191 +1,224 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Isolated margin order info /// - public record HuobiIsolatedMarginOrder + public record HTXIsolatedMarginOrder { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Quantity of contract /// - [JsonProperty("volume")] + [JsonPropertyName("volume")] public decimal Quantity { get; set; } /// /// Price /// + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// Order price type /// - [JsonProperty("order_price_type")] + [JsonPropertyName("order_price_type")] [JsonConverter(typeof(EnumConverter))] public OrderPriceType OrderPriceType { get; set; } /// /// Order type /// - [JsonProperty("order_type")] + [JsonPropertyName("order_type")] [JsonConverter(typeof(EnumConverter))] public MarginOrderType OrderType { get; set; } /// /// Direction /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("direction")] + [JsonPropertyName("direction")] public OrderSide Side { get; set; } /// /// Offset /// [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("offset")] public Offset Offset { get; set; } /// /// Leverage rate /// - [JsonProperty("lever_rate")] + [JsonPropertyName("lever_rate")] public int LeverageRate { get; set; } /// /// Order id /// - [JsonProperty("order_id")] + [JsonPropertyName("order_id")] public long OrderId { get; set; } /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// /// Client order id /// - [JsonProperty("client_order_id")] + [JsonPropertyName("client_order_id")] public long? ClientOrderId { get; set; } /// /// Creation time /// - [JsonProperty("created_at")] + [JsonPropertyName("created_at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } + [JsonInclude, JsonPropertyName("create_date")] + internal DateTime CreateTimeInt + { + get => CreateTime; + set => CreateTime = value; + } + /// /// Cancel time /// - [JsonProperty("canceled_at")] + [JsonPropertyName("canceled_at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime? CancelTime { get; set; } /// /// Quantity filled /// - [JsonProperty("trade_volume")] + [JsonPropertyName("trade_volume")] public decimal QuantityFilled { get; set; } /// /// Value of the quantity filled /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal ValueFilled { get; set; } /// /// Fee /// + [JsonPropertyName("fee")] public decimal Fee { get; set; } /// /// Average fill price /// - [JsonProperty("trade_avg_price")] - public decimal AverageFillPrice { get; set; } + [JsonPropertyName("trade_avg_price")] + public decimal? AverageFillPrice { get; set; } /// /// Margin frozen /// - [JsonProperty("margin_frozen")] + [JsonPropertyName("margin_frozen")] public decimal MarginFrozen { get; set; } /// /// Margin asset /// - [JsonProperty("margin_asset")] + [JsonPropertyName("margin_asset")] public string MarginAsset { get; set; } = String.Empty; /// /// Profit /// + [JsonPropertyName("profit")] public decimal Profit { get; set; } /// /// Order status /// [JsonConverter(typeof(EnumConverter))] - public SwapMarginOrderStatus Status { get; set; } + [JsonPropertyName("status")] + public SwapMarginOrderStatus Status { get; set; } /// /// Source /// - [JsonProperty("order_source")] + [JsonPropertyName("order_source")] public string OrderSource { get; set; } = string.Empty; /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Liquidation type /// - [JsonProperty("liquidation_type")] - public LiquidationType LiquidationType { get; set; } + [JsonPropertyName("liquidation_type")] + public LiquidationType? LiquidationType { get; set; } /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Is take profit/stop loss /// - [JsonProperty("is_tpsl")] + [JsonPropertyName("is_tpsl")] public bool IsTakeProfitStopLoss { get; set; } /// - /// Real profit + /// Realized profit and loss /// - [JsonProperty("real_profit")] - public decimal RealProfit { get; set; } + [JsonPropertyName("real_profit")] + public decimal RealizedPnl { get; set; } /// /// Reduce only /// - [JsonProperty("reduce_only")] + [JsonPropertyName("reduce_only")] public bool ReduceOnly { get; set; } /// + /// HTX fee quantity + /// + [JsonPropertyName("fee_amount")] + public decimal FeeQuantity { get; set; } + /// + /// HTX fee quote quantity + /// + [JsonPropertyName("fee_quote_amount")] + public decimal FeeQuoteQuantity { get; set; } + /// + /// Cancel source + /// + [JsonPropertyName("canceled_source")] + public string? CancelSource { get; set; } + /// + /// Update time + /// + [JsonPropertyName("update_time")] + public DateTime? UpdateTime { get; set; } + /// /// Trades /// - [JsonProperty("trade")] - public IEnumerable? Trades { get; set; } + [JsonPropertyName("trade")] + public IEnumerable? Trades { get; set; } } /// /// Cross margin order info /// - public record HuobiCrossMarginOrder : HuobiIsolatedMarginOrder + public record HTXCrossMarginOrder : HTXIsolatedMarginOrder { /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof (EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof (EnumConverter))] public ContractType ContractType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrderPage.cs new file mode 100644 index 00000000..f0e4afe3 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginOrderPage.cs @@ -0,0 +1,14 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Order page + /// + public record HTXIsolatedMarginOrderPage : HTXPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginSubAccountAssets.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginSubAccountAssets.cs similarity index 63% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginSubAccountAssets.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginSubAccountAssets.cs index 818c3036..89bd81ee 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginSubAccountAssets.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginSubAccountAssets.cs @@ -1,73 +1,69 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Sub account assets info /// - public record HuobiIsolatedMarginSubAccountAssets + public record HTXIsolatedMarginSubAccountAssets { /// /// Sub account uid /// - [JsonProperty("sub_uid")] + [JsonPropertyName("sub_uid")] public long SubUid { get; set; } /// /// Assets /// - [JsonProperty("list")] - public IEnumerable Assets { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable Assets { get; set; } = Array.Empty(); } /// /// Sub account asset info /// - public record HuobiIsolatedMarginSubAccountAsset + public record HTXIsolatedMarginSubAccountAsset { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Margin balance /// - [JsonProperty("margin_balance")] + [JsonPropertyName("margin_balance")] public decimal MarginBalance { get; set; } /// /// Liquidation price /// - [JsonProperty("liquidation_price")] + [JsonPropertyName("liquidation_price")] public decimal? LiquidationPrice { get; set; } /// /// Risk rate /// - [JsonProperty("risk_rate")] + [JsonPropertyName("risk_rate")] public decimal? RiskRate { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin asset /// - [JsonProperty("margin_asset")] + [JsonPropertyName("margin_asset")] public string MarginAsset { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserSettlementRecord.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserSettlementRecord.cs similarity index 65% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserSettlementRecord.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserSettlementRecord.cs index c566b35b..bbe12ef9 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserSettlementRecord.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserSettlementRecord.cs @@ -1,166 +1,167 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// User settlement record page /// - public record HuobiIsolatedMarginUserSettlementRecordPage + public record HTXIsolatedMarginUserSettlementRecordPage { /// /// Total pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current pages /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total amount of records /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalRecords { get; set; } /// /// Records /// - [JsonProperty("settlement_records")] - public IEnumerable Records { get; set; } = Array.Empty(); + [JsonPropertyName("settlement_records")] + public IEnumerable Records { get; set; } = Array.Empty(); } /// /// User settlement record /// - public record HuobiIsolatedMarginUserSettlementRecord + public record HTXIsolatedMarginUserSettlementRecord { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Margin balance init /// - [JsonProperty("margin_balance_init")] + [JsonPropertyName("margin_balance_init")] public decimal MarginBalanceInit { get; set; } /// /// Margin balance /// - [JsonProperty("margin_balance")] + [JsonPropertyName("margin_balance")] public decimal MarginBalance { get; set; } /// /// Settlement profit realized /// - [JsonProperty("settlement_profit_real")] - public decimal SettlementProfitReal { get; set; } + [JsonPropertyName("settlement_profit_real")] + public decimal SettlementRealizedPnl { get; set; } /// /// Settlement time /// - [JsonProperty("settlement_time")] + [JsonPropertyName("settlement_time")] [JsonConverter(typeof(DateTimeConverter))] public DateTime SettlementTime { get; set; } /// /// Clawback /// + [JsonPropertyName("clawback")] public decimal Clawback { get; set; } /// /// Funding fee /// - [JsonProperty("funding_fee")] + [JsonPropertyName("funding_fee")] public decimal FundingFee { get; set; } /// /// Offset profit loss /// - [JsonProperty("offset_profitloss")] + [JsonPropertyName("offset_profitloss")] public decimal OffsetProfitLoss { get; set; } /// /// Fee /// + [JsonPropertyName("fee")] public decimal Fee { get; set; } /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Positions /// - public IEnumerable Positions { get; set; } = Array.Empty(); + [JsonPropertyName("positions")] + public IEnumerable Positions { get; set; } = Array.Empty(); } /// /// Settlement position /// - public record HuobiCrossSettlementPosition + public record HTXCrossSettlementPosition { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Direction /// + [JsonPropertyName("direction")] public OrderSide Direction { get; set; } /// /// Volume /// + [JsonPropertyName("volume")] public decimal Volume { get; set; } /// /// Cost open /// - [JsonProperty("cost_open")] + [JsonPropertyName("cost_open")] public decimal CostOpen { get; set; } /// /// Cost hold before settlement /// - [JsonProperty("cost_hold_pre")] + [JsonPropertyName("cost_hold_pre")] public decimal CostHoldPre { get; set; } /// /// Cost hold after settlement /// - [JsonProperty("cost_hold")] + [JsonPropertyName("cost_hold")] public decimal ColdHold { get; set; } /// - /// Settlement profit unreal + /// Settlement unrealized profit and loss /// - [JsonProperty("settlement_profit_unreal")] - public decimal SettlementProfitUnreal { get; set; } + [JsonPropertyName("settlement_profit_unreal")] + public decimal SettlementUnrealizedPnl { get; set; } /// /// Settlement price /// - [JsonProperty("settlement_price")] + [JsonPropertyName("settlement_price")] public decimal SettlementPrice { get; set; } /// /// Settlement type /// - [JsonProperty("settlement_type")] + [JsonPropertyName("settlement_type")] [JsonConverter(typeof(EnumConverter))] public SettlementType SettlementType { get; set; } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserTrade.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserTrade.cs new file mode 100644 index 00000000..ce0e63a3 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXIsolatedMarginUserTrade.cs @@ -0,0 +1,138 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// + /// + public record HTXIsolatedMarginUserTrade + { + /// + /// Query id + /// + [JsonPropertyName("query_id")] + public long QueryId { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Match id + /// + [JsonPropertyName("match_id")] + public long MatchId { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide Side { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Quantity + /// + [JsonPropertyName("trade_volume")] + public decimal Quantity { get; set; } + /// + /// Price + /// + [JsonPropertyName("trade_price")] + public decimal Price { get; set; } + /// + /// Value + /// + [JsonPropertyName("trade_turnover")] + public decimal Value { get; set; } + /// + /// Fee + /// + [JsonPropertyName("trade_fee")] + public decimal Fee { get; set; } + /// + /// Offset profit loss + /// + [JsonPropertyName("offset_profitloss")] + public decimal OffsetProfitLoss { get; set; } + /// + /// Create time + /// + [JsonPropertyName("create_date")] + public DateTime CreateTime { get; set; } + /// + /// Role + /// + [JsonPropertyName("role")] + public OrderRole Role { get; set; } + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Order id str + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Id + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + /// + /// Fee asset + /// + [JsonPropertyName("fee_asset")] + public string FeeAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Real profit + /// + [JsonPropertyName("real_profit")] + public decimal RealProfit { get; set; } + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLastTrade.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLastTrade.cs similarity index 57% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLastTrade.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXLastTrade.cs index d9ced5c6..3fd710d9 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLastTrade.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLastTrade.cs @@ -1,69 +1,77 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { - internal record HuobiLastTradeWrapper + internal record HTXLastTradeWrapper { - public HuobiLastTrade[] Data { get; set; } = Array.Empty(); + [JsonPropertyName("data")] + public HTXLastTrade[] Data { get; set; } = Array.Empty(); } - internal record HuobiTradeWrapper + internal record HTXTradeWrapper { - public HuobiTrade[] Data { get; set; } = Array.Empty(); + [JsonPropertyName("data")] + public HTXTrade[] Data { get; set; } = Array.Empty(); } /// /// Last trade data /// - public record HuobiTrade + public record HTXTrade { /// /// Amount of contracts /// + [JsonPropertyName("amount")] public decimal Amount { get; set; } /// /// Quantity /// + [JsonPropertyName("quantity")] public decimal Quantity { get; set; } /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("ts")] + [JsonPropertyName("ts")] public DateTime Timestamp { get; set; } /// /// Id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Direction /// + [JsonPropertyName("direction")] public OrderSide Direction { get; set; } /// /// Value /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal QuoteQuantity { get; set; } } /// /// Last trade info /// - public record HuobiLastTrade: HuobiTrade + public record HTXLastTrade: HTXTrade { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = String.Empty; /// /// Business type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeveragePositionLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeveragePositionLimit.cs new file mode 100644 index 00000000..12a091c5 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeveragePositionLimit.cs @@ -0,0 +1,55 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Leverage position limit info + /// + public record HTXLeveragePositionLimit + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Limits + /// + [JsonPropertyName("list")] + public IEnumerable Limits { get; set; } = Array.Empty(); + } + + /// + /// Leverage position limit + /// + public record HTXLeveragePositionLeverageLimit + { + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Buy limit value + /// + [JsonPropertyName("buy_limit_value")] + public decimal BuyLimitValue { get; set; } + /// + /// Sell limit value + /// + [JsonPropertyName("sell_limit_value")] + public decimal SellLimitValue { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLeverageRate.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeverageRate.cs similarity index 67% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLeverageRate.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeverageRate.cs index a6a1166b..fc1540e4 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLeverageRate.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLeverageRate.cs @@ -1,52 +1,51 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Leverage rate /// - public record HuobiIsolatedMarginLeverageRate + public record HTXIsolatedMarginLeverageRate { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode Mode { get; set; } /// /// Leverage rate /// - [JsonProperty("lever_rate")] + [JsonPropertyName("lever_rate")] public int LeverageRate { get; set; } } /// /// Leverage rate /// - public record HuobiCrossMarginLeverageRate: HuobiIsolatedMarginLeverageRate + public record HTXCrossMarginLeverageRate: HTXIsolatedMarginLeverageRate { /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLiquidationOrder.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLiquidationOrder.cs similarity index 58% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLiquidationOrder.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXLiquidationOrder.cs index 99ceb72d..0118c805 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiLiquidationOrder.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXLiquidationOrder.cs @@ -1,95 +1,75 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// - /// Liquidation order page + /// Liquidation order /// - public record HuobiLiquidationOrderPage + public record HTXLiquidationOrder { /// - /// Total pages - /// - [JsonProperty("total_page")] - public int TotalPages { get; set; } - /// - /// Current page - /// - [JsonProperty("current_page")] - public int CurrentPage { get; set; } - /// - /// Total results - /// - [JsonProperty("total_size")] - public int TotalSize { get; set; } - /// - /// Orders + /// Query id /// - public IEnumerable Orders { get; set; } = Array.Empty(); - } - - /// - /// Liquidation order - /// - public record HuobiLiquidationOrder - { + [JsonPropertyName("query_id")] + public long QueryId { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Direction /// [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("direction")] public OrderSide Direction { get; set; } /// /// Offset /// [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("offset")] public Offset Offset { get; set; } /// /// Volume /// + [JsonPropertyName("volume")] public decimal Volume { get; set; } /// /// Price /// + [JsonPropertyName("price")] public decimal Price { get; set; } /// /// Creation time /// - [JsonProperty("created_at")] + [JsonPropertyName("created_at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Amount /// + [JsonPropertyName("amount")] public decimal Amount { get; set; } /// /// Turnover /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal Turnover { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginOrderDetails.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginOrderDetails.cs similarity index 58% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginOrderDetails.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginOrderDetails.cs index 2cabb986..7083a57e 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginOrderDetails.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginOrderDetails.cs @@ -1,47 +1,44 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Isolated margin order info /// - public record HuobiMarginOrderDetails : HuobiIsolatedMarginOrder + public record HTXMarginOrderDetails : HTXIsolatedMarginOrder { /// /// Instrument price /// - [JsonProperty("instrument_price")] - public decimal IntrumentPrice { get; set; } + [JsonPropertyName("instrument_price")] + public decimal InstrumentPrice { get; set; } /// /// Final interest /// - [JsonProperty("final_interest")] + [JsonPropertyName("final_interest")] public decimal FinalInterest { get; set; } /// /// Adjust value /// - [JsonProperty("adjust_value")] + [JsonPropertyName("adjust_value")] public decimal AdjustValue { get; set; } /// /// Total pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current page /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total amount of records /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalRecords { get; set; } /// /// Trades /// - public new IEnumerable Trades { get; set; } = Array.Empty(); + [JsonPropertyName("trades")] + public new IEnumerable Trades { get; set; } = Array.Empty(); } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginTrade.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginTrade.cs similarity index 66% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginTrade.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginTrade.cs index 91ccede2..c447ea4c 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarginTrade.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMarginTrade.cs @@ -1,69 +1,68 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Trade info /// - public record HuobiMarginTrade + public record HTXMarginTrade { /// /// Id /// + [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; /// /// Trade id /// - [JsonProperty("trade_id")] + [JsonPropertyName("trade_id")] public long TradeId { get; set; } /// /// Trade price /// - [JsonProperty("trade_price")] + [JsonPropertyName("trade_price")] public decimal Price { get; set; } /// /// Trade quantity /// - [JsonProperty("trade_volume")] + [JsonPropertyName("trade_volume")] public decimal Quantity { get; set; } /// /// Trade value /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal Value { get; set; } /// /// Fee /// - [JsonProperty("trade_fee")] + [JsonPropertyName("trade_fee")] public decimal Fee { get; set; } /// /// Creation time /// - [JsonProperty("created_at")] + [JsonPropertyName("created_at")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Trade role /// - [JsonConverter(typeof(OrderRoleConverter))] + [JsonConverter(typeof(EnumConverter))] + [JsonPropertyName("role")] public OrderRole Role { get; set; } /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAssset { get; set; } = string.Empty; /// /// Profit /// + [JsonPropertyName("profit")] public decimal Profit { get; set; } /// - /// Real profit + /// Real pnl /// - [JsonProperty("real_profit")] - public decimal RealProfit { get; set; } + [JsonPropertyName("real_profit")] + public decimal RealizedPnl { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMasterSubTransfer.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMasterSubTransfer.cs similarity index 62% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMasterSubTransfer.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXMasterSubTransfer.cs index db59d5a0..97860be5 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMasterSubTransfer.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXMasterSubTransfer.cs @@ -1,64 +1,76 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + + /// + /// Sub transfer page + /// + public record HTXMasterSubTransferPage : HTXPage + { + /// + /// Transfers + /// + [JsonPropertyName("transfer_record")] + public IEnumerable Transfers { get; set; } = Array.Empty(); + } -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ /// /// Transfer between master and sub account /// - public record HuobiMasterSubTransfer + public record HTXMasterSubTransfer { /// /// Id /// + [JsonPropertyName("id")] public long Id { get; set; } /// /// Creation time /// - [JsonProperty("ts")] + [JsonPropertyName("ts")] [JsonConverter(typeof(DateTimeConverter))] public DateTime CreateTime { get; set; } /// /// Asset name /// + [JsonPropertyName("asset")] public string Asset { get; set; } = string.Empty; /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// From margin account /// - [JsonProperty("from_margin_account")] + [JsonPropertyName("from_margin_account")] public string FromMarginAccount { get; set; } = string.Empty; /// /// To margin account /// - [JsonProperty("to_margin_account")] + [JsonPropertyName("to_margin_account")] public string ToMarginAccount { get; set; } = string.Empty; /// /// Sub uid /// - [JsonProperty("sub_uid")] + [JsonPropertyName("sub_uid")] public string SubUid { get; set; } = string.Empty; /// /// Sub account name /// - [JsonProperty("sub_account_name")] + [JsonPropertyName("sub_account_name")] public string SubAccountName { get; set; } = string.Empty; /// /// Transfer type /// - [JsonProperty("tranfer_type")] + [JsonPropertyName("transfer_type")] [JsonConverter(typeof(EnumConverter))] public MasterSubTransferType Type { get; set; } /// /// Quantity /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Quantity { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterest.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterest.cs similarity index 72% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterest.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterest.cs index 39083144..f0d39dee 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterest.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterest.cs @@ -1,66 +1,68 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Open interest /// - public record HuobiOpenInterest + public record HTXOpenInterest { /// /// The asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Amount /// + [JsonPropertyName("amount")] public decimal Amount { get; set; } /// /// Volume /// + [JsonPropertyName("volume")] public decimal Volume { get; set; } /// /// Value /// + [JsonPropertyName("value")] public decimal Value { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Trade amount /// - [JsonProperty("trade_amount")] + [JsonPropertyName("trade_amount")] public decimal TradeAmount { get; set; } /// /// Trade volume /// - [JsonProperty("trade_volume")] + [JsonPropertyName("trade_volume")] public decimal TradeVolume { get; set; } /// /// Trade turnover /// - [JsonProperty("trade_turnover")] + [JsonPropertyName("trade_turnover")] public decimal TradeTurnover { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterestValue.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterestValue.cs similarity index 69% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterestValue.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterestValue.cs index 36663e41..dc6ad026 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOpenInterestValue.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOpenInterestValue.cs @@ -1,74 +1,73 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Open interest value /// - public record HuobiOpenInterestValue + public record HTXOpenInterestValue { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Business type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } /// /// Tick /// - public IEnumerable Tick { get; set; } = Array.Empty(); + [JsonPropertyName("tick")] + public IEnumerable Tick { get; set; } = Array.Empty(); } /// /// Open interest value tick /// - public record HuobiOpenInterestValueTick + public record HTXOpenInterestValueTick { /// /// Volume /// + [JsonPropertyName("volume")] public decimal Volume { get; set; } /// /// Unit /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("amount_type")] + [JsonPropertyName("amount_type")] public Unit Unit { get; set; } /// /// Value /// + [JsonPropertyName("value")] public decimal Value { get; set; } /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("ts")] + [JsonPropertyName("ts")] public DateTime Timestamp { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOrderId.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderId.cs similarity index 58% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOrderId.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderId.cs index 7bd9be4c..a0926054 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiOrderId.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderId.cs @@ -1,16 +1,16 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Order id /// - public record HuobiOrderId + public record HTXOrderId { /// /// Order id /// - [JsonProperty("order_id")] + [JsonPropertyName("order_id")] public string OrderId { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderIds.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderIds.cs new file mode 100644 index 00000000..71869a5e --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderIds.cs @@ -0,0 +1,26 @@ + + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Order id + /// + public record HTXOrderIds + { + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Client order id + /// + [JsonPropertyName("client_order_id")] + public long? ClientOrderId { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderLimit.cs new file mode 100644 index 00000000..1dbdb717 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXOrderLimit.cs @@ -0,0 +1,65 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Order limit info + /// + public record HTXOrderLimit + { + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType? OrderType { get; set; } + /// + /// Limits + /// + [JsonPropertyName("list")] + public IEnumerable Limits { get; set; } = Array.Empty(); + } + + /// + /// Limit info + /// + public record HTXOrderTypeLimit + { + /// + /// Asset + /// + [JsonPropertyName("symbol")] + public string Asset { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Max open order limit + /// + [JsonPropertyName("open_limit")] + public decimal? OpenLimit { get; set; } + /// + /// Max close order limit + /// + [JsonPropertyName("close_limit")] + public decimal? CloseLimit { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType? BusinessType { get; set; } + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType? ContractType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPage.cs similarity index 66% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPage.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXPage.cs index 6c505db5..22bfcec7 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPage.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPage.cs @@ -1,26 +1,26 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Page of data /// - public record HuobiPage + public record HTXPage { /// /// Total amount of pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current page /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total amount of records /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalRecords { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPlacedOrderId.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPlacedOrderId.cs similarity index 61% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPlacedOrderId.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXPlacedOrderId.cs index 842b97c5..48f7235b 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPlacedOrderId.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPlacedOrderId.cs @@ -1,21 +1,21 @@ -using Newtonsoft.Json; + -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Placed order id /// - public record HuobiPlacedOrderId + public record HTXPlacedOrderId { /// /// Order id /// - [JsonProperty("order_id")] + [JsonPropertyName("order_id")] public long OrderId { get; set; } /// /// Client order id /// - [JsonProperty("client_order_id")] + [JsonPropertyName("client_order_id")] public long? ClientOrderId { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPosition.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPosition.cs new file mode 100644 index 00000000..11ee00e3 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPosition.cs @@ -0,0 +1,141 @@ +using HTX.Net.Enums; + + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Isolated margin position info + /// + public record HTXPosition + { + /// + /// Asset + /// + [JsonPropertyName("symbol")] + public string Asset { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Available + /// + [JsonPropertyName("available")] + public decimal Available { get; set; } + /// + /// Frozen + /// + [JsonPropertyName("frozen")] + public decimal Frozen { get; set; } + /// + /// Opening average price + /// + [JsonPropertyName("cost_open")] + public decimal CostOpen { get; set; } + /// + /// Average price of position + /// + [JsonPropertyName("cost_hold")] + public decimal CostHold { get; set; } + /// + /// Unrealized profit and loss + /// + [JsonPropertyName("profit_unreal")] + public decimal UnrealizedPnl { get; set; } + /// + /// Profit rate + /// + [JsonPropertyName("profit_rate")] + public decimal ProfitRate { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } + /// + /// Position margin + /// + [JsonPropertyName("position_margin")] + public decimal PositionMargin { get; set; } + /// + /// Order direction + /// + [JsonPropertyName("direction")] + public OrderSide Side { get; set; } + /// + /// Profit + /// + [JsonPropertyName("profit")] + public decimal Profit { get; set; } + /// + /// Last price + /// + [JsonPropertyName("last_price")] + public decimal LastPrice { get; set; } + /// + /// New risk rate + /// + [JsonPropertyName("new_risk_rate")] + public decimal? NewRiskRate { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + [JsonConverter(typeof(EnumConverter))] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Position mode + /// + [JsonPropertyName("position_mode")] + [JsonConverter(typeof(EnumConverter))] + public PositionMode PositionMode { get; set; } + /// + /// ADL risk percentage + /// + [JsonPropertyName("adl_risk_percent")] + public decimal? AdlRiskPercentage { get; set; } + /// + /// Trade partition + /// + [JsonPropertyName("trade_partition")] + public string? TradePartition { get; set; } + } + + /// + /// Cross margin position + /// + public record HTXCrossPosition : HTXPosition + { + /// + /// Contract type + /// + [JsonPropertyName("contract_type")] + public ContractType ContractType { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType BusinessType { get; set; } + /// + /// Pair + /// + [JsonPropertyName("pair")] + public string Pair { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionLimit.cs new file mode 100644 index 00000000..316053c5 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionLimit.cs @@ -0,0 +1,58 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Position limit + /// + public record HTXPositionLimit + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Buy limit + /// + [JsonPropertyName("buy_limit")] + public decimal BuyLimit { get; set; } + /// + /// Sell limit + /// + [JsonPropertyName("sell_limit")] + public decimal SellLimit { get; set; } + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LevererageRate { get; set; } + /// + /// Buy limit value + /// + [JsonPropertyName("buy_limit_value")] + public decimal BuyLimitValue { get; set; } + /// + /// Sell limit value + /// + [JsonPropertyName("sell_limit_value")] + public decimal SellLimitValue { get; set; } + /// + /// Mark price + /// + [JsonPropertyName("mark_price")] + public decimal MarkPrice { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPositionMode.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionMode.cs similarity index 60% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPositionMode.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionMode.cs index 225426a7..d65ec769 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPositionMode.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionMode.cs @@ -1,23 +1,22 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Position mode /// - public record HuobiPositionMode + public record HTXPositionMode { /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Position mode /// - [JsonProperty("position_mode")] + [JsonPropertyName("position_mode")] [JsonConverter(typeof(EnumConverter))] public PositionMode PositionMode { get; set; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionOpenTpSlOrders.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionOpenTpSlOrders.cs new file mode 100644 index 00000000..6448ac10 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPositionOpenTpSlOrders.cs @@ -0,0 +1,235 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Position open and tp/sl info + /// + public record HTXPositionOpenTpSlOrders + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Price + /// + [JsonPropertyName("price")] + public decimal Price { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide Side { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Client order id + /// + [JsonPropertyName("client_order_id")] + public string? ClientOrderId { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Filled quantity + /// + [JsonPropertyName("trade_volume")] + public decimal QuantityFilled { get; set; } + /// + /// Value filled + /// + [JsonPropertyName("trade_turnover")] + public decimal ValueFilled { get; set; } + /// + /// Fee + /// + [JsonPropertyName("fee")] + public decimal Fee { get; set; } + /// + /// Average trade price + /// + [JsonPropertyName("trade_avg_price")] + public decimal AveragePrice { get; set; } + /// + /// Margin frozen + /// + [JsonPropertyName("margin_frozen")] + public decimal MarginFrozen { get; set; } + /// + /// Profit + /// + [JsonPropertyName("profit")] + public decimal Profit { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public OrderStatusFilter Status { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public MarginOrderType OrderType { get; set; } + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Fee asset + /// + [JsonPropertyName("fee_asset")] + public string FeeAsset { get; set; } = string.Empty; + /// + /// Cancelation time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Tpsl order info + /// + [JsonPropertyName("tpsl_order_info")] + public IEnumerable TpslOrderInfo { get; set; } = Array.Empty(); + } + + /// + /// + /// + public record HTXPositionOpenTpSlOrdersSUB + { + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide Side { get; set; } + /// + /// Tpsl order type + /// + [JsonPropertyName("tpsl_order_type")] + public TpslOrderType TpslOrderType { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Trigger type + /// + [JsonPropertyName("trigger_type")] + public TriggerType TriggerType { get; set; } + /// + /// Trigger price + /// + [JsonPropertyName("trigger_price")] + public decimal TriggerPrice { get; set; } + /// + /// Order price + /// + [JsonPropertyName("order_price")] + public decimal? OrderPrice { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType? OrderPriceType { get; set; } + /// + /// Relation tpsl order id + /// + [JsonPropertyName("relation_tpsl_order_id")] + public string? RelationTpslOrderId { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public TpSlStatus Status { get; set; } + /// + /// Cancelation time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Fail code + /// + [JsonPropertyName("fail_code")] + public int? FailCode { get; set; } + /// + /// Fail reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public decimal? TriggeredPrice { get; set; } + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string? RelationOrderId { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPriceLimitation.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPriceLimitation.cs similarity index 70% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPriceLimitation.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXPriceLimitation.cs index 32772d70..473131a2 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPriceLimitation.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXPriceLimitation.cs @@ -1,50 +1,49 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Price limitation /// - public record HuobiPriceLimitation + public record HTXPriceLimitation { /// /// The asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// High limit /// - [JsonProperty("high_limit")] + [JsonPropertyName("high_limit")] public decimal HighLimit { get; set; } /// /// Low limit /// - [JsonProperty("low_limit")] + [JsonPropertyName("low_limit")] public decimal LowLimit { get; set; } /// /// Business type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] public ContractType ContractType { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSettlementRecord.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSettlementRecord.cs similarity index 67% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSettlementRecord.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSettlementRecord.cs index 42d1a247..2e759aeb 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSettlementRecord.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSettlementRecord.cs @@ -1,86 +1,82 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Settlement page /// - public record HuobiSettlementPage + public record HTXSettlementPage { /// /// Total pages /// - [JsonProperty("total_page")] + [JsonPropertyName("total_page")] public int TotalPages { get; set; } /// /// Current page /// - [JsonProperty("current_page")] + [JsonPropertyName("current_page")] public int CurrentPage { get; set; } /// /// Total size /// - [JsonProperty("total_size")] + [JsonPropertyName("total_size")] public int TotalSize { get; set; } /// /// Records /// - [JsonProperty("settlement_record")] - public IEnumerable Records { get; set; } = Array.Empty(); + [JsonPropertyName("settlement_record")] + public IEnumerable Records { get; set; } = Array.Empty(); } /// /// Settlement info /// - public record HuobiSettlementRecord + public record HTXSettlementRecord { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Settlement time /// - [JsonProperty("settlement_time")] + [JsonPropertyName("settlement_time")] [JsonConverter(typeof(DateTimeConverter))] public DateTime SettlementTime { get; set; } /// /// Clawback ratio /// - [JsonProperty("clawback_ratio")] + [JsonPropertyName("clawback_ratio")] public decimal ClawbackRatio { get; set; } /// /// Settlement price /// - [JsonProperty("settlement_price")] + [JsonPropertyName("settlement_price")] public decimal SettlementPrice { get; set; } /// /// Settlement type /// - [JsonProperty("settlement_type")] + [JsonPropertyName("settlement_type")] [JsonConverter(typeof(EnumConverter))] public SettlementType SettlementType { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountAssetInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountAssetInfo.cs new file mode 100644 index 00000000..3261b996 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountAssetInfo.cs @@ -0,0 +1,97 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Sub account asset info page + /// + public record HTXSubAccountAssetInfoPage + { + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total items + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + /// + /// Sub accounts + /// + [JsonPropertyName("sub_list")] + public IEnumerable SubAccounts { get; set; } = Array.Empty(); + } + + /// + /// Sub account asset info + /// + public record HTXSubAccountAssetInfo + { + /// + /// Sub user id + /// + [JsonPropertyName("sub_uid")] + public long SubUserId { get; set; } + /// + /// Assets + /// + [JsonPropertyName("account_info_list")] + public IEnumerable Assets { get; set; } = Array.Empty(); + } + + /// + /// Sub account asset + /// + public record HTXSubAccountAssetInfoAsset + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Margin balance + /// + [JsonPropertyName("margin_balance")] + public decimal MarginBalance { get; set; } + /// + /// Liquidation price + /// + [JsonPropertyName("liquidation_price")] + public decimal? LiquidationPrice { get; set; } + /// + /// Risk rate + /// + [JsonPropertyName("risk_rate")] + public decimal? RiskRate { get; set; } + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountCrossAssetInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountCrossAssetInfo.cs new file mode 100644 index 00000000..13ae56d2 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountCrossAssetInfo.cs @@ -0,0 +1,82 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Sub account asset info page + /// + public record HTXSubAccountCrossAssetInfoPage + { + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total items + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + /// + /// Sub accounts + /// + [JsonPropertyName("sub_list")] + public IEnumerable SubAccounts { get; set; } = Array.Empty(); + } + + /// + /// Sub account asset info + /// + public record HTXSubAccountCrossAssetInfo + { + /// + /// Sub user id + /// + [JsonPropertyName("sub_uid")] + public long SubUserId { get; set; } + /// + /// Assets + /// + [JsonPropertyName("account_info_list")] + public IEnumerable Assets { get; set; } = Array.Empty(); + } + + /// + /// Sub account asset + /// + public record HTXSubAccountCrossAssetInfoAsset + { + /// + /// Margin balance + /// + [JsonPropertyName("margin_balance")] + public decimal MarginBalance { get; set; } + /// + /// Risk rate + /// + [JsonPropertyName("risk_rate")] + public decimal? RiskRate { get; set; } + /// + /// Margin asset + /// + [JsonPropertyName("margin_asset")] + public string MarginAsset { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSubAccountResult.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountResult.cs similarity index 59% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSubAccountResult.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountResult.cs index ac2573cc..5988ceb9 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSubAccountResult.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubAccountResult.cs @@ -1,43 +1,41 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// sub account results /// - public record HuobiSubAccountResult + public record HTXSubAccountResult { /// /// Successfully updated ids /// + [JsonPropertyName("successes")] public string Successes { get; set; } = string.Empty; /// /// Errors /// - public IEnumerable Errors { get; set; } = Array.Empty(); + [JsonPropertyName("errors")] + public IEnumerable Errors { get; set; } = Array.Empty(); } /// /// Sub account error info /// - public record HuobiSubAccountError + public record HTXSubAccountError { /// /// Sub uid /// - [JsonProperty("sub_uid")] + [JsonPropertyName("sub_uid")] public string SubUid { get; set; } = string.Empty; /// /// Error code /// - [JsonProperty("err_code")] - public string ErrorCode { get; set; } = string.Empty; + [JsonPropertyName("err_code")] + public int ErrorCode { get; set; } /// /// Error message /// - [JsonProperty("err_msg")] + [JsonPropertyName("err_msg")] public string ErrorMessage { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubTradePermissions.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubTradePermissions.cs new file mode 100644 index 00000000..6dfd9521 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSubTradePermissions.cs @@ -0,0 +1,65 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trade permissions result + /// + public record HTXSubTradePermissions + { + /// + /// Errors + /// + [JsonPropertyName("errors")] + public IEnumerable Errors { get; set; } = Array.Empty(); + /// + /// Successes + /// + [JsonPropertyName("successes")] + public IEnumerable Successes { get; set; } = Array.Empty(); + } + + /// + /// Error + /// + public record HTXSubTradePermissionsError + { + /// + /// Sub user id + /// + [JsonPropertyName("sub_uid")] + public decimal SubUserId { get; set; } + /// + /// Error code + /// + [JsonPropertyName("err_code")] + public decimal ErrorCode { get; set; } + /// + /// Error msg + /// + [JsonPropertyName("err_msg")] + public string ErrorMsg { get; set; } = string.Empty; + } + + /// + /// Status + /// + public record HTXSubTradePermissionsStatus + { + /// + /// Query id + /// + [JsonPropertyName("query_id")] + public long QueryId { get; set; } + /// + /// Sub uid + /// + [JsonPropertyName("sub_uid")] + public string SubUid { get; set; } = string.Empty; + /// + /// Sub auth + /// + [JsonPropertyName("sub_auth")] + public bool SubAuth { get; set; } + } + + +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapAdjustFactorInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapAdjustFactorInfo.cs similarity index 63% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapAdjustFactorInfo.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapAdjustFactorInfo.cs index 2a507862..52ef32df 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapAdjustFactorInfo.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapAdjustFactorInfo.cs @@ -1,99 +1,98 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Adjust factor info /// - public record HuobiSwapAdjustFactorInfo + public record HTXSwapAdjustFactorInfo { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// list /// - public IEnumerable List { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable List { get; set; } = Array.Empty(); } /// /// Cross margin adjust factor info /// - public record HuobiCrossSwapAdjustFactorInfo: HuobiSwapAdjustFactorInfo + public record HTXCrossSwapAdjustFactorInfo: HTXSwapAdjustFactorInfo { /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] public ContractType ContractType { get; set; } } /// /// Factor info /// - public record HuobiFactorInfo + public record HTXFactorInfo { /// /// Lever rate /// - [JsonProperty("lever_rate")] - public decimal LeverRate { get; set; } + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } /// /// Ladders /// - public IEnumerable Ladders { get; set; } = Array.Empty(); + [JsonPropertyName("ladders")] + public IEnumerable Ladders { get; set; } = Array.Empty(); } /// /// Factor info /// - public record HuobiFactorEntry + public record HTXFactorEntry { /// /// Ladder /// + [JsonPropertyName("ladder")] public int Ladder { get; set; } /// /// Min size /// - [JsonProperty("min_size")] + [JsonPropertyName("min_size")] public int? MinSize { get; set; } /// /// Max size /// - [JsonProperty("max_size")] + [JsonPropertyName("max_size")] public int? MaxSize { get; set; } /// /// Adjust factor /// - [JsonProperty("adjust_factor")] + [JsonPropertyName("adjust_factor")] public decimal AdjustFactor { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapBestOffer.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapBookTicker.cs similarity index 63% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapBestOffer.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapBookTicker.cs index e9316010..d4bbfbeb 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapBestOffer.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapBookTicker.cs @@ -1,44 +1,43 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Best offer /// - public record HuobiSwapBestOffer + public record HTXSwapBookTicker { /// /// Business type /// [JsonConverter(typeof(EnumConverter))] - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinessType { get; set; } /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Best ask /// - public HuobiOrderBookEntry Ask { get; set; } = null!; + [JsonPropertyName("ask")] + public HTXOrderBookEntry Ask { get; set; } = null!; /// /// Best bid /// - public HuobiOrderBookEntry Bid { get; set; } = null!; + [JsonPropertyName("bid")] + public HTXOrderBookEntry Bid { get; set; } = null!; /// /// Order id /// - [JsonProperty("mrid")] + [JsonPropertyName("mrid")] public long Id { get; set; } /// /// Timestamp /// [JsonConverter(typeof(DateTimeConverter))] - [JsonProperty("ts")] + [JsonPropertyName("ts")] public DateTime Timestamp { get; set; } } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapIndex.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapIndex.cs similarity index 64% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapIndex.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapIndex.cs index 51df9e11..4ab30fbc 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapIndex.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapIndex.cs @@ -1,28 +1,24 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; -using System; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Swap index /// - public record HuobiSwapIndex + public record HTXSwapIndex { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Index price /// - [JsonProperty("index_price")] + [JsonPropertyName("index_price")] public decimal IndexPrice { get; set; } /// /// Timestamp /// - [JsonProperty("index_ts")] + [JsonPropertyName("index_ts")] [JsonConverter(typeof(DateTimeConverter))] public DateTime Timestamp { get; set; } } diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapRiskInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapRiskInfo.cs similarity index 60% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapRiskInfo.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapRiskInfo.cs index 8c1f3169..1781435a 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiSwapRiskInfo.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXSwapRiskInfo.cs @@ -1,41 +1,37 @@ -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Swap risk info /// - public record HuobiSwapRiskInfo + public record HTXSwapRiskInfo { /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Insurance fund /// - [JsonProperty("insurance_fund")] + [JsonPropertyName("insurance_fund")] public decimal InsuranceFund { get; set; } /// /// Estimated clawback /// - [JsonProperty("estimated_clawback")] + [JsonPropertyName("estimated_clawback")] public decimal EstimatedClawback { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] public BusinessType BusinuessType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; - /// - /// Trade partition - /// - public string TradePartition { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTicker.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTicker.cs new file mode 100644 index 00000000..c03c95ae --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTicker.cs @@ -0,0 +1,61 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Market data + /// + public record HTXTicker: HTXSymbolData + { + /// + /// Open time + /// + [JsonPropertyName("id")] + public DateTime OpenTime { get; set; } + /// + /// Timestamp + /// + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + /// + /// Turnover, quantity * contract value * price + /// + [JsonPropertyName("trade_turnover")] + public decimal? Value { get; set; } + /// + /// Best ask + /// + [JsonConverter(typeof(ArrayConverter))] + [JsonPropertyName("ask")] + public HTXOrderBookEntry? Ask { get; set; } + /// + /// Best bid + /// + [JsonConverter(typeof(ArrayConverter))] + [JsonPropertyName("bid")] + public HTXOrderBookEntry? Bid { get; set; } + } + + /// + /// Ticker info + /// + public record HTXListTicker : HTXTicker + { + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string? ContractCode { get; set; } + /// + /// Business type + /// + [JsonPropertyName("business_type")] + public BusinessType? BusinessType { get; set; } + + /// + /// Number of buys and sells in last 24h + /// + [JsonPropertyName("number_of")] + public int Trades { get; set; } + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTieredMarginInfo.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTieredMarginInfo.cs similarity index 64% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTieredMarginInfo.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXTieredMarginInfo.cs index bcbe0d61..8dc45ffa 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTieredMarginInfo.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTieredMarginInfo.cs @@ -1,63 +1,60 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Tiered margin info /// - public record HuobiTieredMarginInfo + public record HTXTieredMarginInfo { /// /// Margin account /// - [JsonProperty("margin_account")] + [JsonPropertyName("margin_account")] public string MarginAccount { get; set; } = string.Empty; /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Margin mode /// - [JsonProperty("margin_mode")] + [JsonPropertyName("margin_mode")] [JsonConverter(typeof(EnumConverter))] public MarginMode MarginMode { get; set; } /// /// List /// - public IEnumerable List { get; set; } = Array.Empty(); + [JsonPropertyName("list")] + public IEnumerable List { get; set; } = Array.Empty(); } /// /// Tiered cross margin info /// - public record HuobiTieredCrossMarginInfo: HuobiTieredMarginInfo + public record HTXTieredCrossMarginInfo: HTXTieredMarginInfo { /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get;set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } } @@ -65,43 +62,44 @@ public record HuobiTieredCrossMarginInfo: HuobiTieredMarginInfo /// /// Margin rate /// - public record HuobiTieredMarginRate + public record HTXTieredMarginRate { /// /// Lever rate /// - [JsonProperty("lever_rate")] - public decimal LeverRate { get; set; } + [JsonPropertyName("lever_rate")] + public decimal LeverageRate { get; set; } /// /// Ladders /// - public IEnumerable Ladders { get; set; } = Array.Empty(); + [JsonPropertyName("ladders")] + public IEnumerable Ladders { get; set; } = Array.Empty(); } /// /// Ladder info /// - public record HuobiTieredMarginLadder + public record HTXTieredMarginLadder { /// /// Min marging balance /// - [JsonProperty("min_margin_balance")] + [JsonPropertyName("min_margin_balance")] public decimal? MinMarginBalance { get; set; } /// /// Max margin balance /// - [JsonProperty("max_margin_balance")] + [JsonPropertyName("max_margin_balance")] public decimal? MaxMarginBalance { get; set; } /// /// Min margin available /// - [JsonProperty("min_margin_available")] + [JsonPropertyName("min_margin_available")] public decimal? MinMarginAvailable { get; set; } /// /// Max margin available /// - [JsonProperty("max_margin_available")] + [JsonPropertyName("max_margin_available")] public decimal? MaxMarginAvailable { get; set; } } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlClosedOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlClosedOrderPage.cs new file mode 100644 index 00000000..7deae95a --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlClosedOrderPage.cs @@ -0,0 +1,68 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Take profit / stop loss order page + /// + public record HTXTpSlClosedOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Tp/Sl order + /// + public record HTXTpSlClosedOrder : HTXTpSlOrder + { + /// + /// Cancel time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Update time + /// + [JsonPropertyName("update_time")] + public DateTime? UpdateTime { get; set; } + /// + /// Error code + /// + [JsonPropertyName("fail_code")] + public int? FailCode { get; set; } + /// + /// Error reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public int? TriggeredPrice { get; set; } + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string? RelationOrderId { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlOrderPage.cs new file mode 100644 index 00000000..066ed57d --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlOrderPage.cs @@ -0,0 +1,135 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Take profit / stop loss order page + /// + public record HTXTpSlOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Tp/Sl order + /// + public record HTXTpSlOrder + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public int OrderType { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Trigger type + /// + [JsonPropertyName("trigger_type")] + public TriggerType TriggerType { get; set; } + /// + /// Trigger price + /// + [JsonPropertyName("trigger_price")] + public decimal TriggerPrice { get; set; } + /// + /// Order price + /// + [JsonPropertyName("order_price")] + public decimal? OrderPrice { get; set; } + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public TpSlStatus? Status { get; set; } + /// + /// Tpsl order type + /// + [JsonPropertyName("tpsl_order_type")] + public TpslOrderType? TpslOrderType { get; set; } + /// + /// Source order id + /// + [JsonPropertyName("source_order_id")] + public string? SourceOrderId { get; set; } + /// + /// Relation tpsl order id + /// + [JsonPropertyName("relation_tpsl_order_id")] + public string? RelationTpslOrderId { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlResult.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlResult.cs new file mode 100644 index 00000000..d40092e5 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTpSlResult.cs @@ -0,0 +1,36 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Tp/sl set result + /// + public record HTXTpSlResult + { + /// + /// Take profit order + /// + [JsonPropertyName("tp_order")] + public HTXTpSlResultOrder? TpOrder { get; set; } + /// + /// Stop loss order + /// + [JsonPropertyName("sl_order")] + public HTXTpSlResultOrder? SlOrder { get; set; } + } + + /// + /// Order info + /// + public record HTXTpSlResultOrder + { + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id string + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + } +} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTradingFee.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingFee.cs similarity index 72% rename from Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTradingFee.cs rename to HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingFee.cs index 99b751cb..086c1c7b 100644 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiTradingFee.cs +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingFee.cs @@ -1,70 +1,69 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; +using HTX.Net.Enums; -namespace Huobi.Net.Objects.Models.UsdtMarginSwap + +namespace HTX.Net.Objects.Models.UsdtMarginSwap { /// /// Trading fee info /// - public record HuobiTradingFee + public record HTXTradingFee { /// /// Asset /// - [JsonProperty("symbol")] + [JsonPropertyName("symbol")] public string Asset { get; set; } = string.Empty; /// /// Contract code /// - [JsonProperty("contract_code")] + [JsonPropertyName("contract_code")] public string ContractCode { get; set; } = string.Empty; /// /// Open position maker fee /// - [JsonProperty("open_maker_fee")] + [JsonPropertyName("open_maker_fee")] public decimal OpenMakerFee { get; set; } /// /// Open position taker fee /// - [JsonProperty("open_taker_fee")] + [JsonPropertyName("open_taker_fee")] public decimal OpenTakerFee { get; set; } /// /// Close position maker fee /// - [JsonProperty("close_maker_fee")] + [JsonPropertyName("close_maker_fee")] public decimal CloseMakerfee { get; set; } /// /// Close position taker fee /// - [JsonProperty("close_taker_fee")] + [JsonPropertyName("close_taker_fee")] public decimal CloseTakerFee { get; set; } /// /// Fee asset /// - [JsonProperty("fee_asset")] + [JsonPropertyName("fee_asset")] public string FeeAsset { get; set; } = string.Empty; /// /// Delivery fee /// - [JsonProperty("delivery_fee")] + [JsonPropertyName("delivery_fee")] public decimal DeliveryFee { get; set; } /// /// Business type /// - [JsonProperty("business_type")] + [JsonPropertyName("business_type")] [JsonConverter(typeof(EnumConverter))] public BusinessType BusinessType { get; set; } /// /// Contract type /// - [JsonProperty("contract_type")] + [JsonPropertyName("contract_type")] [JsonConverter(typeof(EnumConverter))] public ContractType ContractType { get; set; } /// /// Symbol /// - [JsonProperty("pair")] + [JsonPropertyName("pair")] public string Symbol { get; set; } = string.Empty; } } diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingStatus.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingStatus.cs new file mode 100644 index 00000000..1cece7af --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTradingStatus.cs @@ -0,0 +1,115 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trading status + /// + public record HTXTradingStatus + { + /// + /// Is disable + /// + [JsonPropertyName("is_disable")] + public bool IsDisable { get; set; } + /// + /// Order price types + /// + [JsonPropertyName("order_price_types")] + public string OrderPriceTypes { get; set; } = string.Empty; + /// + /// Disable reason + /// + [JsonPropertyName("disable_reason")] + public string DisableReason { get; set; } = string.Empty; + /// + /// Disable interval + /// + [JsonPropertyName("disable_interval")] + public long DisableInterval { get; set; } + /// + /// Recovery time + /// + [JsonPropertyName("recovery_time")] + public long RecoveryTime { get; set; } + /// + /// Cancel order ratio info + /// + [JsonPropertyName("COR")] + public HTXTradingStatusCor CancelOrderRatio { get; set; } = null!; + /// + /// Total disables info + /// + [JsonPropertyName("TDN")] + public HTXTradingStatusTdn TotalDisables { get; set; } = null!; + } + + /// + /// Cancel order ratio + /// + public record HTXTradingStatusCor + { + /// + /// Orders threshold + /// + [JsonPropertyName("orders_threshold")] + public int OrdersThreshold { get; set; } + /// + /// Orders + /// + [JsonPropertyName("orders")] + public int Orders { get; set; } + /// + /// Invalid cancel orders + /// + [JsonPropertyName("invalid_cancel_orders")] + public int InvalidCancelOrders { get; set; } + /// + /// Cancel ratio threshold + /// + [JsonPropertyName("cancel_ratio_threshold")] + public decimal CancelRatioThreshold { get; set; } + /// + /// Cancel ratio + /// + [JsonPropertyName("cancel_ratio")] + public decimal CancelRatio { get; set; } + /// + /// Is trigger + /// + [JsonPropertyName("is_trigger")] + public bool IsTrigger { get; set; } + /// + /// Is active + /// + [JsonPropertyName("is_active")] + public bool IsActive { get; set; } + } + + /// + /// Total disables + /// + public record HTXTradingStatusTdn + { + /// + /// Disables threshold + /// + [JsonPropertyName("disables_threshold")] + public int DisablesThreshold { get; set; } + /// + /// Disables + /// + [JsonPropertyName("disables")] + public int Disables { get; set; } + /// + /// Is trigger + /// + [JsonPropertyName("is_trigger")] + public bool IsTrigger { get; set; } + /// + /// Is active + /// + [JsonPropertyName("is_active")] + public bool IsActive { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingClosedOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingClosedOrderPage.cs new file mode 100644 index 00000000..ef76abbb --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingClosedOrderPage.cs @@ -0,0 +1,83 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trailing order page + /// + public record HTXTrailingClosedOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trailing order info + /// + public record HTXTrailingClosedOrder : HTXTrailingOrder + { + /// + /// Triggered price + /// + [JsonPropertyName("triggered_price")] + public decimal? TriggeredPrice { get; set; } + /// + /// Update time + /// + [JsonPropertyName("update_time")] + public DateTime? UpdateTime { get; set; } + /// + /// Cancel time + /// + [JsonPropertyName("canceled_at")] + public DateTime? CancelTime { get; set; } + /// + /// Error code + /// + [JsonPropertyName("fail_code")] + public int? FailCode { get; set; } + /// + /// Error reason + /// + [JsonPropertyName("fail_reason")] + public string? FailReason { get; set; } + /// + /// Relation order id + /// + [JsonPropertyName("relation_order_id")] + public string? RelationOrderId { get; set; } + /// + /// Lowest/highest market price (use the lowest price when buy. use the highest when sell) + /// + [JsonPropertyName("market_limit_price")] + public decimal? MarketLimitPrice { get; set; } + /// + /// Real volume + /// + [JsonPropertyName("real_volume")] + public decimal? RealVolume { get; set; } + /// + /// Formula price(the lowest (highest) market price* (1 ± callback rate)) + /// + [JsonPropertyName("formula_price")] + public decimal? FormulaPrice { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingOrderPage.cs new file mode 100644 index 00000000..884482c7 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTrailingOrderPage.cs @@ -0,0 +1,135 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trailing order page + /// + public record HTXTrailingOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trailing order info + /// + public record HTXTrailingOrder + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public MarginOrderType OrderType { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide Side { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id str + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Creation time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public TpSlStatus Status { get; set; } + /// + /// Callback rate + /// + [JsonPropertyName("callback_rate")] + public decimal CallbackRate { get; set; } + /// + /// Active price + /// + [JsonPropertyName("active_price")] + public decimal ActivePrice { get; set; } + /// + /// Is active + /// + [JsonPropertyName("is_active")] + public bool IsActive { get; set; } + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTransferLimit.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTransferLimit.cs new file mode 100644 index 00000000..2b6591aa --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTransferLimit.cs @@ -0,0 +1,73 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Transfer limit + /// + public record HTXTransferLimit + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Transfer in max per transfer + /// + [JsonPropertyName("transfer_in_max_each")] + public decimal TransferInMaxEach { get; set; } + /// + /// Transfer in min per transfer + /// + [JsonPropertyName("transfer_in_min_each")] + public decimal TransferInMinEach { get; set; } + /// + /// Transfer out max per transfer + /// + [JsonPropertyName("transfer_out_max_each")] + public decimal TransferOutMaxEach { get; set; } + /// + /// Transfer out min per transfer + /// + [JsonPropertyName("transfer_out_min_each")] + public decimal TransferOutMinEach { get; set; } + /// + /// Transfer in max daily + /// + [JsonPropertyName("transfer_in_max_daily")] + public decimal TransferInMaxDaily { get; set; } + /// + /// Transfer out max daily + /// + [JsonPropertyName("transfer_out_max_daily")] + public decimal TransferOutMaxDaily { get; set; } + /// + /// Net transfer in max daily + /// + [JsonPropertyName("net_transfer_in_max_daily")] + public decimal NetTransferInMaxDaily { get; set; } + /// + /// Net transfer out max daily + /// + [JsonPropertyName("net_transfer_out_max_daily")] + public decimal NetTransferOutMaxDaily { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderPage.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderPage.cs new file mode 100644 index 00000000..baa6fd49 --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderPage.cs @@ -0,0 +1,135 @@ +using HTX.Net.Enums; + +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trigger order page + /// + public record HTXTriggerOrderPage + { + /// + /// Orders + /// + [JsonPropertyName("orders")] + public IEnumerable Orders { get; set; } = Array.Empty(); + /// + /// Total page + /// + [JsonPropertyName("total_page")] + public int TotalPage { get; set; } + /// + /// Current page + /// + [JsonPropertyName("current_page")] + public int CurrentPage { get; set; } + /// + /// Total results + /// + [JsonPropertyName("total_size")] + public int Total { get; set; } + } + + /// + /// Trigger order + /// + public record HTXTriggerOrder + { + /// + /// Symbol + /// + [JsonPropertyName("symbol")] + public string Symbol { get; set; } = string.Empty; + /// + /// Contract code + /// + [JsonPropertyName("contract_code")] + public string ContractCode { get; set; } = string.Empty; + /// + /// Trigger type + /// + [JsonPropertyName("trigger_type")] + public TriggerType TriggerType { get; set; } + /// + /// Quantity + /// + [JsonPropertyName("volume")] + public decimal Quantity { get; set; } + /// + /// Order type + /// + [JsonPropertyName("order_type")] + public int OrderType { get; set; } + /// + /// Side + /// + [JsonPropertyName("direction")] + public OrderSide OrderSide { get; set; } + /// + /// Offset + /// + [JsonPropertyName("offset")] + public Offset Offset { get; set; } + /// + /// Leverage rate + /// + [JsonPropertyName("lever_rate")] + public int LeverageRate { get; set; } + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public long OrderId { get; set; } + /// + /// Order id str + /// + [JsonPropertyName("order_id_str")] + public string OrderIdStr { get; set; } = string.Empty; + /// + /// Order source + /// + [JsonPropertyName("order_source")] + public string OrderSource { get; set; } = string.Empty; + /// + /// Trigger price + /// + [JsonPropertyName("trigger_price")] + public decimal TriggerPrice { get; set; } + /// + /// Order price + /// + [JsonPropertyName("order_price")] + public decimal? OrderPrice { get; set; } + /// + /// Create time + /// + [JsonPropertyName("created_at")] + public DateTime CreateTime { get; set; } + /// + /// Order price type + /// + [JsonPropertyName("order_price_type")] + public OrderPriceType OrderPriceType { get; set; } + /// + /// Status + /// + [JsonPropertyName("status")] + public OrderStatusFilter Status { get; set; } + /// + /// Margin mode + /// + [JsonPropertyName("margin_mode")] + public MarginMode MarginMode { get; set; } + /// + /// Margin account + /// + [JsonPropertyName("margin_account")] + public string MarginAccount { get; set; } = string.Empty; + /// + /// Reduce only + /// + [JsonPropertyName("reduce_only")] + public bool ReduceOnly { get; set; } + } + + +} diff --git a/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderResult.cs b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderResult.cs new file mode 100644 index 00000000..49aa4a1b --- /dev/null +++ b/HTX.Net/Objects/Models/UsdtMarginSwap/HTXTriggerOrderResult.cs @@ -0,0 +1,43 @@ +namespace HTX.Net.Objects.Models.UsdtMarginSwap +{ + /// + /// Trigger order operation result + /// + public record HTXTriggerOrderResult + { + /// + /// Errors + /// + [JsonPropertyName("errors")] + public IEnumerable Errors { get; set; } = Array.Empty(); + /// + /// Successful operations, comma seperated + /// + [JsonPropertyName("successes")] + public string Successes { get; set; } = string.Empty; + } + + /// + /// Error info + /// + public record HTXTriggerOrderResultError + { + /// + /// Order id + /// + [JsonPropertyName("order_id")] + public string OrderId { get; set; } = string.Empty; + /// + /// Err code + /// + [JsonPropertyName("err_code")] + public int ErrorCode { get; set; } + /// + /// Err msg + /// + [JsonPropertyName("err_msg")] + public string ErrorMessage { get; set; } = string.Empty; + } + + +} diff --git a/Huobi.Net/Objects/Options/HuobiOrderBookOptions.cs b/HTX.Net/Objects/Options/HTXOrderBookOptions.cs similarity index 72% rename from Huobi.Net/Objects/Options/HuobiOrderBookOptions.cs rename to HTX.Net/Objects/Options/HTXOrderBookOptions.cs index b8fd922f..3a793191 100644 --- a/Huobi.Net/Objects/Options/HuobiOrderBookOptions.cs +++ b/HTX.Net/Objects/Options/HTXOrderBookOptions.cs @@ -1,17 +1,16 @@ using CryptoExchange.Net.Objects.Options; -using System; -namespace Huobi.Net.Objects.Options +namespace HTX.Net.Objects.Options { /// - /// Options for the Huobi SymbolOrderBook + /// Options for the HTX SymbolOrderBook /// - public class HuobiOrderBookOptions: OrderBookOptions + public class HTXOrderBookOptions: OrderBookOptions { /// - /// Default options for the Huobi SymbolOrderBook + /// Default options for the HTX SymbolOrderBook /// - public static HuobiOrderBookOptions Default { get; set; } = new HuobiOrderBookOptions(); + public static HTXOrderBookOptions Default { get; set; } = new HTXOrderBookOptions(); /// /// The way the entries are merged. 0 is no merge, 2 means to combine the entries on 2 decimal places @@ -28,9 +27,9 @@ public class HuobiOrderBookOptions: OrderBookOptions /// public TimeSpan? InitialDataTimeout { get; set; } - internal HuobiOrderBookOptions Copy() + internal HTXOrderBookOptions Copy() { - var options = Copy(); + var options = Copy(); options.MergeStep = MergeStep; options.Levels = Levels; options.InitialDataTimeout = InitialDataTimeout; diff --git a/Huobi.Net/Objects/Options/HuobiRestOptions.cs b/HTX.Net/Objects/Options/HTXRestOptions.cs similarity index 65% rename from Huobi.Net/Objects/Options/HuobiRestOptions.cs rename to HTX.Net/Objects/Options/HTXRestOptions.cs index 31c8cad4..9804e74d 100644 --- a/Huobi.Net/Objects/Options/HuobiRestOptions.cs +++ b/HTX.Net/Objects/Options/HTXRestOptions.cs @@ -1,22 +1,18 @@ -using CryptoExchange.Net.Interfaces; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Options; -using System; -using System.Collections.Generic; +using CryptoExchange.Net.Objects.Options; -namespace Huobi.Net.Objects.Options +namespace HTX.Net.Objects.Options { /// - /// Options for the HuobiRestClient + /// Options for the HTXRestClient /// - public class HuobiRestOptions : RestExchangeOptions + public class HTXRestOptions : RestExchangeOptions { /// - /// Default options for the HuobiRestClient + /// Default options for the HTXRestClient /// - public static HuobiRestOptions Default { get; set; } = new HuobiRestOptions() + public static HTXRestOptions Default { get; set; } = new HTXRestOptions() { - Environment = HuobiEnvironment.Live + Environment = HTXEnvironment.Live }; /// @@ -39,9 +35,9 @@ public class HuobiRestOptions : RestExchangeOptions /// public RestApiOptions UsdtMarginSwapOptions { get; private set; } = new RestApiOptions(); - internal HuobiRestOptions Copy() + internal HTXRestOptions Copy() { - var options = Copy(); + var options = Copy(); options.SpotOptions = SpotOptions.Copy(); options.UsdtMarginSwapOptions = UsdtMarginSwapOptions.Copy(); options.SignPublicRequests = SignPublicRequests; diff --git a/Huobi.Net/Objects/Options/HuobiSocketOptions.cs b/HTX.Net/Objects/Options/HTXSocketOptions.cs similarity index 63% rename from Huobi.Net/Objects/Options/HuobiSocketOptions.cs rename to HTX.Net/Objects/Options/HTXSocketOptions.cs index 5c95b108..0a399964 100644 --- a/Huobi.Net/Objects/Options/HuobiSocketOptions.cs +++ b/HTX.Net/Objects/Options/HTXSocketOptions.cs @@ -1,18 +1,18 @@ using CryptoExchange.Net.Objects.Options; -namespace Huobi.Net.Objects.Options +namespace HTX.Net.Objects.Options { /// - /// Options for the HuobiSocketClient + /// Options for the HTXSocketClient /// - public class HuobiSocketOptions : SocketExchangeOptions + public class HTXSocketOptions : SocketExchangeOptions { /// - /// Default options for the HuobiSocketClient + /// Default options for the HTXSocketClient /// - public static HuobiSocketOptions Default { get; set; } = new HuobiSocketOptions + public static HTXSocketOptions Default { get; set; } = new HTXSocketOptions { - Environment = HuobiEnvironment.Live, + Environment = HTXEnvironment.Live, SocketSubscriptionsCombineTarget = 10 }; @@ -26,9 +26,9 @@ public class HuobiSocketOptions : SocketExchangeOptions /// public SocketApiOptions UsdtMarginSwapOptions { get; private set; } = new SocketApiOptions(); - internal HuobiSocketOptions Copy() + internal HTXSocketOptions Copy() { - var options = Copy(); + var options = Copy(); options.SpotOptions = SpotOptions.Copy(); options.UsdtMarginSwapOptions = UsdtMarginSwapOptions.Copy(); return options; diff --git a/HTX.Net/Objects/Sockets/HTXAuthParams.cs b/HTX.Net/Objects/Sockets/HTXAuthParams.cs new file mode 100644 index 00000000..28a4f2b8 --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXAuthParams.cs @@ -0,0 +1,14 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXAuthParams + { + [JsonPropertyName("authType")] public string AuthType { get; set; } = "api"; + [JsonPropertyName("accessKey")] public string AccessKey { get; set; } = string.Empty; + [JsonPropertyName("signatureMethod")] public string SignatureMethod { get; set; } = "HmacSHA256"; + [JsonPropertyName("signatureVersion")] public string SignatureVersion { get; set; } = "2.1"; + [JsonPropertyName("timestamp")] public string Timestamp { get; set; } = string.Empty; + [JsonPropertyName("signature")] public string Signature { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Sockets/HTXAuthPongMessage.cs b/HTX.Net/Objects/Sockets/HTXAuthPongMessage.cs new file mode 100644 index 00000000..ba5d79ae --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXAuthPongMessage.cs @@ -0,0 +1,32 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXAuthPongMessage + { + [JsonPropertyName("action")] + public string Action { get; set; } = string.Empty; + [JsonPropertyName("data")] + public HTXAuthPongMessageTimestamp Data { get; set; } = null!; + } + + internal class HTXAuthPingMessage + { + [JsonPropertyName("action")] + public string Action { get; set; } = string.Empty; + [JsonPropertyName("data")] + public HTXAuthPingMessageTimestamp Data { get; set; } = null!; + } + + internal class HTXAuthPongMessageTimestamp + { + [JsonPropertyName("pong")] + public long Pong { get; set; } + } + + internal class HTXAuthPingMessageTimestamp + { + [JsonPropertyName("ts")] + public long Ping { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/HTXAuthRequest.cs b/HTX.Net/Objects/Sockets/HTXAuthRequest.cs new file mode 100644 index 00000000..6911cb59 --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXAuthRequest.cs @@ -0,0 +1,18 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXAuthRequest + { + [JsonPropertyName("action")] + public string Action { get; set; } = string.Empty; + [JsonPropertyName("ch")] + public string Channel { get; set; } = string.Empty; + } + + internal class HTXAuthRequest : HTXAuthRequest + { + [JsonPropertyName("params")] + public T Params { get; set; } = default!; + } +} diff --git a/HTX.Net/Objects/Sockets/HTXOpMessage.cs b/HTX.Net/Objects/Sockets/HTXOpMessage.cs new file mode 100644 index 00000000..c5911026 --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXOpMessage.cs @@ -0,0 +1,42 @@ +namespace HTX.Net.Objects.Sockets +{ + /// + /// Message + /// + public record HTXOpMessage + { + /// + /// Operation + /// + [JsonPropertyName("op")] + public string Operation { get; set; } = string.Empty; + /// + /// Request id + /// + [JsonPropertyName("cid")] + public string? RequestId { get; set; } + /// + /// Topic + /// + [JsonPropertyName("topic")] + public string Topic { get; set; } = string.Empty; + } + + internal record HTXOpPingMessage : HTXOpMessage + { + [JsonPropertyName("ts")] + public long Timestamp { get; set; } + } + + internal record HTXOpResponse : HTXOpMessage + { + [JsonPropertyName("ts")] + public DateTime Timestamp { get; set; } + + [JsonPropertyName("err-code")] + public int ErrorCode { get; set; } + + [JsonPropertyName("err-msg")] + public string ErrorMessage { get; set; } = string.Empty; + } +} diff --git a/HTX.Net/Objects/Sockets/HTXPingMessage.cs b/HTX.Net/Objects/Sockets/HTXPingMessage.cs new file mode 100644 index 00000000..e5203361 --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXPingMessage.cs @@ -0,0 +1,22 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXPingMessage + { + [JsonPropertyName("ping")] + public long Ping { get; set; } + } + + internal class HTXSpotPingWrapper + { + [JsonPropertyName("data")] + public HTXSpotPingMessage Data { get; set; } = null!; + } + + internal class HTXSpotPingMessage + { + [JsonPropertyName("ts")] + public long Ping { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/HTXPongMessage.cs b/HTX.Net/Objects/Sockets/HTXPongMessage.cs new file mode 100644 index 00000000..52449e6d --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXPongMessage.cs @@ -0,0 +1,18 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXPongMessage + { + [JsonPropertyName("pong")] + public long Pong { get; set; } + } + + internal class HTXSpotPongMessage + { + [JsonPropertyName("action")] + public string Action { get; set; } = "pong"; + [JsonPropertyName("data")] + public HTXSpotPingMessage Pong { get; set; } = null!; + } +} diff --git a/HTX.Net/Objects/Sockets/HTXSocketAuthResponse.cs b/HTX.Net/Objects/Sockets/HTXSocketAuthResponse.cs new file mode 100644 index 00000000..bedcfd0e --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXSocketAuthResponse.cs @@ -0,0 +1,16 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXSocketAuthResponse + { + [JsonPropertyName("action")] + public string Action { get; set; } = string.Empty; + [JsonPropertyName("ch")] + public string Channel { get; set; } = string.Empty; + [JsonPropertyName("code")] + public int Code { get; set; } + [JsonPropertyName("message")] + public string? Message { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/HTXSocketResponse.cs b/HTX.Net/Objects/Sockets/HTXSocketResponse.cs new file mode 100644 index 00000000..7e7dfe1d --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXSocketResponse.cs @@ -0,0 +1,16 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXSocketResponse + { + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + [JsonPropertyName("status")] + public string? Status { get; set; } + [JsonPropertyName("err-code")] + public string? ErrorCode { get; set; } + [JsonPropertyName("err-msg")] + public string? ErrorMessage { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/HTXSubscribeRequest.cs b/HTX.Net/Objects/Sockets/HTXSubscribeRequest.cs new file mode 100644 index 00000000..0b8936c5 --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXSubscribeRequest.cs @@ -0,0 +1,14 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXSubscribeRequest + { + [JsonPropertyName("sub")] + public string Topic { get; set; } = string.Empty; + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + [JsonPropertyName("data_type"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? DataType { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/HTXUnsubscribeRequest.cs b/HTX.Net/Objects/Sockets/HTXUnsubscribeRequest.cs new file mode 100644 index 00000000..6743765d --- /dev/null +++ b/HTX.Net/Objects/Sockets/HTXUnsubscribeRequest.cs @@ -0,0 +1,14 @@ + + +namespace HTX.Net.Objects.Sockets +{ + internal class HTXUnsubscribeRequest + { + [JsonPropertyName("unsub")] + public string Topic { get; set; } = string.Empty; + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + [JsonPropertyName("data_type"), JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? DataType { get; set; } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXAuthQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXAuthQuery.cs new file mode 100644 index 00000000..383a3bb6 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXAuthQuery.cs @@ -0,0 +1,26 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXAuthQuery : Query + { + public override HashSet ListenerIdentifiers { get; set; } + public HTXAuthQuery(string action, string topic, bool authenticated, int weight = 1) : base(new HTXAuthRequest() { Action = action, Channel = topic }, authenticated, weight) + { + ListenerIdentifiers = new HashSet { action + topic }; + } + public HTXAuthQuery(HTXAuthRequest request) : base(request, true, 1) + { + ListenerIdentifiers = new HashSet { request.Action + request.Channel }; + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + if (message.Data.Code != 200) + return new CallResult(new ServerError(message.Data.Code, message.Data.Message!)); + + return base.HandleMessage(connection, message); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXOpAuthQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXOpAuthQuery.cs new file mode 100644 index 00000000..debd206b --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXOpAuthQuery.cs @@ -0,0 +1,23 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Objects.Internal; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXOpAuthQuery : Query + { + public override HashSet ListenerIdentifiers { get; set; } + public HTXOpAuthQuery(HTXAuthenticationRequest2 request) : base(request, false, 1) + { + ListenerIdentifiers = new HashSet { "auth" }; + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + if (message.Data.ErrorCode != 0) + return new CallResult(new ServerError(message.Data.ErrorCode, message.Data.ErrorMessage!)); + + return base.HandleMessage(connection, message); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXOpQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXOpQuery.cs new file mode 100644 index 00000000..8a953c2f --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXOpQuery.cs @@ -0,0 +1,23 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXOpQuery : Query + { + public override HashSet ListenerIdentifiers { get; set; } + + public HTXOpQuery(string topic, string op, bool authenticated, int weight = 1) : base(new HTXOpMessage { RequestId = ExchangeHelpers.NextId().ToString(), Topic = topic, Operation = op }, authenticated, weight) + { + ListenerIdentifiers = new HashSet { ((HTXOpMessage)Request).RequestId! }; + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + if (message.Data.ErrorCode == 0) + return message.ToCallResult(message.Data); + + return new CallResult(new ServerError(message.Data.ErrorCode!, message.Data.ErrorMessage)); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXQuery.cs new file mode 100644 index 00000000..7072b946 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXQuery.cs @@ -0,0 +1,24 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Objects.Internal; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXQuery : Query> + { + public override HashSet ListenerIdentifiers { get; set; } + + public HTXQuery(string topic, bool authenticated, int weight = 1) : base(new HTXSocketRequest(ExchangeHelpers.NextId().ToString(), topic), authenticated, weight) + { + ListenerIdentifiers = new HashSet { ((HTXSocketRequest)Request).Id }; + } + + public override CallResult> HandleMessage(SocketConnection connection, DataEvent> message) + { + if (message.Data.IsSuccessful) + return new CallResult>(message.Data, message.OriginalData, null); + + return new CallResult>(new ServerError(message.Data.ErrorCode!, message.Data.ErrorMessage)); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXSubscribeQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXSubscribeQuery.cs new file mode 100644 index 00000000..095c596c --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXSubscribeQuery.cs @@ -0,0 +1,23 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXSubscribeQuery : Query + { + public override HashSet ListenerIdentifiers { get; set; } + + public HTXSubscribeQuery(string topic, bool authenticated, int weight = 1, string? dataType = null) : base(new HTXSubscribeRequest() { Id = ExchangeHelpers.NextId().ToString(), Topic = topic, DataType = dataType }, authenticated, weight) + { + ListenerIdentifiers = new HashSet { ((HTXSubscribeRequest)Request).Id }; + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + if (message.Data.Status != "ok") + return new CallResult(new ServerError(message.Data.ErrorMessage!)); + + return new CallResult(message.Data, message.OriginalData, null); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Queries/HTXUnsubscribeQuery.cs b/HTX.Net/Objects/Sockets/Queries/HTXUnsubscribeQuery.cs new file mode 100644 index 00000000..3c2ba1c1 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Queries/HTXUnsubscribeQuery.cs @@ -0,0 +1,15 @@ +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Queries +{ + internal class HTXUnsubscribeQuery : Query + { + public override HashSet ListenerIdentifiers { get; set; } + + public HTXUnsubscribeQuery(string topic, bool authenticated, int weight = 1, string? dataType = null) : base(new HTXUnsubscribeRequest() { Id = ExchangeHelpers.NextId().ToString(), Topic = topic, DataType = dataType }, authenticated, weight) + { + ListenerIdentifiers = new HashSet { ((HTXUnsubscribeRequest)Request).Id }; + } + + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXAccountSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXAccountSubscription.cs new file mode 100644 index 00000000..1c048736 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXAccountSubscription.cs @@ -0,0 +1,40 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Sockets.Queries; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXAccountSubscription : Subscription + { + private string _topic; + private Action> _handler; + + public override HashSet ListenerIdentifiers { get; set; } + + public HTXAccountSubscription(ILogger logger, string topic, Action> handler, bool authenticated) : base(logger, authenticated) + { + _handler = handler; + _topic = topic; + ListenerIdentifiers = new HashSet() { topic }; + } + + public override Query? GetSubQuery(SocketConnection connection) + { + return new HTXAuthQuery("sub", _topic, Authenticated); + } + public override Query? GetUnsubQuery() + { + return new HTXAuthQuery("unsub", _topic, Authenticated); + } + public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) + { + var update = (HTXDataEvent)message.Data; + _handler.Invoke(message.As(update.Data, update.Channel, null, SocketUpdateType.Update)); + return new CallResult(null); + } + + public override Type? GetMessageType(IMessageAccessor message) => typeof(HTXDataEvent); + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXAuthPingSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXAuthPingSubscription.cs new file mode 100644 index 00000000..6deb693e --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXAuthPingSubscription.cs @@ -0,0 +1,20 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXAuthPingSubscription : SystemSubscription + { + public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingv2" }; + + public HTXAuthPingSubscription(ILogger logger) : base(logger, false) + { + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + connection.Send(ExchangeHelpers.NextId(), new HTXAuthPongMessage() { Action = "pong", Data = new HTXAuthPongMessageTimestamp { Pong = message.Data.Data.Ping } }, 1); + return new CallResult(null); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXIncrementalOrderBookSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXIncrementalOrderBookSubscription.cs new file mode 100644 index 00000000..5577892b --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXIncrementalOrderBookSubscription.cs @@ -0,0 +1,43 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Sockets.Queries; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXIncrementalOrderBookSubscription : Subscription + { + private string _topic; + private bool _snapshots; + private Action> _handler; + + public override HashSet ListenerIdentifiers { get; set; } + + public HTXIncrementalOrderBookSubscription(ILogger logger, bool snapshots, string topic, Action> handler) : base(logger, false) + { + _handler = handler; + _snapshots = snapshots; + _topic = topic; + ListenerIdentifiers = new HashSet() { topic }; + } + + public override Query? GetSubQuery(SocketConnection connection) + { + return new HTXSubscribeQuery(_topic, Authenticated, dataType: _snapshots ? null : "incremental"); + } + public override Query? GetUnsubQuery() + { + return new HTXUnsubscribeQuery(_topic, Authenticated, dataType: _snapshots ? null : "incremental"); + } + + public override Type? GetMessageType(IMessageAccessor message) => typeof(HTXDataEvent); + + public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) + { + var huobiEvent = (HTXDataEvent)message.Data; + _handler.Invoke(message.As(huobiEvent.Data).WithStreamId(huobiEvent.Channel).WithUpdateType(huobiEvent.Data.Event == "snapshot" ? SocketUpdateType.Snapshot: SocketUpdateType.Update)); + return new CallResult(null); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXOpPingSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXOpPingSubscription.cs new file mode 100644 index 00000000..500c27ba --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXOpPingSubscription.cs @@ -0,0 +1,20 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXOpPingSubscription : SystemSubscription + { + public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "ping" }; + + public HTXOpPingSubscription(ILogger logger) : base(logger, false) + { + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + connection.Send(ExchangeHelpers.NextId(), new { op = "pong", ts = message.Data.Timestamp.ToString() }, 1); + return new CallResult(null); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXOpSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXOpSubscription.cs new file mode 100644 index 00000000..1589e02f --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXOpSubscription.cs @@ -0,0 +1,39 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; +using HTX.Net.Objects.Sockets.Queries; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXOpSubscription : Subscription where T: HTXOpMessage + { + private string _topic; + private Action> _handler; + + public override HashSet ListenerIdentifiers { get; set; } + + public HTXOpSubscription(ILogger logger, string listenId, string topic, Action> handler, bool authenticated) : base(logger, authenticated) + { + _handler = handler; + _topic = topic; + ListenerIdentifiers = new HashSet() { listenId }; + } + + public override Query? GetSubQuery(SocketConnection connection) + { + return new HTXOpQuery(_topic, "sub", Authenticated); + } + public override Query? GetUnsubQuery() + { + return new HTXOpQuery(_topic, "unsub", Authenticated); + } + + public override Type? GetMessageType(IMessageAccessor message) => typeof(T); + + public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) + { + var huobiEvent = (T)message.Data; + _handler.Invoke(message.As(huobiEvent).WithUpdateType(SocketUpdateType.Update).WithStreamId(huobiEvent.Topic)); + return new CallResult(null); + } + } +} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderDetailsSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXOrderDetailsSubscription.cs similarity index 57% rename from Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderDetailsSubscription.cs rename to HTX.Net/Objects/Sockets/Subscriptions/HTXOrderDetailsSubscription.cs index ec529cce..3b152082 100644 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderDetailsSubscription.cs +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXOrderDetailsSubscription.cs @@ -1,30 +1,25 @@ using CryptoExchange.Net.Converters.MessageParsing; -using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.Objects.Sockets.Queries; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Sockets.Queries; -namespace Huobi.Net.Objects.Sockets.Subscriptions +namespace HTX.Net.Objects.Sockets.Subscriptions { - internal class HuobiOrderDetailsSubscription : Subscription + internal class HTXOrderDetailsSubscription : Subscription { private string _topic; - private Action>? _onOrderMatch; - private Action>? _onOrderCancel; + private Action>? _onOrderMatch; + private Action>? _onOrderCancel; public override HashSet ListenerIdentifiers { get; set; } - public HuobiOrderDetailsSubscription( + public HTXOrderDetailsSubscription( ILogger logger, string? symbol, - Action>? onOrderMatch, - Action>? onOrderCancel) : base(logger, true) + Action>? onOrderMatch, + Action>? onOrderCancel) : base(logger, true) { _topic = $"trade.clearing#{symbol ?? "*"}#1"; _onOrderMatch = onOrderMatch; @@ -34,18 +29,18 @@ public HuobiOrderDetailsSubscription( public override Query? GetSubQuery(SocketConnection connection) { - return new HuobiAuthQuery("sub", _topic, Authenticated); + return new HTXAuthQuery("sub", _topic, Authenticated); } public override Query? GetUnsubQuery() { - return new HuobiAuthQuery("unsub", _topic, Authenticated); + return new HTXAuthQuery("unsub", _topic, Authenticated); } public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) { var data = message.Data; - if (data is HuobiDataEvent tradeEvent) + if (data is HTXDataEvent tradeEvent) _onOrderMatch?.Invoke(message.As(tradeEvent.Data, tradeEvent.Channel, tradeEvent.Data.Symbol, SocketUpdateType.Update)); - if (data is HuobiDataEvent cancelEvent) + if (data is HTXDataEvent cancelEvent) _onOrderCancel?.Invoke(message.As(cancelEvent.Data, cancelEvent.Channel, cancelEvent.Data.Symbol, SocketUpdateType.Update)); return new CallResult(null); } @@ -55,9 +50,9 @@ public override CallResult DoHandleMessage(SocketConnection connection, DataEven var typePath = MessagePath.Get().Property("data").Property("eventType"); var eventType = message.GetValue(typePath); if (string.Equals(eventType, "trade", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); if (string.Equals(eventType, "cancellation", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); return null; } diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXOrderSubscription.cs similarity index 53% rename from Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderSubscription.cs rename to HTX.Net/Objects/Sockets/Subscriptions/HTXOrderSubscription.cs index 33bad2dd..ebd8de78 100644 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiOrderSubscription.cs +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXOrderSubscription.cs @@ -1,36 +1,31 @@ using CryptoExchange.Net.Converters.MessageParsing; -using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.Objects.Sockets.Queries; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Models.Socket; +using HTX.Net.Objects.Sockets.Queries; -namespace Huobi.Net.Objects.Sockets.Subscriptions +namespace HTX.Net.Objects.Sockets.Subscriptions { - internal class HuobiOrderSubscription : Subscription + internal class HTXOrderSubscription : Subscription { private string _topic; - private Action>? _onOrderSubmitted; - private Action>? _onOrderMatched; - private Action>? _onOrderCancelation; - private Action>? _onConditionalOrderTriggerFailure; - private Action>? _onConditionalOrderCanceled; + private Action>? _onOrderSubmitted; + private Action>? _onOrderMatched; + private Action>? _onOrderCancelation; + private Action>? _onConditionalOrderTriggerFailure; + private Action>? _onConditionalOrderCanceled; public override HashSet ListenerIdentifiers { get; set; } - public HuobiOrderSubscription( + public HTXOrderSubscription( ILogger logger, string? symbol, - Action>? onOrderSubmitted, - Action>? onOrderMatched, - Action>? onOrderCancelation, - Action>? onConditionalOrderTriggerFailure, - Action>? onConditionalOrderCanceled) : base(logger, true) + Action>? onOrderSubmitted, + Action>? onOrderMatched, + Action>? onOrderCancelation, + Action>? onConditionalOrderTriggerFailure, + Action>? onConditionalOrderCanceled) : base(logger, true) { _topic = $"orders#{symbol ?? "*"}"; _onOrderSubmitted = onOrderSubmitted; @@ -43,24 +38,24 @@ public HuobiOrderSubscription( public override Query? GetSubQuery(SocketConnection connection) { - return new HuobiAuthQuery("sub", _topic, Authenticated); + return new HTXAuthQuery("sub", _topic, Authenticated); } public override Query? GetUnsubQuery() { - return new HuobiAuthQuery("unsub", _topic, Authenticated); + return new HTXAuthQuery("unsub", _topic, Authenticated); } public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) { var data = message.Data; - if (data is HuobiDataEvent triggerFailEvent) + if (data is HTXDataEvent triggerFailEvent) _onConditionalOrderTriggerFailure?.Invoke(message.As(triggerFailEvent.Data, triggerFailEvent.Channel, triggerFailEvent.Data.Symbol, SocketUpdateType.Update)); - if (data is HuobiDataEvent orderEvent) + if (data is HTXDataEvent orderEvent) _onConditionalOrderCanceled?.Invoke(message.As(orderEvent.Data, orderEvent.Channel, orderEvent.Data.Symbol, SocketUpdateType.Update)); - if (data is HuobiDataEvent submitOrderEvent) + if (data is HTXDataEvent submitOrderEvent) _onOrderSubmitted?.Invoke(message.As(submitOrderEvent.Data, submitOrderEvent.Channel, submitOrderEvent.Data.Symbol, SocketUpdateType.Update)); - if (data is HuobiDataEvent matchOrderEvent) + if (data is HTXDataEvent matchOrderEvent) _onOrderMatched?.Invoke(message.As(matchOrderEvent.Data, matchOrderEvent.Channel, matchOrderEvent.Data.Symbol, SocketUpdateType.Update)); - if (data is HuobiDataEvent cancelOrderEvent) + if (data is HTXDataEvent cancelOrderEvent) _onOrderCancelation?.Invoke(message.As(cancelOrderEvent.Data, cancelOrderEvent.Channel, cancelOrderEvent.Data.Symbol, SocketUpdateType.Update)); return new CallResult(null); } @@ -70,15 +65,15 @@ public override CallResult DoHandleMessage(SocketConnection connection, DataEven var typePath = MessagePath.Get().Property("data").Property("eventType"); var eventType = message.GetValue(typePath); if (string.Equals(eventType, "trigger", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); if (string.Equals(eventType, "deletion", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); if (string.Equals(eventType, "creation", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); if (string.Equals(eventType, "trade", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); if (string.Equals(eventType, "cancellation", StringComparison.Ordinal)) - return typeof(HuobiDataEvent); + return typeof(HTXDataEvent); return null; } diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXPingSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXPingSubscription.cs new file mode 100644 index 00000000..5e6463e5 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXPingSubscription.cs @@ -0,0 +1,20 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXPingSubscription : SystemSubscription + { + public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingV3" }; + + public HTXPingSubscription(ILogger logger) : base(logger, false) + { + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + connection.Send(ExchangeHelpers.NextId(), new HTXPongMessage() { Pong = message.Data.Ping }, 1); + return new CallResult(null); + } + } +} diff --git a/HTX.Net/Objects/Sockets/Subscriptions/HTXSpotPingSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXSpotPingSubscription.cs new file mode 100644 index 00000000..c279d275 --- /dev/null +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXSpotPingSubscription.cs @@ -0,0 +1,20 @@ +using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Sockets; + +namespace HTX.Net.Objects.Sockets.Subscriptions +{ + internal class HTXSpotPingSubscription : SystemSubscription + { + public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingV2" }; + + public HTXSpotPingSubscription(ILogger logger) : base(logger, false) + { + } + + public override CallResult HandleMessage(SocketConnection connection, DataEvent message) + { + connection.Send(ExchangeHelpers.NextId(), new HTXSpotPongMessage() { Pong = new HTXSpotPingMessage { Ping = message.Data.Data.Ping } }, 1); + return new CallResult(null); + } + } +} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiSubscription.cs b/HTX.Net/Objects/Sockets/Subscriptions/HTXSubscription.cs similarity index 51% rename from Huobi.Net/Objects/Sockets/Subscriptions/HuobiSubscription.cs rename to HTX.Net/Objects/Sockets/Subscriptions/HTXSubscription.cs index da879844..77b7dd09 100644 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiSubscription.cs +++ b/HTX.Net/Objects/Sockets/Subscriptions/HTXSubscription.cs @@ -1,23 +1,18 @@ -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; +using CryptoExchange.Net.Objects.Sockets; using CryptoExchange.Net.Sockets; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Sockets.Queries; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; +using HTX.Net.Objects.Internal; +using HTX.Net.Objects.Sockets.Queries; -namespace Huobi.Net.Objects.Sockets.Subscriptions +namespace HTX.Net.Objects.Sockets.Subscriptions { - internal class HuobiSubscription : Subscription + internal class HTXSubscription : Subscription { private string _topic; private Action> _handler; public override HashSet ListenerIdentifiers { get; set; } - public HuobiSubscription(ILogger logger, string topic, Action> handler, bool authenticated) : base(logger, authenticated) + public HTXSubscription(ILogger logger, string topic, Action> handler, bool authenticated) : base(logger, authenticated) { _handler = handler; _topic = topic; @@ -26,18 +21,18 @@ public HuobiSubscription(ILogger logger, string topic, Action> hand public override Query? GetSubQuery(SocketConnection connection) { - return new HuobiSubscribeQuery(_topic, Authenticated); + return new HTXSubscribeQuery(_topic, Authenticated); } public override Query? GetUnsubQuery() { - return new HuobiUnsubscribeQuery(_topic, Authenticated); + return new HTXUnsubscribeQuery(_topic, Authenticated); } - public override Type? GetMessageType(IMessageAccessor message) => typeof(HuobiDataEvent); + public override Type? GetMessageType(IMessageAccessor message) => typeof(HTXDataEvent); public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) { - var huobiEvent = (HuobiDataEvent)message.Data; + var huobiEvent = (HTXDataEvent)message.Data; _handler.Invoke(message.As(huobiEvent.Data).WithStreamId(huobiEvent.Channel)); return new CallResult(null); } diff --git a/HTX.Net/SymbolOrderBooks/HTXOrderBookFactory.cs b/HTX.Net/SymbolOrderBooks/HTXOrderBookFactory.cs new file mode 100644 index 00000000..7f1e15ff --- /dev/null +++ b/HTX.Net/SymbolOrderBooks/HTXOrderBookFactory.cs @@ -0,0 +1,45 @@ +using CryptoExchange.Net.OrderBook; +using HTX.Net.Interfaces; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Objects.Options; +using Microsoft.Extensions.DependencyInjection; + +namespace HTX.Net.SymbolOrderBooks +{ + /// + public class HTXOrderBookFactory : IHTXOrderBookFactory + { + private readonly IServiceProvider _serviceProvider; + + /// + public IOrderBookFactory Spot { get; } + /// + public IOrderBookFactory UsdtFutures { get; } + + /// + /// ctor + /// + /// Service provider for resolving logging and clients + public HTXOrderBookFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + + Spot = new OrderBookFactory((symbol, options) => CreateSpot(symbol, options), (baseAsset, quoteAsset, options) => CreateSpot(baseAsset.ToLowerInvariant() + quoteAsset.ToLowerInvariant(), options)); + UsdtFutures = new OrderBookFactory((symbol, options) => CreateUsdtFutures(symbol, options), (baseAsset, quoteAsset, options) => CreateUsdtFutures(baseAsset.ToLowerInvariant() + "-" + quoteAsset.ToLowerInvariant(), options)); + } + + /// + public ISymbolOrderBook CreateSpot(string symbol, Action? options = null) + => new HTXSpotSymbolOrderBook(symbol, + options, + _serviceProvider.GetRequiredService(), + _serviceProvider.GetRequiredService()); + + /// + public ISymbolOrderBook CreateUsdtFutures(string symbol, Action? options = null) + => new HTXUsdtFuturesSymbolOrderBook(symbol, + options, + _serviceProvider.GetRequiredService(), + _serviceProvider.GetRequiredService()); + } +} diff --git a/Huobi.Net/SymbolOrderBooks/HuobiSpotSymbolOrderBook.cs b/HTX.Net/SymbolOrderBooks/HTXSpotSymbolOrderBook.cs similarity index 84% rename from Huobi.Net/SymbolOrderBooks/HuobiSpotSymbolOrderBook.cs rename to HTX.Net/SymbolOrderBooks/HTXSpotSymbolOrderBook.cs index 3f601a1e..a19edd5a 100644 --- a/Huobi.Net/SymbolOrderBooks/HuobiSpotSymbolOrderBook.cs +++ b/HTX.Net/SymbolOrderBooks/HTXSpotSymbolOrderBook.cs @@ -1,23 +1,18 @@ -using System.Threading.Tasks; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.OrderBook; -using System; -using Huobi.Net.Objects.Models; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Clients; -using System.Threading; -using Microsoft.Extensions.Logging; -using Huobi.Net.Objects.Options; +using CryptoExchange.Net.OrderBook; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Clients; +using HTX.Net.Objects.Options; using CryptoExchange.Net.Objects.Sockets; -namespace Huobi.Net.SymbolOrderBooks +namespace HTX.Net.SymbolOrderBooks { /// - /// Huobi order book implementation + /// HTX order book implementation /// - public class HuobiSpotSymbolOrderBook : SymbolOrderBook + public class HTXSpotSymbolOrderBook : SymbolOrderBook { - private readonly IHuobiSocketClient _socketClient; + private readonly IHTXSocketClient _socketClient; private readonly int? _mergeStep; private readonly int? _levels; private readonly bool _socketOwner; @@ -28,7 +23,7 @@ public class HuobiSpotSymbolOrderBook : SymbolOrderBook /// /// The symbol the order book is for /// Option configuration delegate - public HuobiSpotSymbolOrderBook(string symbol, Action? optionsDelegate = null) + public HTXSpotSymbolOrderBook(string symbol, Action? optionsDelegate = null) : this(symbol, optionsDelegate, null, null) { } @@ -40,12 +35,12 @@ public HuobiSpotSymbolOrderBook(string symbol, Action? op /// Option configuration delegate /// Logger /// Socket client instance - public HuobiSpotSymbolOrderBook(string symbol, - Action? optionsDelegate, + public HTXSpotSymbolOrderBook(string symbol, + Action? optionsDelegate, ILoggerFactory? logger, - IHuobiSocketClient? socketClient) : base(logger, "Huobi", "Spot", symbol) + IHTXSocketClient? socketClient) : base(logger, "HTX", "Spot", symbol) { - var options = HuobiOrderBookOptions.Default.Copy(); + var options = HTXOrderBookOptions.Default.Copy(); if (optionsDelegate != null) optionsDelegate(options); Initialize(options); @@ -65,7 +60,7 @@ public HuobiSpotSymbolOrderBook(string symbol, _levels = 150; } - _socketClient = socketClient ?? new HuobiSocketClient(); + _socketClient = socketClient ?? new HTXSocketClient(); _socketOwner = socketClient == null; } @@ -119,7 +114,7 @@ protected override async Task> DoStartAsync(Cance } } - private void HandleIncremental(DataEvent book) + private void HandleIncremental(DataEvent book) { if(book.Data.PreviousSequenceNumber != null) UpdateOrderBook(book.Data.PreviousSequenceNumber.Value, book.Data.SequenceNumber, book.Data.Bids, book.Data.Asks); @@ -127,7 +122,7 @@ private void HandleIncremental(DataEvent book) UpdateOrderBook(book.Data.SequenceNumber, book.Data.Bids, book.Data.Asks); } - private void HandleUpdate(DataEvent data) + private void HandleUpdate(DataEvent data) { SetInitialOrderBook(data.Data.Timestamp.Ticks, data.Data.Bids, data.Data.Asks); } diff --git a/HTX.Net/SymbolOrderBooks/HTXUsdtFuturesSymbolOrderBook.cs b/HTX.Net/SymbolOrderBooks/HTXUsdtFuturesSymbolOrderBook.cs new file mode 100644 index 00000000..978fa299 --- /dev/null +++ b/HTX.Net/SymbolOrderBooks/HTXUsdtFuturesSymbolOrderBook.cs @@ -0,0 +1,133 @@ +using CryptoExchange.Net.OrderBook; +using HTX.Net.Objects.Models; +using HTX.Net.Interfaces.Clients; +using HTX.Net.Clients; +using HTX.Net.Objects.Options; +using CryptoExchange.Net.Objects.Sockets; +using HTX.Net.Objects.Models.Socket; + +namespace HTX.Net.SymbolOrderBooks +{ + /// + /// HTX order book implementation + /// + public class HTXUsdtFuturesSymbolOrderBook : SymbolOrderBook + { + private readonly IHTXSocketClient _socketClient; + private readonly int? _mergeStep; + private readonly int? _levels; + private readonly bool _socketOwner; + private readonly TimeSpan _initialDataTimeout; + + /// + /// Create a new order book instance + /// + /// The symbol the order book is for + /// Option configuration delegate + public HTXUsdtFuturesSymbolOrderBook(string symbol, Action? optionsDelegate = null) + : this(symbol, optionsDelegate, null, null) + { + } + + /// + /// Create a new order book instance + /// + /// The symbol the order book is for + /// Option configuration delegate + /// Logger + /// Socket client instance + public HTXUsdtFuturesSymbolOrderBook(string symbol, + Action? optionsDelegate, + ILoggerFactory? logger, + IHTXSocketClient? socketClient) : base(logger, "HTX", "Usdt Futures", symbol) + { + var options = HTXOrderBookOptions.Default.Copy(); + if (optionsDelegate != null) + optionsDelegate(options); + Initialize(options); + + _mergeStep = options?.MergeStep; + _levels = options?.Levels; + _strictLevels = false; + _sequencesAreConsecutive = _levels != null; + _initialDataTimeout = options?.InitialDataTimeout ?? TimeSpan.FromSeconds(30); + + if (_levels == null && _mergeStep == null) + { + _levels = 20; + } + + _socketClient = socketClient ?? new HTXSocketClient(); + _socketOwner = socketClient == null; + } + + /// + protected override async Task> DoStartAsync(CancellationToken ct) + { + if (_mergeStep != null) + { + var subResult = await _socketClient.UsdtFuturesApi.SubscribeToOrderBookUpdatesAsync(Symbol, _mergeStep.Value, HandleUpdate).ConfigureAwait(false); + if (!subResult) + return subResult; + + if (!await WaitForSetOrderBookAsync(_initialDataTimeout, ct).ConfigureAwait(false)) + return new CallResult(new ServerError("No data received")); + + return subResult; + } + else + { + var subResult = await _socketClient.UsdtFuturesApi.SubscribeToIncrementalOrderBookUpdatesAsync(Symbol, false, _levels!.Value, HandleIncremental).ConfigureAwait(false); + if (!subResult) + return subResult; + + if (!await WaitForSetOrderBookAsync(_initialDataTimeout, ct).ConfigureAwait(false)) + return new CallResult(new ServerError("No data received")); + + return subResult; + } + } + + private void HandleIncremental(DataEvent book) + { + if (book.UpdateType == SocketUpdateType.Snapshot) + SetInitialOrderBook(book.Data.Version!.Value, book.Data.Bids, book.Data.Asks); + else + UpdateOrderBook(book.Data.Version!.Value, book.Data.Bids, book.Data.Asks); + } + + private void HandleUpdate(DataEvent data) + { + SetInitialOrderBook(data.Data.Version!.Value, data.Data.Bids, data.Data.Asks); + } + + /// + protected override async Task> DoResyncAsync(CancellationToken ct) + { + if (_mergeStep != null) + { + return await WaitForSetOrderBookAsync(_initialDataTimeout, ct).ConfigureAwait(false); + } + else + { + // Wait a little so that the sequence number of the order book snapshot is higher than the first socket update sequence number + await Task.Delay(5000).ConfigureAwait(false); + var book = await _socketClient.SpotApi.GetOrderBookAsync(Symbol, _levels!.Value).ConfigureAwait(false); + if (!book) + return new CallResult(book.Error!); + + SetInitialOrderBook(book.Data.SequenceNumber, book.Data.Bids!, book.Data.Asks!); + return new CallResult(true); + } + } + + /// + protected override void Dispose(bool disposing) + { + if(_socketOwner) + _socketClient?.Dispose(); + + base.Dispose(disposing); + } + } +} diff --git a/Huobi.Net/Usings.cs b/HTX.Net/Usings.cs similarity index 63% rename from Huobi.Net/Usings.cs rename to HTX.Net/Usings.cs index d7109a0c..5c307b8a 100644 --- a/Huobi.Net/Usings.cs +++ b/HTX.Net/Usings.cs @@ -1,17 +1,14 @@ global using CryptoExchange.Net; global using CryptoExchange.Net.Authentication; -global using CryptoExchange.Net.Converters.JsonNet; +global using CryptoExchange.Net.Converters.SystemTextJson; global using CryptoExchange.Net.Interfaces; global using CryptoExchange.Net.Objects; global using Microsoft.Extensions.Logging; -global using Newtonsoft.Json; -global using Newtonsoft.Json.Linq; -global using Newtonsoft.Json.Serialization; global using System; global using System.Collections.Generic; global using System.Globalization; global using System.Linq; global using System.Net.Http; -global using System.Security; global using System.Threading; -global using System.Threading.Tasks; \ No newline at end of file +global using System.Threading.Tasks; +global using System.Text.Json.Serialization; \ No newline at end of file diff --git a/Huobi.Net.UnitTests/HuobiSocketClientTests.cs b/Huobi.Net.UnitTests/HuobiSocketClientTests.cs deleted file mode 100644 index 2067be84..00000000 --- a/Huobi.Net.UnitTests/HuobiSocketClientTests.cs +++ /dev/null @@ -1,373 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using CryptoExchange.Net; -using Huobi.Net.Enums; -using Huobi.Net.Objects; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.UnitTests.TestImplementations; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NUnit.Framework; -using NUnit.Framework.Legacy; - -namespace Huobi.Net.UnitTests -{ - [TestFixture] - public class HuobiSocketClientTests - { - [Test] - public void SubscribeV1_Should_SucceedIfSubbedResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - // act - var subTask = client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"test\", \"id\":\"{id}\", \"status\": \"ok\"}}"); - var subResult = subTask.Result; - - // assert - Assert.That(subResult.Success); - } - - [Test] - public async Task SubscribeV1_Should_FailIfNoResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket, x => - { - x.RequestTimeout = TimeSpan.FromMilliseconds(10); - }); - - // act - var subResult = await client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); - - // assert - ClassicAssert.IsFalse(subResult.Success); - } - - [Test] - public void SubscribeV1_Should_FailIfErrorResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - // act - var subTask = client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => { }); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"status\": \"error\", \"id\": \"{id}\", \"err-code\": \"Fail\", \"err-msg\": \"failed\"}}"); - var subResult = subTask.Result; - - // assert - ClassicAssert.IsFalse(subResult.Success); - } - - [Test] - public void SubscribeToDepthUpdates_Should_TriggerWithDepthUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - HuobiOrderBook result = null; - var subTask = client.SpotApi.SubscribeToPartialOrderBookUpdates1SecondAsync("ETHBTC", 1, test => result = test.Data); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"ethbtc\", \"status\": \"ok\", \"id\": \"{id}\"}}"); - var subResult = subTask.Result; - - var expected = new HuobiOrderBook() - { - Asks = new List() - { - new HuobiOrderBookEntry() {Quantity = 0.1m, Price = 0.2m} - }, - Bids = new List() - { - new HuobiOrderBookEntry() {Quantity = 0.3m, Price = 0.4m} - } - }; - - // act - socket.InvokeMessage(SerializeExpected("market.ethbtc.depth.step1", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected.Asks.ToList()[0], result.Asks.ToList()[0])); - Assert.That(TestHelpers.AreEqual(expected.Bids.ToList()[0], result.Bids.ToList()[0])); - } - - [Test] - public void SubscribeToDetailUpdates_Should_TriggerWithDetailUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - HuobiSymbolDetails result = null; - var subTask = client.SpotApi.SubscribeToSymbolDetailUpdatesAsync("ETHBTC", test => result = test.Data); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"ethbtc\", \"id\": \"{id}\", \"status\": \"ok\"}}"); - var subResult = subTask.Result; - - var expected = new HuobiSymbolData() - { - QuoteVolume = 0.1m, - ClosePrice = 0.2m, - LowPrice = 0.3m, - HighPrice = 0.4m, - Volume = 0.5m, - OpenPrice = 0.6m, - TradeCount = 12 - }; - - // act - socket.InvokeMessage(SerializeExpected("market.ethbtc.detail", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected, result)); - } - - [Test] - public void SubscribeToKlineUpdates_Should_TriggerWithKlineUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - HuobiSymbolData result = null; - var subTask = client.SpotApi.SubscribeToKlineUpdatesAsync("ETHBTC", KlineInterval.FiveMinutes, test => result = test.Data); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"ethbtc\", \"id\": \"{id}\", \"status\": \"ok\"}}"); - var subResult = subTask.Result; - - var expected = new HuobiSymbolData() - { - QuoteVolume = 0.1m, - ClosePrice = 0.2m, - LowPrice = 0.3m, - HighPrice = 0.4m, - Volume = 0.5m, - OpenPrice = 0.6m, - TradeCount = 12 - }; - - // act - socket.InvokeMessage(SerializeExpected("market.ethbtc.kline.5min", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected, result)); - } - - [Test] - public void SubscribeToTickerUpdates_Should_TriggerWithTickerUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - IEnumerable result = null; - var subTask = client.SpotApi.SubscribeToTickerUpdatesAsync((test => result = test.Data)); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"test\", \"id\": \"{id}\", \"status\": \"ok\"}}"); - var subResult = subTask.Result; - - var expected = new List - { - new HuobiSymbolTicker() - { - QuoteVolume = 0.1m, - ClosePrice = 0.2m, - LowPrice = 0.3m, - HighPrice = 0.4m, - Volume = 0.5m, - OpenPrice = 0.6m, - TradeCount = 12 - } - }; - - // act - socket.InvokeMessage(SerializeExpected("market.tickers", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected[0], result.First())); - } - - [Test] - public void SubscribeToTradeUpdates_Should_TriggerWithTradeUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - HuobiSymbolTrade result = null; - var subTask = client.SpotApi.SubscribeToTradeUpdatesAsync("ethusdt", test => result = test.Data); - var id = JToken.Parse(socket.LastSendMessage)["id"]; - socket.InvokeMessage($"{{\"subbed\": \"test\", \"id\": \"{id}\", \"status\": \"ok\"}}"); - var subResult = subTask.Result; - - var expected = - new HuobiSymbolTrade() - { - Id = 123, - Timestamp = new DateTime(2018, 1, 1), - Details = new List() - { - new HuobiSymbolTradeDetails() - { - Id = "123", - Quantity = 0.1m, - Price = 0.2m, - Timestamp = new DateTime(2018,2,1), - Side = OrderSide.Buy - } - } - }; - - // act - socket.InvokeMessage(SerializeExpected("market.ethusdt.trade.detail", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected, result, "Details")); - Assert.That(TestHelpers.AreEqual(expected.Details.ToList()[0], result.Details.ToList()[0])); - } - - [Test] - public void SubscribeToAccountUpdates_Should_TriggerWithAccountUpdate() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateAuthenticatedSocketClient(socket); - - HuobiAccountUpdate result = null; - var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => result = test.Data); - socket.InvokeMessage("{\"ch\": \"auth\", \"code\": 200, \"action\": \"req\"}"); - Thread.Sleep(100); - socket.InvokeMessage($"{{\"action\": \"sub\", \"code\": 200, \"ch\": \"accounts.update#1\"}}"); - var subResult = subTask.Result; - - var expected = new HuobiAccountUpdate() - { - AccountId = 123, - AccountType = BalanceType.Frozen, - Available = 456, - Balance = 789, - ChangeTime = new DateTime(2020, 11, 25), - ChangeType = AccountEventType.Deposit, - Asset = "usdt" - }; - - // act - socket.InvokeMessage(SerializeExpectedAuth("accounts.update#1", expected)); - - // assert - Assert.That(subResult.Success); - Assert.That(TestHelpers.AreEqual(expected, result)); - } - - [Test] - public void SubscribeV2_Should_SucceedIfSubbedResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateAuthenticatedSocketClient(socket); - - // act - var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); - socket.InvokeMessage("{\"action\": \"req\", \"code\": 200, \"ch\": \"auth\"}"); - Thread.Sleep(10); - socket.InvokeMessage("{\"action\": \"sub\", \"code\": 200, \"ch\": \"accounts.update#1\"}"); - var subResult = subTask.Result; - - // assert - Assert.That(subResult.Success); - } - - [Test] - public void SubscribeV2_Should_FailIfAuthErrorResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket); - - // act - var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); - socket.InvokeMessage("{ \"action\": \"req\", \"ch\": \"auth\", \"code\": 400}"); - var subResult = subTask.Result; - - // assert - ClassicAssert.IsFalse(subResult.Success); - } - - //[Test] - //public async Task SubscribeV2_Should_FailIfErrorResponse() - //{ - // // arrange - // var socket = new TestSocket(); - // socket.CanConnect = true; - // var client = TestHelpers.CreateSocketClient(socket); - - // // act - // var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); - // socket.InvokeMessage("{\"op\": \"auth\"}"); - // Thread.Sleep(10); - // var id = JToken.Parse(socket.LastSendMessage)["id"]; - // socket.InvokeMessage($"{{\"op\": \"sub\", \"cid\": \"{id}\", \"status\": \"error\", \"err-code\": 1, \"err-msg\": \"failed\"}}"); - // var subResult = subTask.Result; - - // // assert - // ClassicAssert.IsFalse(subResult.Success); - //} - - [Test] - public void SubscribeV2_Should_FailIfNoResponse() - { - // arrange - var socket = new TestSocket(); - socket.CanConnect = true; - var client = TestHelpers.CreateSocketClient(socket, x => - { - x.RequestTimeout = TimeSpan.FromMilliseconds(10); - }); - - // act - var subTask = client.SpotApi.SubscribeToAccountUpdatesAsync(test => { }); - var subResult = subTask.Result; - - // assert - ClassicAssert.IsFalse(subResult.Success); - } - - public string SerializeExpected(string channel, T data) - { - return $"{{\"ch\": \"{channel}\", \"data\": {JsonConvert.SerializeObject(data)}}}"; - } - - public string SerializeExpectedAuth(string channel, T data) - { - return $"{{\"action\": \"push\", \"ch\": \"{channel}\", \"code\": 200, \"data\": {JsonConvert.SerializeObject(data)}}}"; - } - } -} diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountHistoryAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountHistoryAsync.txt deleted file mode 100644 index c6852525..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountHistoryAsync.txt +++ /dev/null @@ -1,26 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "account-id": 10000001, - "currency": "usdt", - "record-id": 359044707902783794, - "transact-amt": "-10.000000000000000000", - "transact-type": "other-types", - "avail-balance": "81.850043797676510303", - "acct-balance": "97.010043797676510318", - "transact-time": 1629882096557 - }, - { - "account-id": 10000001, - "currency": "usdt", - "record-id": 359044690723242123, - "transact-amt": "-10.000000000000000000", - "transact-type": "transfer", - "avail-balance": "81.850043797676510303", - "acct-balance": "87.010043797676510318", - "transact-time": 1629882096569 - } - ], - "next-id": 47996522235 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountLedgerAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountLedgerAsync.txt deleted file mode 100644 index 76f50a8b..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountLedgerAsync.txt +++ /dev/null @@ -1,30 +0,0 @@ -{ - "code": 200, - "message": "success", - "data": [ - { - "accountId": 10000001, - "currency": "usdt", - "transactAmt": 10.000000000000000000, - "transactType": "transfer", - "transferType": "margin-transfer-out", - "transactId": 0, - "transactTime": 1629882331066, - "transferer": 28483123, - "transferee": 13496526 - }, - { - "accountId": 10000001, - "currency": "usdt", - "transactAmt": -10.000000000000000000, - "transactType": "transfer", - "transferType": "margin-transfer-in", - "transactId": 0, - "transactTime": 1629882096562, - "transferer": 13496526, - "transferee": 28483123 - } - ], - "nextId": 1624316679, - "ok": true -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountsAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountsAsync.txt deleted file mode 100644 index c9897a85..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAccountsAsync.txt +++ /dev/null @@ -1,23 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "id": 10000001, - "type": "spot", - "subtype": "", - "state": "working" - }, - { - "id": 10000002, - "type": "otc", - "subtype": "", - "state": "working" - }, - { - "id": 10000003, - "type": "point", - "subtype": "", - "state": "working" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAssetValuationAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAssetValuationAsync.txt deleted file mode 100644 index 2dafb698..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetAssetValuationAsync.txt +++ /dev/null @@ -1,8 +0,0 @@ -{ - "code": 200, - "data": { - "balance": "34.75", - "timestamp": 1594901254363 - }, - "ok": true -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetBalancesAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetBalancesAsync.txt deleted file mode 100644 index 1487ee72..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetBalancesAsync.txt +++ /dev/null @@ -1,28 +0,0 @@ -{ - "status": "ok", - "data": { - "id": 1000001, - "type": "spot", - "state": "working", - "list": [ - { - "currency": "usdt", - "type": "trade", - "balance": "91.850043797676510303", - "seq-num": "477" - }, - { - "currency": "usdt", - "type": "frozen", - "balance": "5.160000000000000015", - "seq-num": "477" - }, - { - "currency": "poly", - "type": "trade", - "balance": "147.928994082840236", - "seq-num": "2" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossLoanInterestRateAndQuotaAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossLoanInterestRateAndQuotaAsync.txt deleted file mode 100644 index ee44b696..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossLoanInterestRateAndQuotaAsync.txt +++ /dev/null @@ -1,62 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "currency": "bch", - "interest-rate": "0.00098", - "min-loan-amt": "0.35", - "max-loan-amt": "3500", - "loanable-amt": "0.70405181", - "actual-rate": "0.000343" - }, - { - "currency": "btc", - "interest-rate": "0.00098", - "min-loan-amt": "0.01", - "max-loan-amt": "100", - "loanable-amt": "0.02281914", - "actual-rate": "0.000343" - }, - { - "currency": "eos", - "interest-rate": "0.00098", - "min-loan-amt": "30", - "max-loan-amt": "300000", - "loanable-amt": "57.69175296", - "actual-rate": "0.000343" - }, - { - "currency": "eth", - "interest-rate": "0.00098", - "min-loan-amt": "0.5", - "max-loan-amt": "6000", - "loanable-amt": "1.06712197", - "actual-rate": "0.000343" - }, - { - "currency": "ltc", - "interest-rate": "0.00098", - "min-loan-amt": "1.5", - "max-loan-amt": "15000", - "loanable-amt": "3.28947368", - "actual-rate": "0.000343" - }, - { - "currency": "usdt", - "interest-rate": "0.00098", - "min-loan-amt": "100", - "max-loan-amt": "1500000", - "loanable-amt": "200.00000000", - "actual-rate": "0.000343" - }, - { - "currency": "xrp", - "interest-rate": "0.00098", - "min-loan-amt": "380", - "max-loan-amt": "4000000", - "loanable-amt": "734.21439060", - "actual-rate": "0.000343" - } - ], - "code": 200 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginBalanceAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginBalanceAsync.txt deleted file mode 100644 index 5fe2137e..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginBalanceAsync.txt +++ /dev/null @@ -1,43 +0,0 @@ -{ - "status":"ok", - "data":{ - "id":18264, - "type":"cross-margin", - "state":"working", - "risk-rate":"1000", - "acct-balance-sum":"12312.123123", - "debt-balance-sum":"1231.2123123", - "list":[ - { - "currency":"btc", - "type":"trade", - "balance":"1168.533000000000000000" - }, - { - "currency":"btc", - "type":"frozen", - "balance":"0.000000000000000000" - }, - { - "currency":"btc", - "type":"loan", - "balance":"-2.433000000000000000" - }, - { - "currency":"btc", - "type":"interest", - "balance":"-0.000533000000000000" - }, - { - "currency":"btc", - "type":"transfer-out-available", - "balance":"1163.872174670000000000" - }, - { - "currency":"btc", - "type":"loan-available", - "balance":"8161.876538350676000000" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginClosedOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginClosedOrdersAsync.txt deleted file mode 100644 index 94dde77a..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetCrossMarginClosedOrdersAsync.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "status":"ok", - "data":[ - { - "loan-balance":"0.100000000000000000", - "interest-balance":"0.000200000000000000", - "loan-amount":"0.100000000000000000", - "accrued-at":1511169724531, - "interest-amount":"0.000200000000000000", - "filled-points":"0.2", - "filled-ht":"0.2", - "currency":"btc", - "id":394, - "state":"accrual", - "account-id":17747, - "user-id":119913, - "created-at":1511169724531 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetDepositAddressesAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetDepositAddressesAsync.txt deleted file mode 100644 index 1645b515..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetDepositAddressesAsync.txt +++ /dev/null @@ -1,26 +0,0 @@ -{ - "code": 200, - "data": [ - { - "userId": 12345678, - "currency": "btc", - "address": "0xd476b0d77583fbda5180039f1f513b750cb4f527", - "addressTag": "", - "chain": "hbtc" - }, - { - "userId": 12345678, - "currency": "btc", - "address": "16egzDeZiVDJ4D44UbWKN6snLYFjS1aEmJ", - "addressTag": "", - "chain": "btc" - }, - { - "userId": 12345678, - "currency": "btc", - "address": "0xd476b0d77583fbda5180039f1f513b750cb4f527", - "addressTag": "", - "chain": "hrc20btc" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedLoanInterestRateAndQuotaAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedLoanInterestRateAndQuotaAsync.txt deleted file mode 100644 index bede781c..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedLoanInterestRateAndQuotaAsync.txt +++ /dev/null @@ -1,26 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "symbol": "btcusdt", - "currencies": [ - { - "currency": "btc", - "interest-rate": "0.00098", - "min-loan-amt": "0.020000000000000000", - "max-loan-amt": "550.000000000000000000", - "loanable-amt": "0.045696000000000000", - "actual-rate": "0.00098" - }, - { - "currency": "usdt", - "interest-rate": "0.00098", - "min-loan-amt": "100.000000000000000000", - "max-loan-amt": "4000000.000000000000000000", - "loanable-amt": "400.000000000000000000", - "actual-rate": "0.00098" - } - ] - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginBalanceAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginBalanceAsync.txt deleted file mode 100644 index 125a64d9..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginBalanceAsync.txt +++ /dev/null @@ -1,45 +0,0 @@ -{ - "data": [ - { - "id": 18264, - "type": "margin", - "state": "working", - "symbol": "btcusdt", - "fl-price": "0", - "fl-type": "safe", - "risk-rate": "475.952571086994250554", - "list": [ - { - "currency": "btc", - "type": "trade", - "balance": "1168.533000000000000000" - }, - { - "currency": "btc", - "type": "frozen", - "balance": "0.000000000000000000" - }, - { - "currency": "btc", - "type": "loan", - "balance": "-2.433000000000000000" - }, - { - "currency": "btc", - "type": "interest", - "balance": "-0.000533000000000000" - }, - { - "currency": "btc", - "type": "transfer-out-available", - "balance": "1163.872174670000000000" - }, - { - "currency": "btc", - "type": "loan-available", - "balance": "8161.876538350676000000" - } - ] - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginClosedOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginClosedOrdersAsync.txt deleted file mode 100644 index 52af5251..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetIsolatedMarginClosedOrdersAsync.txt +++ /dev/null @@ -1,28 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "deduct-rate": "1", - "created-at": 1595831651478, - "updated-at": 1595832010845, - "accrued-at": 1595831651478, - "interest-amount": "0.004083000000000000", - "loan-amount": "100.000000000000000000", - "hour-interest-rate": "0.000040830000000000", - "loan-balance": "0.000000000000000000", - "interest-balance": "0.000000000000000000", - "paid-coin": "0.004083000000000000", - "day-interest-rate": "0.000980000000000000", - "interest-rate": "0.000040830000000000", - "user-id": 5574974, - "account-id": 5463409, - "currency": "usdt", - "symbol": "btcusdt", - "paid-point": "0.000000000000000000", - "deduct-currency": "", - "deduct-amount": "0", - "id": 7839857, - "state": "cleared" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetRepaymentHistoryAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetRepaymentHistoryAsync.txt deleted file mode 100644 index f2dd367c..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetRepaymentHistoryAsync.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "code":200, - "data":[ - { - "repayId": 1174413, - "repayTime":1600747389111, - "accountId": 1266826, - "currency":"btc", - "repaidAmount": "0.00200083", - "transactIds": - { - "transactId":502, - "repaidprincipal": "0.00199666", - "repaidInterest": "0.00000417", - "paidHt": "0", - "paidPoint": "0" - } - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetWithdrawDepositAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetWithdrawDepositAsync.txt deleted file mode 100644 index 5023042f..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/GetWithdrawDepositAsync.txt +++ /dev/null @@ -1,37 +0,0 @@ -{ - "status":"ok", - "data":[ - { - "id":45182894, - "type":"withdraw", - "sub-type":"FAST", - "currency":"usdt", - "chain":"trc20usdt", - "tx-hash":"", - "amount":400, - "from-addr-tag":"", - "address":"TRwkUYHWgUh23jbKpgTcYHgE9CcBzhGno9", - "address-tag":"", - "fee":0, - "state":"confirmed", - "created-at":1612261330443, - "updated-at":1612261389250 - }, - { - "id":61003926, - "type":"withdraw", - "sub-type":"FAST", - "currency":"usdt", - "chain":"trc20usdt", - "tx-hash":"", - "amount":2, - "from-addr-tag":"", - "address":"TYGvZSD1duPctGaMPSP12Fy8BrQMu2KCdp", - "address-tag":"", - "fee":0, - "state":"confirmed", - "created-at":1621416907639, - "updated-at":1621416907788 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayIsolatedMarginLoanAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayIsolatedMarginLoanAsync.txt deleted file mode 100644 index bb923ce3..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayIsolatedMarginLoanAsync.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": 1000 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayMarginLoanAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayMarginLoanAsync.txt deleted file mode 100644 index fb6ccaa1..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RepayMarginLoanAsync.txt +++ /dev/null @@ -1,9 +0,0 @@ -{ - "code":200, - "data": [ - { - "repayId":1174424, - "repayTime":1600747722018 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RequestCrossMarginLoanAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RequestCrossMarginLoanAsync.txt deleted file mode 100644 index 1c91efc1..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/RequestCrossMarginLoanAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": 1000 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferAssetAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferAssetAsync.txt deleted file mode 100644 index d745debe..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferAssetAsync.txt +++ /dev/null @@ -1,7 +0,0 @@ -{ - "status": "ok", - "data": { - "transact-id": 220521190, - "transact-time": 1590662591832 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferCrossMarginToSpotAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferCrossMarginToSpotAsync.txt deleted file mode 100644 index 1c91efc1..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferCrossMarginToSpotAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": 1000 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferIsolatedMarginToSpotAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferIsolatedMarginToSpotAsync.txt deleted file mode 100644 index dcfb3583..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferIsolatedMarginToSpotAsync.txt +++ /dev/null @@ -1,5 +0,0 @@ -{ - "status": "ok", - "data": 46971504, - "code": 200 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToCrossMarginAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToCrossMarginAsync.txt deleted file mode 100644 index 1c91efc1..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToCrossMarginAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": 1000 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToIsolatedMarginAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToIsolatedMarginAsync.txt deleted file mode 100644 index dcfb3583..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/TransferSpotToIsolatedMarginAsync.txt +++ /dev/null @@ -1,5 +0,0 @@ -{ - "status": "ok", - "data": 46971504, - "code": 200 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/WithdrawAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/WithdrawAsync.txt deleted file mode 100644 index bb923ce3..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Account/WithdrawAsync.txt +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": 1000 -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetDetailsAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetDetailsAsync.txt deleted file mode 100644 index 2beb7549..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetDetailsAsync.txt +++ /dev/null @@ -1,72 +0,0 @@ -{ - "code":200, - "data":[ - { - "chains":[ - { - "chain":"trc20usdt", - "displayName":"", - "baseChain": "TRX", - "baseChainProtocol": "TRC20", - "isDynamic": false, - "depositStatus":"allowed", - "maxTransactFeeWithdraw":"1.00000000", - "maxWithdrawAmt":"280000.00000000", - "minDepositAmt":"100", - "minTransactFeeWithdraw":"0.10000000", - "minWithdrawAmt":"0.01", - "numOfConfirmations":999, - "numOfFastConfirmations":999, - "withdrawFeeType":"circulated", - "withdrawPrecision":5, - "withdrawQuotaPerDay":"280000.00000000", - "withdrawQuotaPerYear":"2800000.00000000", - "withdrawQuotaTotal":"2800000.00000000", - "withdrawStatus":"allowed" - }, - { - "chain":"usdt", - "displayName":"", - "baseChain": "BTC", - "baseChainProtocol": "OMNI", - "isDynamic": false, - "depositStatus":"allowed", - "maxWithdrawAmt":"19000.00000000", - "minDepositAmt":"0.0001", - "minWithdrawAmt":"2", - "numOfConfirmations":30, - "numOfFastConfirmations":15, - "transactFeeRateWithdraw":"0.00100000", - "withdrawFeeType":"ratio", - "withdrawPrecision":7, - "withdrawQuotaPerDay":"90000.00000000", - "withdrawQuotaPerYear":"111000.00000000", - "withdrawQuotaTotal":"1110000.00000000", - "withdrawStatus":"allowed" - }, - { - "chain":"usdterc20", - "displayName":"", - "baseChain": "ETH", - "baseChainProtocol": "ERC20", - "isDynamic": false, - "depositStatus":"allowed", - "maxWithdrawAmt":"18000.00000000", - "minDepositAmt":"100", - "minWithdrawAmt":"1", - "numOfConfirmations":999, - "numOfFastConfirmations":999, - "transactFeeWithdraw":"0.10000000", - "withdrawFeeType":"fixed", - "withdrawPrecision":6, - "withdrawQuotaPerDay":"180000.00000000", - "withdrawQuotaPerYear":"200000.00000000", - "withdrawQuotaTotal":"300000.00000000", - "withdrawStatus":"allowed" - } - ], - "currency":"usdt", - "instStatus":"normal" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetsAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetsAsync.txt deleted file mode 100644 index f109fbcd..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetAssetsAsync.txt +++ /dev/null @@ -1,13 +0,0 @@ -{ - "status": "ok", - "data": [ - "usdt", - "btc", - "bch", - "eth", - "xrp", - "ltc", - "ht", - "ada" - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetKlinesAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetKlinesAsync.txt deleted file mode 100644 index 19abc479..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetKlinesAsync.txt +++ /dev/null @@ -1,27 +0,0 @@ -{ - "ch": "market.btcusdt.kline.5min", - "status": "ok", - "ts": 1629769247172, - "data": [ - { - "id": 1629769200, - "open": 49056.37, - "close": 49025.51, - "low": 49022.86, - "high": 49056.38, - "amount": 3.946281917950917, - "vol": 193489.67275732, - "count": 196 - }, - { - "id": 1629768900, - "open": 48994.61, - "close": 49056.37, - "low": 48966.72, - "high": 49072.46, - "amount": 30.72223099519689, - "vol": 1505870.732227976, - "count": 1504 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolStatusAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolStatusAsync.txt deleted file mode 100644 index 63f3cd50..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolStatusAsync.txt +++ /dev/null @@ -1,7 +0,0 @@ -{ - "code": 200, - "message": "success", - "data": { - "marketStatus": 1 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolsAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolsAsync.txt deleted file mode 100644 index 1d6496a5..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetSymbolsAsync.txt +++ /dev/null @@ -1,47 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "base-currency": "ekt", - "quote-currency": "usdt", - "price-precision": 6, - "amount-precision": 2, - "symbol-partition": "innovation", - "symbol": "ektusdt", - "state": "online", - "value-precision": 8, - "min-order-amt": 0.1, - "max-order-amt": 10000000, - "min-order-value": 5, - "limit-order-min-order-amt": 0.1, - "limit-order-max-order-amt": 10000000, - "limit-order-max-buy-amt": 10000000, - "limit-order-max-sell-amt": 10000000, - "sell-market-min-order-amt": 0.1, - "sell-market-max-order-amt": 1000000, - "buy-market-max-order-value": 200000, - "api-trading": "enabled" - }, - { - "base-currency": "snx", - "quote-currency": "husd", - "price-precision": 4, - "amount-precision": 2, - "symbol-partition": "innovation", - "symbol": "snxhusd", - "state": "online", - "value-precision": 8, - "min-order-amt": 0.01, - "max-order-amt": 250000, - "min-order-value": 5, - "limit-order-min-order-amt": 0.01, - "limit-order-max-order-amt": 250000, - "limit-order-max-buy-amt": 250000, - "limit-order-max-sell-amt": 250000, - "sell-market-min-order-amt": 0.01, - "sell-market-max-order-amt": 25000, - "buy-market-max-order-value": 100000, - "api-trading": "enabled" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTickersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTickersAsync.txt deleted file mode 100644 index f39b90e2..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTickersAsync.txt +++ /dev/null @@ -1,34 +0,0 @@ -{ - "status":"ok", - "ts":1629789355531, - "data":[ - { - "symbol":"smtusdt", - "open":0.004659, - "high":0.004696, - "low":0.0046, - "close":0.00468, - "amount":36551302.17544405, - "vol":170526.0643855023, - "count":1709, - "bid":0.004651, - "bidSize":54300.341, - "ask":0.004679, - "askSize":1923.4879 - }, - { - "symbol":"ltcht", - "open":12.795626, - "high":12.918053, - "low":12.568926, - "close":12.918053, - "amount":1131.801675005825, - "vol":14506.9381937385, - "count":923, - "bid":12.912687, - "bidSize":0.1068, - "ask":12.927032, - "askSize":5.3228 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTradeHistoryAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTradeHistoryAsync.txt deleted file mode 100644 index f4922be0..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/ExchangeData/GetTradeHistoryAsync.txt +++ /dev/null @@ -1,43 +0,0 @@ -{ - "ch": "market.btcusdt.trade.detail", - "status": "ok", - "ts": 1629793657842, - "data": [ - { - "id": 136108764379, - "ts": 1629793656939, - "data": [ - { - "id": 136108764379348400430265987, - "ts": 1629793656939, - "trade-id": 102517381182, - "amount": 1.24E-4, - "price": 49656.4, - "direction": "buy" - } - ] - }, - { - "id": 136108763320, - "ts": 1629793656198, - "data": [ - { - "id": 136108763320348400439066863, - "ts": 1629793656198, - "trade-id": 102517381181, - "amount": 0.01125, - "price": 49655.0, - "direction": "buy" - }, - { - "id": 136108763320348400429773626, - "ts": 1629793656198, - "trade-id": 102517381180, - "amount": 8.3E-4, - "price": 49651.35, - "direction": "buy" - } - ] - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderAsync.txt deleted file mode 100644 index 7c9ddc89..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": "356501495694025" -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderByClientOrderIdAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderByClientOrderIdAsync.txt deleted file mode 100644 index 7c9ddc89..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrderByClientOrderIdAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": "356501495694025" -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersAsync.txt deleted file mode 100644 index 10251434..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersAsync.txt +++ /dev/null @@ -1,17 +0,0 @@ -{ - "status": "ok", - "data": { - "success": [ - "12345" - ], - "failed": [ - { - "err-msg": "Incorrect order state", - "order-state": 7, - "order-id": "357631450723117", - "err-code": "order-orderstate-error", - "client-order-id": "123456" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersByCriteriaAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersByCriteriaAsync.txt deleted file mode 100644 index e9909401..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/CancelOrdersByCriteriaAsync.txt +++ /dev/null @@ -1,8 +0,0 @@ -{ - "status":"ok", - "data":{ - "success-count":2, - "failed-count":0, - "next-id":5454600 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetHistoricalOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetHistoricalOrdersAsync.txt deleted file mode 100644 index 6fe08aab..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetHistoricalOrdersAsync.txt +++ /dev/null @@ -1,39 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "id": 357632718898331, - "symbol": "adausdt", - "account-id": 13496526, - "client-order-id": "23456", - "amount": "5.000000000000000000", - "price": "1.000000000000000000", - "created-at": 1630649406687, - "type": "buy-limit-maker", - "field-amount": "0.0", - "field-cash-amount": "0.0", - "field-fees": "0.0", - "finished-at": 0, - "source": "spot-api", - "state": "submitted", - "canceled-at": 0 - }, - { - "id": 357632718898330, - "symbol": "adausdt", - "account-id": 13496526, - "client-order-id": "2345", - "amount": "5.000000000000000000", - "price": "1.000000000000000000", - "created-at": 1630649406687, - "type": "buy-limit-maker", - "field-amount": "0.0", - "field-cash-amount": "0.0", - "field-fees": "0.0", - "finished-at": 0, - "source": "spot-api", - "state": "submitted", - "canceled-at": 0 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOpenOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOpenOrdersAsync.txt deleted file mode 100644 index eda473d6..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOpenOrdersAsync.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "symbol": "apnusdt", - "source": "web", - "price": "1.555550000000000000", - "created-at": 1630633835224, - "amount": "572.330000000000000000", - "account-id": 13496526, - "filled-cash-amount": "0.0", - "client-order-id": "", - "filled-amount": "0.0", - "filled-fees": "0.0", - "id": 357630527817871, - "state": "submitted", - "type": "sell-limit" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderAsync.txt deleted file mode 100644 index 8d626e0c..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderAsync.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "status": "ok", - "data": { - "id": 357632718898331, - "symbol": "adausdt", - "account-id": 13496526, - "client-order-id": "23456", - "amount": "5.000000000000000000", - "price": "1.000000000000000000", - "created-at": 1630649406687, - "type": "buy-limit-maker", - "field-amount": "0.0", - "field-cash-amount": "0.0", - "field-fees": "0.0", - "finished-at": 0, - "source": "spot-api", - "state": "submitted", - "canceled-at": 0 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderByClientOrderIdAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderByClientOrderIdAsync.txt deleted file mode 100644 index 8d626e0c..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderByClientOrderIdAsync.txt +++ /dev/null @@ -1,20 +0,0 @@ -{ - "status": "ok", - "data": { - "id": 357632718898331, - "symbol": "adausdt", - "account-id": 13496526, - "client-order-id": "23456", - "amount": "5.000000000000000000", - "price": "1.000000000000000000", - "created-at": 1630649406687, - "type": "buy-limit-maker", - "field-amount": "0.0", - "field-cash-amount": "0.0", - "field-fees": "0.0", - "finished-at": 0, - "source": "spot-api", - "state": "submitted", - "canceled-at": 0 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderTradesAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderTradesAsync.txt deleted file mode 100644 index 49d402c8..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrderTradesAsync.txt +++ /dev/null @@ -1,23 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "symbol": "polyusdt", - "fee-currency": "poly", - "source": "spot-web", - "order-id": 345487249132375, - "price": "0.338", - "created-at": 1629443051839, - "role": "taker", - "match-id": 5014, - "filled-amount": "147.928994082840236", - "filled-fees": "0", - "filled-points": "0.1", - "fee-deduct-currency": "hbpoint", - "fee-deduct-state": "done", - "trade-id": 1085, - "id": 313288753120940, - "type": "buy-market" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrdersAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrdersAsync.txt deleted file mode 100644 index 4d433134..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetOrdersAsync.txt +++ /dev/null @@ -1,22 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "id": 345487249132375, - "symbol": "polyusdt", - "account-id": 13496526, - "client-order-id": "", - "amount": "50.000000000000000000", - "price": "0.0", - "created-at": 1629443051822, - "type": "buy-market", - "field-amount": "147.928994082840236000", - "field-cash-amount": "49.999999999999999768", - "field-fees": "0.295857988165680472", - "finished-at": 1629443051838, - "source": "spot-web", - "state": "filled", - "canceled-at": 0 - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetUserTradesAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetUserTradesAsync.txt deleted file mode 100644 index 15e98222..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/GetUserTradesAsync.txt +++ /dev/null @@ -1,23 +0,0 @@ -{ - "status": "ok", - "data": [ - { - "symbol": "polyusdt", - "fee-currency": "poly", - "source": "spot-web", - "price": "0.338", - "created-at": 1629443051839, - "role": "taker", - "order-id": 345487249132375, - "match-id": 5014, - "trade-id": 1085, - "filled-amount": "147.928994082840236", - "filled-fees": "0", - "filled-points": "0.1", - "fee-deduct-currency": "hbpoint", - "fee-deduct-state": "done", - "id": 313288753120940, - "type": "buy-market" - } - ] -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/PlaceOrderAsync.txt b/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/PlaceOrderAsync.txt deleted file mode 100644 index 3f6bfd84..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/DataResponses/Trading/PlaceOrderAsync.txt +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": "ok", - "data": "356501383558845" -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/AccountUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/AccountUpdate.txt deleted file mode 100644 index 23584191..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/AccountUpdate.txt +++ /dev/null @@ -1,9 +0,0 @@ - { - "currency": "btc", - "accountId": 123456, - "balance": "23.111", - "changeType": "deposit", - "accountType":"trade", - "seqNum": 86872993928, - "changeTime": 1568601800000 - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/BestOfferUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/BestOfferUpdate.txt deleted file mode 100644 index fe7980f4..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/BestOfferUpdate.txt +++ /dev/null @@ -1,13 +0,0 @@ -{ - "ch":"market.btcusdt.bbo", - "ts":1630994555540, - "tick":{ - "seqId":137005210233, - "ask":52665.02, - "askSize":1.502181, - "bid":52665.01, - "bidSize":0.178567, - "quoteTime":1630994555539, - "symbol":"btcusdt" - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/KlineUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/KlineUpdate.txt deleted file mode 100644 index 7d87ad08..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/KlineUpdate.txt +++ /dev/null @@ -1,14 +0,0 @@ -{ - "ch":"market.ethbtc.kline.1min", - "ts":1630981694370, - "tick":{ - "id":1630981680, - "open":0.074849, - "close":0.074848, - "low":0.074848, - "high":0.074849, - "amount":2.4448, - "vol":0.1829884187, - "count":3 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderDetailsUpdate1.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderDetailsUpdate1.txt deleted file mode 100644 index 066cdf61..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderDetailsUpdate1.txt +++ /dev/null @@ -1,22 +0,0 @@ -{ - "eventType": "trade", - "symbol": "btcusdt", - "orderId": 99998888, - "tradePrice": "9999.99", - "tradeVolume": "0.96", - "orderSide": "buy", - "aggressor": true, - "tradeId": 919219323232, - "tradeTime": 998787897878, - "transactFee": "19.88", - "feeDeduct": "0", - "feeDeductType": "", - "feeCurrency": "btc", - "accountId": 9912791, - "source": "spot-api", - "orderPrice": "10000", - "orderSize": "1", - "clientOrderId": "a001", - "orderCreateTime": 998787897878, - "orderStatus": "partial-filled" - } \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate1.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate1.txt deleted file mode 100644 index 23f7d7e2..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate1.txt +++ /dev/null @@ -1,11 +0,0 @@ - - { - "orderSide":"buy", - "lastActTime":1583853365586, - "clientOrderId":"abc123", - "orderStatus":"rejected", - "symbol":"btcusdt", - "eventType":"trigger", - "errCode": 2002, - "errMessage":"invalid.client.order.id (NT)" - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate2.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate2.txt deleted file mode 100644 index 37ca3182..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate2.txt +++ /dev/null @@ -1,9 +0,0 @@ - - { - "orderSide":"buy", - "lastActTime":1583853365586, - "clientOrderId":"abc123", - "orderStatus":"canceled", - "symbol":"btcusdt", - "eventType":"deletion" - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate3.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate3.txt deleted file mode 100644 index 6cf097b4..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate3.txt +++ /dev/null @@ -1,15 +0,0 @@ - - { - "orderSize":"2.000000000000000000", - "orderCreateTime":1583853365586, - "accountId":992701, - "orderPrice":"77.000000000000000000", - "type":"sell-limit", - "orderId":27163533, - "clientOrderId":"abc123", - "orderSource":"spot-api", - "orderStatus":"submitted", - "symbol":"btcusdt", - "eventType":"creation" - - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate4.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate4.txt deleted file mode 100644 index 0fe3aefc..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate4.txt +++ /dev/null @@ -1,19 +0,0 @@ - - { - "tradePrice":"76.000000000000000000", - "tradeVolume":"1.013157894736842100", - "tradeId":301, - "tradeTime":1583854188883, - "aggressor":true, - "remainAmt":"0.000000000000000400000000000000000000", - "execAmt":"2", - "orderId":27163536, - "type":"sell-limit", - "clientOrderId":"abc123", - "orderSource":"spot-api", - "orderPrice":"15000", - "orderSize":"0.01", - "orderStatus":"filled", - "symbol":"btcusdt", - "eventType":"trade" - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate5.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate5.txt deleted file mode 100644 index cef88e8a..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/OrderUpdate5.txt +++ /dev/null @@ -1,15 +0,0 @@ - - { - "lastActTime":1583853475406, - "remainAmt":"2.000000000000000000", - "execAmt":"2", - "orderId":27163533, - "type":"sell-limit", - "clientOrderId":"abc123", - "orderSource":"spot-api", - "orderPrice":"15000", - "orderSize":"0.01", - "orderStatus":"canceled", - "symbol":"btcusdt", - "eventType":"cancellation" - } diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/PartialOrderBookUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/PartialOrderBookUpdate.txt deleted file mode 100644 index 5676faf7..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/PartialOrderBookUpdate.txt +++ /dev/null @@ -1,28 +0,0 @@ -{ - "ch":"market.btcusdt.depth.step0", - "ts":1630983549503, - "tick":{ - "bids":[ - [ - 52690.69, - 0.36281 - ], - [ - 52690.68, - 0.2 - ] - ], - "asks":[ - [ - 52690.7, - 0.372591 - ], - [ - 52691.26, - 0.13 - ] - ], - "version":136998124622, - "ts":1630983549500 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/SymbolDetailUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/SymbolDetailUpdate.txt deleted file mode 100644 index 277988f8..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/SymbolDetailUpdate.txt +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ch":"market.btcusdt.detail", - "ts":1630998026649, - "tick":{ - "id":273956868110, - "low":51000, - "high":52924.14, - "open":51823.62, - "close":52379.99, - "vol":727676440.200527, - "amount":13991.028076056185, - "version":273956868110, - "count":471348 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/TickerUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/TickerUpdate.txt deleted file mode 100644 index a926c91b..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/TickerUpdate.txt +++ /dev/null @@ -1,19 +0,0 @@ -{ - "ch":"market.btcusdt.ticker", - "ts":1630982370526, - "tick":{ - "open":51732, - "high":52785.64, - "low":51000, - "close":52735.63, - "amount":13259.24137056181, - "vol":687640987.4125315, - "count":448737, - "bid":52732.88, - "bidSize":0.036, - "ask":52732.89, - "askSize":0.583653, - "lastPrice":52735.63, - "lastSize":0.03 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/Socket/TradeUpdate.txt b/Huobi.Net.UnitTests/JsonResponses/Socket/TradeUpdate.txt deleted file mode 100644 index ff355cdc..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/Socket/TradeUpdate.txt +++ /dev/null @@ -1,18 +0,0 @@ -{ - "ch":"market.btcusdt.trade.detail", - "ts":1630994963175, - "tick":{ - "id":137005445109, - "ts":1630994963173, - "data":[ - { - "id":137005445109359286410323766, - "ts":1630994963173, - "tradeId":102523573486, - "amount":0.006754, - "price":52648.62, - "direction":"buy" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetLastTradeAsync.txt b/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetLastTradeAsync.txt deleted file mode 100644 index d620b62a..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetLastTradeAsync.txt +++ /dev/null @@ -1,27 +0,0 @@ -{ - "ch": "market.btcusdt.trade.detail", - "status": "ok", - "ts": 1629792192037, - "tick": { - "id": 136107843051, - "ts": 1629792191928, - "data": [ - { - "id": 136107843051348400221001656, - "ts": 1629792191928, - "trade-id": 102517374388, - "amount": 0.028416, - "price": 49806.0, - "direction": "buy" - }, - { - "id": 136107843051348400229813302, - "ts": 1629792191928, - "trade-id": 102517374387, - "amount": 0.025794, - "price": 49806.0, - "direction": "buy" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetMergedTickerAsync.txt b/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetMergedTickerAsync.txt deleted file mode 100644 index 403b04dd..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetMergedTickerAsync.txt +++ /dev/null @@ -1,24 +0,0 @@ -{ - "ch": "market.btcusdt.detail.merged", - "status": "ok", - "ts": 1629788763750, - "tick": { - "id": 272156789143, - "version": 272156789143, - "open": 50080.0, - "close": 49820.92, - "low": 48767.0, - "high": 50500.0, - "amount": 12055.365781937457, - "vol": 5.985618685709001E8, - "count": 420573, - "bid": [ - 49819.48, - 2.58112 - ], - "ask": [ - 49819.49, - 0.002411 - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetNavAsync.txt b/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetNavAsync.txt deleted file mode 100644 index 3a00a613..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetNavAsync.txt +++ /dev/null @@ -1,22 +0,0 @@ -{ - "ch":"market.btc3lusdt.etp", - "status":"ok", - "ts":1597890198849, - "tick":{ - "actualLeverage":2.988538205272293, - "nav":17.463067985747816, - "outstanding":98338.57818006596, - "symbol":"btc3lusdt", - "navTime":1597890198525, - "basket":[ - { - "amount":0.004438693860243208, - "currency":"btc" - }, - { - "amount":-34.725977870927, - "currency":"usdt" - } - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetOrderBookAsync.txt b/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetOrderBookAsync.txt deleted file mode 100644 index d07e3743..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetOrderBookAsync.txt +++ /dev/null @@ -1,53 +0,0 @@ -{ - "ch": "market.btcusdt.depth.step0", - "status": "ok", - "ts": 1629790438801, - "tick": { - "ts": 1629790438215, - "version": 136107114472, - "bids": [ - [ - 49790.87, - 0.779876 - ], - [ - 49785.9, - 1.82E-4 - ], - [ - 49784.48, - 0.002758 - ], - [ - 49784.29, - 0.05 - ], - [ - 49783.06, - 0.005038 - ] - ], - "asks": [ - [ - 49790.88, - 2.980472 - ], - [ - 49790.89, - 0.006613 - ], - [ - 49792.16, - 0.080302 - ], - [ - 49792.67, - 0.030112 - ], - [ - 49793.23, - 0.043103 - ] - ] - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetSymbolDetails24HAsync.txt b/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetSymbolDetails24HAsync.txt deleted file mode 100644 index f3c8651e..00000000 --- a/Huobi.Net.UnitTests/JsonResponses/TickResponses/GetSymbolDetails24HAsync.txt +++ /dev/null @@ -1,16 +0,0 @@ -{ - "ch": "market.btcusdt.detail", - "status": "ok", - "ts": 1629795484817, - "tick": { - "id": 272164011416, - "low": 48767.0, - "high": 50500.0, - "open": 50266.89, - "close": 49728.71, - "vol": 6.010379336834868E8, - "amount": 12110.642402972368, - "version": 272164011416, - "count": 420452 - } -} \ No newline at end of file diff --git a/Huobi.Net.UnitTests/JsonSocketTests.cs b/Huobi.Net.UnitTests/JsonSocketTests.cs deleted file mode 100644 index 8180b77b..00000000 --- a/Huobi.Net.UnitTests/JsonSocketTests.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; -using Newtonsoft.Json; -using NUnit.Framework; - -namespace Huobi.Net.UnitTests -{ - internal class JsonSocketTests - { - [Test] - public async Task ValidateKlineUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/KlineUpdate.txt"); - } - - [Test] - public async Task ValidatePartialBookUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/PartialOrderBookUpdate.txt"); - } - - [Test] - public async Task ValidateTradeUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/TradeUpdate.txt"); - } - - [Test] - public async Task ValidateSymbolDetailUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/SymbolDetailUpdate.txt"); - } - - [Test] - public async Task ValidateTickerUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/TickerUpdate.txt"); - } - - [Test] - public async Task ValidateBestOfferUpdateStreamJson() - { - await TestFileToObject>(@"JsonResponses/Socket/BestOfferUpdate.txt"); - } - - [Test] - public async Task ValidateOrderUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Socket/OrderUpdate1.txt"); - await TestFileToObject(@"JsonResponses/Socket/OrderUpdate2.txt", new List { "orderSide" }); - await TestFileToObject(@"JsonResponses/Socket/OrderUpdate3.txt"); - await TestFileToObject(@"JsonResponses/Socket/OrderUpdate4.txt"); - await TestFileToObject(@"JsonResponses/Socket/OrderUpdate5.txt"); - } - - [Test] - public async Task ValidateAccountUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Socket/AccountUpdate.txt"); - } - - [Test] - public async Task ValidateOrderDetailsUpdateStreamJson() - { - await TestFileToObject(@"JsonResponses/Socket/OrderDetailsUpdate1.txt"); - } - - - private static async Task TestFileToObject(string filePath, List ignoreProperties = null) - { - var listener = new EnumValueTraceListener(); - Trace.Listeners.Add(listener); - var path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; - string json; - try - { - var file = File.OpenRead(Path.Combine(path, filePath)); - using var reader = new StreamReader(file); - json = await reader.ReadToEndAsync(); - } - catch (FileNotFoundException) - { - throw; - } - - var result = JsonConvert.DeserializeObject(json); - JsonToObjectComparer.ProcessData("", result, json, ignoreProperties: new Dictionary> - { - { "", ignoreProperties ?? new List() } - }); - Trace.Listeners.Remove(listener); - } - } - - internal class EnumValueTraceListener : TraceListener - { - public override void Write(string message) - { - if (message.Contains("Cannot map")) - throw new Exception("Enum value error: " + message); - } - - public override void WriteLine(string message) - { - if (message.Contains("Cannot map")) - throw new Exception("Enum value error: " + message); - } - } -} diff --git a/Huobi.Net.UnitTests/JsonTests.cs b/Huobi.Net.UnitTests/JsonTests.cs deleted file mode 100644 index 56ecbcfc..00000000 --- a/Huobi.Net.UnitTests/JsonTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Huobi.Net; -using Huobi.Net.Interfaces; -using Huobi.Net.UnitTests.TestImplementations; -using NUnit.Framework; -using System.Collections.Generic; -using System.Threading.Tasks; -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Objects; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Objects.Options; - -namespace Huobi.Net.UnitTests -{ - [TestFixture] - public class JsonTests - { - private JsonToObjectComparer _comparer = new JsonToObjectComparer((json) => TestHelpers.CreateResponseClient(json, x => - { - x.ApiCredentials = new CryptoExchange.Net.Authentication.ApiCredentials("123", "123"); - x.SpotOptions.OutputOriginalData = true; - x.RateLimiterEnabled = false; - })); - - [Test] - public async Task ValidateAccountCalls() - { - await _comparer.ProcessSubject("DataResponses/Account", c => c.SpotApi.Account, - useNestedObjectPropertyForCompare: new Dictionary - { - }, - useNestedJsonPropertyForCompare: new Dictionary - { - { "GetBalancesAsync", "list" } - }, - useNestedJsonPropertyForAllCompare: new List { "data" } - ); - } - - [Test] - public async Task ValidateTradingCalls() - { - await _comparer.ProcessSubject("DataResponses/Trading", c => c.SpotApi.Trading, - useNestedObjectPropertyForCompare: new Dictionary - { - }, - useNestedJsonPropertyForCompare: new Dictionary - { - }, - useNestedJsonPropertyForAllCompare: new List { "data" }, - ignoreProperties: new Dictionary> { - { "GetOpenOrdersAsync", new List { "Type", "Side" } }, - { "GetOrdersAsync", new List { "Type", "Side" } }, - } - ); - } - - [Test] - public async Task ValidateExchangeDataDataCalls() - { - await _comparer.ProcessSubject("DataResponses/ExchangeData", c => c.SpotApi.ExchangeData, - useNestedObjectPropertyForCompare: new Dictionary - { - { "GetTickersAsync", "Ticks" }, - }, - useNestedJsonPropertyForCompare: new Dictionary - { - }, - useNestedJsonPropertyForAllCompare: new List { "data" } - ); - } - - [Test] - public async Task ValidateExchangeDataTickCalls() - { - await _comparer.ProcessSubject("TickResponses", c => c.SpotApi.ExchangeData, - parametersToSetNull: new [] { "limit" }, - useNestedObjectPropertyForCompare: new Dictionary - { - }, - useNestedJsonPropertyForAllCompare: new List { "tick" } - ); - } - - } -} diff --git a/Huobi.Net.UnitTests/JsonToObjectComparer.cs b/Huobi.Net.UnitTests/JsonToObjectComparer.cs deleted file mode 100644 index 5f747ca7..00000000 --- a/Huobi.Net.UnitTests/JsonToObjectComparer.cs +++ /dev/null @@ -1,420 +0,0 @@ -using CryptoExchange.Net.Converters; -using CryptoExchange.Net.Converters.JsonNet; -using CryptoExchange.Net.Objects; -using Huobi.Net.UnitTests.TestImplementations; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NUnit.Framework; -using NUnit.Framework.Legacy; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace Huobi.Net.UnitTests -{ - public class JsonToObjectComparer - { - private Func _clientFunc; - - public JsonToObjectComparer(Func getClient) - { - _clientFunc = getClient; - } - - public async Task ProcessSubject(Func getSubject, - string[] parametersToSetNull = null, - Dictionary useNestedJsonPropertyForCompare = null, - Dictionary useNestedObjectPropertyForCompare = null, - List useNestedJsonPropertyForAllCompare = null, - Dictionary> ignoreProperties = null, - List takeFirstItemForCompare = null) - => await ProcessSubject("", getSubject, parametersToSetNull, useNestedJsonPropertyForCompare, useNestedObjectPropertyForCompare, useNestedJsonPropertyForAllCompare, ignoreProperties, takeFirstItemForCompare); - - public async Task ProcessSubject( - string folderPrefix, - Func getSubject, - string[] parametersToSetNull = null, - Dictionary useNestedJsonPropertyForCompare = null, - Dictionary useNestedObjectPropertyForCompare = null, - List useNestedJsonPropertyForAllCompare = null, - Dictionary> ignoreProperties = null, - List takeFirstItemForCompare = null) - { - var listener = new EnumValueTraceListener(); - Trace.Listeners.Add(listener); - var methods = typeof(K).GetMethods(); - var callResultMethods = methods.Where(m => m.Name.EndsWith("Async")).ToList(); - var skippedMethods = new List(); - - foreach (var method in callResultMethods) - { - var path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName; - FileStream file = null; - try - { - file = File.OpenRead(Path.Combine(path, $"JsonResponses", folderPrefix, $"{method.Name}.txt")); - } - catch (FileNotFoundException) - { - skippedMethods.Add(method.Name); - continue; - } - - var buffer = new byte[file.Length]; - await file.ReadAsync(buffer, 0, buffer.Length); - file.Close(); - - var json = Encoding.UTF8.GetString(buffer); - var client = _clientFunc(json); - - var parameters = method.GetParameters(); - var input = new List(); - foreach (var parameter in parameters) - { - if (parametersToSetNull?.Contains(parameter.Name) == true && parameter.ParameterType != typeof(int)) - input.Add(null); - else - input.Add(TestHelpers.GetTestValue(parameter.ParameterType, 1)); - } - - // act - var result = (CallResult)await TestHelpers.InvokeAsync(method, getSubject(client), input.ToArray()); - - // asset - ClassicAssert.Null(result.Error, method.Name); - - var resultProp = result.GetType().GetProperty("Data", BindingFlags.Public | BindingFlags.Instance); - if (resultProp == null) - // No result - continue; - - var resultData = resultProp.GetValue(result); - ProcessData(method.Name, resultData, json, useNestedJsonPropertyForCompare, useNestedObjectPropertyForCompare, useNestedJsonPropertyForAllCompare, ignoreProperties, takeFirstItemForCompare); - } - - if (skippedMethods.Any()) - Debug.WriteLine("Skipped methods:"); - foreach (var method in skippedMethods) - Debug.WriteLine(method); - - Trace.Listeners.Remove(listener); - } - - public static void ProcessData(string method, - object resultData, - string json, - Dictionary useNestedJsonPropertyForCompare = null, - Dictionary useNestedObjectPropertyForCompare = null, - List useNestedJsonPropertyForAllCompare = null, - Dictionary> ignoreProperties = null, - List takeFirstItemForCompare = null) - { - var resultProperties = resultData.GetType().GetProperties().Select(p => (p, (JsonPropertyAttribute)p.GetCustomAttributes(typeof(JsonPropertyAttribute), true).SingleOrDefault())); - var jsonObject = JToken.Parse(json); - if (useNestedJsonPropertyForAllCompare?.Any() == true) - jsonObject = jsonObject[useNestedJsonPropertyForAllCompare[0]]; - - if (useNestedJsonPropertyForCompare?.ContainsKey(method) == true) - { - jsonObject = jsonObject[useNestedJsonPropertyForCompare[method]]; - } - - if (useNestedObjectPropertyForCompare?.ContainsKey(method) == true) - resultData = resultData.GetType().GetProperty(useNestedObjectPropertyForCompare[method]).GetValue(resultData); - - if (resultData.GetType().GetInterfaces().Contains(typeof(IDictionary))) - { - var dict = (IDictionary)resultData; - var jObj = (JObject)jsonObject; - var properties = jObj.Properties(); - foreach (var dictProp in properties) - { - if (!dict.Contains(dictProp.Name)) - throw new Exception($"{method}: Dictionary has no value for {dictProp.Name} while input json `{dictProp.Name}` has value {dictProp.Value}"); - - if (dictProp.Value.Type == JTokenType.Object) - { - // TODO Some additional checking for objects - foreach (var prop in ((JObject)dictProp.Value).Properties()) - CheckObject(method, prop, dict[dictProp.Name], ignoreProperties); - } - else - { - if (dict[dictProp.Name] == default && dictProp.Value.Type != JTokenType.Null) - { - // Property value not correct - throw new Exception($"{method}: Dictionary entry `{dictProp.Name}` has no value while input json has value {dictProp.Value}"); - } - } - } - } - else if (jsonObject.Type == JTokenType.Array) - { - var jObjs = (JArray)jsonObject; - if (resultData.GetType().GetCustomAttribute()?.ConverterType == typeof(ArrayConverter)) - { - var resultProps = resultData.GetType().GetProperties().Select(p => (p, p.GetCustomAttributes(typeof(ArrayPropertyAttribute), true).Cast().SingleOrDefault())); - var arrayConverterProperty = resultData.GetType().GetCustomAttributes(typeof(JsonConverterAttribute), true).FirstOrDefault(); - var jsonConverter = (arrayConverterProperty as JsonConverterAttribute).ConverterType; - if (jsonConverter != typeof(ArrayConverter)) - // Not array converter? - return; - - int i = 0; - foreach (var item in jObjs.Children()) - { - var arrayProp = resultProps.SingleOrDefault(p => p.Item2?.Index == i).p; - if (arrayProp != null) - CheckPropertyValue(method, item, arrayProp.GetValue(resultData), arrayProp.Name, "Array index " + i, arrayProp, ignoreProperties); - - i++; - } - } - else - { - if (takeFirstItemForCompare?.Contains(method) == true) - { - resultData = new object[] { resultData }; - } - - var list = (IEnumerable)resultData; - var enumerator = list.GetEnumerator(); - foreach (var jObj in jObjs) - { - enumerator.MoveNext(); - if (jObj.Type == JTokenType.Object) - { - foreach (var subProp in ((JObject)jObj).Properties()) - { - if (ignoreProperties?.ContainsKey(method) == true && ignoreProperties[method].Contains(subProp.Name)) - continue; - CheckObject(method, subProp, enumerator.Current, ignoreProperties); - } - } - else if (jObj.Type == JTokenType.Array) - { - var resultObj = enumerator.Current; - ProcessArray(method, resultObj, jObj, ignoreProperties); - } - else - { - var value = enumerator.Current; - if (value == default && ((JValue)jObj).Type != JTokenType.Null) - { - throw new Exception($"{method}: Array has no value while input json array has value {jObj}"); - } - } - } - } - } - else - { - foreach (var item in jsonObject) - { - if (item is JProperty prop) - { - if (ignoreProperties?.ContainsKey(method) == true && ignoreProperties[method].Contains(prop.Name)) - continue; - - CheckObject(method, prop, resultData, ignoreProperties); - } - } - } - - Debug.WriteLine($"Successfully validated {method}"); - } - - private static void CheckObject(string method, JProperty prop, object obj, Dictionary> ignoreProperties) - { - var resultProperties = obj.GetType() - .GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.SetProperty).Select(p => (p, (JsonPropertyAttribute)p.GetCustomAttributes(typeof(JsonPropertyAttribute), true).SingleOrDefault())); - - // Property has a value - var property = resultProperties.SingleOrDefault(p => p.Item2?.PropertyName == prop.Name).p; - property ??= resultProperties.SingleOrDefault(p => p.p.Name == prop.Name).p; - property ??= resultProperties.SingleOrDefault(p => p.p.Name.ToUpperInvariant() == prop.Name.ToUpperInvariant()).p; - - if (property is null) - { - // Property not found - throw new Exception($"{method}: Missing property `{prop.Name}` on `{obj.GetType().Name}`"); - } - - var propertyValue = property.GetValue(obj); - if(property.GetCustomAttribute(true)?.ItemConverterType == null) - CheckPropertyValue(method, prop.Value, propertyValue, property.Name, prop.Name, property, ignoreProperties); - } - - private static void CheckPropertyValue(string method, JToken propValue, object propertyValue, string propertyName = null, string propName = null, PropertyInfo info = null, Dictionary> ignoreProperties = null) - { - if (propertyValue == default && propValue.Type != JTokenType.Null && !string.IsNullOrEmpty(propValue.ToString())) - { - // Property value not correct - throw new Exception($"{method}: Property `{propertyName}` has no value while input json `{propName}` has value {propValue}"); - } - - if (propertyValue == default && (propValue.Type == JTokenType.Null || string.IsNullOrEmpty(propValue.ToString()))) - return; - - if (propertyValue.GetType().GetInterfaces().Contains(typeof(IDictionary))) - { - var dict = (IDictionary)propertyValue; - var jObj = (JObject)propValue; - var properties = jObj.Properties(); - foreach (var dictProp in properties) - { - if (!dict.Contains(dictProp.Name)) - throw new Exception($"{method}: Property `{propertyName}` has no value while input json `{propName}` has value {propValue}"); - - if (dictProp.Value.Type == JTokenType.Object) - { - // TODO Some additional checking for objects - } - else - { - if (dict[dictProp.Name] == default && dictProp.Value.Type != JTokenType.Null) - { - // Property value not correct - throw new Exception($"{method}: Dictionary entry `{dictProp.Name}` has no value while input json has value {propValue}"); - } - } - } - } - else if (propertyValue.GetType().GetInterfaces().Contains(typeof(IEnumerable)) - && propertyValue.GetType() != typeof(string)) - { - var jObjs = (JArray)propValue; - var list = (IEnumerable)propertyValue; - var enumerator = list.GetEnumerator(); - foreach (JToken jtoken in jObjs) - { - enumerator.MoveNext(); - var typeConverter = enumerator.Current.GetType().GetCustomAttributes(typeof(JsonConverterAttribute), true); - if (typeConverter.Any() && ((JsonConverterAttribute)typeConverter.First()).ConverterType != typeof(ArrayConverter)) - // Custom converter for the type, skip - continue; - - if (jtoken.Type == JTokenType.Object) - { - foreach (var subProp in ((JObject)jtoken).Properties()) - { - if (ignoreProperties?.ContainsKey(method) == true && ignoreProperties[method].Contains(subProp.Name)) - continue; - - CheckObject(method, subProp, enumerator.Current, ignoreProperties); - } - } - else if (jtoken.Type == JTokenType.Array) - { - var resultObj = enumerator.Current; - ProcessArray(method, resultObj, jtoken, ignoreProperties); - } - else - { - var value = enumerator.Current; - if (value == default && ((JValue)jtoken).Type != JTokenType.Null) - { - throw new Exception($"{method}: Property `{propertyName}` has no value while input json `{propName}` has value {jtoken}"); - } - - if(!(ignoreProperties?.ContainsKey(method) == true && ignoreProperties[method].Contains(propertyName))) - CheckValues(method, propertyName, (JValue)jtoken, value); - } - } - } - else - { - if (propValue.Type == JTokenType.Object) - { - foreach (var item in propValue) - { - if (item is JProperty prop) - { - if (ignoreProperties?.ContainsKey(method) == true && ignoreProperties[method].Contains(prop.Name)) - continue; - - CheckObject(method, prop, propertyValue, ignoreProperties); - } - } - } - else if(propValue.Type == JTokenType.Array) - { - ProcessArray(method, propertyValue, propValue, ignoreProperties); - } - else - { - if (info.GetCustomAttribute(true) == null - && info.GetCustomAttribute(true) == null - && info.GetCustomAttribute(true)?.ItemConverterType == null) - { - CheckValues(method, propertyName, (JValue)propValue, propertyValue); - } - } - } - } - - private static void ProcessArray(string method, object resultObj, JToken jtoken, Dictionary> ignoreProperties = null) - { - var resultProps = resultObj.GetType().GetProperties().Select(p => (p, p.GetCustomAttributes(typeof(ArrayPropertyAttribute), true).Cast().SingleOrDefault())); - var arrayConverterProperty = resultObj.GetType().GetCustomAttributes(typeof(JsonConverterAttribute), true).FirstOrDefault(); - var jsonConverter = (arrayConverterProperty as JsonConverterAttribute)?.ConverterType; - if (jsonConverter != typeof(ArrayConverter)) - // Not array converter? - return; - - int i = 0; - foreach (var item in jtoken.Children()) - { - var arrayProp = resultProps.SingleOrDefault(p => p.Item2?.Index == i).p; - if (arrayProp != null) - CheckPropertyValue(method, item, arrayProp.GetValue(resultObj), arrayProp.Name, "Array index " + i, arrayProp, ignoreProperties); - - i++; - } - } - - private static void CheckValues(string method, string property, JValue jsonValue, object objectValue) - { - if (jsonValue.Type == JTokenType.String) - { - if (objectValue is decimal dec) - { - if (jsonValue.Value() != dec) - throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {dec}"); - } - else if (objectValue is DateTime time) - { - // timestamp, hard to check.. - } - else if (jsonValue.Value.ToString().ToLowerInvariant() != objectValue.ToString().ToLowerInvariant()) - { - throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {objectValue.ToString()}"); - } - } - else if (jsonValue.Type == JTokenType.Integer) - { - if (objectValue is string str) - { - if(jsonValue.Value.ToString().ToLowerInvariant() != objectValue.ToString().ToLowerInvariant()) - throw new Exception($"{method}: {property} not equal: {jsonValue.Value().ToLowerInvariant()} vs {objectValue.ToString().ToLowerInvariant()}"); - } - else - { - if (jsonValue.Value() != Convert.ToInt64(objectValue)) - throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {Convert.ToInt64(objectValue)}"); - } - } - else if (jsonValue.Type == JTokenType.Boolean) - { - if (jsonValue.Value() != (bool)objectValue) - throw new Exception($"{method}: {property} not equal: {jsonValue.Value()} vs {(bool)objectValue}"); - } - } - } -} diff --git a/Huobi.Net/Clients/HuobiRestClient.cs b/Huobi.Net/Clients/HuobiRestClient.cs deleted file mode 100644 index 90824cd1..00000000 --- a/Huobi.Net/Clients/HuobiRestClient.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CryptoExchange.Net.Authentication; -using Huobi.Net.Clients.FuturesApi; -using Huobi.Net.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Microsoft.Extensions.Logging; -using System.Net.Http; -using System; -using Huobi.Net.Objects.Options; -using CryptoExchange.Net.Clients; - -namespace Huobi.Net.Clients -{ - /// - public class HuobiRestClient : BaseRestClient, IHuobiRestClient - { - #region Api clients - - /// - public IHuobiRestClientSpotApi SpotApi { get; } - - /// - public IHuobiRestClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } - - #endregion - - #region constructor/destructor - /// - /// Create a new instance of the HuobiRestClient using provided options - /// - /// Option configuration delegate - public HuobiRestClient(Action? optionsDelegate = null) : this(null, null, optionsDelegate) - { - } - - /// - /// Create a new instance of the HuobiRestClient - /// - /// Option configuration delegate - /// The logger factory - /// Http client for this client - public HuobiRestClient(HttpClient? httpClient, ILoggerFactory? loggerFactory, Action? optionsDelegate = null) - : base(loggerFactory, "Huobi") - { - var options = HuobiRestOptions.Default.Copy(); - if (optionsDelegate != null) - optionsDelegate(options); - Initialize(options); - - SpotApi = AddApiClient(new HuobiRestClientSpotApi(_logger, httpClient, options)); - UsdtMarginSwapApi = AddApiClient(new HuobiRestClientUsdtMarginSwapApi(_logger, httpClient, options)); - } - #endregion - - #region methods - /// - /// Set the default options to be used when creating new clients - /// - /// Option configuration delegate - public static void SetDefaultOptions(Action optionsDelegate) - { - var options = HuobiRestOptions.Default.Copy(); - optionsDelegate(options); - HuobiRestOptions.Default = options; - } - - /// - public void SetApiCredentials(ApiCredentials apiCredentials) - { - SpotApi.SetApiCredentials(apiCredentials); - UsdtMarginSwapApi.SetApiCredentials(apiCredentials); - } - #endregion - } -} diff --git a/Huobi.Net/Clients/HuobiSocketClient.cs b/Huobi.Net/Clients/HuobiSocketClient.cs deleted file mode 100644 index 61b62b1f..00000000 --- a/Huobi.Net/Clients/HuobiSocketClient.cs +++ /dev/null @@ -1,76 +0,0 @@ -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Clients; -using Huobi.Net.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Huobi.Net.Objects.Options; -using Microsoft.Extensions.Logging; -using System; - -namespace Huobi.Net.Clients -{ - /// - public class HuobiSocketClient : BaseSocketClient, IHuobiSocketClient - { - #region fields - /// - public IHuobiSocketClientSpotApi SpotApi { get; } - /// - public IHuobiSocketClientUsdtMarginSwapApi UsdtMarginSwapApi { get; } - #endregion - - #region ctor - /// - /// Create a new instance of the HuobiSocketClient - /// - /// The logger factory - public HuobiSocketClient(ILoggerFactory? loggerFactory = null) : this((x) => { }, loggerFactory) - { - } - - /// - /// Create a new instance of the HuobiSocketClient - /// - /// Option configuration delegate - public HuobiSocketClient(Action optionsDelegate) : this(optionsDelegate, null) - { - } - - /// - /// Create a new instance of the HuobiSocketClient - /// - /// The logger factory - /// Option configuration delegate - public HuobiSocketClient(Action optionsDelegate, ILoggerFactory? loggerFactory = null) : base(loggerFactory, "Huobi") - { - var options = HuobiSocketOptions.Default.Copy(); - optionsDelegate(options); - Initialize(options); - - SpotApi = AddApiClient(new HuobiSocketClientSpotApi(_logger, options)); - UsdtMarginSwapApi = AddApiClient(new HuobiSocketClientUsdtMarginSwapApi(_logger, options)); - } - #endregion - - #region methods - /// - /// Set the default options to be used when creating new clients - /// - /// Option configuration delegate - public static void SetDefaultOptions(Action optionsDelegate) - { - var options = HuobiSocketOptions.Default.Copy(); - optionsDelegate(options); - HuobiSocketOptions.Default = options; - } - - /// - public void SetApiCredentials(ApiCredentials apiCredentials) - { - SpotApi.SetApiCredentials(apiCredentials); - UsdtMarginSwapApi.SetApiCredentials(apiCredentials); - } - #endregion - } -} diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs deleted file mode 100644 index 4bd880d1..00000000 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiAccount.cs +++ /dev/null @@ -1,455 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; -using CryptoExchange.Net.Converters; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.ExtensionMethods; - -namespace Huobi.Net.Clients.SpotApi -{ - /// - internal class HuobiRestClientSpotApiAccount : IHuobiRestClientSpotApiAccount - { - private const string GetUserId = "user/uid"; - private const string GetSubAccountUsers = "sub-user/user-list"; - private const string GetSubUserAccounts = "sub-user/account-list"; - - private const string GetAccountsEndpoint = "account/accounts"; - private const string GetAssetValuationEndpoint = "account/asset-valuation"; - private const string TransferAssetValuationEndpoint = "account/transfer"; - private const string GetBalancesEndpoint = "account/accounts/{}/balance"; - private const string GetAccountHistoryEndpoint = "account/history"; - private const string GetLedgerEndpoint = "account/ledger"; - - private const string GetSubAccountBalancesEndpoint = "account/accounts/{}"; - private const string TransferWithSubAccountEndpoint = "subuser/transfer"; - - private const string QueryDepositAddressEndpoint = "account/deposit/address"; - private const string PlaceWithdrawEndpoint = "dw/withdraw/api/create"; - private const string QueryWithdrawDepositEndpoint = "query/deposit-withdraw"; - - private readonly HuobiRestClientSpotApi _baseClient; - - internal HuobiRestClientSpotApiAccount(HuobiRestClientSpotApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task> GetUserIdAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(GetUserId, "2"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetSubAccountUsersAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(GetSubAccountUsers, "2"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - } - - /// - public async Task> GetSubUserAccountsAsync(long subUserId, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "subUid", subUserId.ToString(CultureInfo.InvariantCulture)} - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(GetSubUserAccounts, "2"), HttpMethod.Get, ct, parameters, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetAccountsAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(GetAccountsEndpoint, "1"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetBalancesAsync(long accountId, CancellationToken ct = default) - { - var result = await _baseClient.SendHuobiRequest(_baseClient.GetUrl(GetBalancesEndpoint.FillPathParameters(accountId.ToString(CultureInfo.InvariantCulture)), "1"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - if (!result) - return result.AsError>(result.Error!); - - return result.As(result.Data.Data); - } - - /// - public async Task> GetAssetValuationAsync(AccountType accountType, string? valuationCurrency = null, long? subUserId = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "accountType", JsonConvert.SerializeObject(accountType, new AccountTypeConverter(false))} - }; - parameters.AddOptionalParameter("valuationCurrency", valuationCurrency); - parameters.AddOptionalParameter("subUid", subUserId); - - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl(GetAssetValuationEndpoint, "2"), HttpMethod.Get, ct, parameters, signed: true).ConfigureAwait(false); - } - - /// - public async Task> TransferAssetAsync(long fromUserId, AccountType fromAccountType, long fromAccountId, - long toUserId, AccountType toAccountType, long toAccountId, string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "from-account-id", fromAccountId.ToString(CultureInfo.InvariantCulture)}, - { "from-user", fromUserId.ToString(CultureInfo.InvariantCulture)}, - { "from-account-type", JsonConvert.SerializeObject(fromAccountType, new AccountTypeConverter(false))}, - - { "to-account-id", toAccountId.ToString(CultureInfo.InvariantCulture)}, - { "to-user", toUserId.ToString(CultureInfo.InvariantCulture)}, - { "to-account-type", JsonConvert.SerializeObject(toAccountType, new AccountTypeConverter(false))}, - - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(TransferAssetValuationEndpoint, "1"), HttpMethod.Post, ct, parameters, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetAccountHistoryAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? size = null, CancellationToken ct = default) - { - size?.ValidateIntBetween(nameof(size), 1, 500); - - var transactionTypeConverter = new TransactionTypeConverter(false); - var parameters = new Dictionary - { - { "account-id", accountId } - }; - parameters.AddOptionalParameter("currency", asset); - parameters.AddOptionalParameter("transact-types", transactionTypes == null ? null : string.Join(",", transactionTypes.Select(s => JsonConvert.SerializeObject(s, transactionTypeConverter)))); - parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("sort", sort == null ? null : JsonConvert.SerializeObject(sort, new SortingTypeConverter(false))); - parameters.AddOptionalParameter("size", size); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(GetAccountHistoryEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetAccountLedgerAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? size = null, long? fromId = null, CancellationToken ct = default) - { - size?.ValidateIntBetween(nameof(size), 1, 500); - - var transactionTypeConverter = new TransactionTypeConverter(false); - var parameters = new Dictionary - { - { "accountId", accountId } - }; - parameters.AddOptionalParameter("currency", asset); - parameters.AddOptionalParameter("transactTypes", transactionTypes == null ? null : string.Join(",", transactionTypes.Select(s => JsonConvert.SerializeObject(s, transactionTypeConverter)))); - parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("sort", sort == null ? null : JsonConvert.SerializeObject(sort, new SortingTypeConverter(false))); - parameters.AddOptionalParameter("limit", size); - parameters.AddOptionalParameter("fromId", fromId?.ToString(CultureInfo.InvariantCulture)); - - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl(GetLedgerEndpoint, "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetSubAccountBalancesAsync(long subAccountId, CancellationToken ct = default) - { - var result = await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(GetSubAccountBalancesEndpoint.FillPathParameters(subAccountId.ToString(CultureInfo.InvariantCulture)), "1"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - if (!result) - return result.AsError>(result.Error!); - - return result.As(result.Data.First().Data); - } - - /// - public async Task> TransferWithSubAccountAsync(long subAccountId, string asset, decimal quantity, TransferType transferType, CancellationToken ct = default) - { - asset.ValidateNotNull(nameof(asset)); - var parameters = new Dictionary - { - { "sub-uid", subAccountId }, - { "currency", asset }, - { "amount", quantity }, - { "type", JsonConvert.SerializeObject(transferType, new TransferTypeConverter(false)) } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(TransferWithSubAccountEndpoint, "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - - - /// - public async Task>> GetDepositAddressesAsync(string asset, CancellationToken ct = default) - { - var parameters = new Dictionary() { { "currency", asset } }; - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl(QueryDepositAddressEndpoint, "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> WithdrawAsync(string address, string asset, decimal quantity, decimal fee, string? network = null, string? addressTag = null, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "address", address }, - { "currency", asset }, - { "amount", quantity }, - { "fee", fee }, - }; - - parameters.AddOptionalParameter("chain", network); - parameters.AddOptionalParameter("addr-tag", addressTag); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(PlaceWithdrawEndpoint, "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetWithdrawDepositAsync(WithdrawDepositType type, string? asset = null, int? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "type", JsonConvert.SerializeObject(type, new WithdrawDepositTypeConverter(false)) }, - }; - - parameters.AddOptionalParameter("currency", asset); - parameters.AddOptionalParameter("from", from?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("size", size?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("direct", direction == null ? null : JsonConvert.SerializeObject(direction, new FilterDirectionConverter(false))); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(QueryWithdrawDepositEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> RepayMarginLoanAsync(string accountId, string asset, decimal quantity, string? transactionId = null, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "accountId", accountId }, - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) } - }; - - parameters.AddOptionalParameter("transactId", transactionId); - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl("account/repayment", "2"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferSpotToIsolatedMarginAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "symbol", symbol }, - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) } - }; - - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl("dw/transfer-in/margin", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferIsolatedMarginToSpotAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "symbol", symbol }, - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) } - }; - - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl("dw/transfer-out/margin", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedLoanInterestRateAndQuotaAsync(IEnumerable? symbols = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("symbols", symbols == null? null: string.Join(",", symbols)); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("margin/loan-info", "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> RequestIsolatedMarginLoanAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "symbol", symbol }, - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("margin/orders", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> RepayIsolatedMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "amount", quantity.ToString(CultureInfo.InvariantCulture) } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl($"margin/orders/{orderId}/repay", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginClosedOrdersAsync( - string symbol, - IEnumerable? states = null, - DateTime? startDate = null, - DateTime? endDate= null, - string? from = null, - FilterDirection? direction = null, - int? limit = null, - int? subUserId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - parameters.AddOptionalParameter("states", states == null ? null : string.Join(",", states.Select(EnumConverter.GetString))); - parameters.AddOptionalParameter("start-date", startDate == null ? null: startDate.Value.ToString("yyyy-mm-dd")); - parameters.AddOptionalParameter("end-date", endDate == null ? null: endDate.Value.ToString("yyyy-mm-dd")); - parameters.AddOptionalParameter("from", from); - parameters.AddOptionalParameter("direct", EnumConverter.GetString(direction)); - parameters.AddOptionalParameter("size", limit); - parameters.AddOptionalParameter("sub-uid", subUserId); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl($"margin/loan-orders", "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginBalanceAsync(string symbol, int? subUserId = null, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - parameters.AddOptionalParameter("sub-uid", subUserId); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl($"margin/accounts/balance", "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferSpotToCrossMarginAsync(string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "currency", asset }, - { "amount", quantity }, - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl($"cross-margin/transfer-in", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferCrossMarginToSpotAsync(string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "currency", asset }, - { "amount", quantity }, - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl($"cross-margin/transfer-out", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossLoanInterestRateAndQuotaAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl($"cross-margin/loan-info", "1"), HttpMethod.Get, ct, null, true).ConfigureAwait(false); - } - - /// - public async Task> RequestCrossMarginLoanAsync(string asset, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "currency", asset }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("cross-margin/orders", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> RepayCrossMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "amount", quantity.ToString(CultureInfo.InvariantCulture) } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl($"cross-margin/orders/{orderId}/repay", "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginClosedOrdersAsync( - string? asset = null, - MarginOrderStatus? state = null, - DateTime? startDate = null, - DateTime? endDate = null, - string? from = null, - FilterDirection? direction = null, - int? limit = null, - int? subUserId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("currency", asset); - parameters.AddOptionalParameter("state", EnumConverter.GetString(state)); - parameters.AddOptionalParameter("start-date", startDate == null ? null : startDate.Value.ToString("yyyy-mm-dd")); - parameters.AddOptionalParameter("end-date", endDate == null ? null : endDate.Value.ToString("yyyy-mm-dd")); - parameters.AddOptionalParameter("from", from); - parameters.AddOptionalParameter("direct", EnumConverter.GetString(direction)); - parameters.AddOptionalParameter("size", limit); - parameters.AddOptionalParameter("sub-uid", subUserId); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl($"cross-margin/loan-orders", "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginBalanceAsync(int? subUserId = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("sub-uid", subUserId); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl($"cross-margin/accounts/balance", "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetRepaymentHistoryAsync(long? repayId = null, long? accountId =null, string? asset =null, DateTime? startTime = null, DateTime? endTime = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("repayId", repayId); - parameters.AddOptionalParameter("accountId", accountId); - parameters.AddOptionalParameter("currency", asset); - parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("sort", sort); - parameters.AddOptionalParameter("limit", limit); - parameters.AddOptionalParameter("fromId", fromId); - - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl($"account/repayment", "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCurrentFeeRatesAsync(IEnumerable symbols, - CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("symbols", string.Join(",", symbols)); - - return await _baseClient - .SendHuobiV2Request>(_baseClient.GetUrl("reference/transact-fee-rate", "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - } -} diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs deleted file mode 100644 index ed761ba1..00000000 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiExchangeData.cs +++ /dev/null @@ -1,204 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Converters; -using CryptoExchange.Net.Objects; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.ExtensionMethods; - -namespace Huobi.Net.Clients.SpotApi -{ - /// - internal class HuobiRestClientSpotApiExchangeData : IHuobiRestClientSpotApiExchangeData - { - private const string MarketTickerEndpoint = "market/tickers"; - private const string MarketTickerMergedEndpoint = "market/detail/merged"; - private const string MarketKlineEndpoint = "market/history/kline"; - private const string MarketDepthEndpoint = "market/depth"; - private const string MarketLastTradeEndpoint = "market/trade"; - private const string MarketTradeHistoryEndpoint = "market/history/trade"; - private const string MarketDetailsEndpoint = "market/detail"; - private const string NavEndpoint = "market/etp"; - - private const string MarketStatusEndpoint = "market-status"; - private const string CommonSymbolsEndpoint = "common/symbols"; - private const string CommonCurrenciesEndpoint = "common/currencys"; - private const string CommonCurrenciesAndChainsEndpoint = "reference/currencies"; - private const string ServerTimeEndpoint = "common/timestamp"; - - private readonly HuobiRestClientSpotApi _baseClient; - - internal HuobiRestClientSpotApiExchangeData(HuobiRestClientSpotApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task> GetTickersAsync(CancellationToken ct = default) - { - var result = await _baseClient.SendHuobiTimestampRequest>(_baseClient.GetUrl(MarketTickerEndpoint), HttpMethod.Get, ct).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - - return result.As(new HuobiSymbolTicks() { Ticks = result.Data.Item1, Timestamp = result.Data.Item2 }); - } - - /// - public async Task> GetTickerAsync(string symbol, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - var result = await _baseClient.SendHuobiTimestampRequest(_baseClient.GetUrl(MarketTickerMergedEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - - result.Data.Item1.Timestamp = result.Data.Item2; - return result.As(result.Data.Item1); - } - - /// - public async Task>> GetKlinesAsync(string symbol, KlineInterval period, int? limit = null, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - limit?.ValidateIntBetween(nameof(limit), 0, 2000); - - var parameters = new Dictionary - { - { "symbol", symbol }, - { "period", JsonConvert.SerializeObject(period, new PeriodConverter(false)) }, - }; - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(MarketKlineEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetOrderBookAsync(string symbol, int mergeStep, int? limit = null, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - mergeStep.ValidateIntBetween(nameof(mergeStep), 0, 2000); - limit?.ValidateIntValues(nameof(limit), 5, 10, 20); - - var parameters = new Dictionary - { - { "symbol", symbol }, - { "type", "step"+mergeStep } - }; - parameters.AddOptionalParameter("depth", limit); - - var result = await _baseClient.SendHuobiTimestampRequest(_baseClient.GetUrl(MarketDepthEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - - return result.As(result.Data.Item1); - } - - /// - public async Task> GetLastTradeAsync(string symbol, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(MarketLastTradeEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetTradeHistoryAsync(string symbol, int? limit = null, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - limit?.ValidateIntBetween(nameof(limit), 0, 2000); - - var parameters = new Dictionary - { - { "symbol", symbol }, - }; - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(MarketTradeHistoryEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetSymbolDetails24HAsync(string symbol, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - var result = await _baseClient.SendHuobiTimestampRequest(_baseClient.GetUrl(MarketDetailsEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - - result.Data.Item1.Timestamp = result.Data.Item2; - return result.As(result.Data.Item1); - } - - /// - public async Task> GetNavAsync(string symbol, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - var parameters = new Dictionary - { - { "symbol", symbol } - }; - - var result = await _baseClient.SendHuobiTimestampRequest(_baseClient.GetUrl(NavEndpoint), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - - return result.As(result.Data.Item1); - } - - /// - public async Task> GetSymbolStatusAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl(MarketStatusEndpoint, "2"), HttpMethod.Get, ct).ConfigureAwait(false); - } - - /// - public async Task>> GetSymbolsAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(CommonSymbolsEndpoint, "1"), HttpMethod.Get, ct).ConfigureAwait(false); - } - - /// - public async Task>> GetAssetsAsync(CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(CommonCurrenciesEndpoint, "1"), HttpMethod.Get, ct).ConfigureAwait(false); - } - - /// - public async Task>> GetAssetDetailsAsync(string? asset = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("currency", asset); - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl(CommonCurrenciesAndChainsEndpoint, "2"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetServerTimeAsync(CancellationToken ct = default) - { - var result = await _baseClient.SendHuobiRequest(_baseClient.GetUrl(ServerTimeEndpoint, "1"), HttpMethod.Get, ct).ConfigureAwait(false); - if (!result) - return result.AsError(result.Error!); - var time = (DateTime)JsonConvert.DeserializeObject(result.Data, typeof(DateTime), new DateTimeConverter())!; - return result.As(time); - } - - } -} diff --git a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs b/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs deleted file mode 100644 index c5b3166f..00000000 --- a/Huobi.Net/Clients/SpotApi/HuobiRestClientSpotApiTrading.cs +++ /dev/null @@ -1,322 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; -using CryptoExchange.Net.Converters; -using Huobi.Net.Interfaces.Clients.SpotApi; -using CryptoExchange.Net.CommonObjects; -using Huobi.Net.ExtensionMethods; - -namespace Huobi.Net.Clients.SpotApi -{ - /// - internal class HuobiRestClientSpotApiTrading : IHuobiRestClientSpotApiTrading - { - private const string PlaceOrderEndpoint = "order/orders/place"; - private const string OpenOrdersEndpoint = "order/openOrders"; - private const string OrdersEndpoint = "order/orders"; - private const string CancelOrderEndpoint = "order/orders/{}/submitcancel"; - private const string CancelOrderByClientOrderIdEndpoint = "order/orders/submitCancelClientOrder"; - private const string CancelOrdersByCriteriaEndpoint = "order/orders/batchCancelOpenOrders"; - private const string CancelOrdersEndpoint = "order/orders/batchcancel"; - private const string OrderInfoEndpoint = "order/orders/{}"; - private const string ClientOrderInfoEndpoint = "order/orders/getClientOrder"; - private const string OrderTradesEndpoint = "order/orders/{}/matchresults"; - private const string SymbolTradesEndpoint = "order/matchresults"; - private const string HistoryOrdersEndpoint = "order/history"; - - private readonly HuobiRestClientSpotApi _baseClient; - - internal HuobiRestClientSpotApiTrading(HuobiRestClientSpotApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task> PlaceOrderAsync(long accountId, string symbol, Enums.OrderSide side, Enums.OrderType type, decimal quantity, decimal? price = null, string? clientOrderId = null, SourceType? source = null, decimal? stopPrice = null, Operator? stopOperator = null, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - if (type == Enums.OrderType.StopLimit) - throw new ArgumentException("Stop limit orders not supported by API"); - - var orderType = JsonConvert.SerializeObject(side, new OrderSideConverter(false)) + "-" + JsonConvert.SerializeObject(type, new OrderTypeConverter(false)); - - var parameters = new Dictionary - { - { "account-id", accountId }, - { "amount", quantity }, - { "symbol", symbol }, - { "type", orderType } - }; - - clientOrderId = clientOrderId ?? ExchangeHelpers.AppendRandomString(_baseClient._brokerId, 64); - - parameters.AddOptionalParameter("client-order-id", clientOrderId); - parameters.AddOptionalParameter("source", source == null ? null : JsonConvert.SerializeObject(source, new SourceTypeConverter(false))); - parameters.AddOptionalParameter("stop-price", stopPrice); - parameters.AddOptionalParameter("operator", stopOperator == null ? null : JsonConvert.SerializeObject(stopOperator, new OperatorConverter(false))); - - // If precision of the symbol = 1 (eg has to use whole amounts, 1,2,3 etc) Huobi doesn't except the .0 postfix (1.0) for amount - // Issue at the Huobi side - if (quantity % 1 == 0) - parameters["amount"] = quantity.ToString(CultureInfo.InvariantCulture); - - parameters.AddOptionalParameter("price", price); - var result = await _baseClient.SendHuobiRequest(_baseClient.GetUrl(PlaceOrderEndpoint, "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - if (result) - _baseClient.InvokeOrderPlaced(new OrderId { SourceObject = result.Data, Id = result.Data.ToString(CultureInfo.InvariantCulture) }); - return result; - } - - /// - public async Task>> GetOpenOrdersAsync(long? accountId = null, string? symbol = null, Enums.OrderSide? side = null, int? limit = null, CancellationToken ct = default) - { - symbol = symbol?.ValidateHuobiSymbol(); - - var parameters = new Dictionary(); - parameters.AddOptionalParameter("account-id", accountId); - parameters.AddOptionalParameter("symbol", symbol); - parameters.AddOptionalParameter("side", side == null ? null : JsonConvert.SerializeObject(side, new OrderSideConverter(false))); - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(OpenOrdersEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelOrderAsync(long orderId, CancellationToken ct = default) - { - var result = await _baseClient.SendHuobiRequest(_baseClient.GetUrl(CancelOrderEndpoint.FillPathParameters(orderId.ToString(CultureInfo.InvariantCulture)), "1"), HttpMethod.Post, ct, signed: true).ConfigureAwait(false); - if (result) - _baseClient.InvokeOrderCanceled(new OrderId { SourceObject = result.Data, Id = result.Data.ToString(CultureInfo.InvariantCulture) }); - return result; - } - - /// - public async Task> CancelOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "client-order-id", clientOrderId } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(CancelOrderByClientOrderIdEndpoint, "1"), HttpMethod.Post, ct, parameters: parameters, signed: true).ConfigureAwait(false); - } - - /// - public async Task> CancelOrdersAsync(IEnumerable? orderIds = null, IEnumerable? clientOrderIds = null, CancellationToken ct = default) - { - if (orderIds == null && clientOrderIds == null) - throw new ArgumentException("Either orderIds or clientOrderIds should be provided"); - - var parameters = new Dictionary(); - parameters.AddOptionalParameter("order-ids", orderIds?.Select(s => s.ToString(CultureInfo.InvariantCulture))); - parameters.AddOptionalParameter("client-order-ids", clientOrderIds?.Select(s => s.ToString(CultureInfo.InvariantCulture))); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(CancelOrdersEndpoint, "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelOrdersByCriteriaAsync(long? accountId = null, IEnumerable? symbols = null, Enums.OrderSide? side = null, int? limit = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("account-id", accountId?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("symbol", symbols == null ? null : string.Join(",", symbols)); - parameters.AddOptionalParameter("side", side == null ? null : JsonConvert.SerializeObject(side, new OrderSideConverter(false))); - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(CancelOrdersByCriteriaEndpoint, "1"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetOrderAsync(long orderId, CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(OrderInfoEndpoint.FillPathParameters(orderId.ToString(CultureInfo.InvariantCulture)), "1"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - } - - /// - public async Task> GetOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "clientOrderId", clientOrderId } - }; - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl(ClientOrderInfoEndpoint, "1"), HttpMethod.Get, ct, parameters: parameters, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetOrderTradesAsync(long orderId, CancellationToken ct = default) - { - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(OrderTradesEndpoint.FillPathParameters(orderId.ToString(CultureInfo.InvariantCulture)), "1"), HttpMethod.Get, ct, signed: true).ConfigureAwait(false); - } - - /// - public async Task>> GetClosedOrdersAsync(string symbol, IEnumerable? states = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) - { - symbol = symbol.ValidateHuobiSymbol(); - - states ??= new OrderState[] { OrderState.Filled, OrderState.Canceled, OrderState.PartiallyCanceled }; - - var stateConverter = new OrderStateConverter(false); - var typeConverter = new OrderTypeConverter(false); - var parameters = new Dictionary - { - { "states", string.Join(",", states.Select(s => JsonConvert.SerializeObject(s, stateConverter))) } - }; - parameters.AddOptionalParameter("symbol", symbol); - parameters.AddOptionalParameter("start-date", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end-date", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("types", types == null ? null : string.Join(",", types.Select(s => JsonConvert.SerializeObject(s, typeConverter)))); - parameters.AddOptionalParameter("from", fromId); - parameters.AddOptionalParameter("direct", direction == null ? null : JsonConvert.SerializeObject(direction, new FilterDirectionConverter(false))); - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(OrdersEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetUserTradesAsync(IEnumerable? states = null, string? symbol = null, IEnumerable? types = null, DateTime? startTime = null, DateTime? endTime = null, long? fromId = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) - { - symbol = symbol?.ValidateHuobiSymbol(); - var stateConverter = new OrderStateConverter(false); - var typeConverter = new OrderTypeConverter(false); - var parameters = new Dictionary(); - parameters.AddOptionalParameter("states", states == null ? null : string.Join(",", states.Select(s => JsonConvert.SerializeObject(s, stateConverter)))); - parameters.AddOptionalParameter("symbol", symbol); - parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("types", types == null ? null : string.Join(",", types.Select(s => JsonConvert.SerializeObject(s, typeConverter)))); - parameters.AddOptionalParameter("from", fromId); - parameters.AddOptionalParameter("direct", direction == null ? null : JsonConvert.SerializeObject(direction, new FilterDirectionConverter(false))); - parameters.AddOptionalParameter("size", limit); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(SymbolTradesEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetHistoricalOrdersAsync(string? symbol = null, DateTime? startTime = null, DateTime? endTime = null, FilterDirection? direction = null, int? limit = null, CancellationToken ct = default) - { - symbol = symbol?.ValidateHuobiSymbol(); - var parameters = new Dictionary(); - parameters.AddOptionalParameter("symbol", symbol); - parameters.AddOptionalParameter("start-time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end-time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("direct", direction == null ? null : JsonConvert.SerializeObject(direction, new FilterDirectionConverter(false))); - parameters.AddOptionalParameter("size", limit); - - var result = await _baseClient.SendHuobiRequest>(_baseClient.GetUrl(HistoryOrdersEndpoint, "1"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - if (!result) - return result.AsError>(result.Error!); - - return result; - } - - /// - public async Task> PlaceConditionalOrderAsync( - long accountId, - string symbol, - OrderSide side, - ConditionalOrderType type, - decimal stopPrice, - decimal? quantity = null, - decimal? price = null, - decimal? quoteQuantity = null, - decimal? trailingRate = null, - TimeInForce? timeInForce = null, - string? clientOrderId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "accountId", accountId }, - { "symbol", symbol }, - { "orderSide", EnumConverter.GetString(side) }, - { "orderType", EnumConverter.GetString(type) }, - { "clientOrderId", clientOrderId ?? Guid.NewGuid().ToString() }, - { "stopPrice", stopPrice.ToString(CultureInfo.InvariantCulture) }, - }; - - parameters.AddOptionalParameter("orderPrice", price?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("orderSize", quantity?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("orderValue", quoteQuantity?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("timeInForce", EnumConverter.GetString(timeInForce)); - parameters.AddOptionalParameter("trailingRate", trailingRate?.ToString(CultureInfo.InvariantCulture)); - - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl("algo-orders", "2"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelConditionalOrdersAsync(IEnumerable clientOrderIds, CancellationToken ct = default) - { - var parameters = new Dictionary - { - { "clientOrderIds", clientOrderIds } - }; - - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl("algo-orders/cancellation", "2"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetOpenConditionalOrdersAsync(long? accountId = null, string? symbol = null, OrderSide? side = null, ConditionalOrderType? type = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("accountId", accountId); - parameters.AddOptionalParameter("symbol", symbol); - parameters.AddOptionalParameter("orderSide", EnumConverter.GetString(side)); - parameters.AddOptionalParameter("orderType", EnumConverter.GetString(type)); - parameters.AddOptionalParameter("sort", sort); - parameters.AddOptionalParameter("limit", limit); - parameters.AddOptionalParameter("fromId", fromId); - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl("algo-orders/opening", "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetClosedConditionalOrdersAsync( - string symbol, - ConditionalOrderStatus status, - long? accountId = null, - OrderSide? side = null, - ConditionalOrderType? type = null, - DateTime? startTime = null, - DateTime? endTime = null, - string? sort = null, - int? limit = null, - long? fromId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "symbol", symbol }, - { "orderStatus", EnumConverter.GetString(status) } - }; - parameters.AddOptionalParameter("accountId", accountId); - parameters.AddOptionalParameter("orderSide", EnumConverter.GetString(side)); - parameters.AddOptionalParameter("orderType", EnumConverter.GetString(type)); - parameters.AddOptionalParameter("startTime", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("endTime", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("sort", sort); - parameters.AddOptionalParameter("limit", limit); - parameters.AddOptionalParameter("fromId", fromId); - return await _baseClient.SendHuobiV2Request>(_baseClient.GetUrl("algo-orders/history", "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetConditionalOrderAsync(string clientOrderId, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "clientOrderId", clientOrderId } - }; - return await _baseClient.SendHuobiV2Request(_baseClient.GetUrl("algo-orders/specific", "2"), HttpMethod.Get, ct, parameters, true).ConfigureAwait(false); - } - } -} diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs deleted file mode 100644 index cf533d75..00000000 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApi.cs +++ /dev/null @@ -1,145 +0,0 @@ -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Clients; -using CryptoExchange.Net.CommonObjects; -using CryptoExchange.Net.Converters.MessageParsing; -using CryptoExchange.Net.Objects; -using Huobi.Net.Clients.UsdtMarginSwapApi; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Options; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Clients.FuturesApi -{ - /// - internal class HuobiRestClientUsdtMarginSwapApi : RestApiClient, IHuobiRestClientUsdtMarginSwapApi - { - /// - public new HuobiRestOptions ClientOptions => (HuobiRestOptions)base.ClientOptions; - - internal static TimeSyncState _timeSyncState = new TimeSyncState("Usdt Margin Swap Api"); - - /// - /// Event triggered when an order is placed via this client - /// - public event Action? OnOrderPlaced; - /// - /// Event triggered when an order is canceled via this client - /// - public event Action? OnOrderCanceled; - - /// - public string ExchangeName => "Huobi"; - - internal readonly string _brokerId; - - #region Api clients - - /// - public IHuobiRestClientUsdtMarginSwapApiAccount Account { get; } - /// - public IHuobiRestClientUsdtMarginSwapApiExchangeData ExchangeData { get; } - /// - public IHuobiRestClientUsdtMarginSwapApiTrading Trading { get; } - - #endregion - - #region constructor/destructor - internal HuobiRestClientUsdtMarginSwapApi(ILogger log, HttpClient? httpClient, HuobiRestOptions options) - : base(log, httpClient, options.Environment.UsdtMarginSwapRestBaseAddress, options, options.UsdtMarginSwapOptions) - { - Account = new HuobiRestClientUsdtMarginSwapApiAccount(this); - ExchangeData = new HuobiRestClientUsdtMarginSwapApiExchangeData(this); - Trading = new HuobiRestClientUsdtMarginSwapApiTrading(this); - - _brokerId = !string.IsNullOrEmpty(options.BrokerId) ? options.BrokerId! : "AA1ef14811"; - } - #endregion - - /// - public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}-{quoteAsset.ToUpperInvariant()}"; - - /// - protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) - => new HuobiAuthenticationProvider(credentials, ClientOptions.SignPublicRequests); - - /// - /// Construct url - /// - /// - /// - /// - internal Uri GetUrl(string endpoint, string? version = null) - { - if (version == null) - return new Uri(BaseAddress.AppendPath(endpoint)); - return new Uri(BaseAddress.AppendPath($"v{version}", endpoint)); - } - - internal async Task> SendTimestampRequestAsync(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) - { - var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); - if (!result || result.Data == null) - return result.AsError(result.Error!); - - return result.As(result.Data.Timestamp); - } - - - internal async Task> SendHuobiRequest(Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary? parameters = null, bool signed = false) - { - var result = await SendRequestAsync>(uri, method, cancellationToken, parameters, signed, requestWeight: 0).ConfigureAwait(false); - if (!result || result.Data == null) - return result.AsError(result.Error!); - - if (result.Data.ErrorCode != null) - return result.AsError(new ServerError(result.Data.ErrorCode, result.Data.ErrorMessage)); - - return result.As(result.Data.Data); - } - - /// - protected override Error ParseErrorResponse(int httpStatusCode, IEnumerable>> responseHeaders, IMessageAccessor accessor) - { - if (!accessor.IsJson) - return new ServerError(accessor.GetOriginalString()); - - var code = accessor.GetValue(MessagePath.Get().Property("err-code")); - var msg = accessor.GetValue(MessagePath.Get().Property("err-msg")); - - if (code == null || msg == null) - return new ServerError(accessor.GetOriginalString()); - - - return new ServerError($"{code}, {msg}"); - } - - internal void InvokeOrderPlaced(OrderId id) - { - OnOrderPlaced?.Invoke(id); - } - - internal void InvokeOrderCanceled(OrderId id) - { - OnOrderCanceled?.Invoke(id); - } - - /// - protected override Task> GetServerTimestampAsync() - => ExchangeData.GetServerTimeAsync(); - - /// - public override TimeSyncInfo? GetTimeSyncInfo() - => new TimeSyncInfo(_logger, (ApiOptions.AutoTimestamp ?? ClientOptions.AutoTimestamp), (ApiOptions.TimestampRecalculationInterval ?? ClientOptions.TimestampRecalculationInterval), _timeSyncState); - - /// - public override TimeSpan? GetTimeOffset() - => _timeSyncState.TimeOffset; - } -} diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs deleted file mode 100644 index e20332d4..00000000 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiAccount.cs +++ /dev/null @@ -1,254 +0,0 @@ -using CryptoExchange.Net.Objects; -using CryptoExchange.Net; -using Huobi.Net.Clients.FuturesApi; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using System.Threading; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Linq; -using System.Globalization; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; - -namespace Huobi.Net.Clients.UsdtMarginSwapApi -{ - /// - internal class HuobiRestClientUsdtMarginSwapApiAccount : IHuobiRestClientUsdtMarginSwapApiAccount - { - private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - - internal HuobiRestClientUsdtMarginSwapApiAccount(HuobiRestClientUsdtMarginSwapApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task>> GetAssetValuationAsync(string? asset = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("valuation_asset", asset); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_balance_valuation"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginAccountInfoAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_account_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginAccountInfoAsync(string? marginAccount = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("margin_account", marginAccount); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_account_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_position_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_position_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginAssetAndPositionsAsync(string contractCode, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_account_position_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginAssetAndPositionsAsync(string marginAccount, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_account_position_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> SetSubAccountsTradingPermissionsAsync(IEnumerable subAccountUids, bool enabled, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "sub_uid", string.Join(",", subAccountUids) }, - { "sub_auth", enabled ? "1": "0" } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_sub_auth"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginSubAccountsAssetsAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_sub_account_list"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginSubAccountsAssetsAsync(string? marginAccount = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("margin_account", marginAccount); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_sub_account_list"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetFinancialRecordsAsync(string marginAccount, string? contractCode = null, IEnumerable? types = null, DateTime? createDate = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount } - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("type", types == null ? null : string.Join(",", types.Select(EnumConverter.GetString))); - parameters.AddOptionalParameter("create_date", DateTimeConverter.ConvertToMilliseconds(createDate)); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_financial_record"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetIsolatedMarginSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-api/v1/swap_user_settlement_records"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginSettlementRecordsAsync(string marginAccount, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount } - }; - parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-api/v1/swap_cross_user_settlement_records"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginAvailableLeverageAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_available_level_rate"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginAvailableLeverageAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_available_level_rate"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetTradingFeesAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_fee"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferMasterSubAsync(string subUid, string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, MasterSubTransferType type, long? clientOrderId = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "sub_uid", subUid }, - { "asset", asset }, - { "from_margin_account", fromMarginAccount }, - { "to_margin_account", toMarginAccount }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, - { "type", type == MasterSubTransferType.SubToMaster ? "sub_to_master": "master_to_sub" }, - }; - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_master_sub_transfer"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetMasterSubTransferRecordsAsync(string marginAccount, int daysInHistory, MasterSubTransferType? type = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount }, - { "create_date", daysInHistory } - }; - parameters.AddOptionalParameter("transfer_type", EnumConverter.GetString(type)); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_master_sub_transfer_record"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> TransferMarginAccountsAsync(string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, long? clientOrderId = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "asset", asset }, - { "from_margin_account", fromMarginAccount }, - { "to_margin_account", toMarginAccount }, - { "amount", quantity.ToString(CultureInfo.InvariantCulture) }, - }; - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_transfer_inner"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> ModifyIsolatedMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount }, - { "position_mode", EnumConverter.GetString(positionMode) }, - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_switch_position_mode"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> ModifyCrossMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "margin_account", marginAccount }, - { "position_mode", EnumConverter.GetString(positionMode) }, - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_switch_position_mode"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - } -} diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs deleted file mode 100644 index b814de03..00000000 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiExchangeData.cs +++ /dev/null @@ -1,356 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Converters; -using CryptoExchange.Net.Objects; -using Huobi.Net.Clients.FuturesApi; -using Huobi.Net.Enums; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Clients.UsdtMarginSwapApi -{ - /// - internal class HuobiRestClientUsdtMarginSwapApiExchangeData : IHuobiRestClientUsdtMarginSwapApiExchangeData - { - private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - - internal HuobiRestClientUsdtMarginSwapApiExchangeData(HuobiRestClientUsdtMarginSwapApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task> GetServerTimeAsync(CancellationToken ct = default) - { - return await _baseClient.SendTimestampRequestAsync(_baseClient.GetUrl("api/v1/timestamp"), HttpMethod.Get, ct).ConfigureAwait(false); - } - - /// - public async Task>> GetContractInfoAsync(string? contractCode = null, MarginMode? supportMarginMode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("support_margin_mode", supportMarginMode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-api/v1/swap_contract_info"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetSwapIndexPriceAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-api/v1/swap_index"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetSwapPriceLimitationAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-api/v1/swap_price_limit"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetSwapOpenInterestAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-api/v1/swap_open_interest"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetOrderBookAsync(string contractCode, string step, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "type", step }, - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-ex/market/depth"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetBestOfferAsync(string? contractCode = null, BusinessType? type = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(type)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-ex/market/bbo"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetKlinesAsync(string contractCode, KlineInterval interval, int? limit = null, DateTime? from = null, DateTime? to = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "period", EnumConverter.GetString(interval) } - }; - parameters.AddOptionalParameter("size", limit); - parameters.AddOptionalParameter("from", DateTimeConverter.ConvertToSeconds(from)); - parameters.AddOptionalParameter("to", DateTimeConverter.ConvertToSeconds(to)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-ex/market/history/kline"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetMarketDataAsync(string contractCode, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-ex/market/detail/merged"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetMarketDatasAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("linear-swap-ex/market/detail/batch_merged"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetLastTradesAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - var result = await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-ex/market/trade"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - return result.As(result.Data?.Data?.First()!); - } - - /// - public async Task>> GetRecentTradesAsync(string contractCode, int limit, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "size", limit } - }; - var result = await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-ex/market/history/trade"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - return result.As>(result.Data?.SelectMany(d => d.Data)!); - } - - /// - public async Task>> GetSwapRiskInfoAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_risk_info"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetInsuranceFundHistoryAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("linear-swap-api/v1/swap_insurance_fund"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginAdjustFactorInfoAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_adjustfactor"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginAdjustFactorInfoAsync(string? contractCode = null, string? asset = null, ContractType? type = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", asset); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(type)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_adjustfactor"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetOpenInterestAsync(InterestPeriod period, Unit unit, string? contractCode = null, string? symbol = null, ContractType? type = null, int? limit = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "period", EnumConverter.GetString(period) }, - { "amount_type", EnumConverter.GetString(unit) }, - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("size", limit); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(type)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_his_open_interest"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginTieredInfoAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_ladder_margin"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossTieredMarginInfoAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_ladder_margin"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedStatusAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_api_state"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginTransferStatusAsync(string? marginAccount = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("margin_account", marginAccount); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_transfer_state"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginTradeStatusAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_trade_state"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetLiquidationOrdersAsync(int createDate, LiquidationTradeType tradeType, string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "create_date", createDate }, - { "trade_type", EnumConverter.GetString(tradeType) }, - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_liquidation_orders"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetHistoricalSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("start_time", DateTimeConverter.ConvertToMilliseconds(startTime)); - parameters.AddOptionalParameter("end_time", DateTimeConverter.ConvertToMilliseconds(endTime)); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_settlement_records"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetFundingRateAsync(string contractCode, CancellationToken ct = default) - { - var parameters = new Dictionary() { - { "contract_code", contractCode } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_funding_rate"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetFundingRatesAsync(string? contractCode = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_batch_funding_rate"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task> GetHistoricalFundingRatesAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_historical_funding_rate"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetPremiumIndexKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "period", EnumConverter.GetString(interval) }, - { "size", limit } - }; - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/index/market/history/linear_swap_premium_index_kline"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetEstimatedFundingRateKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "period", EnumConverter.GetString(interval) }, - { "size", limit } - }; - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/index/market/history/linear_swap_estimated_rate_kline"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetBasisDataAsync(string contractCode, KlineInterval interval, int limit, string? basisPriceType = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "period", EnumConverter.GetString(interval) }, - { "size", limit } - }; - parameters.AddOptionalParameter("basis_price_type", basisPriceType); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/index/market/history/linear_swap_basis"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - - /// - public async Task>> GetEstimatedSettlementPriceAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("business_type", EnumConverter.GetString(businessType)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_estimated_settlement_price"), HttpMethod.Get, ct, parameters).ConfigureAwait(false); - } - } -} diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs deleted file mode 100644 index 91c1f511..00000000 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiRestClientUsdtMarginSwapApiTrading.cs +++ /dev/null @@ -1,372 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Converters; -using CryptoExchange.Net.Objects; -using Huobi.Net.Clients.FuturesApi; -using Huobi.Net.Enums; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System.Collections.Generic; -using System.Globalization; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Clients.UsdtMarginSwapApi -{ - /// - internal class HuobiRestClientUsdtMarginSwapApiTrading : IHuobiRestClientUsdtMarginSwapApiTrading - { - private readonly HuobiRestClientUsdtMarginSwapApi _baseClient; - - internal HuobiRestClientUsdtMarginSwapApiTrading(HuobiRestClientUsdtMarginSwapApi baseClient) - { - _baseClient = baseClient; - } - - /// - public async Task> PlaceIsolatedMarginOrderAsync( - string contractCode, - decimal quantity, - OrderSide side, - int leverageRate, - decimal? price = null, - Offset? offset = null, - OrderPriceType? orderPriceType = null, - decimal? takeProfitTriggerPrice = null, - decimal? takeProfitOrderPrice = null, - OrderPriceType? takeProfitOrderPriceType = null, - decimal? stopLossTriggerPrice = null, - decimal? stopLossOrderPrice = null, - OrderPriceType? stopLossOrderPriceType = null, - bool? reduceOnly = null, - long? clientOrderId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "volume", quantity.ToString(CultureInfo.InvariantCulture) }, - { "direction", EnumConverter.GetString(side) }, - { "lever_rate", leverageRate }, - { "channel_code", _baseClient._brokerId } - }; - parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); - parameters.AddOptionalParameter("order_price_type", EnumConverter.GetString(orderPriceType)); - parameters.AddOptionalParameter("tp_trigger_price", takeProfitTriggerPrice); - parameters.AddOptionalParameter("tp_order_price", takeProfitOrderPrice); - parameters.AddOptionalParameter("tp_order_price_type", EnumConverter.GetString(takeProfitOrderPriceType)); - parameters.AddOptionalParameter("sl_trigger_price", stopLossTriggerPrice); - parameters.AddOptionalParameter("sl_order_price", stopLossOrderPrice); - parameters.AddOptionalParameter("sl_order_price_type", EnumConverter.GetString(stopLossOrderPriceType)); - parameters.AddOptionalParameter("reduce_only", reduceOnly == null ? null : reduceOnly.Value ? "1" : "0"); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_order"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> PlaceCrossMarginOrderAsync( - decimal quantity, - OrderSide side, - int leverageRate, - string? contractCode = null, - string? symbol = null, - ContractType? contractType = null, - decimal? price = null, - Offset? offset = null, - OrderPriceType? orderPriceType = null, - decimal? takeProfitTriggerPrice = null, - decimal? takeProfitOrderPrice = null, - OrderPriceType? takeProfitOrderPriceType = null, - decimal? stopLossTriggerPrice = null, - decimal? stopLossOrderPrice = null, - OrderPriceType? stopLossOrderPriceType = null, - bool? reduceOnly = null, - long? clientOrderId = null, - CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "volume", quantity.ToString(CultureInfo.InvariantCulture) }, - { "direction", EnumConverter.GetString(side) }, - { "lever_rate", leverageRate }, - { "channel_code", _baseClient._brokerId } - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture)); - parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); - parameters.AddOptionalParameter("order_price_type", EnumConverter.GetString(orderPriceType)); - parameters.AddOptionalParameter("tp_trigger_price", takeProfitTriggerPrice); - parameters.AddOptionalParameter("tp_order_price", takeProfitOrderPrice); - parameters.AddOptionalParameter("tp_order_price_type", EnumConverter.GetString(takeProfitOrderPriceType)); - parameters.AddOptionalParameter("sl_trigger_price", stopLossTriggerPrice); - parameters.AddOptionalParameter("sl_order_price", stopLossOrderPrice); - parameters.AddOptionalParameter("sl_order_price_type", EnumConverter.GetString(stopLossOrderPriceType)); - parameters.AddOptionalParameter("reduce_only", reduceOnly == null ? null : reduceOnly.Value ? "1" : "0"); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_order"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("order_id", orderId); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cancel"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderId, IEnumerable clientOrderId, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "order_id", string.Join(",", orderId) }, - { "client_order_id", string.Join(",", clientOrderId) } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cancel"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelCrossMarginOrderAsync(long? orderId = null, long? clientOrderId = null, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("order_id", orderId); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_cancel"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelCrossMarginOrdersAsync(IEnumerable orderId, IEnumerable clientOrderId, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "order_id", string.Join(",", orderId) }, - { "client_order_id", string.Join(",", clientOrderId) } - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_cancel"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelAllIsolatedMarginOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("direction", EnumConverter.GetString(side)); - parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cancelall"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> CancelAllCrossMarginOrdersAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - parameters.AddOptionalParameter("direction", EnumConverter.GetString(side)); - parameters.AddOptionalParameter("offset", EnumConverter.GetString(offset)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_cancelall"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> ChangeIsolatedMarginLeverageAsync(string contractCode, int leverageRate, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "lever_rate", leverageRate }, - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_switch_lever_rate"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> ChangeCrossMarginLeverageAsync(int leverageRate, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "lever_rate", leverageRate }, - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("contract_type", EnumConverter.GetString(contractType)); - - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_switch_lever_rate"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("order_id", orderId); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_order_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderIds, IEnumerable clientOrderIds, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("order_id", string.Join(",", orderIds)); - parameters.AddOptionalParameter("client_order_id", string.Join(",", clientOrderIds)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_order_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginOrderAsync(string? contractCode = null, string? symbol = null, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("order_id", orderId); - parameters.AddOptionalParameter("client_order_id", clientOrderId); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_order_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task>> GetCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? symbol = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("order_id", string.Join(",", orderIds)); - parameters.AddOptionalParameter("client_order_id", string.Join(",", clientOrderIds)); - return await _baseClient.SendHuobiRequest>(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_order_info"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetIsolatedMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "order_id", orderId } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_order_detail"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "order_id", orderId } - }; - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_order_detail"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetIsolatedMarginOpenOrdersAsync(string contractCode, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - parameters.AddOptionalParameter("sort_by", sortBy); - parameters.AddOptionalParameter("trade_type", EnumConverter.GetString(tradeType)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_openorders"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginOpenOrdersAsync(string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default) - { - var parameters = new Dictionary(); - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - parameters.AddOptionalParameter("sort_by", sortBy); - parameters.AddOptionalParameter("trade_type", EnumConverter.GetString(tradeType)); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_openorders"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetIsolatedMarginClosedOrdersAsync(string contractCode, MarginTradeType tradeType, bool allOrders, int daysInHistory, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "trade_type", EnumConverter.GetString(tradeType) }, - { "type", allOrders ? "1": "2" }, - { "create_date", daysInHistory }, - { "status", "0" } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - parameters.AddOptionalParameter("sort_by", sortBy); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_hisorders"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginClosedOrdersAsync(MarginTradeType tradeType, bool allOrders, int daysInHistory, string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "trade_type", EnumConverter.GetString(tradeType) }, - { "type", allOrders ? "1": "2" }, - { "create_date", daysInHistory }, - { "status", "0" } - }; - parameters.AddOptionalParameter("contract_code", contractCode); - parameters.AddOptionalParameter("pair", symbol); - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - parameters.AddOptionalParameter("sort_by", sortBy); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_hisorders"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetIsolatedMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, int daysInHistory, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "trade_type", EnumConverter.GetString(tradeType) }, - { "create_date", daysInHistory }, - { "status", "0" } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_matchresults"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - - /// - public async Task> GetCrossMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, int daysInHistory, int? page = null, int? pageSize = null, CancellationToken ct = default) - { - var parameters = new Dictionary() - { - { "contract_code", contractCode }, - { "trade_type", EnumConverter.GetString(tradeType) }, - { "create_date", daysInHistory }, - { "status", "0" } - }; - parameters.AddOptionalParameter("page_index", page); - parameters.AddOptionalParameter("page_size", pageSize); - return await _baseClient.SendHuobiRequest(_baseClient.GetUrl("/linear-swap-api/v1/swap_cross_matchresults"), HttpMethod.Post, ct, parameters, true).ConfigureAwait(false); - } - } -} diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs deleted file mode 100644 index 2afde7df..00000000 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System; -using System.IO; -using System.IO.Compression; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Clients; -using CryptoExchange.Net.Converters.MessageParsing; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.Objects.Options; -using Huobi.Net.Objects.Sockets.Subscriptions; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; - -namespace Huobi.Net.Clients.SpotApi -{ - /// - internal class HuobiSocketClientUsdtMarginSwapApi : SocketApiClient, IHuobiSocketClientUsdtMarginSwapApi - { - private static readonly MessagePath _idPath = MessagePath.Get().Property("id"); - private static readonly MessagePath _actionPath = MessagePath.Get().Property("action"); - private static readonly MessagePath _channelPath = MessagePath.Get().Property("ch"); - private static readonly MessagePath _pingPath = MessagePath.Get().Property("ping"); - - #region ctor - internal HuobiSocketClientUsdtMarginSwapApi(ILogger logger, HuobiSocketOptions options) - : base(logger, options.Environment.UsdtMarginSwapSocketBaseAddress, options, options.UsdtMarginSwapOptions) - { - KeepAliveInterval = TimeSpan.Zero; - - AddSystemSubscription(new HuobiPingSubscription(_logger)); - } - - #endregion - - /// - public override string FormatSymbol(string baseAsset, string quoteAsset) => $"{baseAsset.ToUpperInvariant()}-{quoteAsset.ToUpperInvariant()}"; - - /// - public override ReadOnlyMemory PreprocessStreamMessage(SocketConnection connection, WebSocketMessageType type, ReadOnlyMemory data) - { - if (type != WebSocketMessageType.Binary) - return data; - - return data.DecompressGzip(); - } - - /// - public override string? GetListenerIdentifier(IMessageAccessor message) - { - var id = message.GetValue(_idPath); - if (id != null) - return id; - - var ping = message.GetValue(_pingPath); - if (ping != null) - return "pingV3"; - - var channel = message.GetValue(_channelPath); - var action = message.GetValue(_actionPath); - if (action != null && action != "push") - return action + channel; - - return channel; - } - - /// - protected override AuthenticationProvider CreateAuthenticationProvider(ApiCredentials credentials) - => new HuobiAuthenticationProvider(credentials, false); - - /// - public async Task> SubscribeToKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.kline.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToOrderBookUpdatesAsync(string contractCode, int mergeStep, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.depth.step" + mergeStep, x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToIncrementalOrderBookUpdatesAsync(string contractCode, bool snapshot, int limit, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.depth.size_{limit}.high_freq", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToSymbolTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.detail", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToBestOfferUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.bbo", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToTradeUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.trade.detail", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("linear-swap-ws"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.index.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToPremiumIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.premium_index.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToEstimatedFundingRateKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.estimated_rate.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToBasisUpdatesAsync(string contractCode, KlineInterval period, string priceType, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.basis.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}.{priceType}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); - } - - /// - public async Task> SubscribeToMarkPriceKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default) - { - var subscription = new HuobiSubscription(_logger, $"market.{contractCode.ToUpperInvariant()}.mark_price.{JsonConvert.SerializeObject(period, new PeriodConverter(false))}", x => onData(x.WithSymbol(contractCode)), false); - return await SubscribeAsync(BaseAddress.AppendPath("ws_index"), subscription, ct).ConfigureAwait(false); - } - - //// WIP - - /////// - ////public async Task> SubscribeToIsolatedMarginOrderUpdatesAsync(Action> onData, CancellationToken ct = default) - ////{ - //// var request = new HuobiSocketRequest2( - //// "sub", - //// NextId().ToString(CultureInfo.InvariantCulture), - //// $"orders.*"); - //// var internalHandler = new Action>(data => onData(data.As(data.Data, data.Data.ContractCode))); - //// return await SubscribeAsync( _baseAddressAuthenticated, request, null, true, internalHandler, ct).ConfigureAwait(false); - ////} - - /////// - ////public async Task> SubscribeToIsolatedMarginOrderUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) - ////{ - //// var request = new HuobiSocketRequest2( - //// "sub", - //// NextId().ToString(CultureInfo.InvariantCulture), - //// $"orders.{contractCode}"); - //// var internalHandler = new Action>(data => onData(data.As(data.Data, contractCode))); - //// return await SubscribeAsync( _baseAddressAuthenticated, request, null, true, internalHandler, ct).ConfigureAwait(false); - ////} - - /////// - ////public async Task> SubscribeToCrossMarginOrderUpdatesAsync(Action> onData, CancellationToken ct = default) - ////{ - //// var request = new HuobiSocketRequest2( - //// "sub", - //// NextId().ToString(CultureInfo.InvariantCulture), - //// $"orders_cross.*"); - //// var internalHandler = new Action>(data => onData(data.As(data.Data, data.Data.ContractCode))); - //// return await SubscribeAsync(_baseAddressAuthenticated, request, null, true, internalHandler, ct).ConfigureAwait(false); - ////} - - /////// - ////public async Task> SubscribeToCrossMarginOrderUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default) - ////{ - //// var request = new HuobiSocketRequest2( - //// "sub", - //// NextId().ToString(CultureInfo.InvariantCulture), - //// $"orders_cross.{contractCode}"); - //// var internalHandler = new Action>(data => onData(data.As(data.Data, contractCode))); - //// return await SubscribeAsync(_baseAddressAuthenticated, request, null, true, internalHandler, ct).ConfigureAwait(false); - ////} - - } -} diff --git a/Huobi.Net/Converters/AccountActivationConverter.cs b/Huobi.Net/Converters/AccountActivationConverter.cs deleted file mode 100644 index 7403bb76..00000000 --- a/Huobi.Net/Converters/AccountActivationConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class AccountActivationConverter : BaseConverter - { - public AccountActivationConverter() : this(true) { } - public AccountActivationConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(AccountActivation.Activated, "activated"), - new KeyValuePair(AccountActivation.Deactivated, "deactivated") - }; - } -} diff --git a/Huobi.Net/Converters/AccountEventConverter.cs b/Huobi.Net/Converters/AccountEventConverter.cs deleted file mode 100644 index 12a6162f..00000000 --- a/Huobi.Net/Converters/AccountEventConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class AccountEventConverter : BaseConverter - { - public AccountEventConverter() : this(true) { } - public AccountEventConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(AccountEventType.OrderPlaced, "order.place"), - new KeyValuePair(AccountEventType.OrderMatched, "order.match"), - new KeyValuePair(AccountEventType.OrderCanceled, "order.cancel"), - new KeyValuePair(AccountEventType.OrderRefunded, "order.refund"), - new KeyValuePair(AccountEventType.OrderFeeRefunded, "order.fee-refund"), - new KeyValuePair(AccountEventType.MarginInterest, "margin.interest"), - new KeyValuePair(AccountEventType.MarginLoan, "margin.loan"), - new KeyValuePair(AccountEventType.MarginRepay, "margin.repay"), - new KeyValuePair(AccountEventType.MarginTransfer, "margin.transfer"), - new KeyValuePair(AccountEventType.Other, "other"), - new KeyValuePair(AccountEventType.Deposit, "deposit"), - new KeyValuePair(AccountEventType.Withdraw, "withdraw") - }; - } -} diff --git a/Huobi.Net/Converters/AccountStateConverter.cs b/Huobi.Net/Converters/AccountStateConverter.cs deleted file mode 100644 index 190ad7cf..00000000 --- a/Huobi.Net/Converters/AccountStateConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class AccountStateConverter : BaseConverter - { - public AccountStateConverter() : this(true) { } - public AccountStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(AccountState.Locked, "lock"), - new KeyValuePair(AccountState.Working, "working") - }; - } -} diff --git a/Huobi.Net/Converters/AccountTypeConverter.cs b/Huobi.Net/Converters/AccountTypeConverter.cs deleted file mode 100644 index c41d2a07..00000000 --- a/Huobi.Net/Converters/AccountTypeConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class AccountTypeConverter : BaseConverter - { - public AccountTypeConverter() : this(true) { } - public AccountTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(AccountType.Margin, "margin"), - new KeyValuePair(AccountType.SuperMargin, "super-margin"), - new KeyValuePair(AccountType.Investment, "investment"), - new KeyValuePair(AccountType.Borrow, "borrow"), - new KeyValuePair(AccountType.Spot, "spot"), - new KeyValuePair(AccountType.Otc, "otc"), - new KeyValuePair(AccountType.Point, "point"), - new KeyValuePair(AccountType.GridTrading, "grid-trading"), - new KeyValuePair(AccountType.DepositEarning, "deposit-earning"), - new KeyValuePair(AccountType.OtcOptions, "otc-options"), - new KeyValuePair(AccountType.Minepool, "minepool"), - new KeyValuePair(AccountType.Etf, "etf"), - new KeyValuePair(AccountType.CryptoLoans, "crypto-loans"), - }; - } -} diff --git a/Huobi.Net/Converters/BalanceTypeConverter.cs b/Huobi.Net/Converters/BalanceTypeConverter.cs deleted file mode 100644 index 91588834..00000000 --- a/Huobi.Net/Converters/BalanceTypeConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class BalanceTypeConverter : BaseConverter - { - public BalanceTypeConverter() : this(true) { } - public BalanceTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(BalanceType.Frozen, "frozen"), - new KeyValuePair(BalanceType.Trade, "trade"), - new KeyValuePair(BalanceType.Loan, "loan"), - new KeyValuePair(BalanceType.Interest, "interest"), - new KeyValuePair(BalanceType.TransferOutAvailable, "transfer-out-available"), - new KeyValuePair(BalanceType.LoanAvailable, "loan-available"), - }; - } -} diff --git a/Huobi.Net/Converters/CurrencyStatusConverter.cs b/Huobi.Net/Converters/CurrencyStatusConverter.cs deleted file mode 100644 index c37b58ec..00000000 --- a/Huobi.Net/Converters/CurrencyStatusConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class CurrencyStatusConverter : BaseConverter - { - public CurrencyStatusConverter() : this(true) { } - public CurrencyStatusConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(CurrencyStatus.Allowed, "allowed"), - new KeyValuePair(CurrencyStatus.Prohibited, "prohibited") - }; - } -} \ No newline at end of file diff --git a/Huobi.Net/Converters/FeeDeductStateConverter.cs b/Huobi.Net/Converters/FeeDeductStateConverter.cs deleted file mode 100644 index 96a4f0ad..00000000 --- a/Huobi.Net/Converters/FeeDeductStateConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class FeeDeductStateConverter : BaseConverter - { - public FeeDeductStateConverter() : this(true) { } - public FeeDeductStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(FeeDeductState.Ongoing, "ongoing"), - new KeyValuePair(FeeDeductState.Done, "done") - }; - } -} diff --git a/Huobi.Net/Converters/FeeTypeConverter.cs b/Huobi.Net/Converters/FeeTypeConverter.cs deleted file mode 100644 index 58985383..00000000 --- a/Huobi.Net/Converters/FeeTypeConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class FeeTypeConverter : BaseConverter - { - public FeeTypeConverter() : this(true) { } - public FeeTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(FeeType.Fixed, "fixed"), - new KeyValuePair(FeeType.Circulated, "circulated"), - new KeyValuePair(FeeType.Ratio, "ratio") - - }; - } -} \ No newline at end of file diff --git a/Huobi.Net/Converters/FilterDirectionConverter.cs b/Huobi.Net/Converters/FilterDirectionConverter.cs deleted file mode 100644 index b9f5c06a..00000000 --- a/Huobi.Net/Converters/FilterDirectionConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class FilterDirectionConverter : BaseConverter - { - public FilterDirectionConverter() : this(true) { } - public FilterDirectionConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(FilterDirection.Next, "next"), - new KeyValuePair(FilterDirection.Previous, "prev") - }; - } -} diff --git a/Huobi.Net/Converters/OperatorConverter.cs b/Huobi.Net/Converters/OperatorConverter.cs deleted file mode 100644 index b3cdb8ff..00000000 --- a/Huobi.Net/Converters/OperatorConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using System.Collections.Generic; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class OperatorConverter : BaseConverter - { - public OperatorConverter() : this(true) { } - public OperatorConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(Operator.LesserThanOrEqual, "lte"), - new KeyValuePair(Operator.GreaterThanOrEqual, "gte") - }; - } -} diff --git a/Huobi.Net/Converters/OrderRoleConverter.cs b/Huobi.Net/Converters/OrderRoleConverter.cs deleted file mode 100644 index eee1327b..00000000 --- a/Huobi.Net/Converters/OrderRoleConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class OrderRoleConverter : BaseConverter - { - public OrderRoleConverter() : this(true) { } - public OrderRoleConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(OrderRole.Maker, "maker"), - new KeyValuePair(OrderRole.Taker, "taker") - }; - } -} diff --git a/Huobi.Net/Converters/OrderSideConverter.cs b/Huobi.Net/Converters/OrderSideConverter.cs deleted file mode 100644 index de7bf557..00000000 --- a/Huobi.Net/Converters/OrderSideConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class OrderSideConverter : BaseConverter - { - public OrderSideConverter() : this(true) { } - public OrderSideConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(OrderSide.Buy, "buy"), - new KeyValuePair(OrderSide.Sell, "sell"), - - new KeyValuePair(OrderSide.Buy, "buy-market"), - new KeyValuePair(OrderSide.Sell, "sell-market"), - new KeyValuePair(OrderSide.Buy, "buy-limit"), - new KeyValuePair(OrderSide.Sell, "sell-limit"), - new KeyValuePair(OrderSide.Buy, "buy-ioc"), - new KeyValuePair(OrderSide.Sell, "sell-ioc"), - new KeyValuePair(OrderSide.Buy, "buy-limit-maker,"), - new KeyValuePair(OrderSide.Sell, "sell-limit-maker"), - new KeyValuePair(OrderSide.Buy, "buy-stop-limit"), - new KeyValuePair(OrderSide.Sell, "sell-stop-limit"), - new KeyValuePair(OrderSide.Buy, "buy-limit-fok"), - new KeyValuePair(OrderSide.Sell, "sell-limit-fok"), - new KeyValuePair(OrderSide.Buy, "buy-stop-limit-fok"), - new KeyValuePair(OrderSide.Sell, "sell-stop-limit-fok"), - new KeyValuePair(OrderSide.Buy, "buy-limit-grid"), - new KeyValuePair(OrderSide.Sell, "sell-limit-grid"), - new KeyValuePair(OrderSide.Buy, "buy-market-grid"), - new KeyValuePair(OrderSide.Sell, "sell-market-grid"), - }; - } -} diff --git a/Huobi.Net/Converters/OrderStateConverter.cs b/Huobi.Net/Converters/OrderStateConverter.cs deleted file mode 100644 index dab8ffd1..00000000 --- a/Huobi.Net/Converters/OrderStateConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class OrderStateConverter : BaseConverter - { - public OrderStateConverter() : this(true) { } - public OrderStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(OrderState.PreSubmitted, "pre-submitted"), - new KeyValuePair(OrderState.Submitted, "submitted"), - new KeyValuePair(OrderState.PartiallyFilled, "partial-filled"), - new KeyValuePair(OrderState.PartiallyCanceled, "partial-canceled"), - new KeyValuePair(OrderState.Filled, "filled"), - new KeyValuePair(OrderState.Canceled, "canceled"), - new KeyValuePair(OrderState.Rejected, "rejected"), - new KeyValuePair(OrderState.Created, "created") - }; - } -} diff --git a/Huobi.Net/Converters/OrderTypeConverter.cs b/Huobi.Net/Converters/OrderTypeConverter.cs deleted file mode 100644 index 1abd79a4..00000000 --- a/Huobi.Net/Converters/OrderTypeConverter.cs +++ /dev/null @@ -1,44 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class OrderTypeConverter : BaseConverter - { - public OrderTypeConverter() : this(true) { } - public OrderTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(OrderType.Limit, "limit"), - new KeyValuePair(OrderType.Market, "market"), - new KeyValuePair(OrderType.IOC, "ioc"), - new KeyValuePair(OrderType.LimitMaker, "limit-maker"), - new KeyValuePair(OrderType.StopLimit, "stop-limit"), - new KeyValuePair(OrderType.FillOrKillLimit, "limit-fok"), - new KeyValuePair(OrderType.FillOrKillStopLimit, "stop-limit-fok"), - - new KeyValuePair(OrderType.Limit, "buy-limit"), - new KeyValuePair(OrderType.Limit, "sell-limit"), - new KeyValuePair(OrderType.Market, "buy-market"), - new KeyValuePair(OrderType.Market, "sell-market"), - new KeyValuePair(OrderType.IOC, "buy-ioc"), - new KeyValuePair(OrderType.IOC, "sell-ioc"), - new KeyValuePair(OrderType.LimitMaker, "buy-limit-maker"), - new KeyValuePair(OrderType.LimitMaker, "sell-limit-maker"), - new KeyValuePair(OrderType.StopLimit, "buy-stop-limit"), - new KeyValuePair(OrderType.StopLimit, "sell-stop-limit"), - - new KeyValuePair(OrderType.FillOrKillLimit, "buy-limit-fok"), - new KeyValuePair(OrderType.FillOrKillLimit, "sell-limit-fok"), - new KeyValuePair(OrderType.FillOrKillStopLimit, "buy-stop-limit-fok"), - new KeyValuePair(OrderType.FillOrKillStopLimit, "sell-stop-limit-fok"), - - new KeyValuePair(OrderType.LimitGrid, "buy-limit-grid"), - new KeyValuePair(OrderType.LimitGrid, "buy-market-grid"), - new KeyValuePair(OrderType.MarketGrid, "sell-market-grid"), - new KeyValuePair(OrderType.MarketGrid, "sell-limit-grid") - }; - } -} diff --git a/Huobi.Net/Converters/PeriodConverter.cs b/Huobi.Net/Converters/PeriodConverter.cs deleted file mode 100644 index 1617ad40..00000000 --- a/Huobi.Net/Converters/PeriodConverter.cs +++ /dev/null @@ -1,26 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class PeriodConverter : BaseConverter - { - public PeriodConverter() : this(true) { } - public PeriodConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(KlineInterval.OneMinute, "1min"), - new KeyValuePair(KlineInterval.FiveMinutes, "5min"), - new KeyValuePair(KlineInterval.FifteenMinutes, "15min"), - new KeyValuePair(KlineInterval.ThirtyMinutes, "30min"), - new KeyValuePair(KlineInterval.OneHour, "60min"), - new KeyValuePair(KlineInterval.FourHours, "4hour"), - new KeyValuePair(KlineInterval.OneDay, "1day"), - new KeyValuePair(KlineInterval.OneWeek, "1week"), - new KeyValuePair(KlineInterval.OneMonth, "1mon"), - new KeyValuePair(KlineInterval.OneYear, "1year") - }; - } -} diff --git a/Huobi.Net/Converters/SortingTypeConverter.cs b/Huobi.Net/Converters/SortingTypeConverter.cs deleted file mode 100644 index 6aa6330b..00000000 --- a/Huobi.Net/Converters/SortingTypeConverter.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class SortingTypeConverter : BaseConverter - { - public SortingTypeConverter() : this(true) { } - - public SortingTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(SortingType.Ascending, "asc"), - new KeyValuePair(SortingType.Descending, "desc") - }; - } -} \ No newline at end of file diff --git a/Huobi.Net/Converters/SourceTypeConverter.cs b/Huobi.Net/Converters/SourceTypeConverter.cs deleted file mode 100644 index ceed7cf4..00000000 --- a/Huobi.Net/Converters/SourceTypeConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using CryptoExchange.Net.Converters; -using System.Collections.Generic; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class SourceTypeConverter : BaseConverter - { - public SourceTypeConverter() : this(true) { } - public SourceTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(SourceType.Spot, "spot-api"), - new KeyValuePair(SourceType.IsolatedMargin, "margin-api"), - new KeyValuePair(SourceType.CrossMargin, "super-margin-api"), - new KeyValuePair(SourceType.C2CMargin, "c2c-margin-api"), - }; - } -} diff --git a/Huobi.Net/Converters/SymbolStateConverter.cs b/Huobi.Net/Converters/SymbolStateConverter.cs deleted file mode 100644 index e397589c..00000000 --- a/Huobi.Net/Converters/SymbolStateConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class SymbolStateConverter : BaseConverter - { - public SymbolStateConverter() : this(true) { } - public SymbolStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(SymbolState.Online, "online"), - new KeyValuePair(SymbolState.Offline, "offline"), - new KeyValuePair(SymbolState.Suspended, "suspend"), - new KeyValuePair(SymbolState.PreOnline, "pre-online") - }; - } -} diff --git a/Huobi.Net/Converters/TransactionTypeConverter.cs b/Huobi.Net/Converters/TransactionTypeConverter.cs deleted file mode 100644 index 1e16c9e3..00000000 --- a/Huobi.Net/Converters/TransactionTypeConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class TransactionTypeConverter : BaseConverter - { - public TransactionTypeConverter() : this(true) { } - public TransactionTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(TransactionType.Trade, "trade"), - new KeyValuePair(TransactionType.Etf, "etf"), - new KeyValuePair(TransactionType.TransactionFee, "transact-fee"), - new KeyValuePair(TransactionType.Deduction, "fee-deduction"), - new KeyValuePair(TransactionType.Transfer, "transfer"), - new KeyValuePair(TransactionType.Credit, "credit"), - new KeyValuePair(TransactionType.Liquidation, "liquidation"), - new KeyValuePair(TransactionType.Interest, "interest"), - new KeyValuePair(TransactionType.Deposit, "deposit"), - new KeyValuePair(TransactionType.Withdraw, "withdraw"), - new KeyValuePair(TransactionType.WithdrawFee, "withdraw-fee"), - new KeyValuePair(TransactionType.Exchange, "exchange"), - new KeyValuePair(TransactionType.Other, "other-types"), - new KeyValuePair(TransactionType.Rebate, "rebate") - }; - } -} \ No newline at end of file diff --git a/Huobi.Net/Converters/TransferTypeConverter.cs b/Huobi.Net/Converters/TransferTypeConverter.cs deleted file mode 100644 index 5b11eeaf..00000000 --- a/Huobi.Net/Converters/TransferTypeConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class TransferTypeConverter : BaseConverter - { - public TransferTypeConverter() : this(true) { } - public TransferTypeConverter(bool useQuotes) : base(useQuotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(TransferType.FromSubAccount, "master-transfer-in"), - new KeyValuePair(TransferType.ToSubAccount, "master-transfer-out"), - new KeyValuePair(TransferType.PointFromSubAccount, "master-point-transfer-in"), - new KeyValuePair(TransferType.PointToSubAccount, "master-point-transfer-out") - }; - } -} diff --git a/Huobi.Net/Converters/UserStateConverter.cs b/Huobi.Net/Converters/UserStateConverter.cs deleted file mode 100644 index 38741142..00000000 --- a/Huobi.Net/Converters/UserStateConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; - -namespace Huobi.Net.Converters -{ - internal class UserStateConverter : BaseConverter - { - public UserStateConverter() : this(true) { } - public UserStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(UserState.Locked, "lock"), - new KeyValuePair(UserState.Normal, "normal") - }; - } -} diff --git a/Huobi.Net/Converters/WithdrawDepositStateConverter.cs b/Huobi.Net/Converters/WithdrawDepositStateConverter.cs deleted file mode 100644 index 782b05f5..00000000 --- a/Huobi.Net/Converters/WithdrawDepositStateConverter.cs +++ /dev/null @@ -1,33 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class WithdrawDepositStateConverter : BaseConverter - { - public WithdrawDepositStateConverter() : this(true) { } - public WithdrawDepositStateConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(WithdrawDepositState.Verifying, "verifying"), - new KeyValuePair(WithdrawDepositState.Failed, "failed"), - new KeyValuePair(WithdrawDepositState.Submitted, "submitted"), - new KeyValuePair(WithdrawDepositState.Reexamine, "reexamine"), - new KeyValuePair(WithdrawDepositState.Canceled, "canceled"), - new KeyValuePair(WithdrawDepositState.Pass, "pass"), - new KeyValuePair(WithdrawDepositState.Reject, "reject"), - new KeyValuePair(WithdrawDepositState.PreTransfer, "pre-transfer"), - new KeyValuePair(WithdrawDepositState.WalletTransfer, "wallet-transfer"), - new KeyValuePair(WithdrawDepositState.WalletReject, "wallet-reject"), - new KeyValuePair(WithdrawDepositState.Confirmed, "confirmed"), - new KeyValuePair(WithdrawDepositState.ConfirmError, "confirm-error"), - new KeyValuePair(WithdrawDepositState.Repealed, "repealed"), - new KeyValuePair(WithdrawDepositState.Unknown, "unknown"), - new KeyValuePair(WithdrawDepositState.Confirming, "confirming"), - new KeyValuePair(WithdrawDepositState.Safe, "safe"), - new KeyValuePair(WithdrawDepositState.Orphan, "orphan"), - }; - } -} diff --git a/Huobi.Net/Converters/WithdrawDepositTypeConverter.cs b/Huobi.Net/Converters/WithdrawDepositTypeConverter.cs deleted file mode 100644 index 9a67f4f8..00000000 --- a/Huobi.Net/Converters/WithdrawDepositTypeConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using System.Collections.Generic; - -namespace Huobi.Net.Converters -{ - internal class WithdrawDepositTypeConverter : BaseConverter - { - public WithdrawDepositTypeConverter() : this(true) { } - public WithdrawDepositTypeConverter(bool quotes) : base(quotes) { } - - protected override List> Mapping => new List> - { - new KeyValuePair(WithdrawDepositType.Deposit, "deposit"), - new KeyValuePair(WithdrawDepositType.Withdraw, "withdraw"), - }; - } -} diff --git a/Huobi.Net/Enums/BalanceType.cs b/Huobi.Net/Enums/BalanceType.cs deleted file mode 100644 index b5c395a6..00000000 --- a/Huobi.Net/Enums/BalanceType.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Huobi.Net.Enums -{ - /// - /// Balance type - /// - public enum BalanceType - { - /// - /// Trade balance - /// - Trade, - /// - /// Frozen balance - /// - Frozen, - /// - /// Loan balance - /// - Loan, - /// - /// Interest balance - /// - Interest, - /// - /// Transfer out available - /// - TransferOutAvailable, - /// - /// Loan available - /// - LoanAvailable - } -} diff --git a/Huobi.Net/Enums/SymbolState.cs b/Huobi.Net/Enums/SymbolState.cs deleted file mode 100644 index 3c88584e..00000000 --- a/Huobi.Net/Enums/SymbolState.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Huobi.Net.Enums -{ - /// - /// Symbol state - /// - public enum SymbolState - { - /// - /// Not yet online - /// - PreOnline, - /// - /// Online - /// - Online, - /// - /// Offline - /// - Offline, - /// - /// Suspended - /// - Suspended - } -} diff --git a/Huobi.Net/Enums/WithdrawDepositState.cs b/Huobi.Net/Enums/WithdrawDepositState.cs deleted file mode 100644 index 5c986348..00000000 --- a/Huobi.Net/Enums/WithdrawDepositState.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace Huobi.Net.Enums -{ - /// - /// The state of a transfer - /// - public enum WithdrawDepositState - { - /// - /// Awaiting verification - /// - Verifying, - /// - /// Verification failed - /// - Failed, - /// - /// Withdraw request submitted successfully - /// - Submitted, - /// - /// Under examination for withdraw validation - /// - Reexamine, - /// - /// Withdraw canceled by user - /// - Canceled, - /// - /// Withdraw validation passed - /// - Pass, - /// - /// Withdraw validation rejected - /// - Reject, - /// - /// Withdraw is about to be released - /// - PreTransfer, - /// - /// On-chain transfer initiated - /// - WalletTransfer, - /// - /// Transfer rejected by chain - /// - WalletReject, - /// - /// On-chain transfer completed with one confirmation for withdraw or for at least one block for deposit - /// - Confirmed, - /// - /// On-chain transfer faied to get confirmation - /// - ConfirmError, - /// - /// Withdraw terminated by system - /// - Repealed, - /// - /// On-chain transfer has not been received - /// - Unknown, - /// - /// On-chain transfer waits for first confirmation - /// - Confirming, - /// - /// Multiple on-chain confirmation happened - /// - Safe, - /// - /// Confirmed but currently in an orphan branch - /// - Orphan - } -} diff --git a/Huobi.Net/ExtensionMethods/HuobiExtensionMethods.cs b/Huobi.Net/ExtensionMethods/HuobiExtensionMethods.cs deleted file mode 100644 index dc3eb1ba..00000000 --- a/Huobi.Net/ExtensionMethods/HuobiExtensionMethods.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Globalization; -using System.Text.RegularExpressions; - -namespace Huobi.Net.ExtensionMethods -{ - /// - /// Extension methods specific to using the Huobi API - /// - public static class HuobiExtensionMethods - { - /// - /// Validate the string is a valid Huobi symbol. - /// - /// string to validate - public static string ValidateHuobiSymbol(this string symbolString) - { - if (string.IsNullOrEmpty(symbolString)) - throw new ArgumentException("Symbol is not provided"); - symbolString = symbolString.ToLower(CultureInfo.InvariantCulture); - return symbolString; - } - - /// - /// Fill parameters in a path. Parameters are specified by '{}' and should be specified in occuring sequence - /// - /// The total path string - /// The values to fill - /// - public static string FillPathParameters(this string path, params string[] values) - { - foreach (var value in values) - { - var index = path.IndexOf("{}", StringComparison.Ordinal); - if (index >= 0) - { - path = path.Remove(index, 2); - path = path.Insert(index, value); - } - } - return path; - } - } -} diff --git a/Huobi.Net/Huobi.Net.xml b/Huobi.Net/Huobi.Net.xml deleted file mode 100644 index 77ee4466..00000000 --- a/Huobi.Net/Huobi.Net.xml +++ /dev/null @@ -1,9743 +0,0 @@ - - - - Huobi.Net - - - - - - - - - - - - - - Create a new instance of the HuobiRestClient using provided options - - Option configuration delegate - - - - Create a new instance of the HuobiRestClient - - Option configuration delegate - The logger factory - Http client for this client - - - - Set the default options to be used when creating new clients - - Option configuration delegate - - - - - - - - - - - - - - - - Create a new instance of the HuobiSocketClient - - The logger factory - - - - Create a new instance of the HuobiSocketClient - - Option configuration delegate - - - - Create a new instance of the HuobiSocketClient - - The logger factory - Option configuration delegate - - - - Set the default options to be used when creating new clients - - Option configuration delegate - - - - - - - - - - - - - Event triggered when an order is placed via this client - - - - - Event triggered when an order is canceled via this client - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Construct url - - - - - - - - Get the name of a symbol for Huobi based on the base and quote asset - - - - - - - - - - - - - - - - - TODO make this take an accountId param so we don't need it in the interface? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Event triggered when an order is placed via this client - - - - - Event triggered when an order is canceled via this client - - - - - - - - - - - - - - - - - - - - - - - Construct url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account activation - - - - - Activated - - - - - Deactivated - - - - - Event type - - - - - Order placed event - - - - - Order matched event - - - - - Order refunded event - - - - - Order canceled event - - - - - Order fee refunded event - - - - - Margin transfer event - - - - - Margin loan event - - - - - Margin interest event - - - - - Margin repay event - - - - - Other event - - - - - Deposit event - - - - - Withdraw event - - - - - Account state - - - - - Working - - - - - Locked - - - - - Account type - - - - - Spot account - - - - - Margin account - - - - - Super margin account - - - - - Otc account - - - - - Point account - - - - - Investment account - - - - - Borrow account - - - - - Grid trading - - - - - Deposit earning - - - - - Otc options - - - - - Minepool - - - - - Etf - - - - - Crypto loans - - - - - Balance type - - - - - Trade balance - - - - - Frozen balance - - - - - Loan balance - - - - - Interest balance - - - - - Transfer out available - - - - - Loan available - - - - - Business type - - - - - Futures - - - - - Swap - - - - - Status of a conditional order - - - - - Created and active - - - - - Canceled - - - - - Rejected - - - - - Triggered - - - - - Conditional order type - - - - - Limit order - - - - - Market order - - - - - Contract status - - - - - Delisting - - - - - Listing - - - - - Pending listing - - - - - Suspension - - - - - Suspending of listing - - - - - In settlement - - - - - Delivering - - - - - Settlement completed - - - - - Delivered - - - - - Contract type - - - - - Swap - - - - - This week - - - - - Next week - - - - - Quarter - - - - - Next quarter - - - - - Status - - - - - Allowed - - - - - Prohibited - - - - - Fee deduction status. - - - - - In deduction - - - - - Deduction completed - - - - - Fee type - - - - - Fixed - - - - - Circulated - - - - - Ratio - - - - - Filter direction - - - - - Get results after - - - - - Get results before - - - - - Financial record type - - - - - Close long - - - - - Close short - - - - - Fees for open position - taker - - - - - Fess for open position - maker - - - - - Fees for close positon - taker - - - - - Fees for close potion - maker - - - - - Close long for delivery - - - - - Close short for delibery - - - - - Delivery fee - - - - - Close long for liquidation - - - - - Close short for liquidation - - - - - Transfer spot to contract - - - - - Transfer contract to spot - - - - - Settle unrealized long - - - - - Settle unrealized short - - - - - Clawback - - - - - System - - - - - Activity price rewards - - - - - Rebate - - - - - Funding fee income - - - - - Funding fee expenditure - - - - - Transfer to sub account - - - - - Transfer from sub account - - - - - Transfer to master account - - - - - Transfer from master account - - - - - Transfer from other margin account - - - - - Transfer to other margin account - - - - - Adl close long - - - - - Adl close short - - - - - Status of an instrument - - - - - Normal - - - - - Delisted - - - - - Interest period - - - - - One hour - - - - - Four hours - - - - - Twelf hours - - - - - One day - - - - - Interval for klines, int value represent the time in seconds - - - - - 1m - - - - - 5m - - - - - 15m - - - - - 30m - - - - - 1h - - - - - 4h - - - - - 1d - - - - - 1w - - - - - 1m - - - - - 1y - - - - - Trade type - - - - - Fully filled liquidation orders - - - - - Liquidated close orders - - - - - Liquidated open orders - - - - - Liquidation type - - - - - Not a liquidation - - - - - Long and short netting - - - - - Partial liquidation - - - - - Full liquidation - - - - - Margin mode - - - - - Cross margin - - - - - Isolated margin - - - - - All (filter) - - - - - Status of a margin order - - - - - Created - - - - - Loaned - - - - - Paid - - - - - Invalid - - - - - Failed - - - - - Margin order type - - - - - Quoatation - - - - - Canceled order - - - - - Forced liquidation - - - - - Delivery - - - - - Trade type - - - - - All trades - - - - - Buy long - - - - - Sell short - - - - - Buy short - - - - - Sell long - - - - - Buy one way - - - - - Sell one way - - - - - Status of the market - - - - - Operating normally - - - - - Trading halted - - - - - Only cancelation is possible - - - - - Transfer type between master and sub account - - - - - Transfer from master to sub - - - - - Transfer from sub to master - - - - - Offset - - - - - Open - - - - - Close - - - - - Both - - - - - Stop price operator - - - - - Greater than or equal to stop price - - - - - Less than or equal to stop price - - - - - Order price type - - - - - Market - - - - - Limit - - - - - Best offer - - - - - Post only - - - - - Optimal 5 - - - - - Optimal 10 - - - - - Optimal 20 - - - - - Immediate or cancel - - - - - Fill or kill - - - - - Immediate or cancel at best bid - - - - - Immediate or cancel optimal 5 - - - - - Immediate or cancel optimal 10 - - - - - Immediate or cancel optimal 20 - - - - - Fill or kill best offer - - - - - Fill or kill optimal 5 - - - - - Fill or kill optimal 10 - - - - - Fill or kill optimal 20 - - - - - Order role - - - - - Maker of an order book entry - - - - - Taker of an order book entry - - - - - Order side - - - - - Buy - - - - - Sell - - - - - Order state - - - - - Pre-submitted - - - - - Submitted, nothing filled yet - - - - - Partially filled - - - - - Partially filled, then canceled - - - - - Filled completely - - - - - Canceled without fill - - - - - Created - - - - - Rejected - - - - - Order type - - - - - Limit - - - - - Market - - - - - Immediate or cancel - - - - - Limit maker - - - - - Stop limit - - - - - Fill or kill limit - - - - - Fill or kill stop limit - - - - - Grid market order - - - - - Grid limit order - - - - - Position mode - - - - - Single side - - - - - Dual side - - - - - Settlement type - - - - - Settlement - - - - - Delivery - - - - - Sorting order - - - - - Ascending - - - - - Descending - - - - - Source - - - - - Spot api - - - - - Isolate margin api - - - - - Cross margin api - - - - - c2c margin api - - - - - Order status - - - - - Ready to submit - - - - - Submitting - - - - - Submitted / active - - - - - Partially filled - - - - - Partially filled, cancelled - - - - - Filled - - - - - Cancelled - - - - - Cancelling - - - - - Symbol state - - - - - Not yet online - - - - - Online - - - - - Offline - - - - - Suspended - - - - - Time an order is active - - - - - Good until the order is canceled - - - - - Should execute at least partly upon placing - - - - - Should enter the book upon placing - - - - - Should fill entirely upon placing - - - - - Transaction type - - - - - Trade - - - - - ETF - - - - - Transaction fee - - - - - Deduction - - - - - Transfer between accounts - - - - - Credit - - - - - Liquidation - - - - - Interest - - - - - Deposit - - - - - Withdraw - - - - - Withdraw fee - - - - - Exchange - - - - - Other types - - - - - Rebate - - - - - Transfer type - - - - - From sub account - - - - - To sub account - - - - - Point from sub account - - - - - Point to sub account - - - - - Unit type - - - - - Cont - - - - - Crypto currency - - - - - User state - - - - - Normal - - - - - Locked - - - - - The state of a transfer - - - - - Awaiting verification - - - - - Verification failed - - - - - Withdraw request submitted successfully - - - - - Under examination for withdraw validation - - - - - Withdraw canceled by user - - - - - Withdraw validation passed - - - - - Withdraw validation rejected - - - - - Withdraw is about to be released - - - - - On-chain transfer initiated - - - - - Transfer rejected by chain - - - - - On-chain transfer completed with one confirmation for withdraw or for at least one block for deposit - - - - - On-chain transfer faied to get confirmation - - - - - Withdraw terminated by system - - - - - On-chain transfer has not been received - - - - - On-chain transfer waits for first confirmation - - - - - Multiple on-chain confirmation happened - - - - - Confirmed but currently in an orphan branch - - - - - Define transfer type - - - - - Deposit - - - - - Withdraw - - - - - Extension methods specific to using the Huobi API - - - - - Validate the string is a valid Huobi symbol. - - string to validate - - - - Fill parameters in a path. Parameters are specified by '{}' and should be specified in occuring sequence - - The total path string - The values to fill - - - - - Huobi environments - - - - - Spot Rest client address - - - - - Spot Rest client address for USDT margin swap API - - - - - Base address for socket API - - - - - Socket base address for the USDT margin swap API - - - - - Live environment - - - - - Create a custom environment - - - - - - - - - - - Huobi exchange information and configuration - - - - - Exchange name - - - - - Url to the main website - - - - - Urls to the API documentation - - - - - Client for accessing the Huobi API. - - - - - Spot endpoints - - - - - Usdt margin swap endpoints - - - - - Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. - - The credentials to set - - - - Client for accessing the Huobi websocket API. - - - - - Spot streams - - - - - Usdt margin swap streams - - - - - Set the API credentials for this client. All Api clients in this client will use the new credentials, regardless of earlier set options. - - 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 - - - Cancellation token - - - - - Gets a list of users associated with the apikey/secret - - - Cancellation token - - - - - Gets a list of sub-user accounts associated with the sub-user id - - - The if of the user to get accounts for - Cancellation token - - - - - Gets a list of accounts associated with the apikey/secret - - - Cancellation token - - - - - Gets a list of balances for a specific account - - - The id of the account to get the balances for - Cancellation token - - - - - Gets the valuation of all assets - - - Type of account to valuate - The currency to get the value in - The id of the sub user - Cancellation token - - - - - Transfer assets between accounts - - - From user id - From account type - From account id - To user id - To account type - To account id - Asset to transfer - Amount to transfer - Cancellation token - - - - - Gets a list of balance changes of specified user's account - - - The id of the account to get the balances for - Asset name - Blance change types - Far point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days - Near point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days - Sorting order (Ascending by default) - Maximum number of items in each response (from 1 to 500, default is 100) - Cancellation token - - - - - This endpoint returns the balance changes of specified user's account. - - - The id of the account to get the ledger for - Asset name - Blanace change types - Far point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days - Near point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days - Sorting order (Ascending by default) - Maximum number of items in each response (from 1 to 500, default is 100) - Only get orders with ID before or after this. Used together with the direction parameter - Cancellation token - - - - - Gets a list of balances for a specific sub account - - - The id of the sub account to get the balances for - Cancellation token - - - - - Transfer asset between parent and sub account - - - The target sub account id to transfer to or from - The asset to transfer - The quantity of asset to transfer - The type of transfer - Cancellation token - Unique transfer id - - - - Parent user and sub user could query deposit address of corresponding chain, for a specific crypto currency (except IOTA). - - - Asset - 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. - - - The desination address of this withdraw - Asset - The quantity of asset to withdraw - The fee to pay with this withdraw - Set as "usdt" to withdraw USDT to OMNI, set as "trc20usdt" to withdraw USDT to TRX - A tag specified for this address - Cancellation token - - - - - Parent user and sub user searche for all existed withdraws and deposits and return their latest status. - - - Define transfer type to search - The asset to withdraw - The transfer id to begin search - The number of items to return - the order of response - Cancellation token - - - - - Repay a margin loan - - - Account id - Asset to repay - Quantity to repay - Loan transaction ID - Cancellation token - - - - - Transfer asset from spot account to isolated margin account - - - Trading symbol - Asset to transfer - Quantity to transfer - Cancellation token - Transfer id - - - - Transfer asset from isolated margin to spot account - - - Trading symbol - Asset to transfer - Quantity to transfer - Cancellation token - Transfer id - - - - Get isolated loan interest rate and quotas - - - Filter on symbols - Cancellation token - - - - - Request a loan on isolated margin - - - The symbol - The asset - The quantity - Cancellation token - Order id - - - - Repay a isolated margin loan - - - Id to repay - Quantity - Cancellation token - Order id - - - - Get isolated margin orders history - - - The symbol to get history for - Filter by states - Filter by start date - Filter by end date - Start order id for use in combination with direction - Direction of results in combination with from parameter - Max amount of results - Sub user id - Cancellation token - - - - - Get isolated margin account balance - - - The symbol - Sub user id - Cancellation token - - - - - Transfer from spot account to cross margin account - - - The asset to transfer - Quantity to transfer - Cancellation token - - - - - Transfer from cross margin account to spot account - - - The asset to transfer - Quantity to transfer - Cancellation token - - - - - Get cross margin interest rates and quotas - - - - - - - - Request a loan on cross margin - - - The asset - The quantity - Cancellation token - Order id - - - - Repay a isolated margin loan - - - Id to repay - Quantity - Cancellation token - Order id - - - - Get cross margin order history - - - Filter by asset - Filter by state - Filter by start date - Filter by end date - Start order id for use in combination with direction - Direction of results in combination with from parameter - Max amount of results - Sub user id - Cancellation token - - - - - Get cross margin account balance - - - Sub user id - Cancellation token - - - - - Get repayment history - - - Filter by repay id - Filter by account id - Filter by asset - Only show records after this - Only show records before this - Sort direction - Result limit - Search id - Cancellation token - - - - - Get Current Fee Rate Applied to The User - - - Filter on symbols - 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 - - - Cancellation token - - - - - Gets the ticker, including the best bid / best ask for a symbol - - - The symbol to get the ticker for - Cancellation token - - - - - Get candlestick data for a symbol - - - The symbol to get the data for - The period of a single candlestick - The amount of candlesticks - Cancellation token - - - - - Gets the order book for a symbol - - - The symbol to request for - The way the results will be merged together - The depth of the book - Cancellation token - - - - - Gets the last trade for a symbol - - - The symbol to request for - Cancellation token - - - - - Get the last x trades for a symbol - - - The symbol to get trades for - The max number of results - Cancellation token - - - - - Gets 24h stats for a symbol - - - The symbol to get the data for - Cancellation token - - - - - Gets real time NAV for ETP - - - The symbol to get the data for - Cancellation token - - - - - Gets the current market status - - - Cancellation token - - - - - Gets a list of supported symbols - - - Cancellation token - - - - - Gets a list of supported currencies - - - Cancellation token - - - - - Gets a list of supported currencies and chains - - - Filter by asset - Cancellation token - - - - - Gets the server time - - - Cancellation token - - - - - Huobi trading endpoints, placing and mananging orders. - - - - - Places an order - - - The account to place the order for - The symbol to place the order for - The side of the order - The type of the order - The quantity of the order - The price of the order. Should be omitted for market orders - The clientOrderId the order should get - Source. defaults to SpotAPI - Stop price - Operator of the stop price - Cancellation token - - - - - Gets a list of open orders - - - The account id for which to get the orders for - The symbol for which to get the orders for - Only get buy or sell orders - The max number of results - Cancellation token - - - - - Cancels an open order - - - The id of the order to cancel - Cancellation token - - - - - Cancels an open order - - - The client id of the order to cancel - Cancellation token - - - - - Cancel multiple open orders - - - The ids of the orders to cancel - The client ids of the orders to cancel - Cancellation token - - - - - Cancel multiple open orders - - - The account id used for this cancel - The trading symbol list (maximum 10 symbols, default value all symbols) - Filter on the direction of the trade - The number of orders to cancel [1, 100] - Cancellation token - - - - - Get details of an order - - - The id of the order to retrieve - Cancellation token - - - - - Get details of an order by client order id - - - The client id of the order to retrieve - Cancellation token - - - - - Gets a list of trades made for a specific order - - - The id of the order to get trades for - Cancellation token - - - - - Gets a list of orders - - - The symbol to get orders for - The states of orders to return - The types of orders to return - Only get orders after this date - Only get orders before this date - Only get orders with ID before or after this. Used together with the direction parameter - Direction of the results to return when using the fromId parameter - The max number of results - Cancellation token - - - - - Gets a list of trades for a specific symbol - - - Only return trades with specific states - The symbol to retrieve trades for - The type of orders to return - Only get orders after this date - Only get orders before this date - Only get orders with ID before or after this. Used together with the direction parameter - Direction of the results to return when using the fromId parameter - The max number of results - Cancellation token - - - - - Gets a list of history orders - - - The symbol to get orders for - Only get orders after this date - Only get orders before this date - Direction of the results to return - The max number of results - Cancellation token - - - - - Place a new conditional order - - - The account the order should be placed from - The symbol the order is for - Side of the order - Type of the order - Stop price of the order - Quantity of the order - Price of the order - Quote quantity of the order - Trailing rate of the order - Time in force - Client order id - Cancellation token - - - - - Cancel conditional orders - - - Client order ids of the conditional orders to cancels - Cancelation token - - - - - Get open conditional orders based on the parameters - - - Filter by account id - Filter by symbol - Filter by side - Filter by type - Sort direction - Max results - Ids after this - Cancelation token - - - - - Get closed conditional orders - - - Filter by account id - Filter by symbol - Filter by side - Filter by type - Sort direction - Max results - Ids after this - Cancelation token - Filter by status - Return only entries after this time - Return only entries before this time - - - - - Get a conditional order by id - - - Client order id - Cancelation token - - - - - Spot streams - - - - - Gets candlestick data for a symbol - - - The symbol to get the data for - The period of a single candlestick - - - - - Subscribes to candlestick updates for a symbol - - The symbol to subscribe to - The period of a single candlestick - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Gets the current order book for a symbol - - - The symbol to get the data for - The way the results will be merged together - - - - - Gets the current order book for a symbol - - - The symbol to get the data for - The amount of rows. 5, 20, 150 or 400 - - - - - Subscribes to order book updates for a symbol - - - The symbol to subscribe to - The number of price levels. 5, 10 or 20 - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribes to order book updates for a symbol - - - The symbol to subscribe to - The way the results will be merged together - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribes to order book updates for a symbol, - - - The symbol to subscribe to - The number of price levels. 5, 20, 150 or 400 - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Gets a list of trades for a symbol - - - The symbol to get trades for - - - - - Subscribes to trade updates for a symbol - - - The symbol to subscribe to - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Gets details for a symbol - - - The symbol to get data for - - - - - Subscribes to symbol detail updates for a symbol - - - The symbol to subscribe to - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribes to updates for a symbol - - - The symbol to subscribe - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribes to updates for all tickers - - - The handler for updates - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribe to changes of a symbol's best ask/bid - - - Symbol to subscribe to - Data handler - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribe to updates of orders - - - Subscribe on a specific symbol - Event handler for the order submitted event - Event handler for the order matched event - Event handler for the order cancelled event - Event handler for the conditional order trigger failed event - Event handler for the condition order canceled event - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribe to updates of account balances - - - Event handler - The update mode. Defaults to 1, see API docs for more info - Cancellation token for closing this subscription - A stream subscription. This stream subscription can be used to be notified when the socket is disconnected/reconnected - - - - Subscribe to detailed order matched/canceled updates - - - Subscribe to a specific symbol - Event handler for the order matched event - Event handler for the order canceled event - 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 - - - The asset - Cancellation token - - - - - Get isolated margin account info - - - Optional contract code filter - Cancellation token - - - - - Get cross margin account info - - - Optional margin account filter - Cancellation token - - - - - Get cross margin assets and positions - - - Margin account - Cancellation token - - - - - Get cross margin available leverage - - - Contract code - Symbol - Contract type - Business type - Cancellation token - - - - - Get cross margin positions - - - Filter by contract code - Cancellation token - - - - - Get cross margin settlement records - - - Margin account - Filter by start time - Filter by end time - Page - Page size - Cancellation token - - - - - Get cross margin sub account assets - - - Margin account - Cancellation token - - - - - Get financial records - - - Margin account - Contract code - Filter by type - Filter by create date - Page - Page size - Cancellation token - - - - - Get isolated margin assets and positisons - - - Contract code - Cancellation token - - - - - Get isolated margin available leverage - - - Contract code - Cancellation token - - - - - Get isolated margin position info - - - Contract code - Cancellation token - - - - - Get isolated margin settlement records - - - Contract code - Filter by start time - Filter by end time - Page - Page size - Cancellation token - - - - - Get isolated margin sub account assets - - - Contract code - Cancellation token - - - - - Get master sub account transfer records - - - Margin account - Days in history - Filter by type - Page - Page size - Cancellation token - - - - - Get trading fees - - - Contract code - Symbol - Contract type - Business tpye - Cancellation token - - - - - Switch cross margin position mode - - - Margin account - Position mode - Cancellation token - - - - - Switch isolated margin position mode - - - Margin account - Position mode - Cancellation token - - - - - Set sub account trading permissions - - - Uids of the subaccounts - Enable trading - Cancellation token - - - - - Transfer between margin accounts - - - Asset to transfer - From account - To account - Quantity to transfer - Client order id - Cancellation token - - - - - Transfer between master and sub account - - - Sub account uid - Asset to transfer - From account - To account - Quantity to transfer - Type - Client order id - Cancellation token - - - - - Huobi usdt margin swap exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. - - - - - Get basis data - - - Contract code - Kline interval - Limit - Price type (open, close, high, low, average) - Cancellation token - - - - - Get the best current offer - - - Contract code - Type - Cancellation token - - - - - Get contract info - - - Contract code - Support margin mode - Symbol - Contract type - Business type - Cancellation token - - - - - Get cross margin adjust factor info - - - Contract code - Asset - Type - Cancellation token - - - - - Get cross margin trade status - - - Contract code - Asset - Type - Cancellation token - - - - - Get cross margin transfer status - - - Margin account - Cancellation token - - - - - Get cross tiered margin info - - - Contract code - Symbol - Contract type - Cancellation token - - - - - Get estimated funding rate kliens - - - Contract code - Kline interval - Limit - Cancellation token - - - - - Get estimated settlement price - - - Contract code - Symbol - Contract type - Business type - Cancellation token - - - - - Get funding rate - - - Contract code - Cancellation token - - - - - Get funding rates - - - Contract code - Cancellation token - - - - - Get historical funding rates - - - Contract code - Page - Page size - Cancellation token - - - - - Get historical settlement records - - - Contract code - Filter by start time - Filter by end time - Page - Page size - Cancellation token - - - - - Get insurance fund history - - - Contract code - Page - Page size - Cancellation token - - - - - Get isolated margin adjust factor info - - - Contract code - Cancellation token - - - - - Get isolated margin status - - - Contract code - Cancellation token - - - - - Get isolated margin tier info - - - Contract code - Cancellation token - - - - - Get klines - - - Contract code - Kline interval - Limit - Filter by start time - Filter by end time - Cancellation token - - - - - Get last trades - - - Contract code - Business type - Cancellation token - - - - - Get liquidation orders - - - Create date - Trade type - Contract code - Symbol - Page - Page size - Cancellation token - - - - - Get market data - - - Contract code - Cancellation token - - - - - Get market datas - - - Contract code - Business type - Cancellation token - - - - - Get open interest - - - Period - Unit - Contract code - Symbol - Type - Limit - Cancellation token - - - - - Get order book - - - Contract code - Merge step - Cancellation token - - - - - Get premium index klines - - - Contract code - Interval - Limit - Cancellation token - - - - - Get recent trades - - - Contract code - Limit - Cancellation token - - - - - Get server time - - - Cancellation token - - - - - Get swap index price - - - Contract code - Cancellation token - - - - - Get swap open interest - - - Contract code - Symbol - Contract type - Business tpye - Cancellation token - - - - - Get swap price limitation - - - Contract code - Symbol - Contract tpye - Business type - Cancellation token - - - - - Get swap risk info - - - Contract code - Business type - Cancellation token - - - - - Huobi usdt margin swap trading endpoints, placing and mananging orders. - - - - - Cancel all cross margin orders fitting the parameters - - - Contract code - Symbol - Contract type - Side - Offset - Cancellation token - - - - - Cancel all isolated margin order fitting the parameters - - - Contract code - Side - Offset - Cancellation token - - - - - Cancel cross margin order - - - The order id - The client order id - Contract code - Symbol - Contract type - Cancellation token - - - - - Cancel cross margin orders - - - Order ids - Client order ids - Contract code - Symbol - Contract type - Cancellation token - - - - - Cancel isolated margin order - - - Contract code - Order id - Client order id - Cancellation token - - - - - Cancel isolated margin orders - - - Contract code - Order ids - Client order ids - Cancellation token - - - - - Change cross margin leverage - - - Leverage rate - Contract code - Symbol - Contract type - Cancellation token - - - - - Change isolated margin leverage - - - Contract code - Leverage rate - Cancellation token - - - - - Get cross margin closed orders - - - Trade type - All orders - Days in history - Contract code - Symbol - Page - Page size - Sort by - Cancellation token - - - - - Get cross margin open orders - - - Contract code - Symbol - Page - Page size - Sort by - Trade type - Cancellation token - - - - - Get cross margin order - - - Contract code - Symbol - Order id - Client order id - Cancellation token - - - - - Get cross margin order details - - - Contract code - Order id - Cancellation token - - - - - Get cross margin orders - - - Order ids - Client order ids - Contract code - Symbol - Cancellation token - - - - - Get cross margin user trades - - - Contract code - Trade type - Days in history - Page - Page size - Cancellation token - - - - - Get isolated margin closed orders - - - Contract code - Trade type - All orders - Days in history - Page - Page size - Sort by - Cancellation token - - - - - Get isolated margin open orders - - - Contract code - Page - Page size - Sort by - Trade type - Cancellation token - - - - - Get isoalted margin order - - - Contract code - Order id - Client order id - Cancellation token - - - - - Get isolated margin order details - - - Contract code - Order id - Cancellation token - - - - - Get isolated margin orders - - - Contract code - Order ids - Client order ids - Cancellation token - - - - - Get isolated margin user trades - - - Contract code - Trade type - Days in history - Page - Page size - Cancellation token - - - - - Place a new cross margin order - - - Order quantity - Order side - Leverage rate - Contract code - Symbol - Contract type - Price - Offset - Order price type - Take profit trigger price - Take profit order price - Take profit order price type - Stop loss trigger price - Stop loss order price - Stop loss order price type - Reduce only - Client order id - Cancellation token - - - - - Place a new isolated margin order - - - Contract code - Quantity - Order side - Leverage rate - Price - Offset - Order price type - Take profit trigger price - Take profit order price - Take profit order price type - Stop loss trigger price - Stop loss order price - Stop loss order price type - Reduce only - Client order id - Cancellation token - - - - - Usdt margin swap streams - - - - - Subscribe to basis updates - - - Contract code - Period - Price type - Data handler - Cancellation token - - - - - Subscribe to best offer updates - - - Contract code - Data handler - Cancellation token - - - - - Subscribe to estimated funding rate kline updates - - - Contract code - Period - Data handler - Cancellation token - - - - - Subscribe to incremental order book updates - - - Contract code - Snapshot or incremental - Depth - Data handler - Cancellation token - - - - - Subscribe to index kline updates - - - Contract code - Period - Data handler - Cancellation token - - - - - Subscribe to kline updates - - - Contract code - Period - Data handler - Cancellation token - - - - - Subscribe to mark price updates - - - Contract code - Period - Data handler - Cancellation token - - - - - Subscribe to order book updates - - - Contract code - Merge step - Data handler - Cancellation token - - - - - Subscribe to premium index kline updates - - - Contract code - Period - Data handler - Cancellation token - - - - - Subscribe to symbol ticker updates - - - Contract code - Data handler - Cancellation token - - - - - Subscribe to symbol trade updates - - - Contract code - Data handler - Cancellation token - - - - - Huobi order book factory - - - - - Spot order book factory methods - - - - - Create a SymbolOrderBook for the Spot API - - The symbol - Order book options - - - - - Api addresses usable for the Huobi clients - - - - - The address used by the HuobiClient for the rest spot API - - - - - The address used by the HuobiSocketClient for the public socket API - - - - - The address used by the HuobiClient for the rest usdt margin swaps API - - - - - The address used by the HuobiSocketClient for the private user socket API - - - - - The default addresses to connect to the Huobi.com API - - - - - The timestamp of the data - - - - - The data - - - - - The timestamp of the data - - - - - The data - - - - - The action - - - - - The name of the data channel - - - - - The timestamp of the update - - - - - The data of the update - - - - - Huobi account info - - - - - The id of the account - - - - - The state of the account - - - - - The type of the account - - - - - Sub state - - - - - Account and balance info - - - - - The list of balances - - - - - Account history data - - - - - Account ID - - - - - Asset - - - - - Quantity change (positive value if income, negative value if outcome) - - - - - Blance change types - - - - - Available balance - - - - - Account balance - - - - - Transaction time (database time) - - - - - Unique record ID in the database - - - - - Account valuation - - - - - The balance - - - - - Timestamp of the data - - - - - Info on an asset - - - - - Asset - - - - - Status of the asset - - - - - Networks - - - - - Info on an asset network - - - - - Chain - - - - - Display name - - - - - Base chain - - - - - Protocol of the base chain - - - - - Is dynamic fee type or not (only applicable to withdrawFeeType = fixed) - - - - - Deposit status - - - - - Maximum withdraw fee in each request (only applicable to withdrawFeeType = circulated or ratio) - - - - - Max withdraw quantity per request - - - - - Min deposit quantity per request - - - - - Min withdraw quantity per request - - - - - Withdraw fee in each request (only applicable to withdrawFeeType = fixed) - - - - - Withdraw fee in each request (only applicable to withdrawFeeType = ratio) - - - - - Minimal withdraw fee in each request (only applicable to withdrawFeeType = circulated or ratio) - - - - - Number of confirmations required for deposit - - - - - Number of confirmations required for quick success (trading allowed but withdrawal disallowed) - - - - - Type of withdraw fee - - - - - Precision of withdrawing - - - - - Withdraw quota per day - - - - - Withdraw quota per year - - - - - Withdraw quota in total - - - - - Withdraw status - - - - - Balance data - - - - - The asset - - - - - The type of the balance - - - - - The balance - - - - - Sequence number of the update - - - - - Balance info - - - - - Asset - - - - - Frozen - - - - - Trade - - - - - Result of a batch cancel - - - - - Orders that were successfully canceled - - - - - Orders that failed to cancel - - - - - Cancel result - - - - - The error code - - - - - The error message - - - - - The id of the failed order - - - - - The state of the order - - - - - The id of the failed order - - - - - Info on a symbol's best offer - - - - - Symbol - - - - - Time of the data - - - - - Best bid price - - - - - Quantity of the best bid - - - - - Best ask price - - - - - Quantity of the best ask - - - - - Sequence number - - - - - Result of Cancel Orders by Criteria - - - - - The number of cancel request sent successfully - - - - - The number of cancel request failed - - - - - the next order id that can be canceled - - - - - Conditional order info - - - - - Acount id - - - - - Source - - - - - Order id - - - - - Client order id - - - - - Symbol - - - - - Price - - - - - Quantity - - - - - Quote quantity - - - - - Side - - - - - Time in force - - - - - Type - - - - - Stop price - - - - - Trailing rate - - - - - Creation time - - - - - Last update time - - - - - Status - - - - - Error code if the conditional order is rejected - - - - - Error message if conditional order is rejected - - - - - Conditional order cancelation result - - - - - Orders accepted for cancelation - - - - - Orders rejected for cancelation - - - - - Deposit address info - - - - - User id - - - - - Asset - - - - - Deposit address - - - - - Deposit address tag - - - - - Block chain name - - - - - Current transaction fee rate applied to the user - - - - - The symbol - - - - - Basic fee rate – passive side - - - - - Basic fee rate – aggressive side - - - - - Deducted fee rate – passive side - - - - - Basic fee rate – aggressive side - - - - - Ledger entry - - - - - Account id - - - - - Asset - - - - - Quantity of the transaction - - - - - Type of transaction - - - - - Type of transfer - - - - - Transaction id - - - - - Transaction time - - - - - Transferer - - - - - Transferee - - - - - Loan info - - - - - Symbol name - - - - - Currencies - - - - - Asset info - - - - - Asset - - - - - Interest rate - - - - - Minimal loan quantity - - - - - Maximal loan quantity - - - - - Remaining loanable quantity - - - - - Actual interest rate - - - - - Margin account balance - - - - - Id - - - - - Type - - - - - Symbol - - - - - State - - - - - Risk rate - - - - - Account balance sum - - - - - Debt balance sum - - - - - The price which margin closeout was triggered - - - - - Fl type - - - - - Account details - - - - - Balance info - - - - - The asset - - - - - Balance type - - - - - Balance - - - - - Margin order info - - - - - Order id - - - - - Account id - - - - - User id - - - - - Symbol - - - - - Asset - - - - - Creation time - - - - - Accrue time - - - - - Loan quantity - - - - - Loan balance left - - - - - Interst rate - - - - - Interest quantity - - - - - Interest left - - - - - State - - - - - Paid Huobi points - - - - - Paid asset - - - - - Filled Huobi points - - - - - HT deduction amount - - - - - Deduct rate - - - - - Deduct asset - - - - - Deduct quantity - - - - - Last updated - - - - - Hourly interest rate - - - - - Daily interest rate - - - - - NAV info for ETP - - - - - The symbol - - - - - Latest Nav - - - - - Update time - - - - - Outstanding shares - - - - - Baskets - - - - - Actual leverage ratio - - - - - Basket - - - - - Asset - - - - - Amount - - - - - Open order - - - - - The id of the order - - - - - The order id as specified by the client - - - - - The symbol of the order - - - - - The id of the account that placed the order - - - - - The quantity of the order - - - - - The price of the order - - - - - The time the order was created - - - - - The time the order was canceled - - - - - The time the order was completed - - - - - The type of the order - - - - - The type of the order - - - - - The source of the order - - - - - The state of the order - - - - - The quantity of the order that is filled - - - - - Filled cash quantity - - - - - The quantity of fees paid for the filled quantity - - - - - Order info - - - - - The id of the order - - - - - The order id as specified by the client - - - - - The symbol of the order - - - - - The id of the account that placed the order - - - - - The quantity of the order - - - - - The price of the order - - - - - The time the order was created - - - - - The time the order was canceled - - - - - The time the order was finished - - - - - The type of the order - - - - - The side of the order - - - - - The source of the order - - - - - The state of the order - - - - - The quantity of the order that is filled - - - - - Filled cash quantity - - - - - The quantity of fees paid for the filled quantity - - - - - Order book - - - - - Timestamp - - - - - Version - - - - - List of bids - - - - - List of asks - - - - - Incremental order book update - - - - - Sequence number - - - - - Previous sequence number - - - - - List of changed bids - - - - - List of changed asks - - - - - Orders info - - - - - Timestamp for pagination - - - - - List of ticks for symbols - - - - - Trade info - - - - - The id of the trade - - - - - The symbol of the trade - - - - - The timestamp in milliseconds when this record is created - - - - - The quantity which has been filled - - - - - Transaction fee (positive value). If maker rebate applicable, revert maker rebate value per trade (negative value). - - - - - Deduction amount (unit: in ht or hbpoint). - - - - - The id of the trade - - - - - The id of the match - - - - - The id of the order - - - - - The limit price of limit order - - - - - The source where the order was triggered, possible values: sys, web, api, app - - - - - The type of the order - - - - - The side of the order - - - - - The role in the transaction: taker or maker - - - - - Asset of transaction fee or transaction fee rebate (transaction fee of buy order is based on base asset, transaction fee of sell order is based on quote asset; transaction fee rebate of buy order is based on quote asset, transaction fee rebate of sell order is based on base asset) - - - - - Deduction type: ht or hbpoint. - - - - - Fee deduction status. - - - - - Placed conditional order - - - - - The id - - - - - Placed order - - - - - The id - - - - - Repayment info - - - - - Repayment id - - - - - Account id - - - - - Repay time - - - - - Asset - - - - - Repay quantity - - - - - Transactions - - - - - Repayment transaction - - - - - Transact id - - - - - Principal repaid - - - - - Interest repaid - - - - - HT paid - - - - - Points paid - - - - - Repayment result - - - - - Repayment id - - - - - Repay time - - - - - Huobi sub-user account info - - - - - The type of the account - - - - - Whether the account is active of not - - - - - Whether transfers are allowed (only for spot account type) - - - - - Account ids - - - - - Huobi sub-user account id and state - - - - - The id of the account - - - - - The state of the account - - - - - Sub state - - - - - Huobi sub-user account info - - - - - The id of the sub-user - - - - - Deduct mode - - - - - List of accounts for the sub-user - - - - - Symbol data - - - - - The symbol name - - - - - The base asset - - - - - The quote asset - - - - - The precision of the price in decimal numbers - - - - - The precision of the quantity in decimal numbers - - - - - Partition - - - - - The state of the symbol - - - - - Minimum value of the quantity - - - - - Maximum value of the quantity - - - - - Minimum order quantity of limit order in base asset - - - - - Max buy order quantity of limit order in base asset - - - - - Max sell order quantity of limit order in base asset - - - - - Max order quantity of limit order in base asset - - - - - Minimum order quantity of sell-market order in base asset - - - - - Max order quantity of sell-market order in base asset - - - - - Max order value of buy-market order in quote asset - - - - - Minimum value of the order quantity in quote asset - - - - - Max order value of limit order and buy-market order in usdt - - - - - The precision of the order quantity in quote asset - - - - - Api trading status, enabled or disabled - - - - - Symbol data - - - - - The highest price - - - - - The lowest price - - - - - The price at the opening - - - - - The last price - - - - - The volume in base asset - - - - - The volume in quote asset (quantity * price) - - - - - The number of trades - - - - - Version - - - - - Ticker data - - - - - The symbol - - - - - Symbol kline data - - - - - The start time of the kline - - - - - Symbol details - - - - - The id of the details - - - - - Timestamp of the data - - - - - Symbol tick - - - - - The symbol - - - - - Quantity of the best bid - - - - - Quantity of the best ask - - - - - Best bid price - - - - - Best ask price - - - - - Last trade price - - - - - Last trade quantity - - - - - Status of the symbol - - - - - The status - - - - - Start time of when market halted - - - - - Estimated end time of the halt - - - - - Reason for halting - - - - - Affected symbols, comma separated or 'all' if all symbols are affected - - - - - Symbol tick info - - - - - Timestamp of the data - - - - - The id of the tick - - - - - The current best bid for the symbol - - - - - The current best ask for the symbol - - - - - Order book entry - - - - - The price for this entry - - - - - The quantity for this entry - - - - - Symbol ticks - - - - - Timestamp of the data - - - - - List of ticks for symbols - - - - - Symbol ticks - - - - - Timestamp of the data - - - - - List of ticks for symbols - - - - - Symbol trade - - - - - The id of the trade - - - - - The timestamp of the trade - - - - - The details of the trade - - - - - Symbol trade details - - - - - The id of the update - - - - - The id of the trade - - - - - The price of the trade - - - - - The quantity of the trade - - - - - The side of the trade - - - - - The timestamp of the trade - - - - - Transaction result - - - - - Id - - - - - Time - - - - - Huobi user info - - - - - The id of the user - - - - - The state of the user - - - - - Withdraw or Deposit - - - - - Transfer id - - - - - Define transfer type to search, possible values: [deposit, withdraw] - - - - - Sub type - - - - - The crypto asset to withdraw - - - - - The on-chain transaction hash - - - - - Block chain name - - - - - The number of crypto asset transfered in its minimum unit - - - - - The deposit or withdraw target address - - - - - The user defined address tag - - - - - The address tag of the address its from - - - - - Withdraw fee - - - - - The state of this transfer - - - - - Error code for withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". - - - - - Error description of withdrawal failure, only returned when the type is "withdraw" and the state is "reject", "wallet-reject" and "failed". - - - - - The timestamp in milliseconds for the transfer creation - - - - - The timestamp in milliseconds for the transfer's latest update - - - - - Account update - - - - - Asset - - - - - Account id - - - - - Total balance - - - - - Available balance - - - - - Type of change - - - - - Account type - - - - - Change time - - - - - Update sequence number - - - - - Best offer update - - - - - Order id - - - - - Update id - - - - - Best bid - - - - - Best ask - - - - - Incremental order book update - - - - - Order id - - - - - Update id - - - - - List of changed bids - - - - - List of changed asks - - - - - Cancelation details - - - - - Event type - - - - - The symbol - - - - - Order id - - - - - Order side - - - - - Order type - - - - - Account id - - - - - Order source - - - - - Order price - - - - - Order quantity - - - - - Client order id - - - - - Stop price - - - - - Operator - - - - - Order creation time - - - - - Order status - - - - - Remaining quantity - - - - - Order update - - - - - Event type - - - - - The symbol - - - - - Client order id - - - - - Order status - - - - - Timestamp - - - - - Submitted order update - - - - - Account id - - - - - Order id - - - - - Price of the order - - - - - Quantity of the order - - - - - Value of the order - - - - - The type of the order - - - - - The type of the order - - - - - Creation time - - - - - Order source - - - - - Matched order update - - - - - Trade price - - - - - Trade volume - - - - - Order id - - - - - The type of the order - - - - - The type of the order - - - - - Trade id - - - - - Timestamp of trade - - - - - Is the taker - - - - - Remaining quantity - - - - - Executed quantity - - - - - Price of the order - - - - - Quantity of the order - - - - - Order source - - - - - Canceled order update - - - - - Order id - - - - - The type of the order - - - - - The type of the order - - - - - Remaining quantity - - - - - Executed quantity - - - - - Price of the order - - - - - Quantity of the order - - - - - Order source - - - - - Info on a failed trigger for a conditional order - - - - - Side of the order - - - - - The error code - - - - - The error message - - - - - Symbol update - - - - - Id - - - - - Order id - - - - - Turnover - - - - - Best bid - - - - - Best ask - - - - - Trade update - - - - - Event type - - - - - The symbol - - - - - Order id - - - - - Price of this trade - - - - - Volume of this trade - - - - - Order side - - - - - Order type - - - - - Is the taker - - - - - Trade id - - - - - Time of trade - - - - - Transaction fee - - - - - Asset of the fee - - - - - Fee deduction quantity - - - - - Fee deduction type - - - - - Account id - - - - - Order source - - - - - Order price - - - - - Order quantity - - - - - Client order id - - - - - Stop price - - - - - Operator - - - - - Order creation time - - - - - Order status - - - - - Basis update - - - - - Id - - - - - Index price - - - - - Contract price - - - - - Basis - - - - - Basis rate - - - - - Trade info - - - - - Update id - - - - - Update timestamp - - - - - Trades - - - - - Trade info - - - - - Amount of trades - - - - - Timestamp - - - - - Trade id - - - - - Price - - - - - Side - - - - - Quantity - - - - - Turnover - - - - - Asset valuation - - - - - Asset name - - - - - Balance - - - - - Basis data - - - - - Basis - - - - - Basis rate - - - - - Contract price - - - - - Index price - - - - - Unique id - - - - - Batch result - - - - - Errors in the batch - - - - - Success - - - - - Batch operation error - - - - - Order id - - - - - Error code - - - - - Error message - - - - - Contract info - - - - - The asset - - - - - Contract code - - - - - Contract size - - - - - Price tick - - - - - Deliverty date - - - - - Delivery time - - - - - Created date - - - - - Status - - - - - Settlement date - - - - - Margin mode - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Contract status - - - - - Asset - - - - - Contract code - - - - - Margin account - - - - - Margin mode - - - - - Open order access - - - - - Close order access - - - - - Cancel order access - - - - - Deposit access - - - - - Withdrawal access - - - - - Transfer from master to sub - - - - - Transfer from sub to master - - - - - Master transfer sub inner in - - - - - Master transfer sub inner out - - - - - Sub transfer master inner in - - - - - Sub transfer master inner out - - - - - Transfer inner in - - - - - Tranfer inner out - - - - - Cross margin account contract details - - - - - Asset - - - - - Contract type - - - - - Margin position - - - - - Margin frozen - - - - - Margin available - - - - - Profit unreal - - - - - Liquidation price - - - - - Lever rate - - - - - Adjust factor - - - - - Contract type - - - - - Symbol - - - - - Business type - - - - - Trade partition - - - - - Account info - - - - - Margin balance - - - - - Margin position - - - - - Margin frozen - - - - - Margin available - - - - - Profit real - - - - - Profit unreal - - - - - Risk rate - - - - - Withdraw available - - - - - Margin static - - - - - Margin asset - - - - - Margin mode - - - - - Margin account - - - - - Position mode - - - - - Contract details - - - - - Futures contract details - - - - - Cross margin assets and positions info - - - - - Positions - - - - - Available leverage info - - - - - Contract type - - - - - Symbol - - - - - Business type - - - - - Order page - - - - - Orders - - - - - Sub account assets info - - - - - Sub account uid - - - - - Assets - - - - - Sub account asset info - - - - - Margin balance - - - - - Risk rate - - - - - Margin asset - - - - - Margin mode - - - - - Margin account - - - - - Cross margin trade status - - - - - Asset - - - - - Contract code - - - - - Margin mode - - - - - Margin account - - - - - Open order access - - - - - Close order access - - - - - Cancel order access - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Cross margin transfer status - - - - - Margin mode - - - - - Margin account - - - - - Deposit access - - - - - Withdrawal access - - - - - Transfer from master to sub - - - - - Transfer from sub to master - - - - - Master transfer sub inner in - - - - - Master transfer sub inner out - - - - - Sub transfer master inner in - - - - - Sub transfer master inner out - - - - - Transfer inner in - - - - - Tranfer inner out - - - - - User settlement record page - - - - - Total pages - - - - - Current pages - - - - - Total amount of records - - - - - Records - - - - - User settlement record - - - - - Margin account - - - - - Margin mode - - - - - Margin balance init - - - - - Margin balance - - - - - Settlement profit realized - - - - - Settlement time - - - - - Clawback - - - - - Funding fee - - - - - Offset profit loss - - - - - Fee - - - - - Fee asset - - - - - Contract details - - - - - Settlement contract details - - - - - Asset - - - - - Contract code - - - - - Offset profit loss - - - - - Fee - - - - - Fee asset - - - - - Positions - - - - - Settlement position - - - - - Asset - - - - - Contract code - - - - - Direction - - - - - Volume - - - - - Cost open - - - - - Cost hold before settlement - - - - - Cost hold after settlement - - - - - Settlement profit unreal - - - - - Settlement price - - - - - Settlement type - - - - - Margin user trade page - - - - - Trades - - - - - User trade info - - - - - Contract type - - - - - Business type - - - - - Symbol - - - - - Estimated settlement price - - - - - Contract code - - - - - Estimated settlement price - - - - - Settlement type - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Financial records page - - - - - Total amount of pages - - - - - Current page - - - - - Total amount of records - - - - - Data - - - - - Financial records - - - - - Record id - - - - - Record type - - - - - Amount - - - - - Timestamp - - - - - Contract code - - - - - Asset - - - - - Margin account - - - - - Face margin account - - - - - Funding rate - - - - - Estimated rate - - - - - Funding rate - - - - - Contract code - - - - - Symbol - - - - - Fee asset - - - - - Funding rate - - - - - Next funding time - - - - - Funding rates page - - - - - Total pages - - - - - Current page - - - - - Total results - - - - - Rates - - - - - Historical funding rate - - - - - Average premium index - - - - - Funding rate - - - - - Realized rate - - - - - Funding time - - - - - Contract code - - - - - Symbol - - - - - Fee asset - - - - - Insurance info - - - - - Total amount of pages - - - - - Current page - - - - - Total amount of results - - - - - The asset - - - - - Contract code - - - - - Business type - - - - - Symbol - - - - - The history data - - - - - Insurance value - - - - - Insurance fund - - - - - Timestamp - - - - - Account info - - - - - Asset info - - - - - Margin balance - - - - - Margin position - - - - - Margin frozen - - - - - Margin available - - - - - Profit real - - - - - Profit unreal - - - - - Risk rate - - - - - Withdraw available - - - - - Liquidation price - - - - - Lever rate - - - - - Adjust factor - - - - - Margin static - - - - - Contract code - - - - - Margin asset - - - - - Margin mode - - - - - Margin account - - - - - Position mode - - - - - Isolated margin assets and positions info - - - - - Positions - - - - - Available leverage info - - - - - Contract code - - - - - Margin mode - - - - - Available rates - - - - - Isolated margin order info - - - - - Asset - - - - - Contract code - - - - - Quantity of contract - - - - - Price - - - - - Order price type - - - - - Order type - - - - - Direction - - - - - Offset - - - - - Leverage rate - - - - - Order id - - - - - Client order id - - - - - Creation time - - - - - Cancel time - - - - - Quantity filled - - - - - Value of the quantity filled - - - - - Fee - - - - - Average fill price - - - - - Margin frozen - - - - - Margin asset - - - - - Profit - - - - - Order status - - - - - Source - - - - - Fee asset - - - - - Liquidation type - - - - - Margin mode - - - - - Margin account - - - - - Is take profit/stop loss - - - - - Real profit - - - - - Reduce only - - - - - Trades - - - - - Cross margin order info - - - - - Business type - - - - - Contract type - - - - - Symbol - - - - - Order page - - - - - Orders - - - - - Sub account assets info - - - - - Sub account uid - - - - - Assets - - - - - Sub account asset info - - - - - Asset - - - - - Margin balance - - - - - Liquidation price - - - - - Risk rate - - - - - Contract code - - - - - Margin asset - - - - - Margin mode - - - - - Margin account - - - - - User settlement record page - - - - - Total pages - - - - - Current pages - - - - - Total amount of records - - - - - Records - - - - - User settlement record - - - - - Asset - - - - - Contract code - - - - - Margin mode - - - - - Margin account - - - - - Margin balance init - - - - - Margin balance - - - - - Settlement profit realized - - - - - Settlement time - - - - - Clawback - - - - - Funding fee - - - - - Offset profit loss - - - - - Fee - - - - - Fee asset - - - - - Positions - - - - - Settlement position - - - - - Asset - - - - - Contract code - - - - - Direction - - - - - Volume - - - - - Cost open - - - - - Cost hold before settlement - - - - - Cost hold after settlement - - - - - Settlement profit unreal - - - - - Settlement price - - - - - Settlement type - - - - - Margin user trade page - - - - - Trades - - - - - User trade info - - - - - Match id - - - - - Order id - - - - - Asset - - - - - Contract code - - - - - Side - - - - - Offset - - - - - Offset profit loss - - - - - Reduce only - - - - - Last trade data - - - - - Amount of contracts - - - - - Quantity - - - - - Timestamp - - - - - Id - - - - - Direction - - - - - Value - - - - - Last trade info - - - - - Contract code - - - - - Business type - - - - - Leverage rate - - - - - Contract code - - - - - Margin mode - - - - - Leverage rate - - - - - Leverage rate - - - - - Symbol - - - - - Business type - - - - - Contract type - - - - - Liquidation order page - - - - - Total pages - - - - - Current page - - - - - Total results - - - - - Orders - - - - - Liquidation order - - - - - Contract code - - - - - Asset - - - - - Direction - - - - - Offset - - - - - Volume - - - - - Price - - - - - Creation time - - - - - Amount - - - - - Turnover - - - - - Business type - - - - - Symbol - - - - - Isolated margin order info - - - - - Instrument price - - - - - Final interest - - - - - Adjust value - - - - - Total pages - - - - - Current page - - - - - Total amount of records - - - - - Trades - - - - - Trade info - - - - - Id - - - - - Trade id - - - - - Trade price - - - - - Trade quantity - - - - - Trade value - - - - - Fee - - - - - Creation time - - - - - Trade role - - - - - Fee asset - - - - - Profit - - - - - Real profit - - - - - Market data - - - - - Best ask - - - - - Best bid - - - - - Transfer between master and sub account - - - - - Id - - - - - Creation time - - - - - Asset name - - - - - Margin account - - - - - From margin account - - - - - To margin account - - - - - Sub uid - - - - - Sub account name - - - - - Transfer type - - - - - Quantity - - - - - Open interest - - - - - The asset - - - - - Amount - - - - - Volume - - - - - Value - - - - - Contract code - - - - - Trade amount - - - - - Trade volume - - - - - Trade turnover - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Open interest value - - - - - Asset - - - - - Contract code - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Tick - - - - - Open interest value tick - - - - - Volume - - - - - Unit - - - - - Value - - - - - Timestamp - - - - - Order id - - - - - Order id - - - - - Page of data - - - - - Total amount of pages - - - - - Current page - - - - - Total amount of records - - - - - Placed order id - - - - - Order id - - - - - Client order id - - - - - Isolated margin position info - - - - - Asset - - - - - Contract code - - - - - Volume - - - - - Available - - - - - Frozen - - - - - Opening average price - - - - - Average price of position - - - - - Unrealized pnl - - - - - Profit rate - - - - - Leverage rate - - - - - Position margin - - - - - Order direction - - - - - Profit - - - - - Last price - - - - - Margin asset - - - - - Margin mode - - - - - Margin account - - - - - Position mode - - - - - Position mode - - - - - Margin account - - - - - Position mode - - - - - Price limitation - - - - - The asset - - - - - Contract code - - - - - High limit - - - - - Low limit - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Settlement page - - - - - Total pages - - - - - Current page - - - - - Total size - - - - - Records - - - - - Settlement info - - - - - Asset - - - - - Contract code - - - - - Settlement time - - - - - Clawback ratio - - - - - Settlement price - - - - - Settlement type - - - - - Business type - - - - - Symbol - - - - - sub account results - - - - - Successfully updated ids - - - - - Errors - - - - - Sub account error info - - - - - Sub uid - - - - - Error code - - - - - Error message - - - - - Adjust factor info - - - - - Asset - - - - - Contract code - - - - - Margin mode - - - - - list - - - - - Cross margin adjust factor info - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Factor info - - - - - Lever rate - - - - - Ladders - - - - - Factor info - - - - - Ladder - - - - - Min size - - - - - Max size - - - - - Adjust factor - - - - - Best offer - - - - - Business type - - - - - Contract code - - - - - Best ask - - - - - Best bid - - - - - Order id - - - - - Timestamp - - - - - Swap index - - - - - Contract code - - - - - Index price - - - - - Timestamp - - - - - Swap risk info - - - - - Contract code - - - - - Insurance fund - - - - - Estimated clawback - - - - - Business type - - - - - Symbol - - - - - Trade partition - - - - - Tiered margin info - - - - - Margin account - - - - - Asset - - - - - Contract code - - - - - Margin mode - - - - - List - - - - - Tiered cross margin info - - - - - Business type - - - - - Symbol - - - - - Contract type - - - - - Margin rate - - - - - Lever rate - - - - - Ladders - - - - - Ladder info - - - - - Min marging balance - - - - - Max margin balance - - - - - Min margin available - - - - - Max margin available - - - - - Trading fee info - - - - - Asset - - - - - Contract code - - - - - Open position maker fee - - - - - Open position taker fee - - - - - Close position maker fee - - - - - Close position taker fee - - - - - Fee asset - - - - - Delivery fee - - - - - Business type - - - - - Contract type - - - - - Symbol - - - - - Options for the Huobi SymbolOrderBook - - - - - Default options for the Huobi SymbolOrderBook - - - - - The way the entries are merged. 0 is no merge, 2 means to combine the entries on 2 decimal places - - - - - The amount of entries to maintain. Either 5, 20 or 150. Level 5 and 20 are currently only supported for the following symbols: btcusdt, ethusdt, xrpusdt, eosusdt, ltcusdt, etcusdt, adausdt, dashusdt, bsvusdt. - - - - - After how much time we should consider the connection dropped if no data is received for this time after the initial subscriptions - - - - - Options for the HuobiRestClient - - - - - Default options for the HuobiRestClient - - - - - Whether public requests should be signed if ApiCredentials are provided. Needed for accurate rate limiting. - - - - - Broker id - - - - - Spot API options - - - - - USDT margin swap API options - - - - - Options for the HuobiSocketClient - - - - - Default options for the HuobiSocketClient - - - - - Spot API options - - - - - Usdt Margin Swap API options - - - - - - - - - - - ctor - - Service provider for resolving logging and clients - - - - - - - Huobi order book implementation - - - - - Create a new order book instance - - The symbol the order book is for - Option configuration delegate - - - - Create a new order book instance - - The symbol the order book is for - Option configuration delegate - Logger - Socket client instance - - - - - - - - - - - - - Extensions for the ICryptoRestClient and ICryptoSocketClient interfaces - - - - - Get the Huobi REST Api client - - - - - - - Get the Huobi Websocket Api client - - - - - - - Extensions for DI - - - - - Add the IHuobiClient and IHuobiSocketClient to the sevice collection so they can be injected - - The service collection - Set default options for the rest client - Set default options for the socket client - The lifetime of the IHuobiSocketClient for the service collection. Defaults to Singleton. - - - - diff --git a/Huobi.Net/HuobiExchange.cs b/Huobi.Net/HuobiExchange.cs deleted file mode 100644 index 64ee5297..00000000 --- a/Huobi.Net/HuobiExchange.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Huobi.Net -{ - /// - /// Huobi exchange information and configuration - /// - public static class HuobiExchange - { - /// - /// Exchange name - /// - public static string ExchangeName => "Huobi"; - - /// - /// Url to the main website - /// - public static string Url { get; } = "https://www.huobi.com"; - - /// - /// Urls to the API documentation - /// - public static string[] ApiDocsUrl { get; } = new[] { - "https://huobiapi.github.io/docs/spot/v1/en/#change-log" - }; - } -} diff --git a/Huobi.Net/Interfaces/Clients/IHuobiSocketClient.cs b/Huobi.Net/Interfaces/Clients/IHuobiSocketClient.cs deleted file mode 100644 index 5ec94168..00000000 --- a/Huobi.Net/Interfaces/Clients/IHuobiSocketClient.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CryptoExchange.Net.Authentication; -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Interfaces.Clients.SpotApi; -using Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi; - -namespace Huobi.Net.Interfaces.Clients -{ - /// - /// Client for accessing the Huobi websocket API. - /// - public interface IHuobiSocketClient : ISocketClient - { - /// - /// Spot streams - /// - public IHuobiSocketClientSpotApi SpotApi { get; } - /// - /// Usdt margin swap streams - /// - public IHuobiSocketClientUsdtMarginSwapApi 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. - /// - /// The credentials to set - void SetApiCredentials(ApiCredentials credentials); - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs deleted file mode 100644 index ca691578..00000000 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiAccount.cs +++ /dev/null @@ -1,381 +0,0 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; - -namespace Huobi.Net.Interfaces.Clients.SpotApi -{ - /// - /// Huobi account endpoints. Account endpoints include balance info, withdraw/deposit info and requesting and account settings - /// - public interface IHuobiRestClientSpotApiAccount - { - /// - /// Get the user id associated with the apikey/secret - /// - /// - /// Cancellation token - /// - Task> GetUserIdAsync(CancellationToken ct = default); - - /// - /// Gets a list of users associated with the apikey/secret - /// - /// - /// Cancellation token - /// - Task>> GetSubAccountUsersAsync(CancellationToken ct = default); - - /// - /// Gets a list of sub-user accounts associated with the sub-user id - /// - /// - /// The if of the user to get accounts for - /// Cancellation token - /// - Task> GetSubUserAccountsAsync(long subUserId, CancellationToken ct = default); - - /// - /// Gets a list of accounts associated with the apikey/secret - /// - /// - /// Cancellation token - /// - Task>> GetAccountsAsync(CancellationToken ct = default); - - /// - /// Gets a list of balances for a specific account - /// - /// - /// The id of the account to get the balances for - /// Cancellation token - /// - Task>> GetBalancesAsync(long accountId, CancellationToken ct = default); - - /// - /// Gets the valuation of all assets - /// - /// - /// Type of account to valuate - /// The currency to get the value in - /// The id of the sub user - /// Cancellation token - /// - Task> GetAssetValuationAsync(AccountType accountType, string? valuationCurrency = null, long? subUserId = null, CancellationToken ct = default); - - /// - /// Transfer assets between accounts - /// - /// - /// From user id - /// From account type - /// From account id - /// To user id - /// To account type - /// To account id - /// Asset to transfer - /// Amount to transfer - /// Cancellation token - /// - Task> TransferAssetAsync(long fromUserId, AccountType fromAccountType, long fromAccountId, - long toUserId, AccountType toAccountType, long toAccountId, string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Gets a list of balance changes of specified user's account - /// - /// - /// The id of the account to get the balances for - /// Asset name - /// Blance change types - /// Far point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days - /// Near point of time of the query window. The maximum size of the query window is 1 hour. The query window can be shifted within 30 days - /// Sorting order (Ascending by default) - /// Maximum number of items in each response (from 1 to 500, default is 100) - /// Cancellation token - /// - Task>> GetAccountHistoryAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? size = null, CancellationToken ct = default); - - /// - /// This endpoint returns the balance changes of specified user's account. - /// - /// - /// The id of the account to get the ledger for - /// Asset name - /// Blanace change types - /// Far point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days - /// Near point of time of the query window. The maximum size of the query window is 10 days. The query window can be shifted within 30 days - /// Sorting order (Ascending by default) - /// Maximum number of items in each response (from 1 to 500, default is 100) - /// Only get orders with ID before or after this. Used together with the direction parameter - /// Cancellation token - /// - Task>> GetAccountLedgerAsync(long accountId, string? asset = null, IEnumerable? transactionTypes = null, DateTime? startTime = null, DateTime? endTime = null, SortingType? sort = null, int? size = null, long? fromId = null, CancellationToken ct = default); - - /// - /// Gets a list of balances for a specific sub account - /// - /// - /// The id of the sub account to get the balances for - /// Cancellation token - /// - Task>> GetSubAccountBalancesAsync(long subAccountId, CancellationToken ct = default); - - /// - /// Transfer asset between parent and sub account - /// - /// - /// The target sub account id to transfer to or from - /// The asset to transfer - /// The quantity of asset to transfer - /// The type of transfer - /// Cancellation token - /// Unique transfer id - Task> TransferWithSubAccountAsync(long subAccountId, string asset, decimal quantity, TransferType transferType, CancellationToken ct = default); - - /// - /// Parent user and sub user could query deposit address of corresponding chain, for a specific crypto currency (except IOTA). - /// - /// - /// Asset - /// Cancellation token - /// - Task>> GetDepositAddressesAsync(string asset, CancellationToken ct = default); - - /// - /// 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. - /// - /// - /// The desination address of this withdraw - /// Asset - /// The quantity of asset to withdraw - /// The fee to pay with this withdraw - /// Set as "usdt" to withdraw USDT to OMNI, set as "trc20usdt" to withdraw USDT to TRX - /// A tag specified for this address - /// Cancellation token - /// - Task> WithdrawAsync(string address, string asset, decimal quantity, decimal fee, string? network = null, string? addressTag = null, CancellationToken ct = default); - - /// - /// Parent user and sub user searche for all existed withdraws and deposits and return their latest status. - /// - /// - /// Define transfer type to search - /// The asset to withdraw - /// The transfer id to begin search - /// The number of items to return - /// the order of response - /// Cancellation token - /// - Task>> GetWithdrawDepositAsync(WithdrawDepositType type, string? asset = null, int? from = null, int? size = null, FilterDirection? direction = null, CancellationToken ct = default); - - /// - /// Repay a margin loan - /// - /// - /// Account id - /// Asset to repay - /// Quantity to repay - /// Loan transaction ID - /// Cancellation token - /// - Task>> RepayMarginLoanAsync(string accountId, string asset, decimal quantity, string? transactionId = null, CancellationToken ct = default); - - /// - /// Transfer asset from spot account to isolated margin account - /// - /// - /// Trading symbol - /// Asset to transfer - /// Quantity to transfer - /// Cancellation token - /// Transfer id - Task> TransferSpotToIsolatedMarginAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Transfer asset from isolated margin to spot account - /// - /// - /// Trading symbol - /// Asset to transfer - /// Quantity to transfer - /// Cancellation token - /// Transfer id - Task> TransferIsolatedMarginToSpotAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Get isolated loan interest rate and quotas - /// - /// - /// Filter on symbols - /// Cancellation token - /// - Task>> GetIsolatedLoanInterestRateAndQuotaAsync(IEnumerable? symbols = null, CancellationToken ct = default); - - /// - /// Request a loan on isolated margin - /// - /// - /// The symbol - /// The asset - /// The quantity - /// Cancellation token - /// Order id - Task> RequestIsolatedMarginLoanAsync(string symbol, string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Repay a isolated margin loan - /// - /// - /// Id to repay - /// Quantity - /// Cancellation token - /// Order id - Task> RepayIsolatedMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default); - - /// - /// Get isolated margin orders history - /// - /// - /// The symbol to get history for - /// Filter by states - /// Filter by start date - /// Filter by end date - /// Start order id for use in combination with direction - /// Direction of results in combination with from parameter - /// Max amount of results - /// Sub user id - /// Cancellation token - /// - Task>> GetIsolatedMarginClosedOrdersAsync( - string symbol, - IEnumerable? states = null, - DateTime? startDate = null, - DateTime? endDate = null, - string? from = null, - FilterDirection? direction = null, - int? limit = null, - int? subUserId = null, - CancellationToken ct = default); - - /// - /// Get isolated margin account balance - /// - /// - /// The symbol - /// Sub user id - /// Cancellation token - /// - Task>> GetIsolatedMarginBalanceAsync(string symbol, int? subUserId = null, CancellationToken ct = default); - - /// - /// Transfer from spot account to cross margin account - /// - /// - /// The asset to transfer - /// Quantity to transfer - /// Cancellation token - /// - Task> TransferSpotToCrossMarginAsync(string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Transfer from cross margin account to spot account - /// - /// - /// The asset to transfer - /// Quantity to transfer - /// Cancellation token - /// - Task> TransferCrossMarginToSpotAsync(string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Get cross margin interest rates and quotas - /// - /// - /// - /// - Task>> GetCrossLoanInterestRateAndQuotaAsync(CancellationToken ct = default); - - /// - /// Request a loan on cross margin - /// - /// - /// The asset - /// The quantity - /// Cancellation token - /// Order id - Task> RequestCrossMarginLoanAsync(string asset, decimal quantity, CancellationToken ct = default); - - /// - /// Repay a isolated margin loan - /// - /// - /// Id to repay - /// Quantity - /// Cancellation token - /// Order id - Task> RepayCrossMarginLoanAsync(string orderId, decimal quantity, CancellationToken ct = default); - - /// - /// Get cross margin order history - /// - /// - /// Filter by asset - /// Filter by state - /// Filter by start date - /// Filter by end date - /// Start order id for use in combination with direction - /// Direction of results in combination with from parameter - /// Max amount of results - /// Sub user id - /// Cancellation token - /// - Task>> GetCrossMarginClosedOrdersAsync( - string? asset = null, - MarginOrderStatus? state = null, - DateTime? startDate = null, - DateTime? endDate = null, - string? from = null, - FilterDirection? direction = null, - int? limit = null, - int? subUserId = null, - CancellationToken ct = default); - - /// - /// Get cross margin account balance - /// - /// - /// Sub user id - /// Cancellation token - /// - Task> GetCrossMarginBalanceAsync(int? subUserId = null, CancellationToken ct = default); - - /// - /// Get repayment history - /// - /// - /// Filter by repay id - /// Filter by account id - /// Filter by asset - /// Only show records after this - /// Only show records before this - /// Sort direction - /// Result limit - /// Search id - /// Cancellation token - /// - Task>> GetRepaymentHistoryAsync(long? repayId = null, long? accountId = null, string? asset = null, DateTime? startTime = null, DateTime? endTime = null, string? sort = null, int? limit = null, long? fromId = null, CancellationToken ct = default); - - /// - /// Get Current Fee Rate Applied to The User - /// - /// - /// Filter on symbols - /// Cancellation token - /// - Task>> GetCurrentFeeRatesAsync(IEnumerable symbols, - CancellationToken ct = default); - } -} diff --git a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs b/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs deleted file mode 100644 index 100ca74f..00000000 --- a/Huobi.Net/Interfaces/Clients/SpotApi/IHuobiRestClientSpotApiExchangeData.cs +++ /dev/null @@ -1,133 +0,0 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Huobi.Net.Objects.Models; - -namespace Huobi.Net.Interfaces.Clients.SpotApi -{ - /// - /// Huobi exchange data endpoints. Exchange data includes market data (tickers, order books, etc) and system status. - /// - public interface IHuobiRestClientSpotApiExchangeData - { - /// - /// Gets the latest ticker for all symbols - /// - /// - /// Cancellation token - /// - Task> GetTickersAsync(CancellationToken ct = default); - - /// - /// Gets the ticker, including the best bid / best ask for a symbol - /// - /// - /// The symbol to get the ticker for - /// Cancellation token - /// - Task> GetTickerAsync(string symbol, CancellationToken ct = default); - - /// - /// Get candlestick data for a symbol - /// - /// - /// The symbol to get the data for - /// The period of a single candlestick - /// The amount of candlesticks - /// Cancellation token - /// - Task>> GetKlinesAsync(string symbol, KlineInterval period, int? limit = null, CancellationToken ct = default); - - /// - /// Gets the order book for a symbol - /// - /// - /// The symbol to request for - /// The way the results will be merged together - /// The depth of the book - /// Cancellation token - /// - Task> GetOrderBookAsync(string symbol, int mergeStep, int? limit = null, CancellationToken ct = default); - - /// - /// Gets the last trade for a symbol - /// - /// - /// The symbol to request for - /// Cancellation token - /// - Task> GetLastTradeAsync(string symbol, CancellationToken ct = default); - - /// - /// Get the last x trades for a symbol - /// - /// - /// The symbol to get trades for - /// The max number of results - /// Cancellation token - /// - Task>> GetTradeHistoryAsync(string symbol, int? limit = null, CancellationToken ct = default); - - /// - /// Gets 24h stats for a symbol - /// - /// - /// The symbol to get the data for - /// Cancellation token - /// - Task> GetSymbolDetails24HAsync(string symbol, CancellationToken ct = default); - - /// - /// Gets real time NAV for ETP - /// - /// - /// The symbol to get the data for - /// Cancellation token - /// - Task> GetNavAsync(string symbol, CancellationToken ct = default); - - /// - /// Gets the current market status - /// - /// - /// Cancellation token - /// - Task> GetSymbolStatusAsync(CancellationToken ct = default); - - /// - /// Gets a list of supported symbols - /// - /// - /// Cancellation token - /// - Task>> GetSymbolsAsync(CancellationToken ct = default); - - /// - /// Gets a list of supported currencies - /// - /// - /// Cancellation token - /// - Task>> GetAssetsAsync(CancellationToken ct = default); - - /// - /// Gets a list of supported currencies and chains - /// - /// - /// Filter by asset - /// Cancellation token - /// - Task>> GetAssetDetailsAsync(string? asset = null, CancellationToken ct = default); - - /// - /// Gets the server time - /// - /// - /// Cancellation token - /// - Task> GetServerTimeAsync(CancellationToken ct = default); - } -} diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs deleted file mode 100644 index 299b5558..00000000 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApi.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Clients.UsdtMarginSwapApi; - -namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi -{ - /// - /// Usdt margin swap api endpoints - /// - public interface IHuobiRestClientUsdtMarginSwapApi : IRestApiClient - { - /// - /// Endpoints related to account settings, info or actions - /// - IHuobiRestClientUsdtMarginSwapApiAccount Account { get; } - /// - /// Endpoints related to retrieving market and system data - /// - IHuobiRestClientUsdtMarginSwapApiExchangeData ExchangeData { get; } - /// - /// Endpoints related to orders and trades - /// - IHuobiRestClientUsdtMarginSwapApiTrading Trading { get; } - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs deleted file mode 100644 index f732115f..00000000 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiAccount.cs +++ /dev/null @@ -1,221 +0,0 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi -{ - /// - /// Huobi usdt swap account endpoints - /// - public interface IHuobiRestClientUsdtMarginSwapApiAccount - { - /// - /// Get asset values - /// - /// - /// The asset - /// Cancellation token - /// - Task>> GetAssetValuationAsync(string? asset = null, CancellationToken ct = default); - /// - /// Get isolated margin account info - /// - /// - /// Optional contract code filter - /// Cancellation token - /// - Task>> GetIsolatedMarginAccountInfoAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get cross margin account info - /// - /// - /// Optional margin account filter - /// Cancellation token - /// - Task>> GetCrossMarginAccountInfoAsync(string? marginAccount = null, CancellationToken ct = default); - /// - /// Get cross margin assets and positions - /// - /// - /// Margin account - /// Cancellation token - /// - Task> GetCrossMarginAssetAndPositionsAsync(string marginAccount, CancellationToken ct = default); - /// - /// Get cross margin available leverage - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Business type - /// Cancellation token - /// - Task>> GetCrossMarginAvailableLeverageAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get cross margin positions - /// - /// - /// Filter by contract code - /// Cancellation token - /// - Task>> GetCrossMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get cross margin settlement records - /// - /// - /// Margin account - /// Filter by start time - /// Filter by end time - /// Page - /// Page size - /// Cancellation token - /// - Task> GetCrossMarginSettlementRecordsAsync(string marginAccount, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get cross margin sub account assets - /// - /// - /// Margin account - /// Cancellation token - /// - Task>> GetCrossMarginSubAccountsAssetsAsync(string? marginAccount = null, CancellationToken ct = default); - /// - /// Get financial records - /// - /// - /// Margin account - /// Contract code - /// Filter by type - /// Filter by create date - /// Page - /// Page size - /// Cancellation token - /// - Task> GetFinancialRecordsAsync(string marginAccount, string? contractCode = null, IEnumerable? types = null, DateTime? createDate = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get isolated margin assets and positisons - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginAssetAndPositionsAsync(string contractCode, CancellationToken ct = default); - /// - /// Get isolated margin available leverage - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginAvailableLeverageAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get isolated margin position info - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginPositionsAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get isolated margin settlement records - /// - /// - /// Contract code - /// Filter by start time - /// Filter by end time - /// Page - /// Page size - /// Cancellation token - /// - Task> GetIsolatedMarginSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get isolated margin sub account assets - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginSubAccountsAssetsAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get master sub account transfer records - /// - /// - /// Margin account - /// Days in history - /// Filter by type - /// Page - /// Page size - /// Cancellation token - /// - Task> GetMasterSubTransferRecordsAsync(string marginAccount, int daysInHistory, MasterSubTransferType? type = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get trading fees - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Business tpye - /// Cancellation token - /// - Task>> GetTradingFeesAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Switch cross margin position mode - /// - /// - /// Margin account - /// Position mode - /// Cancellation token - /// - Task> ModifyCrossMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default); - /// - /// Switch isolated margin position mode - /// - /// - /// Margin account - /// Position mode - /// Cancellation token - /// - Task> ModifyIsolatedMarginPositionModeAsync(string marginAccount, PositionMode positionMode, CancellationToken ct = default); - /// - /// Set sub account trading permissions - /// - /// - /// Uids of the subaccounts - /// Enable trading - /// Cancellation token - /// - Task> SetSubAccountsTradingPermissionsAsync(IEnumerable subAccountUids, bool enabled, CancellationToken ct = default); - /// - /// Transfer between margin accounts - /// - /// - /// Asset to transfer - /// From account - /// To account - /// Quantity to transfer - /// Client order id - /// Cancellation token - /// - Task> TransferMarginAccountsAsync(string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, long? clientOrderId = null, CancellationToken ct = default); - /// - /// Transfer between master and sub account - /// - /// - /// Sub account uid - /// Asset to transfer - /// From account - /// To account - /// Quantity to transfer - /// Type - /// Client order id - /// Cancellation token - /// - Task> TransferMasterSubAsync(string subUid, string asset, string fromMarginAccount, string toMarginAccount, decimal quantity, MasterSubTransferType type, long? clientOrderId = null, CancellationToken ct = default); - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs deleted file mode 100644 index 69f46db3..00000000 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiExchangeData.cs +++ /dev/null @@ -1,319 +0,0 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -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 IHuobiRestClientUsdtMarginSwapApiExchangeData - { - /// - /// Get basis data - /// - /// - /// Contract code - /// Kline interval - /// Limit - /// Price type (open, close, high, low, average) - /// Cancellation token - /// - Task>> GetBasisDataAsync(string contractCode, KlineInterval interval, int limit, string? basisPriceType = null, CancellationToken ct = default); - /// - /// Get the best current offer - /// - /// - /// Contract code - /// Type - /// Cancellation token - /// - Task>> GetBestOfferAsync(string? contractCode = null, BusinessType? type = null, CancellationToken ct = default); - /// - /// Get contract info - /// - /// - /// Contract code - /// Support margin mode - /// Symbol - /// Contract type - /// Business type - /// Cancellation token - /// - Task>> GetContractInfoAsync(string? contractCode = null, MarginMode? supportMarginMode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get cross margin adjust factor info - /// - /// - /// Contract code - /// Asset - /// Type - /// Cancellation token - /// - Task>> GetCrossMarginAdjustFactorInfoAsync(string? contractCode = null, string? asset = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Get cross margin trade status - /// - /// - /// Contract code - /// Asset - /// Type - /// Cancellation token - /// - Task>> GetCrossMarginTradeStatusAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Get cross margin transfer status - /// - /// - /// Margin account - /// Cancellation token - /// - Task>> GetCrossMarginTransferStatusAsync(string? marginAccount = null, CancellationToken ct = default); - /// - /// Get cross tiered margin info - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Cancellation token - /// - Task>> GetCrossTieredMarginInfoAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Get estimated funding rate kliens - /// - /// - /// Contract code - /// Kline interval - /// Limit - /// Cancellation token - /// - Task>> GetEstimatedFundingRateKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default); - /// - /// Get estimated settlement price - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Business type - /// Cancellation token - /// - Task>> GetEstimatedSettlementPriceAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get funding rate - /// - /// - /// Contract code - /// Cancellation token - /// - Task> GetFundingRateAsync(string contractCode, CancellationToken ct = default); - /// - /// Get funding rates - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetFundingRatesAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get historical funding rates - /// - /// - /// Contract code - /// Page - /// Page size - /// Cancellation token - /// - Task> GetHistoricalFundingRatesAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get historical settlement records - /// - /// - /// Contract code - /// Filter by start time - /// Filter by end time - /// Page - /// Page size - /// Cancellation token - /// - Task> GetHistoricalSettlementRecordsAsync(string contractCode, DateTime? startTime = null, DateTime? endTime = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get insurance fund history - /// - /// - /// Contract code - /// Page - /// Page size - /// Cancellation token - /// - Task> GetInsuranceFundHistoryAsync(string contractCode, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get isolated margin adjust factor info - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginAdjustFactorInfoAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get isolated margin status - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedStatusAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get isolated margin tier info - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetIsolatedMarginTieredInfoAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get klines - /// - /// - /// Contract code - /// Kline interval - /// Limit - /// Filter by start time - /// Filter by end time - /// Cancellation token - /// - Task>> GetKlinesAsync(string contractCode, KlineInterval interval, int? limit = null, DateTime? from = null, DateTime? to = null, CancellationToken ct = default); - /// - /// Get last trades - /// - /// - /// Contract code - /// Business type - /// Cancellation token - /// - Task> GetLastTradesAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get liquidation orders - /// - /// - /// Create date - /// Trade type - /// Contract code - /// Symbol - /// Page - /// Page size - /// Cancellation token - /// - Task> GetLiquidationOrdersAsync(int createDate, LiquidationTradeType tradeType, string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get market data - /// - /// - /// Contract code - /// Cancellation token - /// - Task> GetMarketDataAsync(string contractCode, CancellationToken ct = default); - /// - /// Get market datas - /// - /// - /// Contract code - /// Business type - /// Cancellation token - /// - Task>> GetMarketDatasAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get open interest - /// - /// - /// Period - /// Unit - /// Contract code - /// Symbol - /// Type - /// Limit - /// Cancellation token - /// - Task> GetOpenInterestAsync(InterestPeriod period, Unit unit, string? contractCode = null, string? symbol = null, ContractType? type = null, int? limit = null, CancellationToken ct = default); - /// - /// Get order book - /// - /// - /// Contract code - /// Merge step - /// Cancellation token - /// - Task> GetOrderBookAsync(string contractCode, string step, CancellationToken ct = default); - /// - /// Get premium index klines - /// - /// - /// Contract code - /// Interval - /// Limit - /// Cancellation token - /// - Task>> GetPremiumIndexKlinesAsync(string contractCode, KlineInterval interval, int limit, CancellationToken ct = default); - /// - /// Get recent trades - /// - /// - /// Contract code - /// Limit - /// Cancellation token - /// - Task>> GetRecentTradesAsync(string contractCode, int limit, CancellationToken ct = default); - /// - /// Get server time - /// - /// - /// Cancellation token - /// - Task> GetServerTimeAsync(CancellationToken ct = default); - /// - /// Get swap index price - /// - /// - /// Contract code - /// Cancellation token - /// - Task>> GetSwapIndexPriceAsync(string? contractCode = null, CancellationToken ct = default); - /// - /// Get swap open interest - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Business tpye - /// Cancellation token - /// - Task>> GetSwapOpenInterestAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get swap price limitation - /// - /// - /// Contract code - /// Symbol - /// Contract tpye - /// Business type - /// Cancellation token - /// - Task>> GetSwapPriceLimitationAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, BusinessType? businessType = null, CancellationToken ct = default); - /// - /// Get swap risk info - /// - /// - /// Contract code - /// Business type - /// Cancellation token - /// - Task>> GetSwapRiskInfoAsync(string? contractCode = null, BusinessType? businessType = null, CancellationToken ct = default); - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs deleted file mode 100644 index c5242417..00000000 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiRestClientUsdtMarginSwapApiTrading.cs +++ /dev/null @@ -1,286 +0,0 @@ -using CryptoExchange.Net.Objects; -using Huobi.Net.Enums; -using Huobi.Net.Objects.Models.UsdtMarginSwap; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi -{ - /// - /// Huobi usdt margin swap trading endpoints, placing and mananging orders. - /// - public interface IHuobiRestClientUsdtMarginSwapApiTrading - { - /// - /// Cancel all cross margin orders fitting the parameters - /// - /// - /// Contract code - /// Symbol - /// Contract type - /// Side - /// Offset - /// Cancellation token - /// - Task> CancelAllCrossMarginOrdersAsync(string? contractCode = null, string? symbol = null, ContractType? contractType = null, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); - /// - /// Cancel all isolated margin order fitting the parameters - /// - /// - /// Contract code - /// Side - /// Offset - /// Cancellation token - /// - Task> CancelAllIsolatedMarginOrdersAsync(string contractCode, OrderSide? side = null, Offset? offset = null, CancellationToken ct = default); - /// - /// Cancel cross margin order - /// - /// - /// The order id - /// The client order id - /// Contract code - /// Symbol - /// Contract type - /// Cancellation token - /// - Task> CancelCrossMarginOrderAsync(long? orderId = null, long? clientOrderId = null, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Cancel cross margin orders - /// - /// - /// Order ids - /// Client order ids - /// Contract code - /// Symbol - /// Contract type - /// Cancellation token - /// - Task> CancelCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Cancel isolated margin order - /// - /// - /// Contract code - /// Order id - /// Client order id - /// Cancellation token - /// - Task> CancelIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); - /// - /// Cancel isolated margin orders - /// - /// - /// Contract code - /// Order ids - /// Client order ids - /// Cancellation token - /// - Task> CancelIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderId, IEnumerable clientOrderId, CancellationToken ct = default); - /// - /// Change cross margin leverage - /// - /// - /// Leverage rate - /// Contract code - /// Symbol - /// Contract type - /// Cancellation token - /// - Task> ChangeCrossMarginLeverageAsync(int leverageRate, string? contractCode = null, string? symbol = null, ContractType? contractType = null, CancellationToken ct = default); - /// - /// Change isolated margin leverage - /// - /// - /// Contract code - /// Leverage rate - /// Cancellation token - /// - Task> ChangeIsolatedMarginLeverageAsync(string contractCode, int leverageRate, CancellationToken ct = default); - /// - /// Get cross margin closed orders - /// - /// - /// Trade type - /// All orders - /// Days in history - /// Contract code - /// Symbol - /// Page - /// Page size - /// Sort by - /// Cancellation token - /// - Task> GetCrossMarginClosedOrdersAsync(MarginTradeType tradeType, bool allOrders, int daysInHistory, string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); - /// - /// Get cross margin open orders - /// - /// - /// Contract code - /// Symbol - /// Page - /// Page size - /// Sort by - /// Trade type - /// Cancellation token - /// - Task> GetCrossMarginOpenOrdersAsync(string? contractCode = null, string? symbol = null, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default); - /// - /// Get cross margin order - /// - /// - /// Contract code - /// Symbol - /// Order id - /// Client order id - /// Cancellation token - /// - Task>> GetCrossMarginOrderAsync(string? contractCode = null, string? symbol = null, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); - /// - /// Get cross margin order details - /// - /// - /// Contract code - /// Order id - /// Cancellation token - /// - Task> GetCrossMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default); - /// - /// Get cross margin orders - /// - /// - /// Order ids - /// Client order ids - /// Contract code - /// Symbol - /// Cancellation token - /// - Task>> GetCrossMarginOrdersAsync(IEnumerable orderIds, IEnumerable clientOrderIds, string? contractCode = null, string? symbol = null, CancellationToken ct = default); - /// - /// Get cross margin user trades - /// - /// - /// Contract code - /// Trade type - /// Days in history - /// Page - /// Page size - /// Cancellation token - /// - Task> GetCrossMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, int daysInHistory, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Get isolated margin closed orders - /// - /// - /// Contract code - /// Trade type - /// All orders - /// Days in history - /// Page - /// Page size - /// Sort by - /// Cancellation token - /// - Task> GetIsolatedMarginClosedOrdersAsync(string contractCode, MarginTradeType tradeType, bool allOrders, int daysInHistory, int? page = null, int? pageSize = null, string? sortBy = null, CancellationToken ct = default); - /// - /// Get isolated margin open orders - /// - /// - /// Contract code - /// Page - /// Page size - /// Sort by - /// Trade type - /// Cancellation token - /// - Task> GetIsolatedMarginOpenOrdersAsync(string contractCode, int? page = null, int? pageSize = null, string? sortBy = null, MarginTradeType? tradeType = null, CancellationToken ct = default); - /// - /// Get isoalted margin order - /// - /// - /// Contract code - /// Order id - /// Client order id - /// Cancellation token - /// - Task>> GetIsolatedMarginOrderAsync(string contractCode, long? orderId = null, long? clientOrderId = null, CancellationToken ct = default); - /// - /// Get isolated margin order details - /// - /// - /// Contract code - /// Order id - /// Cancellation token - /// - Task> GetIsolatedMarginOrderDetailsAsync(string contractCode, long orderId, CancellationToken ct = default); - /// - /// Get isolated margin orders - /// - /// - /// Contract code - /// Order ids - /// Client order ids - /// Cancellation token - /// - Task>> GetIsolatedMarginOrdersAsync(string contractCode, IEnumerable orderIds, IEnumerable clientOrderIds, CancellationToken ct = default); - /// - /// Get isolated margin user trades - /// - /// - /// Contract code - /// Trade type - /// Days in history - /// Page - /// Page size - /// Cancellation token - /// - Task> GetIsolatedMarginUserTradesAsync(string contractCode, MarginTradeType tradeType, int daysInHistory, int? page = null, int? pageSize = null, CancellationToken ct = default); - /// - /// Place a new cross margin order - /// - /// - /// Order quantity - /// Order side - /// Leverage rate - /// Contract code - /// Symbol - /// Contract type - /// Price - /// Offset - /// Order price type - /// Take profit trigger price - /// Take profit order price - /// Take profit order price type - /// Stop loss trigger price - /// Stop loss order price - /// Stop loss order price type - /// Reduce only - /// Client order id - /// Cancellation token - /// - Task> PlaceCrossMarginOrderAsync(decimal quantity, OrderSide side, int leverageRate, string? contractCode = null, string? symbol = null, ContractType? contractType = null, decimal? price = null, Offset? offset = null, OrderPriceType? orderPriceType = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, bool? reduceOnly = null, long? clientOrderId = null, CancellationToken ct = default); - /// - /// Place a new isolated margin order - /// - /// - /// Contract code - /// Quantity - /// Order side - /// Leverage rate - /// Price - /// Offset - /// Order price type - /// Take profit trigger price - /// Take profit order price - /// Take profit order price type - /// Stop loss trigger price - /// Stop loss order price - /// Stop loss order price type - /// Reduce only - /// Client order id - /// Cancellation token - /// - Task> PlaceIsolatedMarginOrderAsync(string contractCode, decimal quantity, OrderSide side, int leverageRate, decimal? price = null, Offset? offset = null, OrderPriceType? orderPriceType = null, decimal? takeProfitTriggerPrice = null, decimal? takeProfitOrderPrice = null, OrderPriceType? takeProfitOrderPriceType = null, decimal? stopLossTriggerPrice = null, decimal? stopLossOrderPrice = null, OrderPriceType? stopLossOrderPriceType = null, bool? reduceOnly = null, long? clientOrderId = null, CancellationToken ct = default); - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiSocketClientUsdtMarginSwapApi.cs b/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiSocketClientUsdtMarginSwapApi.cs deleted file mode 100644 index 37263db3..00000000 --- a/Huobi.Net/Interfaces/Clients/UsdtMarginSwapApi/IHuobiSocketClientUsdtMarginSwapApi.cs +++ /dev/null @@ -1,128 +0,0 @@ -using CryptoExchange.Net.Interfaces; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using Huobi.Net.Enums; -using Huobi.Net.Objects.Models; -using Huobi.Net.Objects.Models.Socket; -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Huobi.Net.Interfaces.Clients.UsdtMarginSwapApi -{ - /// - /// Usdt margin swap streams - /// - public interface IHuobiSocketClientUsdtMarginSwapApi : ISocketApiClient - { - /// - /// Subscribe to basis updates - /// - /// - /// Contract code - /// Period - /// Price type - /// Data handler - /// Cancellation token - /// - Task> SubscribeToBasisUpdatesAsync(string contractCode, KlineInterval period, string priceType, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to best offer updates - /// - /// - /// Contract code - /// Data handler - /// Cancellation token - /// - Task> SubscribeToBestOfferUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to estimated funding rate kline updates - /// - /// - /// Contract code - /// Period - /// Data handler - /// Cancellation token - /// - Task> SubscribeToEstimatedFundingRateKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to incremental order book updates - /// - /// - /// Contract code - /// Snapshot or incremental - /// Depth - /// Data handler - /// Cancellation token - /// - Task> SubscribeToIncrementalOrderBookUpdatesAsync(string contractCode, bool snapshot, int limit, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to index kline updates - /// - /// - /// Contract code - /// Period - /// Data handler - /// Cancellation token - /// - Task> SubscribeToIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to kline updates - /// - /// - /// Contract code - /// Period - /// Data handler - /// Cancellation token - /// - Task> SubscribeToKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to mark price updates - /// - /// - /// Contract code - /// Period - /// Data handler - /// Cancellation token - /// - Task> SubscribeToMarkPriceKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to order book updates - /// - /// - /// Contract code - /// Merge step - /// Data handler - /// Cancellation token - /// - Task> SubscribeToOrderBookUpdatesAsync(string contractCode, int mergeStep, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to premium index kline updates - /// - /// - /// Contract code - /// Period - /// Data handler - /// Cancellation token - /// - Task> SubscribeToPremiumIndexKlineUpdatesAsync(string contractCode, KlineInterval period, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to symbol ticker updates - /// - /// - /// Contract code - /// Data handler - /// Cancellation token - /// - Task> SubscribeToSymbolTickerUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); - /// - /// Subscribe to symbol trade updates - /// - /// - /// Contract code - /// Data handler - /// Cancellation token - /// - Task> SubscribeToTradeUpdatesAsync(string contractCode, Action> onData, CancellationToken ct = default); - } -} \ No newline at end of file diff --git a/Huobi.Net/Interfaces/IHuobiOrderBookFactory.cs b/Huobi.Net/Interfaces/IHuobiOrderBookFactory.cs deleted file mode 100644 index b71e5ca5..00000000 --- a/Huobi.Net/Interfaces/IHuobiOrderBookFactory.cs +++ /dev/null @@ -1,25 +0,0 @@ -using CryptoExchange.Net.Interfaces; -using Huobi.Net.Objects.Options; -using System; - -namespace Huobi.Net.Interfaces -{ - /// - /// Huobi order book factory - /// - public interface IHuobiOrderBookFactory - { - /// - /// Spot order book factory methods - /// - public IOrderBookFactory Spot { get; } - - /// - /// Create a SymbolOrderBook for the Spot API - /// - /// The symbol - /// Order book options - /// - ISymbolOrderBook CreateSpot(string symbol, Action? options = null); - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiApiResponse.cs b/Huobi.Net/Objects/Internal/HuobiApiResponse.cs deleted file mode 100644 index d0d7c200..00000000 --- a/Huobi.Net/Objects/Internal/HuobiApiResponse.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal abstract class HuobiApiResponse - { - [JsonProperty("status")] - internal string? Status { get; set; } - - - [JsonProperty("err-msg")] - internal string? ErrorMessage { get; set; } - [JsonProperty("err_msg")] - private string? ErrorMessageInternal - { - get => ErrorMessage; - set => ErrorMessage = value; - } - [JsonProperty("err-code")] - internal string? ErrorCode { get; set; } - [JsonProperty("err_code")] - private string? ErrorCodeInternal - { - get => ErrorCode; - set => ErrorCode = value; - } - [JsonProperty("code")] - private string? ErrorCodeInternal2 - { - get => ErrorCode; - set => ErrorCode = value; - } - } - - internal class HuobiBasicResponse : HuobiApiResponse - { - public T Data { get; set; } = default!; - [JsonProperty("tick")] - private T Tick { set => Data = value; get => Data; } - [JsonProperty("ticks")] - private T Ticks { set => Data = value; get => Data; } - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] - public DateTime Timestamp { get; set; } - [JsonProperty("ch")] - public string Channel { get; set; } = string.Empty; - [JsonProperty("next-time"), JsonConverter(typeof(DateTimeConverter))] - private DateTime NextTime { get => Timestamp; set => Timestamp = value; } - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiAuthenticationRequest2.cs b/Huobi.Net/Objects/Internal/HuobiAuthenticationRequest2.cs deleted file mode 100644 index 0c2c7dc2..00000000 --- a/Huobi.Net/Objects/Internal/HuobiAuthenticationRequest2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiAuthenticationRequest2 - { - [JsonProperty("op")] public string Operation { get; set; } = "auth"; - [JsonProperty("type")] public string AuthType { get; set; } = "api"; - [JsonProperty("AccessKeyId")] public string AccessKey { get; set; } = string.Empty; - [JsonProperty("SignatureMethod")] public string SignatureMethod { get; set; } = "HmacSHA256"; - [JsonProperty("SignatureVersion")] public string SignatureVersion { get; set; } = "2"; - [JsonProperty("Timestamp")] public string Timestamp { get; set; } = string.Empty; - [JsonProperty("Signature")] public string Signature { get; set; } = string.Empty; - - public HuobiAuthenticationRequest2(string accessKey, string timestamp, string signature) - { - AccessKey = accessKey; - Timestamp = timestamp; - Signature = signature; - } - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiPingRequest.cs b/Huobi.Net/Objects/Internal/HuobiPingRequest.cs deleted file mode 100644 index 224cab9d..00000000 --- a/Huobi.Net/Objects/Internal/HuobiPingRequest.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiPingRequest - { - [JsonProperty("ping")] - public long Ping { get; set; } - } - - internal class HuobiPingResponse - { - [JsonProperty("pong")] - public long Pong { get; set; } - - public HuobiPingResponse(long id) - { - Pong = id; - } - } - - internal class HuobiPingAuthResponse - { - [JsonProperty("action")] - public string Action { get; set; } - [JsonProperty("data")] - public Dictionary Data { get; set; } - - public HuobiPingAuthResponse(long id) - { - Action = "pong"; - Data = new Dictionary() - { - { "ts", id} - }; - } - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiSocketRequest.cs b/Huobi.Net/Objects/Internal/HuobiSocketRequest.cs deleted file mode 100644 index 7be787c8..00000000 --- a/Huobi.Net/Objects/Internal/HuobiSocketRequest.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiRequest - { - [JsonIgnore] - public string? Id { get; set; } - } - - internal class HuobiSocketRequest: HuobiRequest - { - [JsonProperty("req")] - public string Request { get; set; } - - [JsonProperty("id")] - public new string Id { get; set; } - - - public HuobiSocketRequest(string id, string topic) - { - Id = id; - Request = topic; - } - } - - internal class HuobiAuthenticatedSubscribeRequest - { - [JsonProperty("action")] - public string Action { get; set; } - [JsonProperty("ch")] - public string Channel { get; set; } - - public HuobiAuthenticatedSubscribeRequest(string channel, string action = "sub") - { - Action = action; - Channel = channel; - } - } - - internal class HuobiSubscribeRequest: HuobiRequest - { - [JsonProperty("sub")] - public string Topic { get; set; } - [JsonProperty("id")] - public new string Id { get; set; } - - public HuobiSubscribeRequest(string id, string topic) - { - Id = id; - Topic = topic; - } - } - - internal class HuobiIncrementalOrderBookSubscribeRequest : HuobiSubscribeRequest - { - [JsonProperty("data_type")] - public string DataType { get; set; } - public HuobiIncrementalOrderBookSubscribeRequest(string id, string topic, string dataType) : base(id, topic) - { - DataType = dataType; - } - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiSocketRequest2.cs b/Huobi.Net/Objects/Internal/HuobiSocketRequest2.cs deleted file mode 100644 index 37c2ec72..00000000 --- a/Huobi.Net/Objects/Internal/HuobiSocketRequest2.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiSocketRequest2 - { - [JsonProperty("op")] - public string Operation { get; set; } - [JsonProperty("cid")] - public string ClientId { get; set; } - [JsonProperty("topic")] - public string Topic { get; set; } - - public HuobiSocketRequest2(string operation, string clientId, string topic) - { - Operation = operation; - ClientId = clientId; - Topic = topic; - } - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiSocketResponse.cs b/Huobi.Net/Objects/Internal/HuobiSocketResponse.cs deleted file mode 100644 index cb5453ed..00000000 --- a/Huobi.Net/Objects/Internal/HuobiSocketResponse.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal abstract class HuobiResponse - { - internal abstract bool IsSuccessful { get; } - public string? Id { get; set; } - [JsonProperty("err-code")] - public string? ErrorCode { get; set; } - [JsonProperty("err-msg")] - public string? ErrorMessage { get; set; } - } - - internal class HuobiSocketResponse: HuobiResponse - { - internal override bool IsSuccessful => string.Equals(Status, "ok", StringComparison.Ordinal); - [JsonProperty("status")] internal string Status { get; set; } = string.Empty; - - /// - /// The timestamp of the data - /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] - public DateTime Timestamp { get; set; } - - /// - /// The data - /// - public T Data { get; set; } = default!; - [JsonProperty("tick")] - private T Tick { set => Data = value; get => Data; } - } - - internal class HuobiSubscribeResponse: HuobiResponse - { - internal override bool IsSuccessful => string.Equals(Status, "ok", StringComparison.Ordinal); - public string Status { get; set; } = string.Empty; - public string Subbed { get; set; } = string.Empty; - [JsonConverter(typeof(DateTimeConverter)), JsonProperty("ts")] - public DateTime Timestamp { get; set; } - } - - internal class HuobiAuthSubscribeResponse - { - internal bool IsSuccessful => Code == 200; - public int Code { get; set; } - public string Message { get; set; } = string.Empty; - [JsonProperty("ch")] - public string Channel { get; set; } = string.Empty; - public string Action { get; set; } = string.Empty; - } - -} diff --git a/Huobi.Net/Objects/Internal/HuobiSocketResponse2.cs b/Huobi.Net/Objects/Internal/HuobiSocketResponse2.cs deleted file mode 100644 index e053e048..00000000 --- a/Huobi.Net/Objects/Internal/HuobiSocketResponse2.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiSocketResponse2: HuobiResponse - { - internal override bool IsSuccessful => string.Equals(ErrorCode, "0", StringComparison.Ordinal); - [JsonProperty("status")] - internal string Status { get; set; } = string.Empty; - - [JsonProperty("cid")] - internal string ClientId { get; set; } = string.Empty; - - [JsonProperty("topic")] - internal string Topic { get; set; } = string.Empty; - - /// - /// The timestamp of the data - /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] - public DateTime Timestamp { get; set; } - } - - internal class HuobiSocketResponse2: HuobiSocketResponse2 - { - /// - /// The data - /// - public T Data { get; set; } = default!; - [JsonProperty("tick")] - private T Tick { set => Data = value; get => Data; } - } - - internal class HuobiAuthResponse - { - internal bool IsSuccessful => Code == 0; - [JsonProperty("err-code")] - public int Code { get; set; } - [JsonProperty("err-msg")] - public string Message { get; set; } = String.Empty; - } -} diff --git a/Huobi.Net/Objects/Internal/HuobiUnsubscribeRequest.cs b/Huobi.Net/Objects/Internal/HuobiUnsubscribeRequest.cs deleted file mode 100644 index 9a317980..00000000 --- a/Huobi.Net/Objects/Internal/HuobiUnsubscribeRequest.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Internal -{ - internal class HuobiUnsubscribeRequest - { - [JsonProperty("unsub")] - public string Topic { get; set; } - - [JsonProperty("id")] - public string Id { get; set; } - - public HuobiUnsubscribeRequest(string id, string topic) - { - Topic = topic; - Id = id; - } - } -} diff --git a/Huobi.Net/Objects/Models/HuobiAccountBalances.cs b/Huobi.Net/Objects/Models/HuobiAccountBalances.cs deleted file mode 100644 index 5b1786cd..00000000 --- a/Huobi.Net/Objects/Models/HuobiAccountBalances.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Account and balance info - /// - public record HuobiAccountBalances: HuobiAccount - { - /// - /// The list of balances - /// - [JsonProperty("list")] - public IEnumerable Data { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/HuobiAssetInfo.cs b/Huobi.Net/Objects/Models/HuobiAssetInfo.cs deleted file mode 100644 index c6cc3418..00000000 --- a/Huobi.Net/Objects/Models/HuobiAssetInfo.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using System.Collections.Generic; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Info on an asset - /// - public record HuobiAssetInfo - { - /// - /// Asset - /// - [JsonProperty("currency")] - public string Asset { get; set; } = string.Empty; - /// - /// Status of the asset - /// - [JsonProperty("instStatus")] - public InstrumentStatus Status { get; set; } - /// - /// Networks - /// - [JsonProperty("chains")] - public IEnumerable Networks { get; set; } = Array.Empty(); - } - - /// - /// Info on an asset network - /// - public record HuobiChain - { - /// - /// Chain - /// - public string Chain { get; set; } = string.Empty; - /// - /// Display name - /// - public string DisplayName { get; set; } = string.Empty; - /// - /// Base chain - /// - public string BaseChain { get; set; } = string.Empty; - /// - /// Protocol of the base chain - /// - public string BaseChainProtocol { get; set; } = string.Empty; - /// - /// Is dynamic fee type or not (only applicable to withdrawFeeType = fixed) - /// - public bool IsDynamic { get; set; } - /// - /// Deposit status - /// - [JsonConverter(typeof(CurrencyStatusConverter))] - public CurrencyStatus DepositStatus { get; set; } - /// - /// Maximum withdraw fee in each request (only applicable to withdrawFeeType = circulated or ratio) - /// - public decimal MaxTransactFeeWithdraw { get; set; } - /// - /// Max withdraw quantity per request - /// - [JsonProperty("maxWithdrawAmt")] - public decimal MaxWithdrawQuantity { get; set; } - /// - /// Min deposit quantity per request - /// - [JsonProperty("minDepositAmt")] - public decimal MinDepositQuantity { get; set; } - /// - /// Min withdraw quantity per request - /// - [JsonProperty("minWithdrawAmt")] - public decimal MinWithdrawQuantity { get; set; } - /// - /// Withdraw fee in each request (only applicable to withdrawFeeType = fixed) - /// - public decimal TransactFeeWithdraw { get; set; } - /// - /// Withdraw fee in each request (only applicable to withdrawFeeType = ratio) - /// - public decimal? TransactFeeRateWithdraw { get; set; } - /// - /// Minimal withdraw fee in each request (only applicable to withdrawFeeType = circulated or ratio) - /// - public decimal MinTransactFeeWithdraw { get; set; } - /// - /// Number of confirmations required for deposit - /// - [JsonProperty("numOfConfirmations")] - public int NumberOfConfirmations { get; set; } - /// - /// Number of confirmations required for quick success (trading allowed but withdrawal disallowed) - /// - [JsonProperty("numOfFastConfirmations")] - public int NumberOfFastConfirmations { get; set; } - /// - /// Type of withdraw fee - /// - [JsonConverter(typeof(FeeTypeConverter))] - public FeeType WithdrawFeeType { get; set; } - /// - /// Precision of withdrawing - /// - public int WithdrawPrecision { get; set; } - /// - /// Withdraw quota per day - /// - public decimal? WithdrawQuotaPerDay { get; set; } - /// - /// Withdraw quota per year - /// - public decimal? WithdrawQuotaPerYear { get; set; } - /// - /// Withdraw quota in total - /// - public decimal? WithdrawQuotaTotal { get; set; } - - /// - /// Withdraw status - /// - [JsonConverter(typeof(CurrencyStatusConverter))] - public CurrencyStatus WithdrawStatus { get; set; } - } -} diff --git a/Huobi.Net/Objects/Models/HuobiOrderBook.cs b/Huobi.Net/Objects/Models/HuobiOrderBook.cs deleted file mode 100644 index 14a83a60..00000000 --- a/Huobi.Net/Objects/Models/HuobiOrderBook.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Order book - /// - public record HuobiOrderBook - { - /// - /// Timestamp - /// - [JsonProperty("ts"), JsonConverter(typeof(DateTimeConverter))] - public DateTime Timestamp { get; set; } - /// - /// Version - /// - public long Version { get; set; } - /// - /// List of bids - /// - public IEnumerable Bids { get; set; } = Array.Empty(); - /// - /// List of asks - /// - public IEnumerable Asks { get; set; } = Array.Empty(); - } - - /// - /// Incremental order book update - /// - public record HuobiIncementalOrderBook - { - /// - /// Sequence number - /// - [JsonProperty("seqNum")] - public long SequenceNumber { get; set; } - /// - /// Previous sequence number - /// - [JsonProperty("prevSeqNum")] - public long? PreviousSequenceNumber { get; set; } - /// - /// List of changed bids - /// - public IEnumerable Bids { get; set; } = Array.Empty(); - /// - /// List of changed asks - /// - public IEnumerable Asks { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/HuobiSubUserAccount.cs b/Huobi.Net/Objects/Models/HuobiSubUserAccount.cs deleted file mode 100644 index a12cbbd5..00000000 --- a/Huobi.Net/Objects/Models/HuobiSubUserAccount.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Huobi sub-user account info - /// - public record HuobiSubUserAccount - { - /// - /// The type of the account - /// - [JsonProperty("accountType"), JsonConverter(typeof(AccountTypeConverter))] - public AccountType Type { get; set; } - /// - /// Whether the account is active of not - /// - [JsonConverter(typeof(AccountActivationConverter))] - public AccountActivation Activation { get; set; } - /// - /// Whether transfers are allowed (only for spot account type) - /// - public bool? Transferrable { get; set; } - /// - /// Account ids - /// - public IEnumerable AccountIds { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/HuobiSubUserAccountId.cs b/Huobi.Net/Objects/Models/HuobiSubUserAccountId.cs deleted file mode 100644 index 118d9f2d..00000000 --- a/Huobi.Net/Objects/Models/HuobiSubUserAccountId.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Huobi sub-user account id and state - /// - public record HuobiSubUserAccountId - { - /// - /// The id of the account - /// - [JsonProperty("accountId")] - public long Id { get; set; } - /// - /// The state of the account - /// - [JsonProperty("accountStatus"), JsonConverter(typeof(AccountStateConverter))] - public AccountState State { get; set; } - /// - /// Sub state - /// - public string? SubType { get; set; } - } -} diff --git a/Huobi.Net/Objects/Models/HuobiSymbol.cs b/Huobi.Net/Objects/Models/HuobiSymbol.cs deleted file mode 100644 index 1e758389..00000000 --- a/Huobi.Net/Objects/Models/HuobiSymbol.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Symbol data - /// - public record HuobiSymbol - { - /// - /// The symbol name - /// - [JsonProperty("symbol")] - public string Name { get; set; } = string.Empty; - /// - /// The base asset - /// - [JsonProperty("base-currency")] - public string BaseAsset { get; set; } = string.Empty; - /// - /// The quote asset - /// - [JsonProperty("quote-currency")] - public string QuoteAsset { get; set; } = string.Empty; - /// - /// The precision of the price in decimal numbers - /// - [JsonProperty("price-precision")] - public int PricePrecision { get; set; } - /// - /// The precision of the quantity in decimal numbers - /// - [JsonProperty("amount-precision")] - public int QuantityPrecision { get; set; } - /// - /// Partition - /// - [JsonProperty("symbol-partition")] - public string SymbolPartition { get; set; } = string.Empty; - /// - /// The state of the symbol - /// - [JsonProperty("state"), JsonConverter(typeof(SymbolStateConverter))] - public SymbolState State { get; set; } - /// - /// Minimum value of the quantity - /// - [Obsolete("Use MinLimitOrderQuantity instead")] - [JsonProperty("min-order-amt")] - public decimal MinOrderQuantity { get; set; } - /// - /// Maximum value of the quantity - /// - [Obsolete("Use MaxLimitOrderQuantity instead")] - [JsonProperty("max-order-amt")] - public decimal MaxOrderQuantity { get; set; } - /// - /// Minimum order quantity of limit order in base asset - /// - [JsonProperty("limit-order-min-order-amt")] - public decimal MinLimitOrderQuantity { get; set; } - /// - /// Max buy order quantity of limit order in base asset - /// - [JsonProperty("limit-order-max-buy-amt")] - public decimal MaxLimitOrderBuyQuantity { get; set; } - /// - /// Max sell order quantity of limit order in base asset - /// - [JsonProperty("limit-order-max-sell-amt")] - public decimal MaxLimitOrderSellQuantity { get; set; } - /// - /// Max order quantity of limit order in base asset - /// - [JsonProperty("limit-order-max-order-amt")] - public decimal MaxLimitOrderQuantity { get; set; } - /// - /// Minimum order quantity of sell-market order in base asset - /// - [JsonProperty("sell-market-min-order-amt")] - public decimal MinMarketSellOrderQuantity { get; set; } - /// - /// Max order quantity of sell-market order in base asset - /// - [JsonProperty("sell-market-max-order-amt")] - public decimal MaxMarketSellOrderQuantity { get; set; } - /// - /// Max order value of buy-market order in quote asset - /// - [JsonProperty("buy-market-max-order-value")] - public decimal MaxMarketBuyOrderValue { get; set; } - /// - /// Minimum value of the order quantity in quote asset - /// - [JsonProperty("min-order-value")] - public decimal MinOrderValue { get; set; } - /// - /// Max order value of limit order and buy-market order in usdt - /// - [JsonProperty("max-order-value")] - public decimal MaxOrderValue { get; set; } - /// - /// The precision of the order quantity in quote asset - /// - [JsonProperty("value-precision")] - public int ValuePrecision { get; set; } - /// - /// Api trading status, enabled or disabled - /// - [JsonProperty("api-trading")] - public string ApiTrading { get; set; } = string.Empty; - } -} diff --git a/Huobi.Net/Objects/Models/HuobiUser.cs b/Huobi.Net/Objects/Models/HuobiUser.cs deleted file mode 100644 index 98799d8c..00000000 --- a/Huobi.Net/Objects/Models/HuobiUser.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Huobi.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models -{ - /// - /// Huobi user info - /// - public record HuobiUser - { - /// - /// The id of the user - /// - [JsonProperty("uid")] - public long Id { get; set; } - /// - /// The state of the user - /// - [JsonProperty("userState"), JsonConverter(typeof(UserStateConverter))] - public UserState State { get; set; } - } -} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiBestOfferUpdate.cs b/Huobi.Net/Objects/Models/Socket/HuobiBestOfferUpdate.cs deleted file mode 100644 index 94423e70..00000000 --- a/Huobi.Net/Objects/Models/Socket/HuobiBestOfferUpdate.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models.Socket -{ - /// - /// Best offer update - /// - public record HuobiBestOfferUpdate - { - /// - /// Order id - /// - [JsonProperty("mrid")] - public long OrderId { get; set; } - /// - /// Update id - /// - public long Id { get; set; } - /// - /// Best bid - /// - public HuobiOrderBookEntry Bid { get; set; } = null!; - /// - /// Best ask - /// - public HuobiOrderBookEntry Ask { get; set; } = null!; - } -} diff --git a/Huobi.Net/Objects/Models/Socket/HuobiOrderBookUpdate.cs b/Huobi.Net/Objects/Models/Socket/HuobiOrderBookUpdate.cs deleted file mode 100644 index 933f6924..00000000 --- a/Huobi.Net/Objects/Models/Socket/HuobiOrderBookUpdate.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.Socket -{ - /// - /// Incremental order book update - /// - public record HuobiUsdtMarginSwapIncementalOrderBook - { - /// - /// Order id - /// - [JsonProperty("mrid")] - public long OrderId { get; set; } - /// - /// Update id - /// - [JsonProperty("id")] - public long Id { get; set; } - /// - /// List of changed bids - /// - public IEnumerable Bids { get; set; } = Array.Empty(); - /// - /// List of changed asks - /// - public IEnumerable Asks { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountInfo.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountInfo.cs deleted file mode 100644 index 4182b509..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAccountInfo.cs +++ /dev/null @@ -1,92 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Account info - /// - public record HuobiCrossMarginAccountInfo - { - /// - /// Margin balance - /// - [JsonProperty("margin_balance")] - public decimal MarginBalance { get; set; } - /// - /// Margin position - /// - [JsonProperty("margin_position")] - public decimal MarginPosition { get; set; } - /// - /// Margin frozen - /// - [JsonProperty("margin_frozen")] - public decimal MarginFrozen { get; set; } - /// - /// Margin available - /// - [JsonProperty("margin_available")] - public decimal MarginAvailable { get; set; } - /// - /// Profit real - /// - [JsonProperty("profit_real")] - public decimal ProfitReal { get; set; } - /// - /// Profit unreal - /// - [JsonProperty("profit_unreal")] - public decimal ProfitUnreal { get; set; } - /// - /// Risk rate - /// - [JsonProperty("risk_rate")] - public decimal? RiskRate { get; set; } - /// - /// Withdraw available - /// - [JsonProperty("withdraw_available")] - public decimal WithdrawAvailable { get; set; } - /// - /// Margin static - /// - [JsonProperty("margin_static")] - public decimal MarginStatic { get; set; } - /// - /// Margin asset - /// - [JsonProperty("margin_asset")] - public string MarginAsset { get; set; } = string.Empty; - /// - /// Margin mode - /// - [JsonConverter(typeof(EnumConverter))] - [JsonProperty("margin_mode")] - public MarginMode MarginMode { get; set; } - /// - /// Margin account - /// - [JsonProperty("margin_account")] - public string MarginAccount { get; set; } = string.Empty; - /// - /// Position mode - /// - [JsonProperty("position_mode")] - [JsonConverter(typeof(EnumConverter))] - public PositionMode PositionMode { get; set; } - /// - /// Contract details - /// - [JsonProperty("contract_detail")] - public IEnumerable ContractDetails { get; set; } = Array.Empty(); - /// - /// Futures contract details - /// - [JsonProperty("futures_contract_detail")] - public IEnumerable FuturesContractDetails { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAssetsAndPositions.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAssetsAndPositions.cs deleted file mode 100644 index f416b34d..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginAssetsAndPositions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Cross margin assets and positions info - /// - public record HuobiCrossMarginAssetsAndPositions : HuobiCrossMarginAccountInfo - { - /// - /// Positions - /// - public IEnumerable? Positions { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginOrderPage.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginOrderPage.cs deleted file mode 100644 index 1794c717..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginOrderPage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Order page - /// - public record HuobiCrossMarginOrderPage : HuobiPage - { - /// - /// Orders - /// - public IEnumerable Orders { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserTrade.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserTrade.cs deleted file mode 100644 index db028bf5..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiCrossMarginUserTrade.cs +++ /dev/null @@ -1,43 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Margin user trade page - /// - public record HuobiCrossMarginUserTradePage : HuobiPage - { - /// - /// Trades - /// - public IEnumerable Trades { get; set; } = Array.Empty(); - } - - /// - /// User trade info - /// - public record HuobiCrossMarginUserTrade : HuobiIsolatedMarginUserTrade - { - /// - /// Contract type - /// - [JsonProperty("contract_type")] - [JsonConverter(typeof(EnumConverter))] - public ContractType ContractType { get; set; } - /// - /// Business type - /// - [JsonProperty("business_type")] - [JsonConverter(typeof(EnumConverter))] - public BusinessType BusinessType { get; set; } - /// - /// Symbol - /// - [JsonProperty("pair")] - public string Symbol { get; set; } = string.Empty; - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAssetsAndPositions.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAssetsAndPositions.cs deleted file mode 100644 index 3cae7727..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginAssetsAndPositions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Isolated margin assets and positions info - /// - public record HuobiIsolatedMarginAssetsAndPositions: HuobiIsolatedMarginAccountInfo - { - /// - /// Positions - /// - public IEnumerable? Positions { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrderPage.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrderPage.cs deleted file mode 100644 index 487d412e..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginOrderPage.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Order page - /// - public record HuobiIsolatedMarginOrderPage : HuobiPage - { - /// - /// Orders - /// - public IEnumerable Orders { get; set; } = Array.Empty(); - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserTrade.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserTrade.cs deleted file mode 100644 index ece049b4..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiIsolatedMarginUserTrade.cs +++ /dev/null @@ -1,66 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Margin user trade page - /// - public record HuobiIsolatedMarginUserTradePage : HuobiPage - { - /// - /// Trades - /// - public IEnumerable Trades { get; set; } = Array.Empty(); - } - - /// - /// User trade info - /// - public record HuobiIsolatedMarginUserTrade : HuobiMarginTrade - { - /// - /// Match id - /// - [JsonProperty("match_id")] - public long MatchId { get; set; } - /// - /// Order id - /// - [JsonProperty("order_id")] - public long OrderId { get; set; } - /// - /// Asset - /// - [JsonProperty("symbol")] - public string Asset { get; set; } = string.Empty; - /// - /// Contract code - /// - [JsonProperty("contract_code")] - public string ContractCode { get; set; } = string.Empty; - /// - /// Side - /// - [JsonConverter(typeof(EnumConverter))] - public OrderSide Side { get; set; } - /// - /// Offset - /// - [JsonConverter(typeof(EnumConverter))] - public Offset Offset { get; set; } - /// - /// Offset profit loss - /// - [JsonProperty("offset_profitloss")] - public decimal OffsetProfitloss { get; set; } - /// - /// Reduce only - /// - [JsonProperty("reduce_only")] - public bool ReduceOnly { get; set; } - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarketData.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarketData.cs deleted file mode 100644 index 746fe93b..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiMarketData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CryptoExchange.Net.Converters; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Market data - /// - public record HuobiMarketData: HuobiSymbolData - { - /// - /// Best ask - /// - [JsonConverter(typeof(ArrayConverter))] - public HuobiOrderBookEntry? Ask { get; set; } - /// - /// Best bid - /// - [JsonConverter(typeof(ArrayConverter))] - public HuobiOrderBookEntry? Bid { get; set; } - } -} diff --git a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPosition.cs b/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPosition.cs deleted file mode 100644 index 2a754b30..00000000 --- a/Huobi.Net/Objects/Models/UsdtMarginSwap/HuobiPosition.cs +++ /dev/null @@ -1,101 +0,0 @@ -using CryptoExchange.Net.Converters; -using Huobi.Net.Enums; -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Models.UsdtMarginSwap -{ - /// - /// Isolated margin position info - /// - public record HuobiPosition - { - /// - /// Asset - /// - [JsonProperty("symbol")] - public string Asset { get; set; } = string.Empty; - /// - /// Contract code - /// - [JsonProperty("contract_code")] - public string ContractCode { get; set; } = string.Empty; - /// - /// Volume - /// - public decimal Volume { get; set; } - /// - /// Available - /// - public decimal Available { get; set; } - /// - /// Frozen - /// - public decimal Frozen { get; set; } - /// - /// Opening average price - /// - [JsonProperty("cost_open")] - public decimal CostOpen { get; set; } - /// - /// Average price of position - /// - [JsonProperty("cost_hold")] - public decimal CostHold { get; set; } - /// - /// Unrealized pnl - /// - [JsonProperty("profit_unreal")] - public decimal ProfitUnreal { get; set; } - /// - /// Profit rate - /// - [JsonProperty("profit_rate")] - public decimal ProfitRate { get; set; } - /// - /// Leverage rate - /// - [JsonProperty("lever_rate")] - public decimal LeverRate { get; set; } - /// - /// Position margin - /// - [JsonProperty("position_margin")] - public decimal PositionMargin { get; set; } - /// - /// Order direction - /// - [JsonProperty("direction")] - public OrderSide Side { get; set; } - /// - /// Profit - /// - public decimal Profit { get; set; } - /// - /// Last price - /// - [JsonProperty("last_price")] - public decimal LastPrice { get; set; } - /// - /// Margin asset - /// - [JsonProperty("margin_asset")] - public string MarginAsset { get; set; } = string.Empty; - /// - /// Margin mode - /// - [JsonProperty("margin_mode")] - [JsonConverter(typeof(EnumConverter))] - public MarginMode MarginMode { get; set; } - /// - /// Margin account - /// - [JsonProperty("margin_account")] - public string MarginAccount { get; set; } = string.Empty; - /// - /// Position mode - /// - [JsonProperty("position_mode")] - [JsonConverter(typeof(EnumConverter))] - public PositionMode PositionMode { get; set; } - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiAuthParams.cs b/Huobi.Net/Objects/Sockets/HuobiAuthParams.cs deleted file mode 100644 index 2016e78b..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiAuthParams.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiAuthParams - { - [JsonProperty("authType")] public string AuthType { get; set; } = "api"; - [JsonProperty("accessKey")] public string AccessKey { get; set; } = string.Empty; - [JsonProperty("signatureMethod")] public string SignatureMethod { get; set; } = "HmacSHA256"; - [JsonProperty("signatureVersion")] public string SignatureVersion { get; set; } = "2.1"; - [JsonProperty("timestamp")] public string Timestamp { get; set; } = string.Empty; - [JsonProperty("signature")] public string Signature { get; set; } = string.Empty; - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiAuthPongMessage.cs b/Huobi.Net/Objects/Sockets/HuobiAuthPongMessage.cs deleted file mode 100644 index b1fca720..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiAuthPongMessage.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiAuthPongMessage - { - [JsonProperty("action")] - public string Action { get; set; } = string.Empty; - [JsonProperty("data")] - public HuobiAuthPongMessageTimestamp Data { get; set; } = null!; - } - - internal class HuobiAuthPingMessage - { - [JsonProperty("action")] - public string Action { get; set; } = string.Empty; - [JsonProperty("data")] - public HuobiAuthPingMessageTimestamp Data { get; set; } = null!; - } - - internal class HuobiAuthPongMessageTimestamp - { - [JsonProperty("pong")] - public long Pong { get; set; } - } - - internal class HuobiAuthPingMessageTimestamp - { - [JsonProperty("ts")] - public long Ping { get; set; } - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiAuthRequest.cs b/Huobi.Net/Objects/Sockets/HuobiAuthRequest.cs deleted file mode 100644 index d534757e..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiAuthRequest.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiAuthRequest - { - [JsonProperty("action")] - public string Action { get; set; } = string.Empty; - [JsonProperty("ch")] - public string Channel { get; set; } = string.Empty; - } - - internal class HuobiAuthRequest : HuobiAuthRequest - { - [JsonProperty("params")] - public T Params { get; set; } = default!; - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiPingMessage.cs b/Huobi.Net/Objects/Sockets/HuobiPingMessage.cs deleted file mode 100644 index 3a15bc3e..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiPingMessage.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiPingMessage - { - [JsonProperty("ping")] - public long Ping { get; set; } - } - - internal class HuobiSpotPingWrapper - { - [JsonProperty("data")] - public HuobiSpotPingMessage Data { get; set; } = null!; - } - - internal class HuobiSpotPingMessage - { - [JsonProperty("ts")] - public long Ping { get; set; } - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiPongMessage.cs b/Huobi.Net/Objects/Sockets/HuobiPongMessage.cs deleted file mode 100644 index 19b6565e..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiPongMessage.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiPongMessage - { - [JsonProperty("pong")] - public long Pong { get; set; } - } - - internal class HuobiSpotPongMessage - { - [JsonProperty("action")] - public string Action { get; set; } = "pong"; - [JsonProperty("data")] - public HuobiSpotPingMessage Pong { get; set; } = null!; - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiSocketAuthResponse.cs b/Huobi.Net/Objects/Sockets/HuobiSocketAuthResponse.cs deleted file mode 100644 index ed5d8850..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiSocketAuthResponse.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiSocketAuthResponse - { - [JsonProperty("action")] - public string Action { get; set; } = string.Empty; - [JsonProperty("ch")] - public string Channel { get; set; } = string.Empty; - [JsonProperty("code")] - public int Code { get; set; } - [JsonProperty("message")] - public string? Message { get; set; } - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiSocketResponse.cs b/Huobi.Net/Objects/Sockets/HuobiSocketResponse.cs deleted file mode 100644 index 6761c517..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiSocketResponse.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiSocketResponse - { - public string Id { get; set; } = string.Empty; - public string? Status { get; set; } - [JsonProperty("err-code")] - public string? ErrorCode { get; set; } - [JsonProperty("err-msg")] - public string? ErrorMessage { get; set; } - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiSubscribeRequest.cs b/Huobi.Net/Objects/Sockets/HuobiSubscribeRequest.cs deleted file mode 100644 index 9c4798e6..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiSubscribeRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiSubscribeRequest - { - [JsonProperty("sub")] - public string Topic { get; set; } = string.Empty; - [JsonProperty("id")] - public string Id { get; set; } = string.Empty; - } -} diff --git a/Huobi.Net/Objects/Sockets/HuobiUnsubscribeRequest.cs b/Huobi.Net/Objects/Sockets/HuobiUnsubscribeRequest.cs deleted file mode 100644 index e8e4ed3c..00000000 --- a/Huobi.Net/Objects/Sockets/HuobiUnsubscribeRequest.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Newtonsoft.Json; - -namespace Huobi.Net.Objects.Sockets -{ - internal class HuobiUnsubscribeRequest - { - [JsonProperty("unsub")] - public string Topic { get; set; } = string.Empty; - [JsonProperty("id")] - public string Id { get; set; } = string.Empty; - } -} diff --git a/Huobi.Net/Objects/Sockets/Queries/HuobiAuthQuery.cs b/Huobi.Net/Objects/Sockets/Queries/HuobiAuthQuery.cs deleted file mode 100644 index e1f4a08a..00000000 --- a/Huobi.Net/Objects/Sockets/Queries/HuobiAuthQuery.cs +++ /dev/null @@ -1,29 +0,0 @@ -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Queries -{ - internal class HuobiAuthQuery : Query - { - public override HashSet ListenerIdentifiers { get; set; } - public HuobiAuthQuery(string action, string topic, bool authenticated, int weight = 1) : base(new HuobiAuthRequest() { Action = action, Channel = topic }, authenticated, weight) - { - ListenerIdentifiers = new HashSet { action + topic }; - } - public HuobiAuthQuery(HuobiAuthRequest request) : base(request, true, 1) - { - ListenerIdentifiers = new HashSet { request.Action + request.Channel }; - } - - public override CallResult HandleMessage(SocketConnection connection, DataEvent message) - { - if (message.Data.Code != 200) - return new CallResult(new ServerError(message.Data.Code, message.Data.Message!)); - - return base.HandleMessage(connection, message); - } - } -} diff --git a/Huobi.Net/Objects/Sockets/Queries/HuobiQuery.cs b/Huobi.Net/Objects/Sockets/Queries/HuobiQuery.cs deleted file mode 100644 index 91e9f3b8..00000000 --- a/Huobi.Net/Objects/Sockets/Queries/HuobiQuery.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Huobi.Net.Objects.Internal; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Queries -{ - internal class HuobiQuery : Query> - { - public override HashSet ListenerIdentifiers { get; set; } - - public HuobiQuery(string topic, bool authenticated, int weight = 1) : base(new HuobiSocketRequest(ExchangeHelpers.NextId().ToString(), topic), authenticated, weight) - { - ListenerIdentifiers = new HashSet { ((HuobiSocketRequest)Request).Id }; - } - - public override CallResult> HandleMessage(SocketConnection connection, DataEvent> message) - { - if (message.Data.IsSuccessful) - return new CallResult>(message.Data, message.OriginalData, null); - - return new CallResult>(new ServerError(message.Data.ErrorCode!, message.Data.ErrorMessage)); - } - } -} diff --git a/Huobi.Net/Objects/Sockets/Queries/HuobiSubscribeQuery.cs b/Huobi.Net/Objects/Sockets/Queries/HuobiSubscribeQuery.cs deleted file mode 100644 index 82ffa526..00000000 --- a/Huobi.Net/Objects/Sockets/Queries/HuobiSubscribeQuery.cs +++ /dev/null @@ -1,27 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Queries -{ - internal class HuobiSubscribeQuery : Query - { - public override HashSet ListenerIdentifiers { get; set; } - - public HuobiSubscribeQuery(string topic, bool authenticated, int weight = 1) : base(new HuobiSubscribeRequest() { Id = ExchangeHelpers.NextId().ToString(), Topic = topic }, authenticated, weight) - { - ListenerIdentifiers = new HashSet { ((HuobiSubscribeRequest)Request).Id }; - } - - public override CallResult HandleMessage(SocketConnection connection, DataEvent message) - { - if (message.Data.Status != "ok") - return new CallResult(new ServerError(message.Data.ErrorMessage!)); - - return new CallResult(message.Data, message.OriginalData, null); - } - } -} diff --git a/Huobi.Net/Objects/Sockets/Queries/HuobiUnsubscribeQuery.cs b/Huobi.Net/Objects/Sockets/Queries/HuobiUnsubscribeQuery.cs deleted file mode 100644 index ad4e0e15..00000000 --- a/Huobi.Net/Objects/Sockets/Queries/HuobiUnsubscribeQuery.cs +++ /dev/null @@ -1,17 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Sockets; -using System.Collections.Generic; - -namespace Huobi.Net.Objects.Sockets.Queries -{ - internal class HuobiUnsubscribeQuery : Query - { - public override HashSet ListenerIdentifiers { get; set; } - - public HuobiUnsubscribeQuery(string topic, bool authenticated, int weight = 1) : base(new HuobiUnsubscribeRequest() { Id = ExchangeHelpers.NextId().ToString(), Topic = topic }, authenticated, weight) - { - ListenerIdentifiers = new HashSet { ((HuobiUnsubscribeRequest)Request).Id }; - } - - } -} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAccountSubscription.cs b/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAccountSubscription.cs deleted file mode 100644 index c8c42fdf..00000000 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAccountSubscription.cs +++ /dev/null @@ -1,45 +0,0 @@ -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Huobi.Net.Objects.Internal; -using Huobi.Net.Objects.Models.Socket; -using Huobi.Net.Objects.Sockets.Queries; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Subscriptions -{ - internal class HuobiAccountSubscription : Subscription - { - private string _topic; - private Action> _handler; - - public override HashSet ListenerIdentifiers { get; set; } - - public HuobiAccountSubscription(ILogger logger, string topic, Action> handler, bool authenticated) : base(logger, authenticated) - { - _handler = handler; - _topic = topic; - ListenerIdentifiers = new HashSet() { topic }; - } - - public override Query? GetSubQuery(SocketConnection connection) - { - return new HuobiAuthQuery("sub", _topic, Authenticated); - } - public override Query? GetUnsubQuery() - { - return new HuobiAuthQuery("unsub", _topic, Authenticated); - } - public override CallResult DoHandleMessage(SocketConnection connection, DataEvent message) - { - var update = (HuobiDataEvent)message.Data; - _handler.Invoke(message.As(update.Data, update.Channel, null, SocketUpdateType.Update)); - return new CallResult(null); - } - - public override Type? GetMessageType(IMessageAccessor message) => typeof(HuobiDataEvent); - } -} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAuthPingSubscription.cs b/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAuthPingSubscription.cs deleted file mode 100644 index 37216dd4..00000000 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiAuthPingSubscription.cs +++ /dev/null @@ -1,25 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Microsoft.Extensions.Logging; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Subscriptions -{ - internal class HuobiAuthPingSubscription : SystemSubscription - { - public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingv2" }; - - public HuobiAuthPingSubscription(ILogger logger) : base(logger, false) - { - } - - public override CallResult HandleMessage(SocketConnection connection, DataEvent message) - { - connection.Send(ExchangeHelpers.NextId(), new HuobiAuthPongMessage() { Action = "pong", Data = new HuobiAuthPongMessageTimestamp { Pong = message.Data.Data.Ping } }, 1); - return new CallResult(null); - } - } -} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiPingSubscription.cs b/Huobi.Net/Objects/Sockets/Subscriptions/HuobiPingSubscription.cs deleted file mode 100644 index a94274cc..00000000 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiPingSubscription.cs +++ /dev/null @@ -1,25 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Microsoft.Extensions.Logging; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Subscriptions -{ - internal class HuobiPingSubscription : SystemSubscription - { - public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingV3" }; - - public HuobiPingSubscription(ILogger logger) : base(logger, false) - { - } - - public override CallResult HandleMessage(SocketConnection connection, DataEvent message) - { - connection.Send(ExchangeHelpers.NextId(), new HuobiPongMessage() { Pong = message.Data.Ping }, 1); - return new CallResult(null); - } - } -} diff --git a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiSpotPingSubscription.cs b/Huobi.Net/Objects/Sockets/Subscriptions/HuobiSpotPingSubscription.cs deleted file mode 100644 index 57b3f61d..00000000 --- a/Huobi.Net/Objects/Sockets/Subscriptions/HuobiSpotPingSubscription.cs +++ /dev/null @@ -1,25 +0,0 @@ -using CryptoExchange.Net; -using CryptoExchange.Net.Objects; -using CryptoExchange.Net.Objects.Sockets; -using CryptoExchange.Net.Sockets; -using Microsoft.Extensions.Logging; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Huobi.Net.Objects.Sockets.Subscriptions -{ - internal class HuobiSpotPingSubscription : SystemSubscription - { - public override HashSet ListenerIdentifiers { get; set; } = new HashSet() { "pingV2" }; - - public HuobiSpotPingSubscription(ILogger logger) : base(logger, false) - { - } - - public override CallResult HandleMessage(SocketConnection connection, DataEvent message) - { - connection.Send(ExchangeHelpers.NextId(), new HuobiSpotPongMessage() { Pong = new HuobiSpotPingMessage { Ping = message.Data.Data.Ping } }, 1); - return new CallResult(null); - } - } -} diff --git a/Huobi.Net/SymbolOrderBooks/HuobiOrderBookFactory.cs b/Huobi.Net/SymbolOrderBooks/HuobiOrderBookFactory.cs deleted file mode 100644 index b5390658..00000000 --- a/Huobi.Net/SymbolOrderBooks/HuobiOrderBookFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CryptoExchange.Net.Interfaces; -using CryptoExchange.Net.OrderBook; -using Huobi.Net.Interfaces; -using Huobi.Net.Interfaces.Clients; -using Huobi.Net.Objects.Options; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System; - -namespace Huobi.Net.SymbolOrderBooks -{ - /// - public class HuobiOrderBookFactory : IHuobiOrderBookFactory - { - private readonly IServiceProvider _serviceProvider; - - /// - public IOrderBookFactory Spot { get; } - - /// - /// ctor - /// - /// Service provider for resolving logging and clients - public HuobiOrderBookFactory(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - - Spot = new OrderBookFactory((symbol, options) => CreateSpot(symbol, options), (baseAsset, quoteAsset, options) => CreateSpot(baseAsset.ToLowerInvariant() + quoteAsset.ToLowerInvariant(), options)); - } - - /// - public ISymbolOrderBook CreateSpot(string symbol, Action? options = null) - => new HuobiSpotSymbolOrderBook(symbol, - options, - _serviceProvider.GetRequiredService(), - _serviceProvider.GetRequiredService()); - } -} diff --git a/README.md b/README.md index 95524d84..ff0d4f34 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ -# ![.Huobi.Net](https://github.com/JKorf/Huobi.Net/blob/master/Huobi.Net/Icon/icon.png?raw=true) Huobi.Net +# ![.HTX.Net](https://github.com/JKorf/HTX.Net/blob/master/HTX.Net/Icon/icon.png?raw=true) HTX.Net -[![.NET](https://img.shields.io/github/actions/workflow/status/JKorf/Huobi.Net/dotnet.yml?style=for-the-badge)](https://github.com/JKorf/Huobi.Net/actions/workflows/dotnet.yml) ![License](https://img.shields.io/github/license/JKorf/Huobi.Net?style=for-the-badge) +[![.NET](https://img.shields.io/github/actions/workflow/status/JKorf/HTX.Net/dotnet.yml?style=for-the-badge)](https://github.com/JKorf/HTX.Net/actions/workflows/dotnet.yml) ![License](https://img.shields.io/github/license/JKorf/HTX.Net?style=for-the-badge) -Huobi.Net is a strongly typed client library for accessing the [Huobi REST and Websocket API](https://github.com/huobiapi). +HTX.Net, previously known as Huobi.Net, is a strongly typed client library for accessing the [HTX REST and Websocket API](https://www.htx.com/en-us/opend/). ## Features * Response data is mapped to descriptive models * Input parameters and response values are mapped to discriptive enum values where possible * Automatic websocket (re)connection management +* Client side rate limiting * Cient side order book implementation * Extensive logging * Support for different environments @@ -28,24 +29,24 @@ The library is targeting both `.NET Standard 2.0` and `.NET Standard 2.1` for op ## Install the library ### NuGet -[![NuGet version](https://img.shields.io/nuget/v/Huobi.net.svg?style=for-the-badge)](https://www.nuget.org/packages/Huobi.Net) [![Nuget downloads](https://img.shields.io/nuget/dt/Huobi.Net.svg?style=for-the-badge)](https://www.nuget.org/packages/Huobi.Net) +[![NuGet version](https://img.shields.io/nuget/v/HTX.net.svg?style=for-the-badge)](https://www.nuget.org/packages/HTX.Net) [![Nuget downloads](https://img.shields.io/nuget/dt/HTX.Net.svg?style=for-the-badge)](https://www.nuget.org/packages/HTX.Net) - dotnet add package Huobi.Net + dotnet add package HTX.Net ### GitHub packages -Huobi.Net is available on [GitHub packages](https://github.com/JKorf/Huobi.Net/pkgs/nuget/Huobi.Net). You'll need to add `https://nuget.pkg.github.com/JKorf/index.json` as a NuGet package source. +HTX.Net is available on [GitHub packages](https://github.com/JKorf/HTX.Net/pkgs/nuget/HTX.Net). You'll need to add `https://nuget.pkg.github.com/JKorf/index.json` as a NuGet package source. ### Download release -[![GitHub Release](https://img.shields.io/github/v/release/JKorf/Huobi.Net?style=for-the-badge&label=GitHub)](https://github.com/JKorf/Huobi.Net/releases) +[![GitHub Release](https://img.shields.io/github/v/release/JKorf/HTX.Net?style=for-the-badge&label=GitHub)](https://github.com/JKorf/HTX.Net/releases) -The NuGet package files are added along side the source with the latest GitHub release which can found [here](https://github.com/JKorf/Huobi.Net/releases). +The NuGet package files are added along side the source with the latest GitHub release which can found [here](https://github.com/JKorf/HTX.Net/releases). ## How to use *REST Endpoints* ```csharp // Get the ETH/USDT ticker via rest request -var restClient = new HuobiRestClient(); +var restClient = new HTXRestClient(); var tickerResult = await restClient.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT"); var lastPrice = tickerResult.Data.ClosePrice; ``` @@ -54,17 +55,17 @@ var lastPrice = tickerResult.Data.ClosePrice; ```csharp // Subscribe to ETH/USDT ticker updates via the websocket API -var socketClient = new HuobiSocketClient(); -var tickerSubscriptionResult = socketClient.SpotApi.SubscribeToTickerUpdatesAsync("ethusdt", (update) => +var socketClient = new HTXSocketClient(); +var tickerSubscriptionResult = socketClient.SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", (update) => { var lastPrice = update.Data.ClosePrice; }); ``` -For information on the clients, dependency injection, response processing and more see the [Huobi.Net documentation](https://jkorf.github.io/Huobi.Net), [CryptoExchange.Net documentation](https://jkorf.github.io/CryptoExchange.Net), or have a look at the examples [here](https://github.com/JKorf/Huobi.Net/tree/master/Examples) or [here](https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples). +For information on the clients, dependency injection, response processing and more see the [HTX.Net documentation](https://jkorf.github.io/HTX.Net), [CryptoExchange.Net documentation](https://jkorf.github.io/CryptoExchange.Net), or have a look at the examples [here](https://github.com/JKorf/HTX.Net/tree/master/Examples) or [here](https://github.com/JKorf/CryptoExchange.Net/tree/master/Examples). ## CryptoExchange.Net -Huobi.Net is based on the [CryptoExchange.Net](https://github.com/JKorf/CryptoExchange.Net) base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic. +HTX.Net is based on the [CryptoExchange.Net](https://github.com/JKorf/CryptoExchange.Net) base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic. CryptoExchange.Net also allows for [easy access to different exchange API's](https://jkorf.github.io/CryptoExchange.Net#idocs_common). @@ -97,24 +98,13 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). Feel free t |Market Data|✓|`restClient.SpotApi.ExchangeData`| |Account|✓|`restClient.SpotApi.Account`| |Wallet|✓|`restClient.SpotApi.Account`| -|Sub user management|Partial|`restClient.SpotApi.Account`| +|Sub user management|✓|`restClient.SpotApi.SubAccount`| |Trading|✓|`restClient.SpotApi.Trading`| |Conditional Order|✓|`restClient.SpotApi.Trading`| |Margin Loan|✓|`restClient.SpotApi.Account`| -|Margin Loan|✓|`restClient.SpotApi.Account`| |Websocket Market Data|✓|`socketClient.SpotApi`| |Websocket Account and Order|✓|`socketClient.SpotApi`| -### Coin-M Futures Api -|API|Supported|Location| -|--|--:|--| -|*|X|| - -### Coin-M Swap Api -|API|Supported|Location| -|--|--:|--| -|*|X|| - ### USDT-M Api |API|Supported|Location| |--|--:|--| @@ -129,6 +119,16 @@ A Discord server is available [here](https://discord.gg/MSpeEtSY8t). Feel free t |Orders And Account WebSocket|X|| |WebSocket System updates|X|| +### Coin-M Futures Api +|API|Supported|Location| +|--|--:|--| +|*|X|| + +### Coin-M Swap Api +|API|Supported|Location| +|--|--:|--| +|*|X|| + ## Support the project I develop and maintain this package on my own for free in my spare time, any support is greatly appreciated. diff --git a/docs/index.html b/docs/index.html index f016d607..c6417199 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,8 +5,8 @@ -Huobi.Net Documentation - +HTX.Net Documentation +

Getting Started

-

The package is available on Nuget. After installing the package the Huobi API is available by using the HuobiRestClient and HuobiSocketClient.

+

The package is available on Nuget. After installing the package the HTX API is available by using the HTXRestClient and HTXSocketClient.

More information and usage documentation is available at the CryptoExchange.Net documentation page
@@ -168,17 +169,17 @@

Getting Started

Installation

Nuget
-

+

-
dotnet add package Huobi.Net
+
dotnet add package HTX.Net
GitHub packages
-

Huobi.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json as a NuGet package source.

+

HTX.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json as a NuGet package source.

Download release
-

+

-

The NuGet package files are added along side the source with the latest GitHub release which can found here.

+

The NuGet package files are added along side the source with the latest GitHub release which can found here.

@@ -187,20 +188,20 @@
Download release

API Access

-

Huobi.Net can be configured using Dotnet dependency injection, after which the clients can be injected into your services. It also correctly configures logging and HttpClient usage.

+

HTX.Net can be configured using Dotnet dependency injection, after which the clients can be injected into your services. It also correctly configures logging and HttpClient usage.

-
builder.Services.AddHuobi(options => {
+		  
builder.Services.AddHTX(options => {
   // Options can be configured here, for example:
   options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
 });
-

The IHuobiRestClient and IHuobiSocketClient can then be injected.

+

The IHTXRestClient and IHTXSocketClient can then be injected.

Alternatively the rest and socket client can be constructed directly

-
var restClient = new HuobiRestClient(options => {
+		  
var restClient = new HTXRestClient(options => {
   // Options can be configured here, for example:
   options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
 });
-var socketClient = new HuobiSocketClient();
+var socketClient = new HTXSocketClient();
@@ -213,130 +214,125 @@

Spot API

Get Symbols

Get a list of supported spot symbols

-
var huobiClient = new HuobiRestClient();
+		  
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.SpotApi.ExchangeData.GetSymbolsAsync();
+var result = await htxClient.SpotApi.ExchangeData.GetSymbolsAsync();
 
Get Symbol Ticker

Get the 24h price ticker of a spot symbol

-
var huobiClient = new HuobiRestClient();
+		  
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
+var result = await htxClient.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
Get Recent Trades

Get the most recent trades for a spot symbol

-
var huobiClient = new HuobiRestClient();
+		  
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.SpotApi.ExchangeData.GetTradeHistoryAsync("ETHUSDT");
+var result = await htxClient.SpotApi.ExchangeData.GetTradeHistoryAsync("ETHUSDT");
Get Balances

Get asset balances of the spot account

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
 // First need to get the id of the account to get balances for
-var accounts = await huobiClient.SpotApi.Account.GetAccountsAsync();
-var spotAccountId = accounts.Data.Single(d => d.Type == Huobi.Net.Enums.AccountType.Spot).Id;
+var accounts = await htxClient.SpotApi.Account.GetAccountsAsync();
+var spotAccountId = accounts.Data.Single(d => d.Type == HTX.Net.Enums.AccountType.Spot).Id;
 
-var result = await huobiClient.SpotApi.Account.GetBalancesAsync(spotAccountId);
+var result = await htxClient.SpotApi.Account.GetBalancesAsync(spotAccountId);
Place Limit Order

Place a new limit order for buying 0.1 ETH at a price of 2000 USDT

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
-var accounts = await huobiClient.SpotApi.Account.GetAccountsAsync();
-var spotAccountId = accounts.Data.Single(d => d.Type == Huobi.Net.Enums.AccountType.Spot).Id;
+var accounts = await htxClient.SpotApi.Account.GetAccountsAsync();
+var spotAccountId = accounts.Data.Single(d => d.Type == HTX.Net.Enums.AccountType.Spot).Id;
 
-var result = await huobiClient.SpotApi.Trading.PlaceOrderAsync(
+var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(
     spotAccountId,
     "ETHUSDT",
-    Huobi.Net.Enums.OrderSide.Buy,
-    Huobi.Net.Enums.OrderType.Limit,
+    HTX.Net.Enums.OrderSide.Buy,
+    HTX.Net.Enums.OrderType.Limit,
     0.1m,
     2000);
Place Market Order

Place a new market order for buying 50 USDT worth of ETH at the best available price

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
-var accounts = await huobiClient.SpotApi.Account.GetAccountsAsync();
-var spotAccountId = accounts.Data.Single(d => d.Type == Huobi.Net.Enums.AccountType.Spot).Id;
+var accounts = await htxClient.SpotApi.Account.GetAccountsAsync();
+var spotAccountId = accounts.Data.Single(d => d.Type == HTX.Net.Enums.AccountType.Spot).Id;
 
-var result = await huobiClient.SpotApi.Trading.PlaceOrderAsync(
+var result = await htxClient.SpotApi.Trading.PlaceOrderAsync(
     spotAccountId,
     "ETHUSDT",
-    Huobi.Net.Enums.OrderSide.Buy,
-    Huobi.Net.Enums.OrderType.Market,
+    HTX.Net.Enums.OrderSide.Buy,
+    HTX.Net.Enums.OrderType.Market,
     50);
Get Order Info

Retrieve order information for a specific order

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
-var result = await huobiClient.SpotApi.Trading.GetOrderAsync(123);
+var result = await htxClient.SpotApi.Trading.GetOrderAsync(123);
Cancel an order

Cancel a currently active order

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
-var result = await huobiClient.SpotApi.Trading.CancelOrderAsync(123);
+var result = await htxClient.SpotApi.Trading.CancelOrderAsync(123);
-

Usdt Margin Swap API

+

Usdt Futures API

Get Contracts
-

Get a list of supported margin swap contracts

-
var huobiClient = new HuobiRestClient();
+		  

Get a list of supported futures contracts

+
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.UsdtMarginSwapApi.ExchangeData.GetContractInfoAsync();
+var result = await htxClient.UsdtFuturesApi.ExchangeData.GetContractsAsync();
Get Symbol Ticker
-

Get the 24h price ticker of a margin swap symbol

-
var huobiClient = new HuobiRestClient();
+		  

Get the 24h price ticker of a futures symbol

+
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.UsdtMarginSwapApi.ExchangeData.GetMarketDataAsync("ETH-USDT");
+var result = await htxClient.UsdtFuturesApi.ExchangeData.GetMarketDataAsync("ETH-USDT");
Get Recent Trades
-

Get the most recent trades for a margin swap symbol

-
var huobiClient = new HuobiRestClient();
+		  

Get the most recent trades for a futures symbol

+
var htxClient = new HTXRestClient();
 
-var result = await huobiClient.UsdtMarginSwapApi.ExchangeData.GetRecentTradesAsync("ETH-USDT", 100);
+var result = await htxClient.UsdtFuturesApi.ExchangeData.GetRecentTradesAsync("ETH-USDT", 100);
Get Balances
-

Get balance of the perpetual futures account

-
var huobiClient = new HuobiRestClient(options => {
+		  

Get balance of the cross futures account

+
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
-
-// First need to get the id of the account to get balances for
-var accounts = await huobiClient.SpotApi.Account.GetAccountsAsync();
-var accountId = accounts.Data.Single(d => d.Type == Huobi.Net.Enums.AccountType.Margin).Id;
-
-var result = await huobiClient.SpotApi.Account.GetBalancesAsync(accountId);
+var result = await restClient.UsdtFuturesApi.Account.GetCrossMarginAccountInfoAsync();
Get Positions
-

Get open positions

-
var huobiClient = new HuobiRestClient(options => {
+		  

Get open cross margin positions

+
var htxClient = new HTXRestClient(options => {
   options.ApiCredentials = new ApiCredentials("KEY", "SECRET");		  
 });
 
-var result = await huobiClient.UsdtMarginSwapApi.Account.GetCrossMarginPositionsAsync();
+var result = await htxClient.UsdtFuturesApi.Account.GetCrossMarginPositionsAsync();
Place Limit Order

Place a new limit order for going long on 0.1 ETH at a price of 2000 USDT

-
var huobiClient = new HuobiRestClient(options => {
+		  
var htxClient = new HTXRestClient(options => {
     options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
 });
 
-var result = await huobiClient.UsdtMarginSwapApi.Trading.PlaceCrossMarginOrderAsync(0.1m, Huobi.Net.Enums.OrderSide.Buy, 10, "ETH-USDT", price: 2000m);
+var result = await htxClient.UsdtFuturesApi.Trading.PlaceCrossMarginOrderAsync(1, HTX.Net.Enums.OrderSide.Buy, 10, HTX.Net.Enums.OrderPriceType.Limit, "ETH-USDT", price: 2000m);