diff --git a/README.md b/README.md index ff226be..013b5cf 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Complete & robust JavaScript & Node.js SDK for the HTX REST APIs and WebSockets: ## Table of Contents - [Installation](#installation) +- [Why not raw ws?](#why-not-raw-ws) - [Examples](#examples) - [Issues & Discussion](#issues--discussion) - [Related Projects](#related-projects) @@ -70,10 +71,24 @@ Complete & robust JavaScript & Node.js SDK for the HTX REST APIs and WebSockets: ## Installation -`npm install --save @siebly/htx-api` +```bash +npm install --save @siebly/htx-api +``` + +Install **`@siebly/htx-api`**. That is the package name for this SDK. The unscoped npm package `htx-api` is a different package (a stale 0.0.9 pre-release). Node.js usage requires Node 22.13.0 or newer. Browser applications should follow the public-data and credential-safety guidance below. +## Why not raw ws? + +A raw `ws` socket still has to gzip-decode HTX frames, answer ping/pong, sign private auth, reconnect, and resubscribe. `WebsocketClient` does that and emits typed events. + +```javascript +import { WebsocketClient, WS_KEY_MAP } from '@siebly/htx-api'; +const ws = new WebsocketClient(); +ws.subscribe('market.btcusdt.ticker', WS_KEY_MAP.spotPublic); +``` + ## Examples Refer to the [examples](./examples) folder for implementation demos, including: diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index ecf9918..c7c9a45 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -125,43 +125,43 @@ This table includes all endpoints from the official Exchange API docs and corres | [getDepositAddress()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1045) | :closed_lock_with_key: | GET | `/v2/account/deposit/address` | | [getWithdrawQuota()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1056) | :closed_lock_with_key: | GET | `/v2/account/withdraw/quota` | | [getWithdrawAddress()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1067) | :closed_lock_with_key: | GET | `/v2/account/withdraw/address` | -| [submitWithdraw()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1080) | :closed_lock_with_key: | POST | `/v1/dw/withdraw/api/create` | -| [getWithdrawByClientId()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1091) | :closed_lock_with_key: | GET | `/v1/query/withdraw/client-order-id` | -| [cancelWithdraw()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1102) | :closed_lock_with_key: | POST | `/v1/dw/withdraw-virtual/{withdrawId}/cancel` | -| [getDepositWithdrawHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1116) | :closed_lock_with_key: | GET | `/v1/query/deposit-withdraw` | -| [getVaspList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1127) | | GET | `/v1/query/vasp-list` | -| [getBrokerUserRebateStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1142) | :closed_lock_with_key: | GET | `/broker/v1/user_rebate_status` | -| [setBrokerSubUserFeeRate()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1168) | :closed_lock_with_key: | POST | `/broker/v1/sub-user/fee_rate/add` | -| [getBrokerAccountCapitalSnapshot()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1181) | :closed_lock_with_key: | POST | `/broker/v1/account_capital_snapshot_everyday` | -| [updateSubUserDeductMode()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1200) | :closed_lock_with_key: | POST | `/v2/sub-user/deduct-mode` | -| [getSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1212) | :closed_lock_with_key: | GET | `/v2/user/api-key` | -| [getUserUid()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1224) | :closed_lock_with_key: | GET | `/v2/user/uid` | -| [getSubUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1247) | :closed_lock_with_key: | GET | `/v2/sub-user/user-list` | -| [updateSubUserLockStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1258) | :closed_lock_with_key: | POST | `/v2/sub-user/management` | -| [getSubUserStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1270) | :closed_lock_with_key: | GET | `/v2/sub-user/user-state` | -| [setSubUserTradableMarket()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1281) | :closed_lock_with_key: | POST | `/v2/sub-user/tradable-market` | -| [setSubUserTransferPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1292) | :closed_lock_with_key: | POST | `/v2/sub-user/transferability` | -| [getSubUserAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1303) | :closed_lock_with_key: | GET | `/v2/sub-user/account-list` | -| [createSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1314) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-generation` | -| [updateSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1327) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-modification` | -| [deleteSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1340) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-deletion` | -| [submitSubUserTransfer()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1354) | :closed_lock_with_key: | POST | `/v1/subuser/transfer` | -| [getSubUserDepositAddress()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1365) | :closed_lock_with_key: | GET | `/v2/sub-user/deposit-address` | -| [getSubUserDepositHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1377) | :closed_lock_with_key: | GET | `/v2/sub-user/query-deposit` | -| [getSubUsersAggregatedBalance()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1390) | :closed_lock_with_key: | GET | `/v1/subuser/aggregate-balance` | -| [getSubUserBalance()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1401) | :closed_lock_with_key: | GET | `/v1/account/accounts/{subUid}` | -| [getSubUserEntrustUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1412) | :closed_lock_with_key: | GET | `/v2/sub-user/entrust-user-list` | -| [getSubUserManagedTransferHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1428) | :closed_lock_with_key: | GET | `/v2/sub-user/managed-transfer-history` | -| [getReferralRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1444) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/detail` | -| [getReferralRebateHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1455) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/history` | -| [getReferralAllRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1466) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/all_rebate/detail` | -| [getReferralMultipleRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1479) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/batcher_rebate/detail` | -| [getReferralInvitedUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1490) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/referrals` | -| [getP2POrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1509) | | GET | `/v1/api/c2c/order/history` | -| [getEarnProjectList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1529) | :closed_lock_with_key: | GET | `/v1/earn/project/queryEarnProjectList` | -| [earnSubscribe()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1542) | :closed_lock_with_key: | POST | `/v1/earn/order/demand/add` | -| [earnRedeem()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1553) | :closed_lock_with_key: | POST | `/v1/earn/order/demand/redeem-order` | -| [getEarnUserAssets()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1566) | :closed_lock_with_key: | GET | `/v1/earn/order/user/assets/list` | +| [submitWithdraw()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1085) | :closed_lock_with_key: | POST | `/v1/dw/withdraw/api/create` | +| [getWithdrawByClientId()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1096) | :closed_lock_with_key: | GET | `/v1/query/withdraw/client-order-id` | +| [cancelWithdraw()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1107) | :closed_lock_with_key: | POST | `/v1/dw/withdraw-virtual/{withdrawId}/cancel` | +| [getDepositWithdrawHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1121) | :closed_lock_with_key: | GET | `/v1/query/deposit-withdraw` | +| [getVaspList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1132) | | GET | `/v1/query/vasp-list` | +| [getBrokerUserRebateStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1147) | :closed_lock_with_key: | GET | `/broker/v1/user_rebate_status` | +| [setBrokerSubUserFeeRate()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1173) | :closed_lock_with_key: | POST | `/broker/v1/sub-user/fee_rate/add` | +| [getBrokerAccountCapitalSnapshot()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1186) | :closed_lock_with_key: | POST | `/broker/v1/account_capital_snapshot_everyday` | +| [updateSubUserDeductMode()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1205) | :closed_lock_with_key: | POST | `/v2/sub-user/deduct-mode` | +| [getSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1217) | :closed_lock_with_key: | GET | `/v2/user/api-key` | +| [getUserUid()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1229) | :closed_lock_with_key: | GET | `/v2/user/uid` | +| [getSubUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1252) | :closed_lock_with_key: | GET | `/v2/sub-user/user-list` | +| [updateSubUserLockStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1263) | :closed_lock_with_key: | POST | `/v2/sub-user/management` | +| [getSubUserStatus()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1275) | :closed_lock_with_key: | GET | `/v2/sub-user/user-state` | +| [setSubUserTradableMarket()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1286) | :closed_lock_with_key: | POST | `/v2/sub-user/tradable-market` | +| [setSubUserTransferPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1297) | :closed_lock_with_key: | POST | `/v2/sub-user/transferability` | +| [getSubUserAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1308) | :closed_lock_with_key: | GET | `/v2/sub-user/account-list` | +| [createSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1319) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-generation` | +| [updateSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1332) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-modification` | +| [deleteSubUserApiKey()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1345) | :closed_lock_with_key: | POST | `/v2/sub-user/api-key-deletion` | +| [submitSubUserTransfer()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1359) | :closed_lock_with_key: | POST | `/v1/subuser/transfer` | +| [getSubUserDepositAddress()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1370) | :closed_lock_with_key: | GET | `/v2/sub-user/deposit-address` | +| [getSubUserDepositHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1382) | :closed_lock_with_key: | GET | `/v2/sub-user/query-deposit` | +| [getSubUsersAggregatedBalance()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1395) | :closed_lock_with_key: | GET | `/v1/subuser/aggregate-balance` | +| [getSubUserBalance()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1406) | :closed_lock_with_key: | GET | `/v1/account/accounts/{subUid}` | +| [getSubUserEntrustUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1417) | :closed_lock_with_key: | GET | `/v2/sub-user/entrust-user-list` | +| [getSubUserManagedTransferHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1433) | :closed_lock_with_key: | GET | `/v2/sub-user/managed-transfer-history` | +| [getReferralRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1449) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/detail` | +| [getReferralRebateHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1460) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/history` | +| [getReferralAllRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1471) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/all_rebate/detail` | +| [getReferralMultipleRebateDetail()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1484) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/batcher_rebate/detail` | +| [getReferralInvitedUserList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1495) | :closed_lock_with_key: | GET | `/v2/invitee/rebate/referrals` | +| [getP2POrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1514) | | GET | `/v1/api/c2c/order/history` | +| [getEarnProjectList()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1534) | :closed_lock_with_key: | GET | `/v1/earn/project/queryEarnProjectList` | +| [earnSubscribe()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1547) | :closed_lock_with_key: | POST | `/v1/earn/order/demand/add` | +| [earnRedeem()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1558) | :closed_lock_with_key: | POST | `/v1/earn/order/demand/redeem-order` | +| [getEarnUserAssets()](https://github.com/sieblyio/htx-api/blob/main/src/SpotClient.ts#L1571) | :closed_lock_with_key: | GET | `/v1/earn/order/user/assets/list` | # FuturesClient.ts @@ -169,350 +169,351 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [getTimestamp()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L438) | | GET | `/api/v1/timestamp` | -| [getHeartbeat()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L448) | | GET | `/heartbeat/` | -| [getLinearSwapAccountType()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L464) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/swap_unified_account_type` | -| [updateLinearSwapAccountType()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L480) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_switch_account_type` | -| [getLinearSwapFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L496) | | GET | `/linear-swap-api/v1/swap_funding_rate` | -| [getLinearSwapFundingRates()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L508) | | GET | `/linear-swap-api/v1/swap_batch_funding_rate` | -| [getLinearSwapHistoricalFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L520) | | GET | `/linear-swap-api/v1/swap_historical_funding_rate` | -| [getLinearSwapLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L532) | | GET | `/linear-swap-api/v3/swap_liquidation_orders` | -| [getLinearSwapSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L544) | | GET | `/linear-swap-api/v1/swap_settlement_records` | -| [getLinearSwapNetAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L556) | | GET | `/linear-swap-api/v1/swap_elite_account_ratio` | -| [getLinearSwapNetPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L569) | | GET | `/linear-swap-api/v1/swap_elite_position_ratio` | -| [getLinearSwapIsolatedSystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L582) | | GET | `/linear-swap-api/v1/swap_api_state` | -| [getLinearSwapCrossTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L595) | | GET | `/linear-swap-api/v1/swap_cross_ladder_margin` | -| [getLinearSwapIsolatedTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L607) | | GET | `/linear-swap-api/v1/swap_ladder_margin` | -| [getLinearSwapEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L620) | | GET | `/linear-swap-api/v1/swap_estimated_settlement_price` | -| [getLinearSwapIsolatedAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L635) | | GET | `/linear-swap-api/v1/swap_adjustfactor` | -| [getLinearSwapCrossAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L648) | | GET | `/linear-swap-api/v1/swap_cross_adjustfactor` | -| [getLinearSwapRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L660) | | GET | `/v1/insurance_fund_info` | -| [getLinearSwapRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L672) | | GET | `/v1/insurance_fund_history` | -| [getLinearSwapContractPriceLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L684) | | GET | `/linear-swap-api/v1/swap_price_limit` | -| [getLinearSwapOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L696) | | GET | `/linear-swap-api/v1/swap_open_interest` | -| [getLinearSwapContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L708) | | GET | `/linear-swap-api/v1/swap_contract_info` | -| [getLinearSwapIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L720) | | GET | `/linear-swap-api/v1/swap_index` | -| [getLinearSwapIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L732) | | GET | `/linear-swap-api/market/swap_contract_constituents` | -| [getLinearSwapContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L747) | | GET | `/linear-swap-api/v1/swap_query_elements` | -| [getLinearSwapMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L765) | | GET | `/linear-swap-ex/market/depth` | -| [getLinearSwapMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L778) | | GET | `/linear-swap-ex/market/bbo` | -| [getLinearSwapKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L791) | | GET | `/linear-swap-ex/market/history/kline` | -| [getLinearSwapMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L802) | | GET | `/index/market/history/linear_swap_mark_price_kline` | -| [getLinearSwapTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L816) | | GET | `/linear-swap-ex/market/detail/merged` | -| [getLinearSwapTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L828) | | GET | `/v2/linear-swap-ex/market/detail/batch_merged` | -| [getLinearSwapLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L841) | | GET | `/linear-swap-ex/market/trade` | -| [getLinearSwapTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L853) | | GET | `/linear-swap-ex/market/history/trade` | -| [getLinearSwapHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L866) | | GET | `/linear-swap-api/v1/swap_his_open_interest` | -| [getLinearSwapPremiumIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L877) | | GET | `/index/market/history/linear_swap_premium_index_kline` | -| [getLinearSwapFundingRateKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L891) | | GET | `/index/market/history/linear_swap_estimated_rate_kline` | -| [getLinearSwapBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L905) | | GET | `/index/market/history/linear_swap_basis` | -| [getLinearSwapAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L923) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_balance_valuation` | -| [getLinearSwapIsolatedAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L936) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_account_info` | -| [getLinearSwapCrossAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L949) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_account_info` | -| [getLinearSwapIsolatedPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L962) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_position_info` | -| [getLinearSwapCrossPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L975) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_position_info` | -| [getLinearSwapIsolatedAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L988) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_account_position_info` | -| [getLinearSwapCrossAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1001) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_account_position_info` | -| [updateLinearSwapSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1015) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_auth` | -| [getLinearSwapSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1029) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_sub_auth_list` | -| [getLinearSwapIsolatedSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1040) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_list` | -| [getLinearSwapCrossSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1053) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_list` | -| [getLinearSwapIsolatedSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1066) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_info_list` | -| [getLinearSwapCrossSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1079) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_info_list` | -| [getLinearSwapIsolatedSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1093) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_info` | -| [getLinearSwapCrossSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1107) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_info` | -| [getLinearSwapIsolatedSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1121) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_position_info` | -| [getLinearSwapCrossSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1135) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_position_info` | -| [getLinearSwapFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1149) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_financial_record` | -| [getLinearSwapFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1162) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_financial_record_exact` | -| [getLinearSwapIsolatedAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1175) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_available_level_rate` | -| [getLinearSwapCrossAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1188) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_available_level_rate` | -| [getLinearSwapOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1202) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_limit` | -| [getLinearSwapFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1215) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_fee` | -| [getLinearSwapIsolatedTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1228) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_transfer_limit` | -| [getLinearSwapCrossTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1241) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_transfer_limit` | -| [getLinearSwapIsolatedPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1254) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_position_limit` | -| [getLinearSwapCrossPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1267) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_position_limit` | -| [getLinearSwapIsolatedLeverageLimits()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1280) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_lever_position_limit` | -| [getLinearSwapCrossLeverageLimits()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1294) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_lever_position_limit` | -| [transferLinearSwapMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1310) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_master_sub_transfer` | -| [getLinearSwapMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1323) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_master_sub_transfer_record` | -| [transferLinearSwapInner()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1339) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_transfer_inner` | -| [setLinearSwapCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1358) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/linear-cancel-after` | -| [getLinearSwapCrossTradeState()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1372) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_trade_state` | -| [getLinearSwapCrossTransferState()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1386) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_transfer_state` | -| [updateLinearSwapIsolatedPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1400) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_switch_position_mode` | -| [updateLinearSwapCrossPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1414) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_switch_position_mode` | -| [submitLinearSwapIsolatedOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1431) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order` | -| [submitLinearSwapCrossOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1444) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order` | -| [submitLinearSwapIsolatedBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1457) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_batchorder` | -| [submitLinearSwapCrossBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1470) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_batchorder` | -| [cancelLinearSwapIsolatedOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1483) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cancel` | -| [cancelLinearSwapCrossOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1496) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_cancel` | -| [cancelLinearSwapIsolatedAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1509) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cancelall` | -| [cancelLinearSwapCrossAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1522) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_cancelall` | -| [updateLinearSwapIsolatedLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1535) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_switch_lever_rate` | -| [updateLinearSwapCrossLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1549) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_switch_lever_rate` | -| [getLinearSwapIsolatedOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1565) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_info` | -| [getLinearSwapCrossOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1578) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order_info` | -| [getLinearSwapIsolatedOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1591) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_detail` | -| [getLinearSwapCrossOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1604) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order_detail` | -| [getLinearSwapIsolatedOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1617) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_openorders` | -| [getLinearSwapCrossOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1630) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_openorders` | -| [getLinearSwapIsolatedHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1643) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_hisorders` | -| [getLinearSwapCrossHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1656) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_hisorders` | -| [getLinearSwapIsolatedHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1669) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_hisorders_exact` | -| [getLinearSwapCrossHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1682) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_hisorders_exact` | -| [getLinearSwapIsolatedFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1695) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_matchresults` | -| [getLinearSwapCrossFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1708) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_matchresults` | -| [getLinearSwapIsolatedFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1721) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_matchresults_exact` | -| [getLinearSwapCrossFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1734) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_matchresults_exact` | -| [submitLinearSwapIsolatedLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1750) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_lightning_close_position` | -| [submitLinearSwapCrossLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1766) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_lightning_close_position` | -| [getLinearSwapIsolatedPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1780) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_position_side` | -| [getLinearSwapCrossPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1791) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_position_side` | -| [submitLinearSwapIsolatedTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1811) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_order` | -| [submitLinearSwapCrossTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1824) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_order` | -| [cancelLinearSwapIsolatedTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1837) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_cancel` | -| [cancelLinearSwapCrossTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1851) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_cancel` | -| [cancelLinearSwapIsolatedAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1864) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_cancelall` | -| [cancelLinearSwapCrossAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1877) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_cancelall` | -| [getLinearSwapIsolatedTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1893) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_openorders` | -| [getLinearSwapCrossTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1906) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_openorders` | -| [getLinearSwapIsolatedTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1920) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_hisorders` | -| [getLinearSwapCrossTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1933) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_hisorders` | -| [submitLinearSwapIsolatedTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1947) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_order` | -| [submitLinearSwapCrossTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1960) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_order` | -| [cancelLinearSwapIsolatedTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1973) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_cancel` | -| [cancelLinearSwapCrossTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1987) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_cancel` | -| [cancelLinearSwapIsolatedAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2000) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_cancelall` | -| [cancelLinearSwapCrossAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2014) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_cancelall` | -| [getLinearSwapIsolatedTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2027) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_openorders` | -| [getLinearSwapCrossTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2040) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_openorders` | -| [getLinearSwapIsolatedTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2053) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_hisorders` | -| [getLinearSwapCrossTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2066) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_hisorders` | -| [getLinearSwapIsolatedRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2079) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_relation_tpsl_order` | -| [getLinearSwapCrossRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2093) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_relation_tpsl_order` | -| [submitLinearSwapIsolatedTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2109) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_order` | -| [submitLinearSwapCrossTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2122) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_order` | -| [cancelLinearSwapIsolatedTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2135) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_cancel` | -| [cancelLinearSwapCrossTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2149) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_cancel` | -| [cancelLinearSwapIsolatedAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2162) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_cancelall` | -| [cancelLinearSwapCrossAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2175) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_cancelall` | -| [getLinearSwapIsolatedTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2188) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_openorders` | -| [getLinearSwapCrossTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2201) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_openorders` | -| [getLinearSwapIsolatedTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2214) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_hisorders` | -| [getLinearSwapCrossTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2227) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_hisorders` | -| [getLinearSwapUnifiedAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2244) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/unified_account_info` | -| [getLinearSwapUnifiedAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2255) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/linear_swap_overview_account_info` | -| [updateLinearSwapUnifiedFeeMethod()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2271) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/linear_swap_fee_switch` | -| [getLinearSwapUnifiedMarginAdjustments()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2285) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/fix_position_margin_change_record` | -| [updateLinearSwapUnifiedMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2301) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/fix_position_margin_change` | -| [getMultiAssetAccountBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2321) | :closed_lock_with_key: | GET | `/v5/account/balance` | -| [getMultiAssetMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2333) | :closed_lock_with_key: | GET | `/v5/account/asset_mode` | -| [updateMultiAssetMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2345) | :closed_lock_with_key: | POST | `/v5/account/asset_mode` | -| [updateMultiAssetFeeCurrency()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2357) | :closed_lock_with_key: | POST | `/v5/account/fee_deduction_currency` | -| [getMultiAssetFeeCurrency()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2372) | :closed_lock_with_key: | GET | `/v5/account/fee_deduction_currency` | -| [getMultiAssetBills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2384) | :closed_lock_with_key: | GET | `/v5/account/bills` | -| [submitMultiAssetOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2402) | :closed_lock_with_key: | POST | `/v5/trade/order` | -| [submitMultiAssetBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2414) | :closed_lock_with_key: | POST | `/v5/trade/batch_orders` | -| [cancelMultiAssetOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2426) | :closed_lock_with_key: | POST | `/v5/trade/cancel_order` | -| [cancelMultiAssetBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2438) | :closed_lock_with_key: | POST | `/v5/trade/cancel_batch_orders` | -| [cancelMultiAssetAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2450) | :closed_lock_with_key: | POST | `/v5/trade/cancel_all_orders` | -| [closeMultiAssetPosition()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2464) | :closed_lock_with_key: | POST | `/v5/trade/position` | -| [closeMultiAssetAllPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2476) | :closed_lock_with_key: | POST | `/v5/trade/position_all` | -| [getMultiAssetOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2488) | :closed_lock_with_key: | GET | `/v5/trade/order/opens` | -| [getMultiAssetFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2500) | :closed_lock_with_key: | GET | `/v5/trade/order/details` | -| [getMultiAssetOrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2512) | :closed_lock_with_key: | GET | `/v5/trade/order/history` | -| [getMultiAssetOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2524) | :closed_lock_with_key: | GET | `/v5/trade/order` | -| [setMultiAssetCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2536) | :closed_lock_with_key: | POST | `/v5/trade/cancel-after` | -| [submitMultiAssetAlgoOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2551) | :closed_lock_with_key: | POST | `/v5/algo/order` | -| [cancelMultiAssetAlgoOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2560) | :closed_lock_with_key: | POST | `/v5/algo/cancel_orders` | -| [getMultiAssetAlgoOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2569) | :closed_lock_with_key: | GET | `/v5/algo/order` | -| [getMultiAssetAlgoOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2578) | :closed_lock_with_key: | GET | `/v5/algo/order/opens` | -| [getMultiAssetAlgoOrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2587) | :closed_lock_with_key: | GET | `/v5/algo/order/history` | -| [getMultiAssetPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2605) | :closed_lock_with_key: | GET | `/v5/trade/position/opens` | -| [getMultiAssetLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2617) | :closed_lock_with_key: | GET | `/v5/position/lever` | -| [updateMultiAssetLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2629) | :closed_lock_with_key: | POST | `/v5/position/lever` | -| [getMultiAssetPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2641) | :closed_lock_with_key: | GET | `/v5/position/mode` | -| [updateMultiAssetPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2653) | :closed_lock_with_key: | POST | `/v5/position/mode` | -| [getMultiAssetRiskLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2665) | :closed_lock_with_key: | GET | `/v5/position/risk/limit` | -| [getMultiAssetRiskLimitTiers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2677) | :closed_lock_with_key: | GET | `/v5/position/risk/limit_tier` | -| [adjustMultiAssetMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2690) | :closed_lock_with_key: | POST | `/v5/position/margin` | -| [getMultiAssetMarketRiskLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2707) | :closed_lock_with_key: | GET | `/v5/market/risk/limit` | -| [getMultiAssetFeeCurrencies()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2719) | :closed_lock_with_key: | GET | `/v5/market/assets_deduction_currency` | -| [getMultiAssetCollateralAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2731) | :closed_lock_with_key: | GET | `/v5/market/multi_assets_margin` | -| [getCoinMDeliveryAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2748) | | GET | `/api/v1/contract_adjustfactor` | -| [getCoinMDeliveryHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2759) | | GET | `/api/v1/contract_his_open_interest` | -| [getCoinMDeliveryTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2770) | | GET | `/api/v1/contract_ladder_margin` | -| [getCoinMDeliveryAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2781) | | GET | `/api/v1/contract_elite_account_ratio` | -| [getCoinMDeliveryPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2793) | | GET | `/api/v1/contract_elite_position_ratio` | -| [getCoinMDeliveryLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2805) | | GET | `/api/v3/contract_liquidation_orders` | -| [getCoinMDeliverySettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2816) | | GET | `/api/v1/contract_settlement_records` | -| [getCoinMDeliveryRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2827) | | GET | `/v1/insurance_fund_info` | -| [getCoinMDeliveryRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2838) | | GET | `/v1/insurance_fund_history` | -| [getCoinMDeliveryContractLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2849) | | GET | `/api/v1/contract_price_limit` | -| [getCoinMDeliveryOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2860) | | GET | `/api/v1/contract_open_interest` | -| [getCoinMDeliveryDeliveryPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2873) | | GET | `/api/v1/contract_delivery_price` | -| [getCoinMDeliveryEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2884) | | GET | `/api/v1/contract_estimated_settlement_price` | -| [getCoinMDeliverySystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2897) | | GET | `/api/v1/contract_api_state` | -| [getCoinMDeliveryContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2908) | | GET | `/api/v1/contract_contract_info` | -| [getCoinMDeliveryIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2919) | | GET | `/api/v1/contract_index` | -| [getCoinMDeliveryIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2930) | | GET | `/api/market/contract_constituents` | -| [getCoinMDeliveryContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2941) | | GET | `/api/v1/contract_query_elements` | -| [getCoinMDeliveryMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2958) | | GET | `/market/depth` | -| [getCoinMDeliveryMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2970) | | GET | `/market/bbo` | -| [getCoinMDeliveryKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2981) | | GET | `/market/history/kline` | -| [getCoinMDeliveryMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2992) | | GET | `/index/market/history/mark_price_kline` | -| [getCoinMDeliveryTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3003) | | GET | `/market/detail/merged` | -| [getCoinMDeliveryTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3014) | | GET | `/v2/market/detail/batch_merged` | -| [getCoinMDeliveryLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3025) | | GET | `/market/trade` | -| [getCoinMDeliveryTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3036) | | GET | `/market/history/trade` | -| [getCoinMDeliveryIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3048) | | GET | `/index/market/history/index` | -| [getCoinMDeliveryBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3059) | | GET | `/index/market/history/basis` | -| [getCoinMDeliveryAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3076) | :closed_lock_with_key: | POST | `/api/v1/contract_balance_valuation` | -| [getCoinMDeliveryAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3089) | :closed_lock_with_key: | POST | `/api/v1/contract_account_info` | -| [getCoinMDeliveryPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3102) | :closed_lock_with_key: | POST | `/api/v1/contract_position_info` | -| [updateCoinMDeliverySubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3115) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_auth` | -| [getCoinMDeliverySubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3129) | :closed_lock_with_key: | GET | `/api/v1/contract_sub_auth_list` | -| [getCoinMDeliverySubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3140) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_list` | -| [getCoinMDeliverySubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3153) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_info_list` | -| [getCoinMDeliverySubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3166) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_info` | -| [getCoinMDeliverySubPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3180) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_position_info` | -| [getCoinMDeliveryFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3194) | :closed_lock_with_key: | POST | `/api/v3/contract_financial_record` | -| [getCoinMDeliveryFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3207) | :closed_lock_with_key: | POST | `/api/v3/contract_financial_record_exact` | -| [getCoinMDeliveryUserSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3220) | :closed_lock_with_key: | POST | `/api/v1/contract_user_settlement_records` | -| [getCoinMDeliveryOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3235) | :closed_lock_with_key: | POST | `/api/v1/contract_order_limit` | -| [getCoinMDeliveryFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3248) | :closed_lock_with_key: | POST | `/api/v1/contract_fee` | -| [getCoinMDeliveryTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3261) | :closed_lock_with_key: | POST | `/api/v1/contract_transfer_limit` | -| [getCoinMDeliveryPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3274) | :closed_lock_with_key: | POST | `/api/v1/contract_position_limit` | -| [getCoinMDeliveryAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3287) | :closed_lock_with_key: | POST | `/api/v1/contract_account_position_info` | -| [transferCoinMDeliveryMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3300) | :closed_lock_with_key: | POST | `/api/v1/contract_master_sub_transfer` | -| [getCoinMDeliveryMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3313) | :closed_lock_with_key: | POST | `/api/v1/contract_master_sub_transfer_record` | -| [getCoinMDeliveryApiStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3326) | :closed_lock_with_key: | GET | `/api/v1/contract_api_trading_status` | -| [getCoinMDeliveryAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3337) | :closed_lock_with_key: | POST | `/api/v1/contract_available_level_rate` | -| [setCoinMDeliveryCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3356) | :closed_lock_with_key: | POST | `/api/v1/contract-cancel-after` | -| [submitCoinMDeliveryOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3370) | :closed_lock_with_key: | POST | `/api/v1/contract_order` | -| [submitCoinMDeliveryBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3383) | :closed_lock_with_key: | POST | `/api/v1/contract_batchorder` | -| [cancelCoinMDeliveryOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3396) | :closed_lock_with_key: | POST | `/api/v1/contract_cancel` | -| [cancelCoinMDeliveryAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3409) | :closed_lock_with_key: | POST | `/api/v1/contract_cancelall` | -| [updateCoinMDeliveryLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3422) | :closed_lock_with_key: | POST | `/api/v1/contract_switch_lever_rate` | -| [getCoinMDeliveryOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3436) | :closed_lock_with_key: | POST | `/api/v1/contract_order_info` | -| [getCoinMDeliveryOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3449) | :closed_lock_with_key: | POST | `/api/v1/contract_order_detail` | -| [getCoinMDeliveryOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3462) | :closed_lock_with_key: | POST | `/api/v1/contract_openorders` | -| [getCoinMDeliveryHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3475) | :closed_lock_with_key: | POST | `/api/v3/contract_hisorders` | -| [getCoinMDeliveryHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3488) | :closed_lock_with_key: | POST | `/api/v3/contract_hisorders_exact` | -| [getCoinMDeliveryFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3501) | :closed_lock_with_key: | POST | `/api/v3/contract_matchresults` | -| [getCoinMDeliveryFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3514) | :closed_lock_with_key: | POST | `/api/v3/contract_matchresults_exact` | -| [submitCoinMDeliveryLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3527) | :closed_lock_with_key: | POST | `/api/v1/lightning_close_position` | -| [submitCoinMDeliveryTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3546) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_order` | -| [cancelCoinMDeliveryTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3559) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_cancel` | -| [cancelCoinMDeliveryAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3573) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_cancelall` | -| [getCoinMDeliveryTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3586) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_openorders` | -| [getCoinMDeliveryTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3599) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_hisorders` | -| [submitCoinMDeliveryTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3612) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_order` | -| [cancelCoinMDeliveryTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3625) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_cancel` | -| [cancelCoinMDeliveryAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3639) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_cancelall` | -| [getCoinMDeliveryTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3652) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_openorders` | -| [getCoinMDeliveryTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3665) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_hisorders` | -| [getCoinMDeliveryRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3678) | :closed_lock_with_key: | POST | `/api/v1/contract_relation_tpsl_order` | -| [submitCoinMDeliveryTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3692) | :closed_lock_with_key: | POST | `/api/v1/contract_track_order` | -| [cancelCoinMDeliveryTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3705) | :closed_lock_with_key: | POST | `/api/v1/contract_track_cancel` | -| [cancelCoinMDeliveryAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3719) | :closed_lock_with_key: | POST | `/api/v1/contract_track_cancelall` | -| [getCoinMDeliveryTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3732) | :closed_lock_with_key: | POST | `/api/v1/contract_track_openorders` | -| [getCoinMDeliveryTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3745) | :closed_lock_with_key: | POST | `/api/v1/contract_track_hisorders` | -| [getCoinMPerpAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3766) | | GET | `/swap-api/v1/swap_adjustfactor` | -| [getCoinMPerpHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3777) | | GET | `/swap-api/v1/swap_his_open_interest` | -| [getCoinMPerpTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3788) | | GET | `/swap-api/v1/swap_ladder_margin` | -| [getCoinMPerpAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3799) | | GET | `/swap-api/v1/swap_elite_account_ratio` | -| [getCoinMPerpPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3811) | | GET | `/swap-api/v1/swap_elite_position_ratio` | -| [getCoinMPerpEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3823) | | GET | `/swap-api/v1/swap_estimated_settlement_price` | -| [getCoinMPerpSystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3836) | | GET | `/swap-api/v1/swap_api_state` | -| [getCoinMPerpFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3847) | | GET | `/swap-api/v1/swap_funding_rate` | -| [getCoinMPerpFundingRates()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3858) | | GET | `/swap-api/v1/swap_batch_funding_rate` | -| [getCoinMPerpHistoricalFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3869) | | GET | `/swap-api/v1/swap_historical_funding_rate` | -| [getCoinMPerpLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3882) | | GET | `/swap-api/v3/swap_liquidation_orders` | -| [getCoinMPerpSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3893) | | GET | `/swap-api/v1/swap_settlement_records` | -| [getCoinMPerpContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3904) | | GET | `/swap-api/v1/swap_contract_info` | -| [getCoinMPerpIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3915) | | GET | `/swap-api/v1/swap_index` | -| [getCoinMPerpContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3926) | | GET | `/swap-api/v1/swap_query_elements` | -| [getCoinMPerpIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3937) | | GET | `/swap-api/market/swap_constituents` | -| [getCoinMPerpRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3948) | | GET | `/v1/insurance_fund_info` | -| [getCoinMPerpRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3959) | | GET | `/v1/insurance_fund_history` | -| [getCoinMPerpPriceLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3970) | | GET | `/swap-api/v1/swap_price_limit` | -| [getCoinMPerpOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3981) | | GET | `/swap-api/v1/swap_open_interest` | -| [getCoinMPerpMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3998) | | GET | `/swap-ex/market/depth` | -| [getCoinMPerpMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4010) | | GET | `/swap-ex/market/bbo` | -| [getCoinMPerpKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4021) | | GET | `/swap-ex/market/history/kline` | -| [getCoinMPerpMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4032) | | GET | `/index/market/history/swap_mark_price_kline` | -| [getCoinMPerpTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4043) | | GET | `/swap-ex/market/detail/merged` | -| [getCoinMPerpTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4054) | | GET | `/v2/swap-ex/market/detail/batch_merged` | -| [getCoinMPerpLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4065) | | GET | `/swap-ex/market/trade` | -| [getCoinMPerpTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4076) | | GET | `/swap-ex/market/history/trade` | -| [getCoinMPerpPremiumIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4088) | | GET | `/index/market/history/swap_premium_index_kline` | -| [getCoinMPerpFundingRateKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4099) | | GET | `/index/market/history/swap_estimated_rate_kline` | -| [getCoinMPerpBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4110) | | GET | `/index/market/history/swap_basis` | -| [getCoinMPerpAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4127) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_balance_valuation` | -| [getCoinMPerpAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4140) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_account_info` | -| [getCoinMPerpPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4153) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_position_info` | -| [getCoinMPerpAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4166) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_account_position_info` | -| [getCoinMPerpSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4179) | :closed_lock_with_key: | GET | `/swap-api/v1/swap_sub_auth_list` | -| [updateCoinMPerpSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4190) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_auth` | -| [getCoinMPerpSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4204) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_list` | -| [getCoinMPerpSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4217) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_info_list` | -| [getCoinMPerpSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4230) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_info` | -| [getCoinMPerpSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4244) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_position_info` | -| [getCoinMPerpFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4258) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_financial_record` | -| [getCoinMPerpFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4271) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_financial_record_exact` | -| [getCoinMPerpAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4284) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_available_level_rate` | -| [getCoinMPerpOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4297) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_limit` | -| [getCoinMPerpFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4310) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_fee` | -| [getCoinMPerpTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4323) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_transfer_limit` | -| [getCoinMPerpPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4336) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_position_limit` | -| [transferCoinMPerpMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4349) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_master_sub_transfer` | -| [getCoinMPerpMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4362) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_master_sub_transfer_record` | -| [getCoinMPerpApiStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4375) | :closed_lock_with_key: | GET | `/swap-api/v1/swap_api_trading_status` | -| [setCoinMPerpCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4392) | :closed_lock_with_key: | POST | `/swap-api/v1/swap-cancel-after` | -| [submitCoinMPerpOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4406) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order` | -| [submitCoinMPerpBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4419) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_batchorder` | -| [cancelCoinMPerpOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4432) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_cancel` | -| [cancelCoinMPerpAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4445) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_cancelall` | -| [updateCoinMPerpLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4458) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_switch_lever_rate` | -| [getCoinMPerpOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4472) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_info` | -| [getCoinMPerpOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4485) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_detail` | -| [getCoinMPerpOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4498) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_openorders` | -| [getCoinMPerpHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4511) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_hisorders` | -| [getCoinMPerpHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4524) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_hisorders_exact` | -| [getCoinMPerpFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4537) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_matchresults` | -| [getCoinMPerpFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4550) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_matchresults_exact` | -| [submitCoinMPerpLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4563) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_lightning_close_position` | -| [submitCoinMPerpTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4582) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_order` | -| [cancelCoinMPerpTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4595) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_cancel` | -| [cancelCoinMPerpAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4609) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_cancelall` | -| [getCoinMPerpTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4622) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_openorders` | -| [getCoinMPerpTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4635) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_hisorders` | -| [submitCoinMPerpTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4648) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_order` | -| [cancelCoinMPerpTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4661) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_cancel` | -| [cancelCoinMPerpAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4674) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_cancelall` | -| [getCoinMPerpTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4687) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_openorders` | -| [getCoinMPerpTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4700) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_hisorders` | -| [getCoinMPerpRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4713) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_relation_tpsl_order` | -| [submitCoinMPerpTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4726) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_order` | -| [cancelCoinMPerpTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4739) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_cancel` | -| [cancelCoinMPerpAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4752) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_cancelall` | -| [getCoinMPerpTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4765) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_openorders` | -| [getCoinMPerpTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4778) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_hisorders` | -| [getCopyTraderInstruments()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4797) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/instruments` | -| [getCopyTraderStatistics()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4808) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/statistics` | -| [getCopyTraderProfitSharingHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4819) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/profit-sharing-history` | -| [getCopyTraderProfitSharingHistorySummary()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4835) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/profit-sharing-history-summary` | -| [getCopyTraderUPNLSharingSummary()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4851) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/unrealized-profit-sharing-summary` | -| [getCopyTraderFollowers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4867) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/followers` | -| [removeCopyTraderFollower()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4878) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/follower` | -| [submitCopyTraderTransfer()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4893) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/transfer` | -| [updateCopyTraderFollowerSettings()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4906) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/follower-settings` | -| [getCopyTraderConfig()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4919) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/config` | -| [createCopyTraderApikey()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4932) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/apikey` | +| [getTimestamp()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L440) | | GET | `/api/v1/timestamp` | +| [getHeartbeat()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L450) | | GET | `/heartbeat/` | +| [getLinearSwapAccountType()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L466) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/swap_unified_account_type` | +| [updateLinearSwapAccountType()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L482) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_switch_account_type` | +| [getLinearSwapFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L498) | | GET | `/linear-swap-api/v1/swap_funding_rate` | +| [getLinearSwapFundingRates()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L510) | | GET | `/linear-swap-api/v1/swap_batch_funding_rate` | +| [getLinearSwapHistoricalFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L522) | | GET | `/linear-swap-api/v1/swap_historical_funding_rate` | +| [getLinearSwapLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L534) | | GET | `/linear-swap-api/v3/swap_liquidation_orders` | +| [getLinearSwapSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L546) | | GET | `/linear-swap-api/v1/swap_settlement_records` | +| [getLinearSwapNetAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L558) | | GET | `/linear-swap-api/v1/swap_elite_account_ratio` | +| [getLinearSwapNetPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L571) | | GET | `/linear-swap-api/v1/swap_elite_position_ratio` | +| [getLinearSwapIsolatedSystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L584) | | GET | `/linear-swap-api/v1/swap_api_state` | +| [getLinearSwapCrossTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L597) | | GET | `/linear-swap-api/v1/swap_cross_ladder_margin` | +| [getLinearSwapIsolatedTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L609) | | GET | `/linear-swap-api/v1/swap_ladder_margin` | +| [getLinearSwapEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L622) | | GET | `/linear-swap-api/v1/swap_estimated_settlement_price` | +| [getLinearSwapIsolatedAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L637) | | GET | `/linear-swap-api/v1/swap_adjustfactor` | +| [getLinearSwapCrossAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L650) | | GET | `/linear-swap-api/v1/swap_cross_adjustfactor` | +| [getLinearSwapRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L662) | | GET | `/v1/insurance_fund_info` | +| [getLinearSwapRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L674) | | GET | `/v1/insurance_fund_history` | +| [getLinearSwapContractPriceLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L686) | | GET | `/linear-swap-api/v1/swap_price_limit` | +| [getLinearSwapOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L698) | | GET | `/linear-swap-api/v1/swap_open_interest` | +| [getLinearSwapContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L710) | | GET | `/linear-swap-api/v1/swap_contract_info` | +| [getLinearSwapIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L722) | | GET | `/linear-swap-api/v1/swap_index` | +| [getLinearSwapIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L734) | | GET | `/linear-swap-api/market/swap_contract_constituents` | +| [getLinearSwapContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L749) | | GET | `/linear-swap-api/v1/swap_query_elements` | +| [getLinearSwapMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L767) | | GET | `/linear-swap-ex/market/depth` | +| [getLinearSwapMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L780) | | GET | `/linear-swap-ex/market/bbo` | +| [getLinearSwapKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L793) | | GET | `/linear-swap-ex/market/history/kline` | +| [getLinearSwapMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L804) | | GET | `/index/market/history/linear_swap_mark_price_kline` | +| [getLinearSwapTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L818) | | GET | `/linear-swap-ex/market/detail/merged` | +| [getLinearSwapTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L830) | | GET | `/v2/linear-swap-ex/market/detail/batch_merged` | +| [getLinearSwapLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L843) | | GET | `/linear-swap-ex/market/trade` | +| [getLinearSwapTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L855) | | GET | `/linear-swap-ex/market/history/trade` | +| [getLinearSwapHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L868) | | GET | `/linear-swap-api/v1/swap_his_open_interest` | +| [getLinearSwapPremiumIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L879) | | GET | `/index/market/history/linear_swap_premium_index_kline` | +| [getLinearSwapFundingRateKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L893) | | GET | `/index/market/history/linear_swap_estimated_rate_kline` | +| [getLinearSwapBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L907) | | GET | `/index/market/history/linear_swap_basis` | +| [getLinearSwapAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L925) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_balance_valuation` | +| [getLinearSwapIsolatedAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L938) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_account_info` | +| [getLinearSwapCrossAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L951) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_account_info` | +| [getLinearSwapIsolatedPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L964) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_position_info` | +| [getLinearSwapCrossPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L977) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_position_info` | +| [getLinearSwapIsolatedAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L990) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_account_position_info` | +| [getLinearSwapCrossAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1003) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_account_position_info` | +| [updateLinearSwapSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1017) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_auth` | +| [getLinearSwapSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1031) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_sub_auth_list` | +| [getLinearSwapIsolatedSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1042) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_list` | +| [getLinearSwapCrossSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1055) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_list` | +| [getLinearSwapIsolatedSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1068) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_info_list` | +| [getLinearSwapCrossSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1081) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_info_list` | +| [getLinearSwapIsolatedSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1095) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_account_info` | +| [getLinearSwapCrossSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1109) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_account_info` | +| [getLinearSwapIsolatedSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1123) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_sub_position_info` | +| [getLinearSwapCrossSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1137) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_sub_position_info` | +| [getLinearSwapFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1151) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_financial_record` | +| [getLinearSwapFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1164) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_financial_record_exact` | +| [getLinearSwapIsolatedAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1177) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_available_level_rate` | +| [getLinearSwapCrossAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1190) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_available_level_rate` | +| [getLinearSwapOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1204) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_limit` | +| [getLinearSwapFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1217) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_fee` | +| [getLinearSwapIsolatedTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1230) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_transfer_limit` | +| [getLinearSwapCrossTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1243) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_transfer_limit` | +| [getLinearSwapIsolatedPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1256) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_position_limit` | +| [getLinearSwapCrossPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1269) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_position_limit` | +| [getLinearSwapIsolatedLeverageLimits()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1282) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_lever_position_limit` | +| [getLinearSwapCrossLeverageLimits()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1296) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_lever_position_limit` | +| [transferLinearSwapMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1312) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_master_sub_transfer` | +| [getLinearSwapMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1325) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_master_sub_transfer_record` | +| [transferLinearSwapInner()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1341) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_transfer_inner` | +| [setLinearSwapCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1360) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/linear-cancel-after` | +| [getLinearSwapCrossTradeState()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1374) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_trade_state` | +| [getLinearSwapCrossTransferState()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1388) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_transfer_state` | +| [updateLinearSwapIsolatedPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1402) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_switch_position_mode` | +| [updateLinearSwapCrossPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1416) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_switch_position_mode` | +| [submitLinearSwapIsolatedOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1433) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order` | +| [submitLinearSwapCrossOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1446) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order` | +| [submitLinearSwapIsolatedBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1459) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_batchorder` | +| [submitLinearSwapCrossBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1472) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_batchorder` | +| [cancelLinearSwapIsolatedOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1485) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cancel` | +| [cancelLinearSwapCrossOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1498) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_cancel` | +| [cancelLinearSwapIsolatedAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1511) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cancelall` | +| [cancelLinearSwapCrossAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1524) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_cancelall` | +| [updateLinearSwapIsolatedLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1537) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_switch_lever_rate` | +| [updateLinearSwapCrossLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1551) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_switch_lever_rate` | +| [getLinearSwapIsolatedOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1567) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_info` | +| [getLinearSwapCrossOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1580) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order_info` | +| [getLinearSwapIsolatedOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1593) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_order_detail` | +| [getLinearSwapCrossOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1606) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_order_detail` | +| [getLinearSwapIsolatedOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1619) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_openorders` | +| [getLinearSwapCrossOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1632) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_openorders` | +| [getLinearSwapIsolatedHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1645) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_hisorders` | +| [getLinearSwapCrossHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1658) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_hisorders` | +| [getLinearSwapIsolatedHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1671) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_hisorders_exact` | +| [getLinearSwapCrossHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1684) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_hisorders_exact` | +| [getLinearSwapIsolatedFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1697) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_matchresults` | +| [getLinearSwapCrossFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1710) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_matchresults` | +| [getLinearSwapIsolatedFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1723) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_matchresults_exact` | +| [getLinearSwapCrossFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1736) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/swap_cross_matchresults_exact` | +| [submitLinearSwapIsolatedLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1752) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_lightning_close_position` | +| [submitLinearSwapCrossLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1768) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_lightning_close_position` | +| [getLinearSwapIsolatedPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1782) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_position_side` | +| [getLinearSwapCrossPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1793) | :closed_lock_with_key: | GET | `/linear-swap-api/v1/swap_cross_position_side` | +| [submitLinearSwapIsolatedTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1813) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_order` | +| [submitLinearSwapCrossTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1826) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_order` | +| [cancelLinearSwapIsolatedTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1839) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_cancel` | +| [cancelLinearSwapCrossTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1853) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_cancel` | +| [cancelLinearSwapIsolatedAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1866) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_cancelall` | +| [cancelLinearSwapCrossAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1879) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_cancelall` | +| [getLinearSwapIsolatedTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1895) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_openorders` | +| [getLinearSwapCrossTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1908) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_openorders` | +| [getLinearSwapIsolatedTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1922) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_trigger_hisorders` | +| [getLinearSwapCrossTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1935) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_trigger_hisorders` | +| [submitLinearSwapIsolatedTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1949) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_order` | +| [submitLinearSwapCrossTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1962) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_order` | +| [cancelLinearSwapIsolatedTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1975) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_cancel` | +| [cancelLinearSwapCrossTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L1989) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_cancel` | +| [cancelLinearSwapIsolatedAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2002) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_cancelall` | +| [cancelLinearSwapCrossAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2016) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_cancelall` | +| [getLinearSwapIsolatedTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2029) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_openorders` | +| [getLinearSwapCrossTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2042) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_openorders` | +| [getLinearSwapIsolatedTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2055) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_tpsl_hisorders` | +| [getLinearSwapCrossTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2068) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_tpsl_hisorders` | +| [getLinearSwapIsolatedRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2081) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_relation_tpsl_order` | +| [getLinearSwapCrossRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2095) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_relation_tpsl_order` | +| [submitLinearSwapIsolatedTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2111) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_order` | +| [submitLinearSwapCrossTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2124) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_order` | +| [cancelLinearSwapIsolatedTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2137) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_cancel` | +| [cancelLinearSwapCrossTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2151) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_cancel` | +| [cancelLinearSwapIsolatedAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2164) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_cancelall` | +| [cancelLinearSwapCrossAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2177) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_cancelall` | +| [getLinearSwapIsolatedTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2190) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_openorders` | +| [getLinearSwapCrossTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2203) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_openorders` | +| [getLinearSwapIsolatedTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2216) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_track_hisorders` | +| [getLinearSwapCrossTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2229) | :closed_lock_with_key: | POST | `/linear-swap-api/v1/swap_cross_track_hisorders` | +| [getLinearSwapUnifiedAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2246) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/unified_account_info` | +| [getLinearSwapUnifiedAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2257) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/linear_swap_overview_account_info` | +| [updateLinearSwapUnifiedFeeMethod()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2273) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/linear_swap_fee_switch` | +| [getLinearSwapUnifiedMarginAdjustments()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2287) | :closed_lock_with_key: | GET | `/linear-swap-api/v3/fix_position_margin_change_record` | +| [updateLinearSwapUnifiedMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2303) | :closed_lock_with_key: | POST | `/linear-swap-api/v3/fix_position_margin_change` | +| [getMultiAssetAccountBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2323) | :closed_lock_with_key: | GET | `/v5/account/balance` | +| [getMultiAssetMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2335) | :closed_lock_with_key: | GET | `/v5/account/asset_mode` | +| [updateMultiAssetMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2347) | :closed_lock_with_key: | POST | `/v5/account/asset_mode` | +| [updateMultiAssetFeeCurrency()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2359) | :closed_lock_with_key: | POST | `/v5/account/fee_deduction_currency` | +| [getMultiAssetFeeCurrency()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2374) | :closed_lock_with_key: | GET | `/v5/account/fee_deduction_currency` | +| [getMultiAssetBills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2386) | :closed_lock_with_key: | GET | `/v5/account/bills` | +| [submitMultiAssetOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2404) | :closed_lock_with_key: | POST | `/v5/trade/order` | +| [submitMultiAssetBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2416) | :closed_lock_with_key: | POST | `/v5/trade/batch_orders` | +| [cancelMultiAssetOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2428) | :closed_lock_with_key: | POST | `/v5/trade/cancel_order` | +| [cancelMultiAssetBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2440) | :closed_lock_with_key: | POST | `/v5/trade/cancel_batch_orders` | +| [cancelMultiAssetAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2452) | :closed_lock_with_key: | POST | `/v5/trade/cancel_all_orders` | +| [closeMultiAssetPosition()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2466) | :closed_lock_with_key: | POST | `/v5/trade/position` | +| [closeMultiAssetAllPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2478) | :closed_lock_with_key: | POST | `/v5/trade/position_all` | +| [getMultiAssetOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2490) | :closed_lock_with_key: | GET | `/v5/trade/order/opens` | +| [getMultiAssetFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2502) | :closed_lock_with_key: | GET | `/v5/trade/order/details` | +| [getMultiAssetOrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2514) | :closed_lock_with_key: | GET | `/v5/trade/order/history` | +| [getMultiAssetOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2526) | :closed_lock_with_key: | GET | `/v5/trade/order` | +| [setMultiAssetCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2538) | :closed_lock_with_key: | POST | `/v5/trade/cancel-after` | +| [submitMultiAssetAlgoOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2553) | :closed_lock_with_key: | POST | `/v5/algo/order` | +| [cancelMultiAssetAlgoOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2562) | :closed_lock_with_key: | POST | `/v5/algo/cancel_orders` | +| [getMultiAssetAlgoOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2571) | :closed_lock_with_key: | GET | `/v5/algo/order` | +| [getMultiAssetAlgoOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2580) | :closed_lock_with_key: | GET | `/v5/algo/order/opens` | +| [getMultiAssetAlgoOrderHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2589) | :closed_lock_with_key: | GET | `/v5/algo/order/history` | +| [getMultiAssetPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2607) | :closed_lock_with_key: | GET | `/v5/trade/position/opens` | +| [getMultiAssetLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2619) | :closed_lock_with_key: | GET | `/v5/position/lever` | +| [updateMultiAssetLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2631) | :closed_lock_with_key: | POST | `/v5/position/lever` | +| [getMultiAssetPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2643) | :closed_lock_with_key: | GET | `/v5/position/mode` | +| [updateMultiAssetPositionMode()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2655) | :closed_lock_with_key: | POST | `/v5/position/mode` | +| [getMultiAssetRiskLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2667) | :closed_lock_with_key: | GET | `/v5/position/risk/limit` | +| [getMultiAssetRiskLimitTiers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2679) | :closed_lock_with_key: | GET | `/v5/position/risk/limit_tier` | +| [adjustMultiAssetMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2692) | :closed_lock_with_key: | POST | `/v5/position/margin` | +| [getMultiAssetFundingRateHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2710) | | GET | `/v5/market/funding_rate_history` | +| [getMultiAssetMarketRiskLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2721) | :closed_lock_with_key: | GET | `/v5/market/risk/limit` | +| [getMultiAssetFeeCurrencies()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2733) | :closed_lock_with_key: | GET | `/v5/market/assets_deduction_currency` | +| [getMultiAssetCollateralAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2745) | :closed_lock_with_key: | GET | `/v5/market/multi_assets_margin` | +| [getCoinMDeliveryAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2762) | | GET | `/api/v1/contract_adjustfactor` | +| [getCoinMDeliveryHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2773) | | GET | `/api/v1/contract_his_open_interest` | +| [getCoinMDeliveryTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2784) | | GET | `/api/v1/contract_ladder_margin` | +| [getCoinMDeliveryAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2795) | | GET | `/api/v1/contract_elite_account_ratio` | +| [getCoinMDeliveryPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2807) | | GET | `/api/v1/contract_elite_position_ratio` | +| [getCoinMDeliveryLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2819) | | GET | `/api/v3/contract_liquidation_orders` | +| [getCoinMDeliverySettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2830) | | GET | `/api/v1/contract_settlement_records` | +| [getCoinMDeliveryRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2841) | | GET | `/v1/insurance_fund_info` | +| [getCoinMDeliveryRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2852) | | GET | `/v1/insurance_fund_history` | +| [getCoinMDeliveryContractLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2863) | | GET | `/api/v1/contract_price_limit` | +| [getCoinMDeliveryOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2874) | | GET | `/api/v1/contract_open_interest` | +| [getCoinMDeliveryDeliveryPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2887) | | GET | `/api/v1/contract_delivery_price` | +| [getCoinMDeliveryEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2898) | | GET | `/api/v1/contract_estimated_settlement_price` | +| [getCoinMDeliverySystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2911) | | GET | `/api/v1/contract_api_state` | +| [getCoinMDeliveryContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2922) | | GET | `/api/v1/contract_contract_info` | +| [getCoinMDeliveryIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2933) | | GET | `/api/v1/contract_index` | +| [getCoinMDeliveryIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2944) | | GET | `/api/market/contract_constituents` | +| [getCoinMDeliveryContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2955) | | GET | `/api/v1/contract_query_elements` | +| [getCoinMDeliveryMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2972) | | GET | `/market/depth` | +| [getCoinMDeliveryMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2984) | | GET | `/market/bbo` | +| [getCoinMDeliveryKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L2995) | | GET | `/market/history/kline` | +| [getCoinMDeliveryMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3006) | | GET | `/index/market/history/mark_price_kline` | +| [getCoinMDeliveryTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3017) | | GET | `/market/detail/merged` | +| [getCoinMDeliveryTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3028) | | GET | `/v2/market/detail/batch_merged` | +| [getCoinMDeliveryLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3039) | | GET | `/market/trade` | +| [getCoinMDeliveryTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3050) | | GET | `/market/history/trade` | +| [getCoinMDeliveryIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3062) | | GET | `/index/market/history/index` | +| [getCoinMDeliveryBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3073) | | GET | `/index/market/history/basis` | +| [getCoinMDeliveryAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3090) | :closed_lock_with_key: | POST | `/api/v1/contract_balance_valuation` | +| [getCoinMDeliveryAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3103) | :closed_lock_with_key: | POST | `/api/v1/contract_account_info` | +| [getCoinMDeliveryPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3116) | :closed_lock_with_key: | POST | `/api/v1/contract_position_info` | +| [updateCoinMDeliverySubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3129) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_auth` | +| [getCoinMDeliverySubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3143) | :closed_lock_with_key: | GET | `/api/v1/contract_sub_auth_list` | +| [getCoinMDeliverySubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3154) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_list` | +| [getCoinMDeliverySubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3167) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_info_list` | +| [getCoinMDeliverySubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3180) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_account_info` | +| [getCoinMDeliverySubPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3194) | :closed_lock_with_key: | POST | `/api/v1/contract_sub_position_info` | +| [getCoinMDeliveryFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3208) | :closed_lock_with_key: | POST | `/api/v3/contract_financial_record` | +| [getCoinMDeliveryFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3221) | :closed_lock_with_key: | POST | `/api/v3/contract_financial_record_exact` | +| [getCoinMDeliveryUserSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3234) | :closed_lock_with_key: | POST | `/api/v1/contract_user_settlement_records` | +| [getCoinMDeliveryOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3249) | :closed_lock_with_key: | POST | `/api/v1/contract_order_limit` | +| [getCoinMDeliveryFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3262) | :closed_lock_with_key: | POST | `/api/v1/contract_fee` | +| [getCoinMDeliveryTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3275) | :closed_lock_with_key: | POST | `/api/v1/contract_transfer_limit` | +| [getCoinMDeliveryPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3288) | :closed_lock_with_key: | POST | `/api/v1/contract_position_limit` | +| [getCoinMDeliveryAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3301) | :closed_lock_with_key: | POST | `/api/v1/contract_account_position_info` | +| [transferCoinMDeliveryMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3314) | :closed_lock_with_key: | POST | `/api/v1/contract_master_sub_transfer` | +| [getCoinMDeliveryMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3327) | :closed_lock_with_key: | POST | `/api/v1/contract_master_sub_transfer_record` | +| [getCoinMDeliveryApiStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3340) | :closed_lock_with_key: | GET | `/api/v1/contract_api_trading_status` | +| [getCoinMDeliveryAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3351) | :closed_lock_with_key: | POST | `/api/v1/contract_available_level_rate` | +| [setCoinMDeliveryCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3370) | :closed_lock_with_key: | POST | `/api/v1/contract-cancel-after` | +| [submitCoinMDeliveryOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3384) | :closed_lock_with_key: | POST | `/api/v1/contract_order` | +| [submitCoinMDeliveryBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3397) | :closed_lock_with_key: | POST | `/api/v1/contract_batchorder` | +| [cancelCoinMDeliveryOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3410) | :closed_lock_with_key: | POST | `/api/v1/contract_cancel` | +| [cancelCoinMDeliveryAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3423) | :closed_lock_with_key: | POST | `/api/v1/contract_cancelall` | +| [updateCoinMDeliveryLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3436) | :closed_lock_with_key: | POST | `/api/v1/contract_switch_lever_rate` | +| [getCoinMDeliveryOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3450) | :closed_lock_with_key: | POST | `/api/v1/contract_order_info` | +| [getCoinMDeliveryOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3463) | :closed_lock_with_key: | POST | `/api/v1/contract_order_detail` | +| [getCoinMDeliveryOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3476) | :closed_lock_with_key: | POST | `/api/v1/contract_openorders` | +| [getCoinMDeliveryHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3489) | :closed_lock_with_key: | POST | `/api/v3/contract_hisorders` | +| [getCoinMDeliveryHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3502) | :closed_lock_with_key: | POST | `/api/v3/contract_hisorders_exact` | +| [getCoinMDeliveryFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3515) | :closed_lock_with_key: | POST | `/api/v3/contract_matchresults` | +| [getCoinMDeliveryFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3528) | :closed_lock_with_key: | POST | `/api/v3/contract_matchresults_exact` | +| [submitCoinMDeliveryLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3541) | :closed_lock_with_key: | POST | `/api/v1/lightning_close_position` | +| [submitCoinMDeliveryTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3560) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_order` | +| [cancelCoinMDeliveryTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3573) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_cancel` | +| [cancelCoinMDeliveryAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3587) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_cancelall` | +| [getCoinMDeliveryTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3600) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_openorders` | +| [getCoinMDeliveryTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3613) | :closed_lock_with_key: | POST | `/api/v1/contract_trigger_hisorders` | +| [submitCoinMDeliveryTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3626) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_order` | +| [cancelCoinMDeliveryTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3639) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_cancel` | +| [cancelCoinMDeliveryAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3653) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_cancelall` | +| [getCoinMDeliveryTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3666) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_openorders` | +| [getCoinMDeliveryTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3679) | :closed_lock_with_key: | POST | `/api/v1/contract_tpsl_hisorders` | +| [getCoinMDeliveryRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3692) | :closed_lock_with_key: | POST | `/api/v1/contract_relation_tpsl_order` | +| [submitCoinMDeliveryTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3706) | :closed_lock_with_key: | POST | `/api/v1/contract_track_order` | +| [cancelCoinMDeliveryTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3719) | :closed_lock_with_key: | POST | `/api/v1/contract_track_cancel` | +| [cancelCoinMDeliveryAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3733) | :closed_lock_with_key: | POST | `/api/v1/contract_track_cancelall` | +| [getCoinMDeliveryTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3746) | :closed_lock_with_key: | POST | `/api/v1/contract_track_openorders` | +| [getCoinMDeliveryTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3759) | :closed_lock_with_key: | POST | `/api/v1/contract_track_hisorders` | +| [getCoinMPerpAdjustFactor()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3780) | | GET | `/swap-api/v1/swap_adjustfactor` | +| [getCoinMPerpHistoricalOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3791) | | GET | `/swap-api/v1/swap_his_open_interest` | +| [getCoinMPerpTieredMargin()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3802) | | GET | `/swap-api/v1/swap_ladder_margin` | +| [getCoinMPerpAccountRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3813) | | GET | `/swap-api/v1/swap_elite_account_ratio` | +| [getCoinMPerpPositionRatio()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3825) | | GET | `/swap-api/v1/swap_elite_position_ratio` | +| [getCoinMPerpEstimatedSettlementPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3837) | | GET | `/swap-api/v1/swap_estimated_settlement_price` | +| [getCoinMPerpSystemStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3850) | | GET | `/swap-api/v1/swap_api_state` | +| [getCoinMPerpFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3861) | | GET | `/swap-api/v1/swap_funding_rate` | +| [getCoinMPerpFundingRates()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3872) | | GET | `/swap-api/v1/swap_batch_funding_rate` | +| [getCoinMPerpHistoricalFundingRate()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3883) | | GET | `/swap-api/v1/swap_historical_funding_rate` | +| [getCoinMPerpLiquidationOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3896) | | GET | `/swap-api/v3/swap_liquidation_orders` | +| [getCoinMPerpSettlementRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3907) | | GET | `/swap-api/v1/swap_settlement_records` | +| [getCoinMPerpContractInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3918) | | GET | `/swap-api/v1/swap_contract_info` | +| [getCoinMPerpIndexPrice()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3929) | | GET | `/swap-api/v1/swap_index` | +| [getCoinMPerpContractElements()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3940) | | GET | `/swap-api/v1/swap_query_elements` | +| [getCoinMPerpIndexConstituents()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3951) | | GET | `/swap-api/market/swap_constituents` | +| [getCoinMPerpRiskReserveBalance()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3962) | | GET | `/v1/insurance_fund_info` | +| [getCoinMPerpRiskReserveHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3973) | | GET | `/v1/insurance_fund_history` | +| [getCoinMPerpPriceLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3984) | | GET | `/swap-api/v1/swap_price_limit` | +| [getCoinMPerpOpenInterest()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L3995) | | GET | `/swap-api/v1/swap_open_interest` | +| [getCoinMPerpMarketDepth()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4012) | | GET | `/swap-ex/market/depth` | +| [getCoinMPerpMarketBbo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4024) | | GET | `/swap-ex/market/bbo` | +| [getCoinMPerpKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4035) | | GET | `/swap-ex/market/history/kline` | +| [getCoinMPerpMarkKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4046) | | GET | `/index/market/history/swap_mark_price_kline` | +| [getCoinMPerpTicker()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4057) | | GET | `/swap-ex/market/detail/merged` | +| [getCoinMPerpTickers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4068) | | GET | `/v2/swap-ex/market/detail/batch_merged` | +| [getCoinMPerpLastTrade()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4079) | | GET | `/swap-ex/market/trade` | +| [getCoinMPerpTradeHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4090) | | GET | `/swap-ex/market/history/trade` | +| [getCoinMPerpPremiumIndexKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4102) | | GET | `/index/market/history/swap_premium_index_kline` | +| [getCoinMPerpFundingRateKlines()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4113) | | GET | `/index/market/history/swap_estimated_rate_kline` | +| [getCoinMPerpBasisData()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4124) | | GET | `/index/market/history/swap_basis` | +| [getCoinMPerpAssetValuation()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4141) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_balance_valuation` | +| [getCoinMPerpAccountInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4154) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_account_info` | +| [getCoinMPerpPositionInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4167) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_position_info` | +| [getCoinMPerpAccountFull()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4180) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_account_position_info` | +| [getCoinMPerpSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4193) | :closed_lock_with_key: | GET | `/swap-api/v1/swap_sub_auth_list` | +| [updateCoinMPerpSubPermissions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4204) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_auth` | +| [getCoinMPerpSubAccounts()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4218) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_list` | +| [getCoinMPerpSubAccountsAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4231) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_info_list` | +| [getCoinMPerpSubAccountAssets()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4244) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_account_info` | +| [getCoinMPerpSubPositions()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4258) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_sub_position_info` | +| [getCoinMPerpFinancialRecords()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4272) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_financial_record` | +| [getCoinMPerpFinancialRecordsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4285) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_financial_record_exact` | +| [getCoinMPerpAvailableLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4298) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_available_level_rate` | +| [getCoinMPerpOrderLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4311) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_limit` | +| [getCoinMPerpFee()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4324) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_fee` | +| [getCoinMPerpTransferLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4337) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_transfer_limit` | +| [getCoinMPerpPositionLimit()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4350) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_position_limit` | +| [transferCoinMPerpMasterSub()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4363) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_master_sub_transfer` | +| [getCoinMPerpMasterSubTransfers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4376) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_master_sub_transfer_record` | +| [getCoinMPerpApiStatus()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4389) | :closed_lock_with_key: | GET | `/swap-api/v1/swap_api_trading_status` | +| [setCoinMPerpCancelAfter()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4406) | :closed_lock_with_key: | POST | `/swap-api/v1/swap-cancel-after` | +| [submitCoinMPerpOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4420) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order` | +| [submitCoinMPerpBatchOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4433) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_batchorder` | +| [cancelCoinMPerpOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4446) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_cancel` | +| [cancelCoinMPerpAllOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4459) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_cancelall` | +| [updateCoinMPerpLeverage()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4472) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_switch_lever_rate` | +| [getCoinMPerpOrderInfo()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4486) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_info` | +| [getCoinMPerpOrderDetail()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4499) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_order_detail` | +| [getCoinMPerpOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4512) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_openorders` | +| [getCoinMPerpHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4525) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_hisorders` | +| [getCoinMPerpHistoryOrdersExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4538) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_hisorders_exact` | +| [getCoinMPerpFills()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4551) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_matchresults` | +| [getCoinMPerpFillsExact()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4564) | :closed_lock_with_key: | POST | `/swap-api/v3/swap_matchresults_exact` | +| [submitCoinMPerpLightningCloseOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4577) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_lightning_close_position` | +| [submitCoinMPerpTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4596) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_order` | +| [cancelCoinMPerpTriggerOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4609) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_cancel` | +| [cancelCoinMPerpAllTriggerOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4623) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_cancelall` | +| [getCoinMPerpTriggerOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4636) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_openorders` | +| [getCoinMPerpTriggerHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4649) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_trigger_hisorders` | +| [submitCoinMPerpTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4662) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_order` | +| [cancelCoinMPerpTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4675) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_cancel` | +| [cancelCoinMPerpAllTpslOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4688) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_cancelall` | +| [getCoinMPerpTpslOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4701) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_openorders` | +| [getCoinMPerpTpslHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4714) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_tpsl_hisorders` | +| [getCoinMPerpRelationTpslOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4727) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_relation_tpsl_order` | +| [submitCoinMPerpTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4740) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_order` | +| [cancelCoinMPerpTrailingOrder()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4753) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_cancel` | +| [cancelCoinMPerpAllTrailingOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4766) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_cancelall` | +| [getCoinMPerpTrailingOpenOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4779) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_openorders` | +| [getCoinMPerpTrailingHistoryOrders()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4792) | :closed_lock_with_key: | POST | `/swap-api/v1/swap_track_hisorders` | +| [getCopyTraderInstruments()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4811) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/instruments` | +| [getCopyTraderStatistics()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4822) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/statistics` | +| [getCopyTraderProfitSharingHistory()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4833) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/profit-sharing-history` | +| [getCopyTraderProfitSharingHistorySummary()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4849) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/profit-sharing-history-summary` | +| [getCopyTraderUPNLSharingSummary()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4865) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/unrealized-profit-sharing-summary` | +| [getCopyTraderFollowers()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4881) | :closed_lock_with_key: | GET | `/api/v6/copyTrading/trader/followers` | +| [removeCopyTraderFollower()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4892) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/follower` | +| [submitCopyTraderTransfer()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4907) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/transfer` | +| [updateCopyTraderFollowerSettings()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4920) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/follower-settings` | +| [getCopyTraderConfig()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4933) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/config` | +| [createCopyTraderApikey()](https://github.com/sieblyio/htx-api/blob/main/src/FuturesClient.ts#L4946) | :closed_lock_with_key: | POST | `/api/v6/copyTrading/trader/apikey` | # WebsocketAPIClient.ts diff --git a/examples/apidoc/FuturesClient/getMultiAssetFundingRateHistory.js b/examples/apidoc/FuturesClient/getMultiAssetFundingRateHistory.js new file mode 100644 index 0000000..a38729d --- /dev/null +++ b/examples/apidoc/FuturesClient/getMultiAssetFundingRateHistory.js @@ -0,0 +1,22 @@ +import { FuturesClient } from '@siebly/htx-api'; +// or, if require is preferred: +// const { FuturesClient } = require('@siebly/htx-api'); + +// This example shows how to call this HTX API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "@siebly/htx-api" for HTX exchange +// This HTX API SDK is available on npm via "npm install @siebly/htx-api" +// ENDPOINT: /v5/market/funding_rate_history +// METHOD: GET +// PUBLIC: YES + +const client = new FuturesClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getMultiAssetFundingRateHistory(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/llms.txt b/llms.txt index 5ade6bd..c9258a3 100644 --- a/llms.txt +++ b/llms.txt @@ -138,73 +138,6 @@ tsconfig.linting.json Files ================================================================ -================ -File: src/types/response/ws.ts -================ -export interface WsServerInfo { - endpoint: string; - encrypt: boolean; - protocol: string; - pingInterval: number; - pingTimeout: number; -} -⋮---- -export interface WsConnectionInfo { - token: string; - instanceServers: WsServerInfo[]; -} -⋮---- -/** Currency detail from v5 `account` WS push */ -export interface WsV5AccountDetail { - currency: string; - equity?: string; - available?: string; - available_margin?: string; - profit_unreal?: string; - initial_margin?: string; - maintenance_margin?: string; - maintenance_margin_rate?: string; - initial_margin_rate?: string; - voucher?: string; - voucher_value?: string; - created_time?: string; - updated_time?: string; - isolated_equity?: string; - isolated_profit_unreal?: string; - withdraw_available?: string; -} -⋮---- -/** Data object from v5 `account` WS push */ -export interface WsV5AccountData { - state?: string; - equity?: string; - initial_margin?: string; - maintenance_margin?: string; - maintenance_margin_rate?: string; - profit_unreal?: string; - available_margin?: string; - voucher_value?: string; - created_time?: string; - updated_time?: string; - version?: number | string; - details?: WsV5AccountDetail[]; -} -⋮---- -/** Order item from v5 `match_orders.$contract_code` WS push */ -export interface WsV5MatchOrder { - volume?: string; - trade_volume?: string; - cancel_volume?: string; -} -⋮---- -/** Tick from spot `market.$symbol.fullDepth.$type` (includes RPI) */ -export interface WsSpotFullDepthTick { - bids?: [number, number][]; - asks?: [number, number][]; - version?: number; - ts?: number; -} - ================ File: .prettierrc ================ @@ -3583,38 +3516,6 @@ export interface WsDataEvent { ⋮---- export function isMessageEvent(msg: unknown): msg is MessageEventLike -================ -File: src/types/websockets/ws-subscriptions.ts -================ -/** - * HTX websocket topics are string templates, e.g.: - * - * - `market.btcusdt.kline.1min` - * - `market.btcusdt.mbp.150` - * - `orders#btcusdt` - * - `orders.btc-usdt` - * - * The exchange publishes a large and evolving topic surface, so the SDK keeps - * the topic type open while exporting common topic groups for discovery and - * private/public routing. - */ -⋮---- -export type WSSpotPublicTopic = (typeof WS_SPOT_PUBLIC_TOPICS)[number]; -export type WSSpotPrivateTopic = (typeof WS_SPOT_PRIVATE_TOPICS)[number]; -export type WSDerivativesPublicTopic = - (typeof WS_DERIVATIVES_PUBLIC_TOPICS)[number]; -export type WSDerivativesPrivateTopic = - (typeof WS_DERIVATIVES_PRIVATE_TOPICS)[number]; -⋮---- -export type WSTopic = - | WSSpotPublicTopic - | WSSpotPrivateTopic - | WSDerivativesPublicTopic - | WSDerivativesPrivateTopic - | string; -⋮---- -export function isPrivateTopic(topic: string): boolean - ================ File: src/WebsocketAPIClient.ts ================ @@ -4341,6 +4242,103 @@ export function removeInternalParamFields(params: TParams): TParams ⋮---- export function getStringOrUndefined(value: unknown): string | undefined +================ +File: src/types/response/ws.ts +================ +export interface WsServerInfo { + endpoint: string; + encrypt: boolean; + protocol: string; + pingInterval: number; + pingTimeout: number; +} +⋮---- +export interface WsConnectionInfo { + token: string; + instanceServers: WsServerInfo[]; +} +⋮---- +/** Currency detail from v5 `account` WS push */ +export interface WsV5AccountDetail { + currency: string; + equity?: string; + available?: string; + /** Isolated-margin available for this currency. "0" when there is no isolated position. */ + isolated_available?: string; + available_margin?: string; + profit_unreal?: string; + initial_margin?: string; + maintenance_margin?: string; + maintenance_margin_rate?: string; + initial_margin_rate?: string; + voucher?: string; + voucher_value?: string; + created_time?: string; + updated_time?: string; + isolated_equity?: string; + isolated_profit_unreal?: string; + withdraw_available?: string; +} +⋮---- +/** Isolated-margin available for this currency. "0" when there is no isolated position. */ +⋮---- +/** Data object from v5 `account` WS push */ +export interface WsV5AccountData { + state?: string; + equity?: string; + initial_margin?: string; + maintenance_margin?: string; + maintenance_margin_rate?: string; + profit_unreal?: string; + available_margin?: string; + voucher_value?: string; + created_time?: string; + updated_time?: string; + version?: number | string; + details?: WsV5AccountDetail[]; +} +⋮---- +/** Order item from v5 `match_orders.$contract_code` WS push */ +export interface WsV5MatchOrder { + volume?: string; + trade_volume?: string; + cancel_volume?: string; +} +⋮---- +/** Tick from spot `market.$symbol.fullDepth.$type` (includes RPI) */ +export interface WsSpotFullDepthTick { + bids?: [number, number][]; + asks?: [number, number][]; + version?: number; + ts?: number; +} +⋮---- +/** Tick from USDT-M `market.$contract_code.full_depth.$type` (includes RPI orders) */ +export interface WsLinearSwapFullDepthTick { + mrid?: number; + id?: number; + bids?: [number, number][]; + asks?: [number, number][]; + ts?: number; + version?: number; + ch?: string; +} +⋮---- +/** Trade from USDT-M `market.$contract_code.trade.detail` (sub and req) */ +export interface WsLinearSwapTradeDetail { + id?: number; + price?: number | string; + amount?: number | string; + direction?: string; + ts?: number; + quantity?: number | string; + trade_turnover?: number | string; + /** Whether the trade involved an RPI order */ + is_rpi_trade?: boolean | number | string; +} +⋮---- +/** Whether the trade involved an RPI order */ + ================ File: src/types/websockets/ws-general.ts ================ @@ -5558,6 +5556,38 @@ export type SpotAPIResponse = export type OrderIdProperty = 'client-order-id'; export type SpotOrderIdProperty = OrderIdProperty | 'clientOrderId'; +================ +File: src/types/websockets/ws-subscriptions.ts +================ +/** + * HTX websocket topics are string templates, e.g.: + * + * - `market.btcusdt.kline.1min` + * - `market.btcusdt.mbp.150` + * - `orders#btcusdt` + * - `orders.btc-usdt` + * + * The exchange publishes a large and evolving topic surface, so the SDK keeps + * the topic type open while exporting common topic groups for discovery and + * private/public routing. + */ +⋮---- +export type WSSpotPublicTopic = (typeof WS_SPOT_PUBLIC_TOPICS)[number]; +export type WSSpotPrivateTopic = (typeof WS_SPOT_PRIVATE_TOPICS)[number]; +export type WSDerivativesPublicTopic = + (typeof WS_DERIVATIVES_PUBLIC_TOPICS)[number]; +export type WSDerivativesPrivateTopic = + (typeof WS_DERIVATIVES_PRIVATE_TOPICS)[number]; +⋮---- +export type WSTopic = + | WSSpotPublicTopic + | WSSpotPrivateTopic + | WSDerivativesPublicTopic + | WSDerivativesPrivateTopic + | string; +⋮---- +export function isPrivateTopic(topic: string): boolean + ================ File: src/index.ts ================ @@ -5909,1809 +5939,1028 @@ public validateOrderId( ): void ================ -File: src/types/response/spot.types.ts +File: src/types/request/futures.types.ts ================ /** - * Reference Data + * Union Types (Request) */ ⋮---- -/** Status page response from status.huobigroup.com */ -export interface SpotSystemStatusPage { - page: { - id: string; - name: string; - url: string; - time_zone: string; - updated_at: string; - }; - components: { - id: string; - name: string; - status: string; - created_at: string; - updated_at: string; - [key: string]: unknown; - }[]; - incidents: - | { - id: string; - name: string; - status: string; - created_at: string; - updated_at: string; - [key: string]: unknown; - }[] - | null; - scheduled_maintenances: - | { - id: string; - name: string; - status: string; - created_at: string; - updated_at: string; - scheduled_for: string; - scheduled_until: string; - [key: string]: unknown; - }[] - | null; - status: { - indicator: 'none' | 'minor' | 'major' | 'critical' | 'maintenance'; - description: string; - }; -} +/** Pagination direction */ +export type FuturesDirect = 'next' | 'prev'; ⋮---- -/** Market status: 1=normal, 2=halted, 3=cancel-only */ -export type SpotMarketStatus = 1 | 2 | 3; +/** Buy or sell */ +export type FuturesDirection = 'buy' | 'sell'; ⋮---- -/** Halt reason: 2=emergency-maintenance, 3=scheduled-maintenance */ -export type SpotHaltReason = 2 | 3; +/** Open or close position */ +export type FuturesOffset = 'open' | 'close'; ⋮---- -export interface SpotMarketStatusData { - marketStatus: SpotMarketStatus; - haltStartTime?: number; - haltEndTime?: number; - haltReason?: SpotHaltReason; - affectedSymbols?: string; -} +/** Open, close, or both (hedge mode) */ +export type FuturesOffsetBoth = 'open' | 'close' | 'both'; ⋮---- -export interface SpotMarketStatusResponse { - code: number; - message: string; - data: SpotMarketStatusData; -} +/** Position side (long, short, both) */ +export type FuturesPositionSide = 'long' | 'short' | 'both'; ⋮---- -/** Trading symbol from /v2/settings/common/symbols */ -export interface SpotTradingSymbol { - sc: string; - si?: string; - scr?: string; - dn: string; - bc: string; - bcdn: string; - qc: string; - qcdn: string; - state: string; - whe?: boolean; - cd?: boolean; - te?: boolean; - toa?: number; - sp?: string; - w?: number; - ttp?: number; - tap?: number; - tpp?: number; - fp?: number; - suspend_desc?: string; - transfer_board_desc?: string; - tags?: string; - lr?: number | null; - smlr?: number | null; - flr?: string | null; - wr?: string | null; - d?: number | null; - elr?: string | null; - /** Whether the symbol supports RPI trading */ - enable_rpi?: boolean | number | string; - p?: { id?: number; name?: string; weight?: number }[]; -} +/** Margin mode */ +export type FuturesMarginMode = 'cross' | 'isolated'; ⋮---- -/** Whether the symbol supports RPI trading */ +/** Margin mode including all */ +export type FuturesMarginModeAll = 'cross' | 'isolated' | 'all'; ⋮---- -export interface SpotCurrency { - cc: string; - dn: string; - fn: string; - at?: number; - wp?: number; - ft?: string; - dma?: string; - wma?: string; - sp?: string; - w?: number; - qc?: boolean; - state?: string; - v?: boolean; - whe?: boolean; - cd?: boolean; - de?: boolean; - wed?: boolean; - cawt?: boolean; - fc?: number; - sc?: number; - swd?: string | null; - wd?: string | null; - sdd?: string | null; - dd?: string | null; - svd?: string | null; - tags?: string; -} +/** Business type filter */ +export type FuturesBusinessType = 'futures' | 'swap' | 'all'; ⋮---- -/** Currency settings item from /v1/settings/common/currencys */ -export interface SpotV1CurrencySettings { - name: string; - dn?: string; - vat?: number; - det?: number; - wet?: number; - wp?: number; - ct?: string; - cp?: string; - ss?: string[]; - oe?: number; - dma?: string; - wma?: string; - sp?: string; - w?: number | string; - qc?: boolean; - state?: string; - v?: boolean; - whe?: boolean; - cd?: boolean; - de?: boolean; - we?: boolean; - cawt?: boolean; - cao?: boolean; - fc?: number; - sc?: number; - swd?: string | null; - wd?: string | null; - sdd?: string | null; - dd?: string | null; - svd?: string | null; - tags?: string; - fn?: string; - bc?: string; - iqc?: boolean; -} +/** Contract type (delivery) */ +export type FuturesContractType = + | 'this_week' + | 'next_week' + | 'quarter' + | 'next_quarter'; ⋮---- -/** Symbol settings item from /v1/settings/common/symbols */ -export interface SpotV1SymbolSettings { - symbol: string; - sn?: string; - bc?: string; - qc?: string; - state?: string; - ve?: boolean; - we?: boolean; - dl?: boolean; - cd?: boolean; - te?: boolean; - ce?: boolean; - tet?: number; - toa?: number; - tca?: number; - voa?: number; - vca?: number; - sp?: string; - tm?: string; - w?: number | string; - ttp?: number; - tap?: number; - tpp?: number; - fp?: number; - tags?: string; - d?: unknown; - bcdn?: string; - qcdn?: string; - elr?: string | null; - castate?: string; - ca1oa?: number; - ca1ca?: number; - ca2oa?: number; - ca2ca?: number; -} +/** Kline period */ +export type FuturesKlinePeriod = + | '1min' + | '5min' + | '15min' + | '30min' + | '60min' + | '1hour' + | '4hour' + | '12hour' + | '1day' + | '1week' + | '1mon'; ⋮---- -/** Market symbol settings item from /v1/settings/common/market-symbols */ -export interface SpotV1MarketSymbolSettings { - symbol: string; - bc?: string; - qc?: string; - state?: string; - sp?: string; - tags?: string; - lr?: number; - smlr?: number; - pp?: number; - ap?: number; - vp?: number; - /** @deprecated No longer valid. */ - minoa?: number | string; - maxoa?: number | string; - minov?: number | string; - /** @deprecated No longer valid. */ - lominoa?: number | string; - lomaxoa?: number | string; - lomaxba?: number | string; - lomaxsa?: number | string; - /** @deprecated No longer valid. */ - smminoa?: number | string; - smmaxoa?: number | string; - bmmaxov?: number | string; - blmlt?: number | string; - slmgt?: number | string; - msormlt?: number | string; - mbormlt?: number | string; - at?: string; - u?: string; - mfr?: number | string; - ct?: string; - rt?: string; - rthr?: number | string; - in?: number | string; - maxov?: number | string; - flr?: number | string; - castate?: string; -} +/** Open interest / funding period */ +export type FuturesOpenInterestPeriod = '60min' | '4hour' | '12hour' | '1day'; ⋮---- -/** @deprecated No longer valid. */ +/** Sort field */ +export type FuturesSortBy = 'created_at' | 'update_time'; ⋮---- -/** @deprecated No longer valid. */ +/** Sort field (extended) */ +export type FuturesSortByExtended = + | 'create_date' + | 'update_time' + | 'created_at'; ⋮---- -/** @deprecated No longer valid. */ +/** Sort field (CmPerp) */ +export type FuturesSortByCmPerp = 'create_date' | 'update_time'; ⋮---- -/** Chain info item from /v1/settings/common/chains */ -export interface SpotV1ChainInfo { - chain?: string; - currency?: string; - code?: string; - ct?: string; - ac?: string; - default?: number; - dma?: string; - wma?: string; - de?: boolean; - we?: boolean; - wp?: number; - ft?: string; - dn?: string; - fn?: string; - awt?: boolean; - adt?: boolean; - ao?: boolean; - fc?: number; - sc?: number; - v?: boolean; - sda?: string | null; - swa?: string | null; - 'deposit-desc'?: string; - 'deposit-tips-desc'?: string; - 'withdraw-desc'?: string; - 'suspend-deposit-desc'?: string; - 'suspend-withdraw-desc'?: string; - 'replace-chain-info-desc'?: string; - 'replace-chain-notification-desc'?: string; - 'replace-chain-popup-desc'?: string; - ca?: string; - cct?: number; - 'withdraw-tips-desc'?: string; - 'suspend-visible-desc'?: string; -} +/** Trigger condition */ +export type FuturesTriggerType = 'ge' | 'le'; ⋮---- -/** Chain reference from /v2/reference/currencies */ -export interface SpotV2ChainReference { - chain?: string; - displayName?: string; - baseChain?: string; - baseChainProtocol?: string; - isDynamic?: boolean; - numOfConfirmations?: number; - numOfFastConfirmations?: number; - minDepositAmt?: string; - depositStatus?: string; - minWithdrawAmt?: string; - maxWithdrawAmt?: string; - withdrawQuotaPerDay?: string; - withdrawQuotaPerYear?: string; - withdrawQuotaTotal?: string; - withdrawPrecision?: number; - withdrawFeeType?: string; - transactFeeWithdraw?: string; - minTransactFeeWithdraw?: string; - maxTransactFeeWithdraw?: string; - transactFeeRateWithdraw?: string; - withdrawStatus?: string; -} +/** Basis price type */ +export type FuturesBasisPriceType = + | 'open' + | 'close' + | 'high' + | 'low' + | 'average'; ⋮---- -/** Fee rate from GET /v2/reference/transact-fee-rate */ -export interface SpotV2TransactFeeRate { - symbol: string; - makerFeeRate: string; - takerFeeRate: string; - actualMakerRate: string; - actualTakerRate: string; - /** RPI order fee rate */ - rpiFeeRate?: string; -} +/** Transfer type */ +export type FuturesTransferType = 'master_to_sub' | 'sub_to_master'; ⋮---- -/** RPI order fee rate */ +/** Margin adjust type */ +export type FuturesMarginAdjustType = 'add' | 'reduce'; ⋮---- -/** Currency reference item from /v2/reference/currencies */ -export interface SpotV2CurrencyReference { - currency?: string; - instStatus?: string; - chains?: SpotV2ChainReference[]; - /** Whether the currency supports direct transfers to Poloniex */ - externalTransferEnabled?: boolean | string | number; -} +/** Self-match prevention */ +export type FuturesSelfMatchPrevent = + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; ⋮---- -/** Whether the currency supports direct transfers to Poloniex */ +/** Lightning order price type */ +export type FuturesLightningOrderPriceType = + | 'market' + | 'lightning_fok' + | 'lightning_ioc'; ⋮---- -/** - * Market Data - */ +/** Lightning order price type (CmDelivery) */ +export type FuturesLightningOrderPriceTypeCm = + | 'lightning' + | 'lightning_fok' + | 'lightning_ioc'; ⋮---- -/** Kline/candlestick item from /market/history/kline */ -export interface SpotKline { - id: number; - open: number; - close: number; - low: number; - high: number; - amount: number; - vol: number; - count: number; -} +/** Trigger order price type */ +export type FuturesTriggerOrderPriceType = + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; ⋮---- -/** Merged ticker from /market/detail/merged (payload is in "tick" not "data"). */ -export interface SpotMergedTicker { - id: number; - version?: number; - open: number; - close: number; - low: number; - high: number; - amount: number; - vol: number; - count: number; - /** [price, size] */ - bid: [number, number]; - /** [price, size] */ - ask: [number, number]; -} +/** Trailing order price type */ +export type FuturesTrailingOrderPriceType = + | 'optimal_5' + | 'optimal_10' + | 'optimal_20' + | 'formula_price'; ⋮---- -/** [price, size] */ +/** V5 order type */ +export type FuturesV5OrderType = 'market' | 'limit' | 'post_only'; ⋮---- -/** [price, size] */ +/** Time in force. `rpi` places an RPI order. */ +export type FuturesTimeInForce = 'fok' | 'ioc' | 'gtc' | 'rpi'; ⋮---- -/** Ticker from /market/tickers */ -export interface SpotTicker { - symbol: string; - open: number; - high: number; - low: number; - close: number; - amount: number; - vol: number; - count: number; - bid: number; - bidSize: number; - ask: number; - askSize: number; -} +/** Trigger price type */ +export type FuturesTriggerPriceType = 'last' | 'market'; ⋮---- -/** Depth tick from /market/depth and /market/fullMbp (payload is in "tick" not "data"). */ -export interface SpotDepth { - ts: number; - version: number; - bids: [number, number][]; - asks: [number, number][]; -} +/** Price match type */ +export type FuturesPriceMatch = + | 'opponent' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; ⋮---- -/** 24h market summary tick from /market/detail (payload is in "tick" not "data"). */ -export interface SpotDetailTick { - id: number; - low: number; - high: number; - open: number; - close: number; - vol: number; - amount: number; - version: number; - count: number; -} +/** Base order price types: limit, opponent, optimal_*, ioc, fok, *_ioc, *_fok */ +export type FuturesOrderPriceTypeBase = + | 'limit' + | 'opponent' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20' + | 'ioc' + | 'fok' + | 'opponent_ioc' + | 'optimal_5_ioc' + | 'optimal_10_ioc' + | 'optimal_20_ioc' + | 'opponent_fok' + | 'optimal_5_fok' + | 'optimal_10_fok' + | 'optimal_20_fok'; ⋮---- -/** Trade (shared by /market/trade and /market/history/trade) */ -export interface SpotTrade { - id: number; - ts: number; - 'trade-id': number; - amount: number; - price: number; - direction: string; -} +/** Order price type for swap_order and swap_cross_order. Base + market + post_only */ +export type FuturesSubmitOrderPriceType = + | FuturesOrderPriceTypeBase + | 'market' + | 'post_only'; ⋮---- -/** Trade tick from /market/trade (payload is in "tick" not "data"). */ -export interface SpotLastTrade { - id: number; - ts: number; - data: SpotTrade[]; -} +/** Order price type for swap_order_limit and contract_order_limit. Base + lightning variants */ +export type FuturesGetOrderLimitPriceType = + | FuturesOrderPriceTypeBase + | 'lightning' + | 'lightning_ioc' + | 'lightning_fok'; ⋮---- -/** Timestamp group from /market/history/trade. Each element in data array. */ -export interface SpotTradeTimestampGroup { - id: number; - ts: number; - data: SpotTrade[]; -} +/** Order price type for contract_order_limit (alias) */ +export type FuturesCmDeliveryOrderLimitPriceType = + FuturesGetOrderLimitPriceType; +⋮---- +/** Order price type for contract_order and swap_order (Delivery/CMPerp). Base + post_only */ +export type FuturesCmDeliverySubmitOrderPriceType = + | FuturesOrderPriceTypeBase + | 'post_only'; +⋮---- +/** Order price type for swap_order and swap_batchorder (CMPerp) (alias) */ +export type FuturesCmPerpSubmitOrderPriceType = + FuturesCmDeliverySubmitOrderPriceType; ⋮---- /** - * Account + * Reference Data */ ⋮---- -/** Account from /v1/account/accounts */ -export interface SpotAccount { - id: number; - type: string; - subtype?: string; - state: string; +/** Req for GET /linear-swap-api/v1/swap_historical_funding_rate */ +export interface FuturesGetHistoricalFundingRateReq { + /** Contract code (e.g. BTC-USDT). Case-insensitive */ + contract_code: string; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; } ⋮---- -/** Balance row from /v1/account/accounts/{account-id}/balance list */ -export interface SpotBalance { - currency: string; - type: string; - balance: string; - debt?: string; - available?: string; - 'seq-num'?: string; -} +/** Contract code (e.g. BTC-USDT). Case-insensitive */ ⋮---- -/** Account balance from /v1/account/accounts/{account-id}/balance */ -export interface SpotAccountBalance { - id: number; - type: string; - state: string; - list: SpotBalance[]; -} +/** Page index. Default 1 */ ⋮---- -/** Profit account balance item from /v2/account/valuation */ -export interface SpotV2ProfitAccountBalance { - distributionType: string; - balance: number; - success: boolean; - accountBalance: string; -} +/** Page size. Default 20, max 50 */ ⋮---- -/** Updated info from /v2/account/valuation */ -export interface SpotV2ValuationUpdated { - success: boolean; - time: number; +/** Req for GET /linear-swap-api/v3/swap_liquidation_orders. One of pair and contract must be filled; contract preferred. */ +export interface FuturesGetLiquidationOrdersReq { + /** Contract code (e.g. BTC-USDT). Case-insensitive */ + contract: string; + /** 0:All; 1:Open long; 2:Open short; 3:Close short; 4:Close long; 5:Liquidate long; 6:Liquidate short; 17:buy(one-way); 18:sell(one-way) */ + trade_type: number; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** Query start time (ms). Window max 2h, within 90 days */ + start_time?: number; + /** Query end time (ms). Default now. Within 90 days */ + end_time?: number; + /** next=chronological, prev=reverse. Default prev */ + direct?: FuturesDirect; + /** Search from query_id for pagination */ + from_id?: number; } ⋮---- -/** Response from /v2/account/valuation */ -export interface SpotV2AccountValuation { - totalBalance?: string; - todayProfit?: string; - todayProfitRate?: string; - profitAccountBalanceList?: SpotV2ProfitAccountBalance[]; - updated?: SpotV2ValuationUpdated; -} +/** Contract code (e.g. BTC-USDT). Case-insensitive */ ⋮---- -/** Response from /v2/account/asset-valuation */ -export interface SpotV2AssetValuation { - balance: string; - timestamp: number; -} +/** 0:All; 1:Open long; 2:Open short; 3:Close short; 4:Close long; 5:Liquidate long; 6:Liquidate short; 17:buy(one-way); 18:sell(one-way) */ ⋮---- -/** Transfer result from POST /v1/account/transfer */ -export interface SpotAccountTransferResult { - 'transact-id': number; - 'transact-time': number; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -export interface SpotV2PointAccountGroupId { - groupId: number; - expiryDate: number | null; - remainAmt: string; -} +/** Query start time (ms). Window max 2h, within 90 days */ ⋮---- -/** Point balance from GET /v2/point/account */ -export interface SpotV2PointAccount { - accountId: string; - accountStatus: string; - acctBalance: string; - groupIds: SpotV2PointAccountGroupId[]; -} +/** Query end time (ms). Default now. Within 90 days */ ⋮---- -/** Point transfer result from POST /v2/point/transfer */ -export interface SpotV2PointTransfer { - transactId: string; - transactTime: number; -} +/** next=chronological, prev=reverse. Default prev */ ⋮---- -/** Deduction info from GET /v1/account/switch/user/info */ -export interface SpotV1AccountSwitchUserInfo { - /** 1=point card deduction, 0=no */ - pointSwitch: number; - /** 1=HTX deduction, 0=no. Choose one of point card and HTX deduction. */ - currencySwitch: number; - deductionCurrency: string; - /** 1: limited, 0: unlimited */ - deductionType: number; - /** Total deductible (USDT). Only when deductionType=1 */ - totalDeductionLimit?: string; - /** Remaining deductible (USDT). Only when deductionType=1 */ - remainingDeductionLimit?: string; +/** Search from query_id for pagination */ +⋮---- +/** Req for GET /linear-swap-api/v1/swap_settlement_records */ +export interface FuturesGetSettlementRecordsReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code: string; + /** Start time (ms). Default: now - 90 days. Within 90 days */ + start_time?: number; + /** End time (ms). Default: now. Must be after start_time */ + end_time?: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; } ⋮---- -/** 1=point card deduction, 0=no */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- -/** 1=HTX deduction, 0=no. Choose one of point card and HTX deduction. */ +/** Start time (ms). Default: now - 90 days. Within 90 days */ ⋮---- -/** 1: limited, 0: unlimited */ +/** End time (ms). Default: now. Must be after start_time */ ⋮---- -/** Total deductible (USDT). Only when deductionType=1 */ +/** Page index. Default 1 */ ⋮---- -/** Remaining deductible (USDT). Only when deductionType=1 */ +/** Page size. Default 20, max 50 */ ⋮---- -/** Deductible currency info from GET /v1/account/overview/info */ -export interface SpotV1AccountOverviewInfo { - currency: string; +/** Req for GET /linear-swap-api/v1/swap_cross_ladder_margin. When all filled, contract_code preferred. business_type required for futures. */ +export interface FuturesGetCrossTieredMarginReq { + /** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** Default swap. futures, swap, all. Required for futures contract query */ + business_type?: FuturesBusinessType; } ⋮---- -/** Account history row from GET /v1/account/history */ -export interface SpotAccountHistory { - 'account-id': number; - currency: string; - 'record-id': number; - 'transact-amt': string; - /** Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ - 'transact-type': string; - 'avail-balance': string; - 'acct-balance': string; - 'transact-time': number; -} +/** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- -/** Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Ledger row from GET /v2/account/ledger */ -export interface SpotV2AccountLedger { - accountId: number; - currency: string; - transactAmt: number; - transactType: string; - transferType?: string; - transactId: number; - transactTime: number; - transferer: number; - transferee: number; -} +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Batch order placement result. Success: order-id, client-order-id. Error: err-code, err-msg. */ -export interface SpotV1OrderBatchPlaceResult { - 'order-id'?: number; - 'client-order-id'?: string; - 'err-code'?: string; - 'err-msg'?: string; -} +/** Default swap. futures, swap, all. Required for futures contract query */ ⋮---- -/** Margin order result from POST /v1/order/auto/place */ -export interface SpotV1OrderAutoPlaceResult { - 'order-id': number; +export type FuturesGetEstimatedSettlementPriceReq = + FuturesGetCrossTieredMarginReq; +export type FuturesGetCrossAdjustFactorReq = FuturesGetCrossTieredMarginReq; +export type FuturesGetContractPriceLimitReq = FuturesGetCrossTieredMarginReq; +export type FuturesGetOpenInterestReq = FuturesGetCrossTieredMarginReq; +⋮---- +/** Req for GET /v1/insurance_fund_history */ +export interface FuturesGetRiskReserveHistoryReq { + /** Query start time (ms) */ + start_time?: number; + /** Query end time (ms) */ + end_time?: number; + /** next=chronological, prev=reverse. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result depending on direct */ + from_id?: number; + /** Items per page [1-100]. Default 10 */ + limit?: number; } ⋮---- -/** Canceled order id from POST /v1/order/orders/{order-id}/submitcancel */ -export type SpotV1OrderCancelResult = string; +/** Query start time (ms) */ ⋮---- -/** Order status from POST /v1/order/orders/submitCancelClientOrder. 1:ready, 2:created, 3:submitted, 4:partial-filled, 5:partial-canceled, 6:filled, 7:canceled, 10:canceling */ -export type SpotV1OrderCancelByClientOrderIdResult = number; +/** Query end time (ms) */ ⋮---- -/** Result from POST /v1/order/orders/batchCancelOpenOrders */ -export interface SpotV1OrderBatchCancelOpenOrdersResult { - 'success-count': number; - 'failed-count': number; - /** Next order id to cancel, -1 = none */ - 'next-id': number; -} +/** next=chronological, prev=reverse. Default prev */ ⋮---- -/** Next order id to cancel, -1 = none */ +/** Pagination: min/max query_id from last result depending on direct */ ⋮---- -/** Failed cancel from POST /v1/order/orders/batchcancel */ -export interface SpotV1OrderBatchCancelFailed { - 'order-id'?: string; - 'client-order-id'?: string; - 'err-code'?: string; - 'err-msg'?: string; - 'order-state'?: string; -} +/** Items per page [1-100]. Default 10 */ ⋮---- -/** Result from POST /v2/algo-orders/cancel-all-after (Dead man's switch) */ -export interface SpotV2AlgoOrdersCancelAllAfterResult { - currentTime: number; - triggerTime: number; +/** Req for GET /linear-swap-api/v1/swap_contract_info. When isolated, contract_type/business_type cannot be futures. */ +export interface FuturesGetContractInfoReq { + /** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code?: string; + /** cross, isolated, or all. Filter by supported margin mode */ + support_margin_mode?: FuturesMarginModeAll; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** Default swap. futures, swap, all. Required for futures query */ + business_type?: FuturesBusinessType; } ⋮---- -/** - * Conditional Order - */ +/** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- -/** Result from POST /v2/algo-orders (Place a conditional order) */ -export interface SpotV2AlgoOrdersPlaceResult { - clientOrderId: string; -} +/** cross, isolated, or all. Filter by supported margin mode */ ⋮---- -/** Result from POST /v2/algo-orders/cancellation (Cancel conditional orders before triggering) */ -export interface SpotV2AlgoOrdersCancellationResult { - accepted: string[]; - rejected: string[]; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Conditional order item from GET /v2/algo-orders/opening (orderStatus=created) and /history and /specific */ -export interface SpotV2AlgoOrder { - accountId: number; - source: string; - clientOrderId: string; - symbol?: string; - orderPrice?: string; - orderSize?: string; - orderValue?: string; - orderSide: string; - orderType: string; - timeInForce?: string; - stopPrice?: string; - trailingRate?: string; - orderOrigTime: number; - lastActTime: number; - orderStatus: string; - /** Only for orderStatus=triggered */ - orderId?: string; - /** Order trigger time. Only for orderStatus=triggered */ - orderCreateTime?: number; - /** Only for orderStatus=rejected */ - errCode?: number; - /** Only for orderStatus=rejected */ - errMessage?: string; +/** swap, this_week, next_week, quarter, next_quarter */ +⋮---- +/** Default swap. futures, swap, all. Required for futures query */ +⋮---- +/** + * Market Data + */ +⋮---- +/** Req for GET /linear-swap-ex/market/history/kline. Either size or (from+to) required. */ +export interface FuturesGetKlinesReq { + /** Contract code or type. swap: BTC-USDT; future: BTC-USDT-220325 or BTC-USDT-CW/NW/CQ/NQ */ + contract_code: string; + /** 1min, 5min, 15min, 30min, 60min, 1hour, 4hour, 1day, 1mon */ + period: FuturesKlinePeriod; + /** Items [1-2000]. Default 150. Ignored if from+to provided */ + size?: number; + /** Start timestamp (seconds) */ + from?: number; + /** End timestamp (seconds). Required if from provided */ + to?: number; } ⋮---- -/** Only for orderStatus=triggered */ +/** Contract code or type. swap: BTC-USDT; future: BTC-USDT-220325 or BTC-USDT-CW/NW/CQ/NQ */ ⋮---- -/** Order trigger time. Only for orderStatus=triggered */ +/** 1min, 5min, 15min, 30min, 60min, 1hour, 4hour, 1day, 1mon */ ⋮---- -/** Only for orderStatus=rejected */ +/** Items [1-2000]. Default 150. Ignored if from+to provided */ ⋮---- -/** Only for orderStatus=rejected */ +/** Start timestamp (seconds) */ ⋮---- -/** - * Margin Loan (Cross/Isolated) - */ +/** End timestamp (seconds). Required if from provided */ ⋮---- -/** Repayment result from POST /v2/account/repayment. Check transaction record to confirm status. */ -export interface SpotMarginRepaymentResult { - repayId: string | number; - repayTime: number; +/** Req for GET /linear-swap-api/v1/swap_his_open_interest. One of (pair+contract_type) or contract_code required. */ +export interface FuturesGetHistoricalOpenInterestReq { + /** Contract code. Omit if pair+contract_type provided */ + contract_code?: string; + /** Pair (e.g. BTC-USDT). Use with contract_type */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** 60min, 4hour, 12hour, 1day */ + period: FuturesOpenInterestPeriod; + /** Items [1-200]. Default 48 */ + size?: number; + /** 1: cont, 2: cryptocurrency */ + amount_type: 1 | 2; } ⋮---- -/** Transact ID detail from GET /v2/account/repayment (Repayment Record Reference) */ -export interface SpotRepaymentRecordTransactId { - transactId: number; - repaidPrincipal?: string; - repaidInterest?: string; - paidHt?: string; - paidPoint?: string; -} +/** Contract code. Omit if pair+contract_type provided */ ⋮---- -/** Repayment record from GET /v2/account/repayment (Repayment Record Reference) */ -export interface SpotRepaymentRecord { - repayId: string | number; - repayTime: number; - accountId: string; - currency: string; - repaidAmount: string; - transactIds?: SpotRepaymentRecordTransactId | SpotRepaymentRecordTransactId[]; -} +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- -/** Currency from GET /v1/margin/loan-info */ -export interface SpotMarginLoanInfoCurrency { - currency: string; - 'interest-rate': string; - 'min-loan-amt': string; - 'max-loan-amt': string; - 'loanable-amt': string; - 'actual-rate': string; -} +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Symbol from GET /v1/margin/loan-info */ -export interface SpotMarginLoanInfo { - symbol: string; - currencies: SpotMarginLoanInfoCurrency[]; -} +/** 60min, 4hour, 12hour, 1day */ ⋮---- -/** Loan order item from GET /v1/margin/loan-orders */ -export interface SpotMarginLoanOrder { - id: number; - 'account-id': number; - 'user-id': number; - symbol: string; - currency: string; - 'created-at': string; - 'accrued-at'?: string; - 'loan-amount': string; - 'loan-balance': string; - 'interest-rate': string; - 'interest-amount'?: string; - 'interest-balance'?: string; - state: string; - 'paid-point'?: string; - 'paid-coin'?: string; - 'deduct-rate'?: string; - 'deduct-currency'?: string; - 'deduct-amount'?: string; - 'updated-at'?: number; - 'hour-interest-rate'?: string; - 'day-interest-rate'?: string; -} +/** Items [1-200]. Default 48 */ ⋮---- -/** Balance row from GET /v1/margin/accounts/balance */ -export interface SpotMarginBalance { - currency: string; - type: string; - balance: string; -} +/** 1: cont, 2: cryptocurrency */ ⋮---- -/** Account item from GET /v1/margin/accounts/balance */ -export interface SpotMarginAccountBalance { - id: number; - type: string; - symbol: string; - state: string; - 'risk-rate'?: string; - 'fl-type'?: string; - 'fl-price'?: string; - list: SpotMarginBalance[]; +/** Req for GET /index/market/history/linear_swap_mark_price_kline. Also used for premium index and estimated rate kline. */ +export interface FuturesGetMarkKlinesReq { + /** Contract code or type. swap: BTC-USDT; future: BTC-USDT-210625 or BTC-USDT-CW/NW/CQ/NQ */ + contract_code: string; + /** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1week, 1mon */ + period: string; + /** Items [1-2000] */ + size: number; } ⋮---- -/** Account balance from GET /v1/cross-margin/accounts/balance. Single object (unlike isolated which returns array). */ -export interface SpotCrossMarginAccountBalance { - id: number; - type: string; - state: string; - 'risk-rate'?: string; - 'acct-balance-sum'?: string; - 'debt-balance-sum'?: string; - list: SpotMarginBalance[]; -} +/** Contract code or type. swap: BTC-USDT; future: BTC-USDT-210625 or BTC-USDT-CW/NW/CQ/NQ */ ⋮---- -/** Loan order item from GET /v1/cross-margin/loan-orders */ -export interface SpotCrossMarginLoanOrder { - id: number; - 'account-id': number; - 'user-id': number; - currency: string; - 'filled-points'?: string; - 'filled-ht'?: string; - 'created-at': string | number; - 'accrued-at'?: string | number; - 'loan-amount': string; - 'loan-balance': string; - 'interest-amount'?: string; - 'interest-balance'?: string; - state: string; -} +/** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1week, 1mon */ ⋮---- -/** Position limit from GET /v2/margin/limit */ -export interface SpotMarginLimit { - currency: string; - 'max-holdings': string; -} +/** Items [1-2000] */ ⋮---- -/** Result from POST /v1/order/orders/batchcancel */ -export interface SpotV1OrderBatchCancelResult { - /** Successfully canceled order ids or client-order-ids */ - success: string[]; - /** Failed cancel requests */ - failed: SpotV1OrderBatchCancelFailed[]; +export type FuturesGetPremiumIndexKlinesReq = FuturesGetMarkKlinesReq; +export type FuturesGetFundingRateKlinesReq = FuturesGetMarkKlinesReq; +⋮---- +/** Req for GET /index/market/history/linear_swap_basis */ +export interface FuturesGetBasisDataReq { + /** Contract code or type */ + contract_code: string; + /** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon */ + period: FuturesKlinePeriod; + /** Items [1-2000]. Default 150 */ + size: number; + /** open, close, high, low, average. Default open */ + basis_price_type?: FuturesBasisPriceType; } ⋮---- -/** Successfully canceled order ids or client-order-ids */ +/** Contract code or type */ ⋮---- -/** Failed cancel requests */ +/** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon */ ⋮---- -/** Match result item from GET /v1/order/orders/{order-id}/matchresults */ -export interface SpotV1OrderMatchResult { - id: number; - symbol: string; - 'order-id': number; - 'match-id': number; - 'trade-id': number; - price: string; - 'created-at': number; - type: string; - 'filled-amount': string; - 'filled-fees': string; - 'fee-currency'?: string; - source?: string; - role?: string; - 'filled-points'?: string; - 'fee-deduct-currency'?: string; - 'fee-deduct-state'?: string; +/** Items [1-2000]. Default 150 */ +⋮---- +/** open, close, high, low, average. Default open */ +⋮---- +/** + * Account + */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_position_info */ +export interface FuturesGetCrossPositionsReq { + /** Contract code. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; } ⋮---- -/** Historical order from GET /v1/order/orders (search past orders) */ -export interface SpotV1OrderHistory { - id: number; - 'client-order-id'?: string; - 'account-id'?: number; - amount?: string; - symbol: string; - price?: string; - 'created-at': number; - 'canceled-at'?: number; - 'finished-at'?: number; - type?: string; - 'field-amount'?: string; - 'field-cash-amount'?: string; - 'field-fees'?: string; - source?: string; - state: string; - 'stop-price'?: string; - operator?: string; - role?: string; - 'canceled-source'?: number | string; - 'canceled-source-desc'?: string; - 'market-amount'?: string; - 'ice-amount'?: string; - 'is-ice'?: boolean; - 'updated-at'?: number; -} +/** Contract code. Omit for all */ ⋮---- -/** Historical order from GET /v1/order/history (48h). Includes next-time when more results exist. */ -export interface SpotV1OrderHistory48h extends SpotV1OrderHistory { - /** Next start-time or end-time for pagination. Only when results exceed size. */ - 'next-time'?: number; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Next start-time or end-time for pagination. Only when results exceed size. */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Order detail from GET /v1/order/orders/{order-id} and getClientOrder */ -export interface SpotV1OrderDetail { - id: number; - 'client-order-id': string; - symbol: string; - 'account-id': number; - amount: string; - price: string; - 'created-at': number; - 'finished-at': number; - 'canceled-at': number; - type: string; - 'field-amount': string; - 'field-cash-amount': string; - 'field-fees': string; - source: string; - 'canceled-source'?: string; - state: string; - 'stop-price'?: string; - operator?: string; +/** Req for GET /linear-swap-api/v1/swap_sub_auth_list. getSubPermissions. */ +export interface FuturesGetSubPermissionsReq { + /** Sub-account UIDs, comma-separated. Max 10 */ + sub_uid?: string; + /** Start time of sub-account creation (ms) */ + start_time?: number; + /** End time of sub-account creation (ms) */ + end_time?: number; + /** next=chronological, prev=reverse */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- -/** Deposit address item from GET /v2/account/deposit/address */ -export interface SpotDepositAddress { - userId: number; - currency: string; - address: string; - addressTag: string; - chain: string; -} +/** Sub-account UIDs, comma-separated. Max 10 */ ⋮---- -/** Withdraw quota chain from GET /v2/account/withdraw/quota */ -export interface SpotWithdrawQuotaChain { - chain: string; - maxWithdrawAmt: string; - withdrawQuotaPerDay: string; - remainWithdrawQuotaPerDay: string; - withdrawQuotaPerYear: string; - remainWithdrawQuotaPerYear: string; - withdrawQuotaTotal: string; - remainWithdrawQuotaTotal: string; -} +/** Start time of sub-account creation (ms) */ ⋮---- -/** Withdraw quota from GET /v2/account/withdraw/quota */ -export interface SpotWithdrawQuota { - currency: string; - chains: SpotWithdrawQuotaChain[]; -} +/** End time of sub-account creation (ms) */ ⋮---- -/** Withdraw address item from GET /v2/account/withdraw/address */ -export interface SpotWithdrawAddress { - currency: string; - chain: string; - note: string; - addressTag?: string; - address: string; - status: string; -} +/** next=chronological, prev=reverse */ ⋮---- -/** Deposit/withdraw record from GET /v1/query/deposit-withdraw or GET /v1/query/withdraw/client-order-id */ -export interface SpotDepositWithdrawRecord { - id: number; - type: string; - 'sub-type'?: string; - currency: string; - /** Chain name. Poloniex rapid transfer defaults to t397342. */ - chain: string; - 'tx-hash': string; - amount: number; - 'from-addr-tag'?: string; - /** On-chain address, or UID:XXXX for Poloniex→HTX rapid transfers. */ - address: string; - 'address-tag'?: string; - fee: number; - state: string; - 'created-at': number; - 'updated-at': number; - 'error-code'?: string; - 'error-msg'?: string; +/** Pagination: min/max query_id from last result */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_sub_account_list. Isolated margin only. */ +export interface FuturesGetIsolatedSubAccountsReq { + /** Contract code (e.g. BTC-USDT). Omit for all */ + contract_code?: string; + /** next=chronological, prev=reverse. Default next */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result depending on direct */ + from_id?: number; } ⋮---- -/** Chain name. Poloniex rapid transfer defaults to t397342. */ +/** Contract code (e.g. BTC-USDT). Omit for all */ ⋮---- -/** On-chain address, or UID:XXXX for Poloniex→HTX rapid transfers. */ +/** next=chronological, prev=reverse. Default next */ ⋮---- -/** VASP exchange from GET /v1/query/vasp-list */ -export interface SpotVaspExchange { - 'vasp-id': string; - 'vasp-name': string; - 'legal-name': string; -} +/** Pagination: min/max query_id from last result depending on direct */ ⋮---- -/** User rebate status from GET /broker/v1/user_rebate_status */ -export interface SpotBrokerUserRebateStatus { - spotRebateStatus: boolean; - contractRebateStatus: boolean; - spotIsNewUser: boolean; - contractIsNewUser?: boolean; +/** Req for POST /linear-swap-api/v1/swap_cross_sub_account_list. Cross margin only. */ +export interface FuturesGetCrossSubAccountsReq { + /** Margin account (e.g. USDT). Omit for all */ + margin_account?: string; + /** next=chronological, prev=reverse. Default next */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result depending on direct */ + from_id?: number; } ⋮---- -/** Sub-user fee rate from GET /broker/v1/sub-user/fee_rate */ -export interface SpotBrokerSubUserFeeRate { - userId: number; - subUserId: number; - bizType: number; - taker: string; - maker: string; - type: number; - addTaker: string; - addMaker: string; - updatedAt: number; - effectAt: number; -} +/** Margin account (e.g. USDT). Omit for all */ ⋮---- -/** Fee rate add result from POST /broker/v1/sub-user/fee_rate/add */ -export interface SpotBrokerFeeRateAddResult { - subUserIds: number[]; - effectAt: string; -} +/** next=chronological, prev=reverse. Default next */ ⋮---- -/** Account capital snapshot item from POST /broker/v1/account_capital_snapshot_everyday */ -export interface SpotBrokerAccountCapitalSnapshot { - accountId: number; - accountType: string; - snapshotTime: string; - convertBalance: string; - dataList: unknown[]; -} +/** Pagination: min/max query_id from last result depending on direct */ ⋮---- -/** Deduct mode result item from POST /v2/sub-user/deduct-mode */ -export interface SpotSubUserDeductModeResult { - subUid: string; - deductMode: string | null; - errCode?: string; - errMessage?: string; +/** Req for POST /linear-swap-api/v1/swap_sub_account_info_list. Isolated margin only. */ +export interface FuturesGetSubAccountsAssetsReq { + /** Contract code (e.g. BTC-USDT). Omit for all */ + contract_code?: string; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; } ⋮---- -/** API key from getSubUserApiKey */ -export interface SpotSubUserApiKey { - accessKey: string; - status: string; - note: string; - permission: string; - ipAddresses: string; - validDays: number; - createTime: number; - updateTime: number; -} +/** Contract code (e.g. BTC-USDT). Omit for all */ ⋮---- -/** Sub user creation result item from POST /v2/sub-user/creation */ -export interface SpotSubUserCreationResult { - userName: string; - note?: string; - uid?: number; - /** Spot account id for spot order transactions */ - spotAccountId?: number; - errCode?: string; - errMessage?: string; -} +/** Page index. Default 1 */ ⋮---- -/** Spot account id for spot order transactions */ +/** Page size. Default 20, max 50 */ ⋮---- -/** Sub user from GET /v2/sub-user/user-list */ -export interface SpotSubUserList { - uid: number; - userState: string; - subUserName: string; - note: string; +/** Req for POST /linear-swap-api/v1/swap_cross_sub_account_info_list. Cross margin only. */ +export interface FuturesGetCrossSubAccountsAssetsReq { + /** Margin account (e.g. USDT). Omit for all */ + margin_account?: string; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; } ⋮---- -/** Result from updateSubUserLockStatus */ -export interface SpotSubUserLockStatusResult { - subUid: number; - userState: string; -} +/** Margin account (e.g. USDT). Omit for all */ ⋮---- -/** Result from getSubUserStatus */ -export interface SpotSubUserStatusResult { - uid: number; - userState: string; -} +/** Page index. Default 1 */ ⋮---- -/** Tradable market result item from POST /v2/sub-user/tradable-market */ -export interface SpotSubUserTradableMarketResult { - subUid: string; - accountType: string; - activation: string; - errCode?: number; - errMessage?: string; -} +/** Page size. Default 20, max 50 */ ⋮---- -/** Result item from setSubUserTransferPermissions */ -export interface SpotSubUserTransferPermissionsResult { - subUid: number; - accountType: string; - transferrable: boolean; - errCode?: number; - errMessage?: string; +/** Req for POST /linear-swap-api/v1/swap_cross_sub_position_info. Cross margin only. */ +export interface FuturesGetCrossSubPositionsReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all. contract_code preferred when all filled */ + contract_code?: string; + /** Sub-account UID */ + sub_uid: number; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; } ⋮---- -/** Account ID from sub user account list */ -export interface SpotSubUserAccountId { - accountId: number; - subType?: string; - accountStatus?: string; -} +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all. contract_code preferred when all filled */ ⋮---- -/** Account from sub user account list */ -export interface SpotSubUserAccount { - accountType: string; - activation: string; - transferrable?: boolean; - accountIds?: SpotSubUserAccountId[]; -} +/** Sub-account UID */ ⋮---- -/** Result from getSubUserAccounts */ -export interface SpotSubUserAccountsResult { - uid: number; - deductMode: string; - list: SpotSubUserAccount[]; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Result from createSubUserApiKey */ -export interface SpotSubUserApiKeyCreationResult { - accessKey: string; - secretKey: string; - note: string; - permission: string; - ipAddresses: string; -} +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Result from updateSubUserApiKey */ -export interface SpotSubUserApiKeyUpdateResult { - note: string; - permission: string; - ipAddresses: string; +/** Req for POST /linear-swap-api/v3/swap_financial_record. Supports cross and isolated. */ +export interface FuturesGetFinancialRecordsReq { + /** Margin account. swap: BTC-USDT, future: BTC-USDT-210625. Required */ + mar_acct: string; + /** Contract code (e.g. BTC-USDT). Omit for all */ + contract?: string; + /** Comma-separated type codes. Omit for all. e.g. 3,4,5,6 */ + type?: string; + /** Query start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** Query end time (ms). Default now. Within 90 days */ + end_time?: number; + /** next=chronological, prev=reverse. Default next */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result depending on direct */ + from_id?: number; } ⋮---- -/** Record from getSubUserDepositHistory */ -export interface SpotSubUserDepositHistoryRecord { - id: number; - currency: string; - txHash: string; - chain: string; - amount: number; - address: string; - addressTag: string; - state: string; - createTime: number; - updateTime: number; -} +/** Margin account. swap: BTC-USDT, future: BTC-USDT-210625. Required */ ⋮---- -/** Balance from getSubUsersAggregatedBalance */ -export interface SpotSubUsersAggregatedBalance { - currency: string; - type: string; - balance: string; -} +/** Contract code (e.g. BTC-USDT). Omit for all */ ⋮---- -/** Result from getSubUserBalance */ -export interface SpotSubUserBalanceResult { - id: number; - type: string; - state: string; - list: SpotBalance[]; - symbol?: string; -} +/** Comma-separated type codes. Omit for all. e.g. 3,4,5,6 */ ⋮---- -/** Custody sub-account from GET /v2/sub-user/entrust-user-list */ -export interface SpotSubUserEntrustUser { - uid: number; - subUserName: string; -} +/** Query start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Managed transfer record from GET /v2/sub-user/managed-transfer-history */ -export interface SpotSubUserManagedTransferRecord { - currency: string; - type: string; - amount: number; - uid: number; - subUserName: string; - query_id?: string; -} +/** Query end time (ms). Default now. Within 90 days */ ⋮---- -/** Referral rebate detail from GET /v2/invitee/rebate/detail */ -export interface SpotReferralRebateDetail { - invitee_type: string; - invitee_rebate_rate_spot_m2: string; - invitee_rebate_rate_contract_m2: string; - invitee_rebate_rate_partner_spot?: string; - invitee_rebate_rate_partner_contract?: string; - join_time_m2: string; - join_time_partner?: string; - invitee_total_commission_usdt: string; - invitee_total_commission_trx: string; - invitee_total_commission_htx: string; - partner_total_commission_usdt: string; - partner_total_commission_trx: string; - partner_total_commission_htx: string; -} +/** next=chronological, prev=reverse. Default next */ ⋮---- -/** Referral rebate history record from GET /v2/invitee/rebate/history */ -export interface SpotReferralRebateHistoryRecord { - date: number; - invitee_total_commission_usdt: string; - invitee_total_commission_trx: string; - invitee_total_commission_htx: string; - partner_total_commission_usdt: string; - partner_total_commission_trx: string; - partner_total_commission_htx: string; -} +/** Pagination: min/max query_id from last result depending on direct */ ⋮---- -/** Referral rebate detail from all_rebate/detail or batcher_rebate/detail */ -export interface SpotReferralAllRebateDetail { - invitee_uid: number; - invitee_type: string; - invitee_rebate_rate_spot_m2: string | null; - invitee_rebate_rate_contract_m2: string | null; - invitee_rebate_rate_partner_spot?: string | null; - invitee_rebate_rate_partner_contract?: string | null; - join_time_m2: string; - join_time_partner?: string | null; - invitee_total_commission_usdt: string; - invitee_total_commission_trx: string; - invitee_total_commission_htx: string; - partner_total_commission_usdt: string; - partner_total_commission_trx: string; - partner_total_commission_htx: string; -} +/** Req for POST /linear-swap-api/v3/swap_financial_record_exact. Same params as swap_financial_record; API default direct is prev. */ +export type FuturesGetFinancialRecordsExactReq = FuturesGetFinancialRecordsReq; ⋮---- -/** P2P order from GET /v1/api/c2c/order/history */ -export interface SpotP2POrderHistory { - orderNo: string; - role: string; - side: string; - counterpartNickName: string; - fiatCurrency: string; - asset: string; - amount: string; - unitPrice: string; - totalPrice: string; - fee: string; - orderStatus: string; - createTime: string; - queryId?: number; +/** Req for POST /linear-swap-api/v1/swap_cross_available_level_rate. Cross margin only. */ +export interface FuturesGetCrossAvailableLeverageReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** futures, swap, all. Required for futures. Default swap */ + business_type?: FuturesBusinessType; } ⋮---- -/** Tiered rate from Earn project */ -export interface SpotEarnTieredRate { - amountStart: string; - amountEnd: string; - rate: string; -} +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ ⋮---- -/** Earn project from GET /v1/earn/project/queryEarnProjectList */ -export interface SpotEarnProject { - projectId: number; - productId: number; - calculationType: number; - type: number; - viewYearRate: string; - finishAmount: string; - projectStatus: number; - totalAmount: string; - currency: string; - startAmount: string; - apyType: number; - tieredRates?: SpotEarnTieredRate[]; - marketPerkUpLimit?: string; - marketTimeApy?: string; - marketPerkApy?: string; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Result from POST /v1/earn/order/demand/add */ -export interface SpotEarnSubscribeResult { - currency: string; - amount: string; - orderId: number; - status: number; -} +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Result from POST /v1/earn/order/demand/redeem-order */ -export interface SpotEarnRedeemResult { - currency: string; - amount: string; - orderId: number; - status: number; +/** futures, swap, all. Required for futures. Default swap */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_order_limit. Supports cross and isolated. */ +export interface FuturesGetOrderLimitReq { + /** Order price type. Required */ + order_price_type: FuturesGetOrderLimitPriceType; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** futures, swap, all. Required for futures. Default swap */ + business_type?: FuturesBusinessType; } ⋮---- -/** Earn user asset from GET /v1/earn/order/user/assets/list */ -export interface SpotEarnUserAsset { - projectId: number; - orderId: number; - projectType: number; - currency: string; - yesterdayIncome: string; - totalIncomeAmount: string; - totalAmount: string; - miningYearRate: string; - apyType: number; -} +/** Order price type. Required */ ⋮---- -/** Referral invited user from GET /v2/invitee/rebate/referrals */ -export interface SpotReferralReferral { - id: number; - invitee_uid: number; - remark: string; - referral_code: string; - invitee_type: string; - invitee_rebate_rate_spot_m2: string; - invitee_rebate_rate_contract_m2: string; - invitee_rebate_rate_partner_spot?: string | null; - invitee_rebate_rate_partner_contract?: string | null; - join_time_m2: number; - join_time_partner?: number | null; - /** Whether advanced KYC was completed */ - completed_kyc?: boolean | number | string; - /** Invitee email */ - mail?: string | null; -} +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ ⋮---- -/** Whether advanced KYC was completed */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Invitee email */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Open order from GET /v1/order/openOrders */ -export interface SpotV1OpenOrder { - id: number; - 'client-order-id'?: string; - symbol: string; - 'account-id'?: number; - price?: string; - amount?: string; - 'created-at': number; - type: string; - 'filled-amount': string; - 'filled-cash-amount': string; - 'filled-fees': string; - source?: string; - state: string; - 'stop-price'?: string; - operator?: string; -} +/** futures, swap, all. Required for futures. Default swap */ ⋮---- -/** Result from POST /v5/account/universal_transfer */ -export interface SpotUniversalTransferResult { - transfer_id: number; +/** Req for POST /linear-swap-api/v1/swap_fee. Supports cross and isolated. */ +export interface FuturesGetFeeReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** futures, swap, all. Required for futures. Default swap */ + business_type?: FuturesBusinessType; } ⋮---- -/** Record from GET /v5/account/universal_transfer_records */ -export interface SpotUniversalTransferRecord { - id: number; - transfer_id: number | string; - amount: string; - currency?: string; - status?: string; - from_account_type: string; - to_account_type: string; - from_account_asset?: string; - to_account_asset?: string; - from_asset_type?: string; - to_asset_type?: string; - transfer_time?: number; -} - -================ -File: .gitignore -================ -!.gitkeep -.DS_Store -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json -pids -*.pid -*.seed -*.pid.lock -node_modules/ -.npm -.eslintcache -.node_repl_history -*.tgz -.yarn-integrity -.env -.env.test -.cache -dist -bundleReport.html -.history/ -examples/ignoreme -localtest.sh -repomix.sh -doc -.cursor/ -futuresOrder2.ts -.vscode/ -WSWIP.md -.tmp-packed* - -================ -File: src/types/request/futures.types.ts -================ -/** - * Union Types (Request) - */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ ⋮---- -/** Pagination direction */ -export type FuturesDirect = 'next' | 'prev'; +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Buy or sell */ -export type FuturesDirection = 'buy' | 'sell'; +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Open or close position */ -export type FuturesOffset = 'open' | 'close'; +/** futures, swap, all. Required for futures. Default swap */ ⋮---- -/** Open, close, or both (hedge mode) */ -export type FuturesOffsetBoth = 'open' | 'close' | 'both'; +/** Req for POST /linear-swap-api/v1/swap_cross_position_limit. Cross margin only. */ +export interface FuturesGetCrossPositionLimitReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** futures, swap, all. Required for futures. Default swap */ + business_type?: FuturesBusinessType; +} ⋮---- -/** Position side (long, short, both) */ -export type FuturesPositionSide = 'long' | 'short' | 'both'; +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ ⋮---- -/** Margin mode */ -export type FuturesMarginMode = 'cross' | 'isolated'; +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Margin mode including all */ -export type FuturesMarginModeAll = 'cross' | 'isolated' | 'all'; +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Business type filter */ -export type FuturesBusinessType = 'futures' | 'swap' | 'all'; +/** futures, swap, all. Required for futures. Default swap */ ⋮---- -/** Contract type (delivery) */ -export type FuturesContractType = - | 'this_week' - | 'next_week' - | 'quarter' - | 'next_quarter'; +/** Req for POST /linear-swap-api/v1/swap_cross_lever_position_limit. Cross margin only. */ +export interface FuturesGetCrossLeverageLimitsReq { + /** futures, swap, all. Required for futures */ + business_type?: FuturesBusinessType; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-211231. Omit for all */ + contract_code?: string; + /** Leverage rate. Omit for all */ + lever_rate?: number; +} ⋮---- -/** Kline period */ -export type FuturesKlinePeriod = - | '1min' - | '5min' - | '15min' - | '30min' - | '60min' - | '1hour' - | '4hour' - | '12hour' - | '1day' - | '1week' - | '1mon'; +/** futures, swap, all. Required for futures */ ⋮---- -/** Open interest / funding period */ -export type FuturesOpenInterestPeriod = '60min' | '4hour' | '12hour' | '1day'; +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Sort field */ -export type FuturesSortBy = 'created_at' | 'update_time'; +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Sort field (extended) */ -export type FuturesSortByExtended = - | 'create_date' - | 'update_time' - | 'created_at'; +/** Contract code. swap: BTC-USDT, future: BTC-USDT-211231. Omit for all */ ⋮---- -/** Sort field (CmPerp) */ -export type FuturesSortByCmPerp = 'create_date' | 'update_time'; +/** Leverage rate. Omit for all */ ⋮---- -/** Trigger condition */ -export type FuturesTriggerType = 'ge' | 'le'; +/** Req for POST /linear-swap-api/v1/swap_master_sub_transfer. Supports cross and isolated. */ +export interface FuturesTransferMasterSubReq { + /** Sub-account UID */ + sub_uid: number; + /** Asset (e.g. USDT) */ + asset: string; + /** From margin account (e.g. USDT, BTC-USDT) */ + from_margin_account: string; + /** To margin account */ + to_margin_account: string; + /** Transfer amount */ + amount: number | string; + /** master_to_sub or sub_to_master */ + type: FuturesTransferType; + /** Optional client order ID [1, 9223372036854775807]. Valid 8h per transfer path */ + client_order_id?: number; +} ⋮---- -/** Basis price type */ -export type FuturesBasisPriceType = - | 'open' - | 'close' - | 'high' - | 'low' - | 'average'; +/** Sub-account UID */ ⋮---- -/** Transfer type */ -export type FuturesTransferType = 'master_to_sub' | 'sub_to_master'; +/** Asset (e.g. USDT) */ ⋮---- -/** Margin adjust type */ -export type FuturesMarginAdjustType = 'add' | 'reduce'; +/** From margin account (e.g. USDT, BTC-USDT) */ ⋮---- -/** Self-match prevention */ -export type FuturesSelfMatchPrevent = - | 'cancel_taker' - | 'cancel_maker' - | 'cancel_both'; +/** To margin account */ ⋮---- -/** Lightning order price type */ -export type FuturesLightningOrderPriceType = - | 'market' - | 'lightning_fok' - | 'lightning_ioc'; +/** Transfer amount */ ⋮---- -/** Lightning order price type (CmDelivery) */ -export type FuturesLightningOrderPriceTypeCm = - | 'lightning' - | 'lightning_fok' - | 'lightning_ioc'; +/** master_to_sub or sub_to_master */ ⋮---- -/** Trigger order price type */ -export type FuturesTriggerOrderPriceType = - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; +/** Optional client order ID [1, 9223372036854775807]. Valid 8h per transfer path */ ⋮---- -/** Trailing order price type */ -export type FuturesTrailingOrderPriceType = - | 'optimal_5' - | 'optimal_10' - | 'optimal_20' - | 'formula_price'; +/** Req for POST /linear-swap-api/v1/swap_master_sub_transfer_record. Supports cross and isolated. */ +export interface FuturesGetMasterSubTransfersReq { + /** Margin account (e.g. BTC-USDT, USDT). Required */ + margin_account: string; + /** 34: to sub, 35: from sub. Comma-separated for multiple. Omit for all */ + transfer_type?: string; + /** Days to query. Max 90 */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; +} ⋮---- -/** V5 order type */ -export type FuturesV5OrderType = 'market' | 'limit' | 'post_only'; +/** Margin account (e.g. BTC-USDT, USDT). Required */ ⋮---- -/** Time in force */ -export type FuturesTimeInForce = 'fok' | 'ioc' | 'gtc'; +/** 34: to sub, 35: from sub. Comma-separated for multiple. Omit for all */ ⋮---- -/** Trigger price type */ -export type FuturesTriggerPriceType = 'last' | 'market'; +/** Days to query. Max 90 */ ⋮---- -/** Price match type */ -export type FuturesPriceMatch = - | 'opponent' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; +/** Page index. Default 1 */ ⋮---- -/** Base order price types: limit, opponent, optimal_*, ioc, fok, *_ioc, *_fok */ -export type FuturesOrderPriceTypeBase = - | 'limit' - | 'opponent' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20' - | 'ioc' - | 'fok' - | 'opponent_ioc' - | 'optimal_5_ioc' - | 'optimal_10_ioc' - | 'optimal_20_ioc' - | 'opponent_fok' - | 'optimal_5_fok' - | 'optimal_10_fok' - | 'optimal_20_fok'; +/** Page size. Default 20, max 50 */ ⋮---- -/** Order price type for swap_order and swap_cross_order. Base + market + post_only */ -export type FuturesSubmitOrderPriceType = - | FuturesOrderPriceTypeBase - | 'market' - | 'post_only'; +/** Req for POST /linear-swap-api/v1/swap_transfer_inner. Transfer between margin accounts under same account. */ +export interface FuturesTransferInnerReq { + /** Asset (e.g. USDT) */ + asset: string; + /** From margin account (e.g. BTC-USDT, USDT) */ + from_margin_account: string; + /** To margin account */ + to_margin_account: string; + /** Transfer amount */ + amount: number | string; + /** Optional client order ID [1, 9223372036854775807]. Valid 8h */ + client_order_id?: number; +} ⋮---- -/** Order price type for swap_order_limit and contract_order_limit. Base + lightning variants */ -export type FuturesGetOrderLimitPriceType = - | FuturesOrderPriceTypeBase - | 'lightning' - | 'lightning_ioc' - | 'lightning_fok'; +/** Asset (e.g. USDT) */ ⋮---- -/** Order price type for contract_order_limit (alias) */ -export type FuturesCmDeliveryOrderLimitPriceType = - FuturesGetOrderLimitPriceType; +/** From margin account (e.g. BTC-USDT, USDT) */ ⋮---- -/** Order price type for contract_order and swap_order (Delivery/CMPerp). Base + post_only */ -export type FuturesCmDeliverySubmitOrderPriceType = - | FuturesOrderPriceTypeBase - | 'post_only'; +/** To margin account */ ⋮---- -/** Order price type for swap_order and swap_batchorder (CMPerp) (alias) */ -export type FuturesCmPerpSubmitOrderPriceType = - FuturesCmDeliverySubmitOrderPriceType; +/** Transfer amount */ ⋮---- -/** - * Reference Data - */ +/** Optional client order ID [1, 9223372036854775807]. Valid 8h */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_historical_funding_rate */ -export interface FuturesGetHistoricalFundingRateReq { - /** Contract code (e.g. BTC-USDT). Case-insensitive */ +/** Req for POST /linear-swap-api/v1/swap_order. Isolated margin only. */ +export interface FuturesSubmitOrderReq { + /** Contract code (e.g. BTC-USDT). Required */ contract_code: string; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; + /** buy or sell */ + direction: FuturesDirection; + /** Order quantity */ + volume: number; + /** Leverage rate */ + lever_rate: number; + /** Order price type */ + order_price_type: FuturesSubmitOrderPriceType; + /** open, close, both. Required in hedge mode */ + offset?: FuturesOffsetBoth; + /** Price. Required for limit, post_only, ioc, fok */ + price?: number | string; + /** 0: no, 1: yes */ + reduce_only?: 0 | 1; + /** Client order ID [1, 9223372036854775807] */ + client_order_id?: number; + /** Take-profit trigger price */ + tp_trigger_price?: number | string; + /** Take-profit order price */ + tp_order_price?: number | string; + /** Take-profit order type */ + tp_order_price_type?: string; + /** Stop-loss trigger price */ + sl_trigger_price?: number | string; + /** Stop-loss order price */ + sl_order_price?: number | string; + /** Stop-loss order type */ + sl_order_price_type?: string; + /** Price protection when setting tp/sl */ + price_protect?: boolean; + /** 0: allow self-trade, 1: prevent (default) */ + self_match_prevent?: 0 | 1; + /** cancel_taker, cancel_maker, cancel_both */ + self_match_prevent_new?: FuturesSelfMatchPrevent; } ⋮---- -/** Contract code (e.g. BTC-USDT). Case-insensitive */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** Page index. Default 1 */ +/** buy or sell */ ⋮---- -/** Page size. Default 20, max 50 */ +/** Order quantity */ ⋮---- -/** Req for GET /linear-swap-api/v3/swap_liquidation_orders. One of pair and contract must be filled; contract preferred. */ -export interface FuturesGetLiquidationOrdersReq { - /** Contract code (e.g. BTC-USDT). Case-insensitive */ - contract: string; - /** 0:All; 1:Open long; 2:Open short; 3:Close short; 4:Close long; 5:Liquidate long; 6:Liquidate short; 17:buy(one-way); 18:sell(one-way) */ - trade_type: number; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Query start time (ms). Window max 2h, within 90 days */ - start_time?: number; - /** Query end time (ms). Default now. Within 90 days */ - end_time?: number; - /** next=chronological, prev=reverse. Default prev */ - direct?: FuturesDirect; - /** Search from query_id for pagination */ - from_id?: number; -} +/** Leverage rate */ ⋮---- -/** Contract code (e.g. BTC-USDT). Case-insensitive */ +/** Order price type */ ⋮---- -/** 0:All; 1:Open long; 2:Open short; 3:Close short; 4:Close long; 5:Liquidate long; 6:Liquidate short; 17:buy(one-way); 18:sell(one-way) */ +/** open, close, both. Required in hedge mode */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Price. Required for limit, post_only, ioc, fok */ ⋮---- -/** Query start time (ms). Window max 2h, within 90 days */ +/** 0: no, 1: yes */ ⋮---- -/** Query end time (ms). Default now. Within 90 days */ +/** Client order ID [1, 9223372036854775807] */ ⋮---- -/** next=chronological, prev=reverse. Default prev */ +/** Take-profit trigger price */ ⋮---- -/** Search from query_id for pagination */ +/** Take-profit order price */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_settlement_records */ -export interface FuturesGetSettlementRecordsReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ - contract_code: string; - /** Start time (ms). Default: now - 90 days. Within 90 days */ - start_time?: number; - /** End time (ms). Default: now. Must be after start_time */ - end_time?: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; -} +/** Take-profit order type */ ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Stop-loss trigger price */ ⋮---- -/** Start time (ms). Default: now - 90 days. Within 90 days */ +/** Stop-loss order price */ ⋮---- -/** End time (ms). Default: now. Must be after start_time */ +/** Stop-loss order type */ ⋮---- -/** Page index. Default 1 */ +/** Price protection when setting tp/sl */ ⋮---- -/** Page size. Default 20, max 50 */ +/** 0: allow self-trade, 1: prevent (default) */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_cross_ladder_margin. When all filled, contract_code preferred. business_type required for futures. */ -export interface FuturesGetCrossTieredMarginReq { - /** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** cancel_taker, cancel_maker, cancel_both */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_order. Cross margin only. One of contract_code or (pair+contract_type) required. */ +export interface FuturesCrossSubmitOrderReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit if pair+contract_type */ contract_code?: string; - /** Pair (e.g. BTC-USDT) */ + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** Default swap. futures, swap, all. Required for futures contract query */ - business_type?: FuturesBusinessType; + /** buy or sell */ + direction: FuturesDirection; + /** Order quantity */ + volume: number; + /** Leverage rate */ + lever_rate: number; + /** Order price type */ + order_price_type: FuturesSubmitOrderPriceType; + /** open, close, both. Required in hedge mode */ + offset?: FuturesOffsetBoth; + /** Price. Required for limit, post_only, ioc, fok */ + price?: number | string; + /** 0: no, 1: yes */ + reduce_only?: 0 | 1; + /** Client order ID [1, 9223372036854775807] */ + client_order_id?: number; + /** Take-profit trigger price */ + tp_trigger_price?: number | string; + /** Take-profit order price */ + tp_order_price?: number | string; + /** Take-profit order type */ + tp_order_price_type?: string; + /** Stop-loss trigger price */ + sl_trigger_price?: number | string; + /** Stop-loss order price */ + sl_order_price?: number | string; + /** Stop-loss order type */ + sl_order_price_type?: string; + /** 0: allow self-trade, 1: prevent (default) */ + self_match_prevent?: 0 | 1; + /** cancel_taker, cancel_maker, cancel_both */ + self_match_prevent_new?: FuturesSelfMatchPrevent; } ⋮---- -/** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit if pair+contract_type */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Default swap. futures, swap, all. Required for futures contract query */ +/** buy or sell */ ⋮---- -export type FuturesGetEstimatedSettlementPriceReq = - FuturesGetCrossTieredMarginReq; -export type FuturesGetCrossAdjustFactorReq = FuturesGetCrossTieredMarginReq; -export type FuturesGetContractPriceLimitReq = FuturesGetCrossTieredMarginReq; -export type FuturesGetOpenInterestReq = FuturesGetCrossTieredMarginReq; +/** Order quantity */ ⋮---- -/** Req for GET /v1/insurance_fund_history */ -export interface FuturesGetRiskReserveHistoryReq { - /** Query start time (ms) */ - start_time?: number; - /** Query end time (ms) */ - end_time?: number; - /** next=chronological, prev=reverse. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result depending on direct */ - from_id?: number; - /** Items per page [1-100]. Default 10 */ - limit?: number; -} +/** Leverage rate */ ⋮---- -/** Query start time (ms) */ +/** Order price type */ ⋮---- -/** Query end time (ms) */ +/** open, close, both. Required in hedge mode */ ⋮---- -/** next=chronological, prev=reverse. Default prev */ +/** Price. Required for limit, post_only, ioc, fok */ ⋮---- -/** Pagination: min/max query_id from last result depending on direct */ +/** 0: no, 1: yes */ ⋮---- -/** Items per page [1-100]. Default 10 */ +/** Client order ID [1, 9223372036854775807] */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_contract_info. When isolated, contract_type/business_type cannot be futures. */ -export interface FuturesGetContractInfoReq { - /** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ - contract_code?: string; - /** cross, isolated, or all. Filter by supported margin mode */ - support_margin_mode?: FuturesMarginModeAll; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** Default swap. futures, swap, all. Required for futures query */ - business_type?: FuturesBusinessType; -} +/** Take-profit trigger price */ ⋮---- -/** Contract code. Omit for all. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Take-profit order price */ ⋮---- -/** cross, isolated, or all. Filter by supported margin mode */ +/** Take-profit order type */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Stop-loss trigger price */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Stop-loss order price */ ⋮---- -/** Default swap. futures, swap, all. Required for futures query */ +/** Stop-loss order type */ ⋮---- -/** - * Market Data - */ +/** 0: allow self-trade, 1: prevent (default) */ ⋮---- -/** Req for GET /linear-swap-ex/market/history/kline. Either size or (from+to) required. */ -export interface FuturesGetKlinesReq { - /** Contract code or type. swap: BTC-USDT; future: BTC-USDT-220325 or BTC-USDT-CW/NW/CQ/NQ */ - contract_code: string; - /** 1min, 5min, 15min, 30min, 60min, 1hour, 4hour, 1day, 1mon */ - period: FuturesKlinePeriod; - /** Items [1-2000]. Default 150. Ignored if from+to provided */ - size?: number; - /** Start timestamp (seconds) */ - from?: number; - /** End timestamp (seconds). Required if from provided */ - to?: number; +/** cancel_taker, cancel_maker, cancel_both */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_batchorder. Isolated. Max 10 orders. */ +export interface FuturesSubmitBatchOrderReq { + orders_data: FuturesSubmitOrderReq[]; } ⋮---- -/** Contract code or type. swap: BTC-USDT; future: BTC-USDT-220325 or BTC-USDT-CW/NW/CQ/NQ */ +/** Req for POST /linear-swap-api/v1/swap_cross_batchorder. Cross. Max 25 orders. */ +export interface FuturesSubmitCrossBatchOrderReq { + orders_data: FuturesCrossSubmitOrderReq[]; +} ⋮---- -/** 1min, 5min, 15min, 30min, 60min, 1hour, 4hour, 1day, 1mon */ +/** Req for POST /linear-swap-api/v1/swap_cancel. Isolated. One of order_id or client_order_id required. Max 25 IDs. */ +export interface FuturesCancelOrderReq { + /** Contract code (e.g. BTC-USDT). Required */ + contract_code: string; + /** Order IDs, comma-separated. Max 25 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 25 */ + client_order_id?: string; +} ⋮---- -/** Items [1-2000]. Default 150. Ignored if from+to provided */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** Start timestamp (seconds) */ +/** Order IDs, comma-separated. Max 25 */ ⋮---- -/** End timestamp (seconds). Required if from provided */ +/** Client order IDs, comma-separated. Max 25 */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_his_open_interest. One of (pair+contract_type) or contract_code required. */ -export interface FuturesGetHistoricalOpenInterestReq { - /** Contract code. Omit if pair+contract_type provided */ +/** Req for POST /linear-swap-api/v1/swap_cross_cancel. Cross. One of order_id/client_order_id and one of contract_code/(pair+contract_type) required. */ +export interface FuturesCancelCrossOrderReq { + /** Order IDs, comma-separated. Max 25 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 25 */ + client_order_id?: string; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ + /** Pair (e.g. BTC-USDT) */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** 60min, 4hour, 12hour, 1day */ - period: FuturesOpenInterestPeriod; - /** Items [1-200]. Default 48 */ - size?: number; - /** 1: cont, 2: cryptocurrency */ - amount_type: 1 | 2; } ⋮---- -/** Contract code. Omit if pair+contract_type provided */ -⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** Order IDs, comma-separated. Max 25 */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Client order IDs, comma-separated. Max 25 */ ⋮---- -/** 60min, 4hour, 12hour, 1day */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- -/** Items [1-200]. Default 48 */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** 1: cont, 2: cryptocurrency */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Req for GET /index/market/history/linear_swap_mark_price_kline. Also used for premium index and estimated rate kline. */ -export interface FuturesGetMarkKlinesReq { - /** Contract code or type. swap: BTC-USDT; future: BTC-USDT-210625 or BTC-USDT-CW/NW/CQ/NQ */ +/** Req for POST /linear-swap-api/v1/swap_cancelall. Isolated. One of direction or offset optional. */ +export interface FuturesCancelAllOrdersReq { + /** Contract code (e.g. BTC-USDT). Required */ contract_code: string; - /** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1week, 1mon */ - period: string; - /** Items [1-2000] */ - size: number; + /** buy or sell. Omit for all */ + direction?: FuturesDirection; + /** open or close. Omit for all */ + offset?: FuturesOffset; } ⋮---- -/** Contract code or type. swap: BTC-USDT; future: BTC-USDT-210625 or BTC-USDT-CW/NW/CQ/NQ */ -⋮---- -/** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1week, 1mon */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** Items [1-2000] */ +/** buy or sell. Omit for all */ ⋮---- -export type FuturesGetPremiumIndexKlinesReq = FuturesGetMarkKlinesReq; -export type FuturesGetFundingRateKlinesReq = FuturesGetMarkKlinesReq; +/** open or close. Omit for all */ ⋮---- -/** Req for GET /index/market/history/linear_swap_basis */ -export interface FuturesGetBasisDataReq { - /** Contract code or type */ - contract_code: string; - /** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon */ - period: FuturesKlinePeriod; - /** Items [1-2000]. Default 150 */ - size: number; - /** open, close, high, low, average. Default open */ - basis_price_type?: FuturesBasisPriceType; +/** Req for POST /linear-swap-api/v1/swap_cross_cancelall. Cross. One of contract_code or (pair+contract_type) required. */ +export interface FuturesCancelCrossAllOrdersReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** buy or sell. Omit for all */ + direction?: FuturesDirection; + /** open or close. Omit for all */ + offset?: FuturesOffset; } ⋮---- -/** Contract code or type */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- -/** 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Items [1-2000]. Default 150 */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** open, close, high, low, average. Default open */ +/** buy or sell. Omit for all */ ⋮---- -/** - * Account - */ +/** open or close. Omit for all */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_position_info */ -export interface FuturesGetCrossPositionsReq { - /** Contract code. Omit for all */ +/** Req for POST /linear-swap-api/v1/swap_cross_switch_lever_rate. Cross margin only. One of contract_code or (pair+contract_type) required. */ +export interface FuturesUpdateCrossLeverageReq { + /** Leverage multiple. Required */ + lever_rate: number; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; @@ -7719,732 +6968,701 @@ export interface FuturesGetCrossPositionsReq { contract_type?: string; } ⋮---- -/** Contract code. Omit for all */ +/** Leverage multiple. Required */ +⋮---- +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_sub_auth_list. getSubPermissions. */ -export interface FuturesGetSubPermissionsReq { - /** Sub-account UIDs, comma-separated. Max 10 */ - sub_uid?: string; - /** Start time of sub-account creation (ms) */ - start_time?: number; - /** End time of sub-account creation (ms) */ - end_time?: number; - /** next=chronological, prev=reverse */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; +/** Req for POST /linear-swap-api/v1/swap_order_info. Isolated. One of order_id or client_order_id required. Max 50 IDs. */ +export interface FuturesGetOrderInfoReq { + /** Contract code (e.g. BTC-USDT). Required */ + contract_code: string; + /** Order IDs, comma-separated. Max 50 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 50 */ + client_order_id?: string; } ⋮---- -/** Sub-account UIDs, comma-separated. Max 10 */ -⋮---- -/** Start time of sub-account creation (ms) */ -⋮---- -/** End time of sub-account creation (ms) */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** next=chronological, prev=reverse */ +/** Order IDs, comma-separated. Max 50 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** Client order IDs, comma-separated. Max 50 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_sub_account_list. Isolated margin only. */ -export interface FuturesGetIsolatedSubAccountsReq { - /** Contract code (e.g. BTC-USDT). Omit for all */ +/** Req for POST /linear-swap-api/v1/swap_cross_order_info. Cross. One of order_id/client_order_id and one of contract_code/pair required. */ +export interface FuturesGetCrossOrderInfoReq { + /** Order IDs, comma-separated. Max 50 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 50 */ + client_order_id?: string; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ contract_code?: string; - /** next=chronological, prev=reverse. Default next */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result depending on direct */ - from_id?: number; + /** Pair (e.g. BTC-USDT) */ + pair?: string; } ⋮---- -/** Contract code (e.g. BTC-USDT). Omit for all */ -⋮---- -/** next=chronological, prev=reverse. Default next */ +/** Order IDs, comma-separated. Max 50 */ ⋮---- -/** Pagination: min/max query_id from last result depending on direct */ +/** Client order IDs, comma-separated. Max 50 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_sub_account_list. Cross margin only. */ -export interface FuturesGetCrossSubAccountsReq { - /** Margin account (e.g. USDT). Omit for all */ - margin_account?: string; - /** next=chronological, prev=reverse. Default next */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result depending on direct */ - from_id?: number; -} +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- -/** Margin account (e.g. USDT). Omit for all */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** next=chronological, prev=reverse. Default next */ +/** Req for POST /linear-swap-api/v1/swap_order_detail. Isolated. Order details with trades. */ +export interface FuturesGetOrderDetailReq { + /** Contract code (e.g. BTC-USDT). Required */ + contract_code: string; + /** Order ID. Required */ + order_id: number | string; + /** Created timestamp (ms). Improves query performance. Cannot be 0 */ + created_at?: number; + /** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ + order_type?: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; +} ⋮---- -/** Pagination: min/max query_id from last result depending on direct */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_sub_account_info_list. Isolated margin only. */ -export interface FuturesGetSubAccountsAssetsReq { - /** Contract code (e.g. BTC-USDT). Omit for all */ +/** Order ID. Required */ +⋮---- +/** Created timestamp (ms). Improves query performance. Cannot be 0 */ +⋮---- +/** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ +⋮---- +/** Page index. Default 1 */ +⋮---- +/** Page size. Default 20, max 50 */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_order_detail. Cross. One of contract_code or pair required. */ +export interface FuturesGetCrossOrderDetailReq { + /** Order ID. Required */ + order_id: number | string; + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** Created timestamp (ms). Cannot be 0 */ + created_at?: number; + /** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ + order_type?: number; /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; } ⋮---- -/** Contract code (e.g. BTC-USDT). Omit for all */ +/** Order ID. Required */ +⋮---- +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +⋮---- +/** Pair (e.g. BTC-USDT) */ +⋮---- +/** Created timestamp (ms). Cannot be 0 */ +⋮---- +/** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ ⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_sub_account_info_list. Cross margin only. */ -export interface FuturesGetCrossSubAccountsAssetsReq { - /** Margin account (e.g. USDT). Omit for all */ - margin_account?: string; +/** Req for POST /linear-swap-api/v1/swap_openorders. Isolated. Current unfilled orders. */ +export interface FuturesGetOpenOrdersReq { + /** Contract code (e.g. BTC-USDT). Omit for all */ + contract_code?: string; /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; + /** created_at or update_time. Default created_at */ + sort_by?: FuturesSortBy; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- -/** Margin account (e.g. USDT). Omit for all */ +/** Contract code (e.g. BTC-USDT). Omit for all */ ⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_sub_position_info. Cross margin only. */ -export interface FuturesGetCrossSubPositionsReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all. contract_code preferred when all filled */ +/** created_at or update_time. Default created_at */ +⋮---- +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_openorders. Cross. Omit all for all contracts. */ +export interface FuturesGetCrossOpenOrdersReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ contract_code?: string; - /** Sub-account UID */ - sub_uid: number; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** created_at or update_time */ + sort_by?: FuturesSortBy; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all. contract_code preferred when all filled */ -⋮---- -/** Sub-account UID */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Page index. Default 1 */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_financial_record. Supports cross and isolated. */ -export interface FuturesGetFinancialRecordsReq { - /** Margin account. swap: BTC-USDT, future: BTC-USDT-210625. Required */ - mar_acct: string; - /** Contract code (e.g. BTC-USDT). Omit for all */ - contract?: string; - /** Comma-separated type codes. Omit for all. e.g. 3,4,5,6 */ - type?: string; - /** Query start time (ms). Window max 48h, within 90 days */ +/** Page size. Default 20, max 50 */ +⋮---- +/** created_at or update_time */ +⋮---- +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +⋮---- +/** Req for POST /linear-swap-api/v3/swap_hisorders. Isolated. History orders. */ +export interface FuturesGetHistoryOrdersReq { + /** Contract code (e.g. BTC-USDT). Required */ + contract: string; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** 1: All Orders, 2: Order in Finished Status */ + type: 1 | 2; + /** 0: all, or comma-separated e.g. "3,4,5" */ + status: string; + /** Start time (ms). Window max 48h, within 90 days */ start_time?: number; - /** Query end time (ms). Default now. Within 90 days */ + /** End time (ms). Default now */ end_time?: number; - /** next=chronological, prev=reverse. Default next */ + /** next or prev. Default prev */ direct?: FuturesDirect; - /** Pagination: min/max query_id from last result depending on direct */ + /** Pagination: min/max query_id from last result */ from_id?: number; } ⋮---- -/** Margin account. swap: BTC-USDT, future: BTC-USDT-210625. Required */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** Contract code (e.g. BTC-USDT). Omit for all */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Comma-separated type codes. Omit for all. e.g. 3,4,5,6 */ +/** 1: All Orders, 2: Order in Finished Status */ ⋮---- -/** Query start time (ms). Window max 48h, within 90 days */ +/** 0: all, or comma-separated e.g. "3,4,5" */ ⋮---- -/** Query end time (ms). Default now. Within 90 days */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** next=chronological, prev=reverse. Default next */ +/** End time (ms). Default now */ ⋮---- -/** Pagination: min/max query_id from last result depending on direct */ +/** next or prev. Default prev */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_financial_record_exact. Same params as swap_financial_record; API default direct is prev. */ -export type FuturesGetFinancialRecordsExactReq = FuturesGetFinancialRecordsReq; +/** Pagination: min/max query_id from last result */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_available_level_rate. Cross margin only. */ -export interface FuturesGetCrossAvailableLeverageReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ - contract_code?: string; +/** Req for POST /linear-swap-api/v3/swap_hisorders_exact. Isolated. History orders via multiple fields; adds price_type filter. */ +export interface FuturesGetHistoryOrdersExactReq { + /** Contract code (e.g. BTC-USDT). Required */ + contract: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** futures, swap, all. Required for futures. Default swap */ - business_type?: FuturesBusinessType; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** 1: All Orders, 2: Order in Finished Status */ + type: 1 | 2; + /** 0: all, or comma-separated e.g. "3,4,5" */ + status: string; + /** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ + price_type?: string; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** Contract code (e.g. BTC-USDT). Required */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** futures, swap, all. Required for futures. Default swap */ +/** 1: All Orders, 2: Order in Finished Status */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_order_limit. Supports cross and isolated. */ -export interface FuturesGetOrderLimitReq { - /** Order price type. Required */ - order_price_type: FuturesGetOrderLimitPriceType; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** futures, swap, all. Required for futures. Default swap */ - business_type?: FuturesBusinessType; -} +/** 0: all, or comma-separated e.g. "3,4,5" */ ⋮---- -/** Order price type. Required */ +/** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** End time (ms). Default now */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** next or prev. Default prev */ ⋮---- -/** futures, swap, all. Required for futures. Default swap */ +/** Pagination: min/max query_id from last result */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_fee. Supports cross and isolated. */ -export interface FuturesGetFeeReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ - contract_code?: string; +/** Req for POST /linear-swap-api/v3/swap_cross_hisorders_exact. Cross. History orders via multiple fields; adds price_type filter. */ +export interface FuturesGetCrossHistoryOrdersExactReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. When both pair and contract filled, contract preferred */ + contract: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** futures, swap, all. Required for futures. Default swap */ - business_type?: FuturesBusinessType; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** 1: All Orders, 2: Order in Finished Status */ + type: 1 | 2; + /** 0: all, or comma-separated e.g. "3,4,5" */ + status: string; + /** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ + price_type?: string; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. When both pair and contract filled, contract preferred */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** futures, swap, all. Required for futures. Default swap */ +/** 1: All Orders, 2: Order in Finished Status */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_position_limit. Cross margin only. */ -export interface FuturesGetCrossPositionLimitReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** futures, swap, all. Required for futures. Default swap */ - business_type?: FuturesBusinessType; -} +/** 0: all, or comma-separated e.g. "3,4,5" */ ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** End time (ms). Default now */ ⋮---- -/** futures, swap, all. Required for futures. Default swap */ +/** next or prev. Default prev */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_lever_position_limit. Cross margin only. */ -export interface FuturesGetCrossLeverageLimitsReq { - /** futures, swap, all. Required for futures */ - business_type?: FuturesBusinessType; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; +/** Pagination: min/max query_id from last result */ +⋮---- +/** Req for POST /linear-swap-api/v3/swap_cross_hisorders. Cross. One of contract or pair required. */ +export interface FuturesGetCrossHistoryOrdersReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ + contract?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-211231. Omit for all */ - contract_code?: string; - /** Leverage rate. Omit for all */ - lever_rate?: number; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** 1: All Orders, 2: Order in Finished Status */ + type: 1 | 2; + /** 0: all, or comma-separated e.g. "3,4,5" */ + status: string; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- -/** futures, swap, all. Required for futures */ -⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-211231. Omit for all */ -⋮---- -/** Leverage rate. Omit for all */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_master_sub_transfer. Supports cross and isolated. */ -export interface FuturesTransferMasterSubReq { - /** Sub-account UID */ - sub_uid: number; - /** Asset (e.g. USDT) */ - asset: string; - /** From margin account (e.g. USDT, BTC-USDT) */ - from_margin_account: string; - /** To margin account */ - to_margin_account: string; - /** Transfer amount */ - amount: number | string; - /** master_to_sub or sub_to_master */ - type: FuturesTransferType; - /** Optional client order ID [1, 9223372036854775807]. Valid 8h per transfer path */ - client_order_id?: number; -} +/** 1: All Orders, 2: Order in Finished Status */ ⋮---- -/** Sub-account UID */ +/** 0: all, or comma-separated e.g. "3,4,5" */ ⋮---- -/** Asset (e.g. USDT) */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** From margin account (e.g. USDT, BTC-USDT) */ +/** End time (ms). Default now */ ⋮---- -/** To margin account */ +/** next or prev. Default prev */ ⋮---- -/** Transfer amount */ +/** Pagination: min/max query_id from last result */ ⋮---- -/** master_to_sub or sub_to_master */ +/** Req for POST /linear-swap-api/v3/swap_matchresults. getFills. Isolated. One of contract or pair required. */ +export interface FuturesGetFillsReq { + /** Contract code (e.g. BTC-USDT) */ + contract?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; +} ⋮---- -/** Optional client order ID [1, 9223372036854775807]. Valid 8h per transfer path */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_master_sub_transfer_record. Supports cross and isolated. */ -export interface FuturesGetMasterSubTransfersReq { - /** Margin account (e.g. BTC-USDT, USDT). Required */ - margin_account: string; - /** 34: to sub, 35: from sub. Comma-separated for multiple. Omit for all */ - transfer_type?: string; - /** Days to query. Max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; -} +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Margin account (e.g. BTC-USDT, USDT). Required */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** 34: to sub, 35: from sub. Comma-separated for multiple. Omit for all */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Days to query. Max 90 */ +/** End time (ms). Default now */ ⋮---- -/** Page index. Default 1 */ +/** next or prev. Default prev */ ⋮---- -/** Page size. Default 20, max 50 */ +/** Pagination: min/max query_id from last result */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_transfer_inner. Transfer between margin accounts under same account. */ -export interface FuturesTransferInnerReq { - /** Asset (e.g. USDT) */ - asset: string; - /** From margin account (e.g. BTC-USDT, USDT) */ - from_margin_account: string; - /** To margin account */ - to_margin_account: string; - /** Transfer amount */ - amount: number | string; - /** Optional client order ID [1, 9223372036854775807]. Valid 8h */ - client_order_id?: number; +/** Req for POST /linear-swap-api/v3/swap_cross_matchresults. getCrossFills. Cross. One of contract or pair required. */ +export interface FuturesGetCrossFillsReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ + contract?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- -/** Asset (e.g. USDT) */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- -/** From margin account (e.g. BTC-USDT, USDT) */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** To margin account */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Transfer amount */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Optional client order ID [1, 9223372036854775807]. Valid 8h */ +/** End time (ms). Default now */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_order. Isolated margin only. */ -export interface FuturesSubmitOrderReq { +/** next or prev. Default prev */ +⋮---- +/** Pagination: min/max query_id from last result */ +⋮---- +/** Req for POST /linear-swap-api/v3/swap_matchresults_exact. getFillsExact. Isolated. No pair param. */ +export interface FuturesGetFillsExactReq { /** Contract code (e.g. BTC-USDT). Required */ - contract_code: string; - /** buy or sell */ - direction: FuturesDirection; - /** Order quantity */ - volume: number; - /** Leverage rate */ - lever_rate: number; - /** Order price type */ - order_price_type: FuturesSubmitOrderPriceType; - /** open, close, both. Required in hedge mode */ - offset?: FuturesOffsetBoth; - /** Price. Required for limit, post_only, ioc, fok */ - price?: number | string; - /** 0: no, 1: yes */ - reduce_only?: 0 | 1; - /** Client order ID [1, 9223372036854775807] */ - client_order_id?: number; - /** Take-profit trigger price */ - tp_trigger_price?: number | string; - /** Take-profit order price */ - tp_order_price?: number | string; - /** Take-profit order type */ - tp_order_price_type?: string; - /** Stop-loss trigger price */ - sl_trigger_price?: number | string; - /** Stop-loss order price */ - sl_order_price?: number | string; - /** Stop-loss order type */ - sl_order_price_type?: string; - /** Price protection when setting tp/sl */ - price_protect?: boolean; - /** 0: allow self-trade, 1: prevent (default) */ - self_match_prevent?: 0 | 1; - /** cancel_taker, cancel_maker, cancel_both */ - self_match_prevent_new?: FuturesSelfMatchPrevent; + contract: string; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; } ⋮---- /** Contract code (e.g. BTC-USDT). Required */ ⋮---- -/** buy or sell */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Order quantity */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Leverage rate */ +/** End time (ms). Default now */ ⋮---- -/** Order price type */ +/** next or prev. Default prev */ ⋮---- -/** open, close, both. Required in hedge mode */ +/** Pagination: min/max query_id from last result */ ⋮---- -/** Price. Required for limit, post_only, ioc, fok */ +/** Req for POST /linear-swap-api/v3/swap_cross_matchresults_exact. getCrossFillsExact. Cross. When both filled, contract preferred. */ +export interface FuturesGetCrossFillsExactReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ + contract: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; + /** Start time (ms). Window max 48h, within 90 days */ + start_time?: number; + /** End time (ms). Default now */ + end_time?: number; + /** next or prev. Default prev */ + direct?: FuturesDirect; + /** Pagination: min/max query_id from last result */ + from_id?: number; +} ⋮---- -/** 0: no, 1: yes */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ ⋮---- -/** Client order ID [1, 9223372036854775807] */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Take-profit trigger price */ +/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Take-profit order price */ +/** Start time (ms). Window max 48h, within 90 days */ ⋮---- -/** Take-profit order type */ +/** End time (ms). Default now */ ⋮---- -/** Stop-loss trigger price */ +/** next or prev. Default prev */ ⋮---- -/** Stop-loss order price */ +/** Pagination: min/max query_id from last result */ ⋮---- -/** Stop-loss order type */ +/** Req for POST /linear-swap-api/v1/swap_lightning_close_position. Isolated. Lightning close order. */ +export interface FuturesSubmitLightningCloseOrderReq { + /** Contract code (e.g. BTC-USDT). Case-insensitive */ + contract_code: string; + /** buy: open, sell: close */ + direction: FuturesDirection; + /** Client order ID. Unique per API, user-maintained */ + client_order_id?: number; + /** market (default), lightning_fok, lightning_ioc */ + order_price_type?: FuturesLightningOrderPriceType; +} ⋮---- -/** Price protection when setting tp/sl */ +/** Contract code (e.g. BTC-USDT). Case-insensitive */ ⋮---- -/** 0: allow self-trade, 1: prevent (default) */ +/** buy: open, sell: close */ ⋮---- -/** cancel_taker, cancel_maker, cancel_both */ +/** Client order ID. Unique per API, user-maintained */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_order. Cross margin only. One of contract_code or (pair+contract_type) required. */ -export interface FuturesCrossSubmitOrderReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit if pair+contract_type */ +/** market (default), lightning_fok, lightning_ioc */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_lightning_close_position. Cross. One of (pair+contract_type) or contract_code required. */ +export interface FuturesSubmitCrossLightningCloseOrderReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ + /** Pair (e.g. BTC-USDT) */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; /** buy or sell */ direction: FuturesDirection; - /** Order quantity */ - volume: number; - /** Leverage rate */ - lever_rate: number; - /** Order price type */ - order_price_type: FuturesSubmitOrderPriceType; - /** open, close, both. Required in hedge mode */ - offset?: FuturesOffsetBoth; - /** Price. Required for limit, post_only, ioc, fok */ - price?: number | string; - /** 0: no, 1: yes */ - reduce_only?: 0 | 1; /** Client order ID [1, 9223372036854775807] */ client_order_id?: number; - /** Take-profit trigger price */ - tp_trigger_price?: number | string; - /** Take-profit order price */ - tp_order_price?: number | string; - /** Take-profit order type */ - tp_order_price_type?: string; - /** Stop-loss trigger price */ - sl_trigger_price?: number | string; - /** Stop-loss order price */ - sl_order_price?: number | string; - /** Stop-loss order type */ - sl_order_price_type?: string; - /** 0: allow self-trade, 1: prevent (default) */ - self_match_prevent?: 0 | 1; - /** cancel_taker, cancel_maker, cancel_both */ - self_match_prevent_new?: FuturesSelfMatchPrevent; + /** market (default), lightning_fok, lightning_ioc */ + order_price_type?: FuturesLightningOrderPriceType; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit if pair+contract_type */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** Pair (e.g. BTC-USDT) */ ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- /** buy or sell */ ⋮---- -/** Order quantity */ -⋮---- -/** Leverage rate */ -⋮---- -/** Order price type */ +/** Client order ID [1, 9223372036854775807] */ ⋮---- -/** open, close, both. Required in hedge mode */ +/** market (default), lightning_fok, lightning_ioc */ ⋮---- -/** Price. Required for limit, post_only, ioc, fok */ +/** Req for GET /linear-swap-api/v1/swap_cross_trade_state. Cross margin only. */ +export interface FuturesGetCrossTradeStateReq { + /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** futures, swap, all. Required for futures. Default swap */ + business_type?: FuturesBusinessType; +} ⋮---- -/** 0: no, 1: yes */ +/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ ⋮---- -/** Client order ID [1, 9223372036854775807] */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Take-profit trigger price */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Take-profit order price */ +/** futures, swap, all. Required for futures. Default swap */ ⋮---- -/** Take-profit order type */ +/** + * Swap Strategy Order Interface + */ ⋮---- -/** Stop-loss trigger price */ +/** Req for POST /linear-swap-api/v1/swap_trigger_order. [Isolated] Submit Trigger Order. Isolated margin only. Trade. 5/s. */ +export interface FuturesSubmitTriggerOrderReq { + /** Contract type (e.g. BTC-USDT) */ + contract_code: string; + /** ge: Equal to or Greater than; le: Less than or Equal to */ + trigger_type: FuturesTriggerType; + /** Trigger price */ + trigger_price: number | string; + /** Order price (required when order_price_type is limit) */ + order_price?: number | string; + /** limit (default), optimal_5, optimal_10, optimal_20 */ + order_price_type?: FuturesTriggerOrderPriceType; + /** Volume (number of contracts) */ + volume: number; + /** buy or sell */ + direction: FuturesDirection; + /** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ + offset?: FuturesOffsetBoth; + /** Leverage. Must match current position leverage when holding. High leverage = high risk */ + lever_rate?: number; + /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ + reduce_only?: 0 | 1; +} ⋮---- -/** Stop-loss order price */ +/** Contract type (e.g. BTC-USDT) */ ⋮---- -/** Stop-loss order type */ +/** ge: Equal to or Greater than; le: Less than or Equal to */ ⋮---- -/** 0: allow self-trade, 1: prevent (default) */ +/** Trigger price */ ⋮---- -/** cancel_taker, cancel_maker, cancel_both */ +/** Order price (required when order_price_type is limit) */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_batchorder. Isolated. Max 10 orders. */ -export interface FuturesSubmitBatchOrderReq { - orders_data: FuturesSubmitOrderReq[]; -} +/** limit (default), optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_batchorder. Cross. Max 25 orders. */ -export interface FuturesSubmitCrossBatchOrderReq { - orders_data: FuturesCrossSubmitOrderReq[]; -} +/** Volume (number of contracts) */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cancel. Isolated. One of order_id or client_order_id required. Max 25 IDs. */ -export interface FuturesCancelOrderReq { - /** Contract code (e.g. BTC-USDT). Required */ - contract_code: string; - /** Order IDs, comma-separated. Max 25 */ - order_id?: string; - /** Client order IDs, comma-separated. Max 25 */ - client_order_id?: string; -} +/** buy or sell */ ⋮---- -/** Contract code (e.g. BTC-USDT). Required */ +/** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ ⋮---- -/** Order IDs, comma-separated. Max 25 */ +/** Leverage. Must match current position leverage when holding. High leverage = high risk */ ⋮---- -/** Client order IDs, comma-separated. Max 25 */ +/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_cancel. Cross. One of order_id/client_order_id and one of contract_code/(pair+contract_type) required. */ -export interface FuturesCancelCrossOrderReq { - /** Order IDs, comma-separated. Max 25 */ - order_id?: string; - /** Client order IDs, comma-separated. Max 25 */ - client_order_id?: string; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Req for POST /linear-swap-api/v1/swap_cross_trigger_order. [Cross] Submit Trigger Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesSubmitCrossTriggerOrderReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; - /** Pair (e.g. BTC-USDT) */ + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; + /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ + reduce_only?: 0 | 1; + /** ge: Equal to or Greater than; le: Less than or Equal to */ + trigger_type: FuturesTriggerType; + /** Trigger price */ + trigger_price: number | string; + /** Order price (required when order_price_type is limit) */ + order_price?: number | string; + /** limit (default), optimal_5, optimal_10, optimal_20 */ + order_price_type?: FuturesTriggerOrderPriceType; + /** Volume (number of contracts) */ + volume: number; + /** buy or sell */ + direction: FuturesDirection; + /** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ + offset?: FuturesOffsetBoth; + /** Leverage. Long = short leverage. High leverage = high risk */ + lever_rate?: number; } ⋮---- -/** Order IDs, comma-separated. Max 25 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** Client order IDs, comma-separated. Max 25 */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** ge: Equal to or Greater than; le: Less than or Equal to */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cancelall. Isolated. One of direction or offset optional. */ -export interface FuturesCancelAllOrdersReq { - /** Contract code (e.g. BTC-USDT). Required */ +/** Trigger price */ +⋮---- +/** Order price (required when order_price_type is limit) */ +⋮---- +/** limit (default), optimal_5, optimal_10, optimal_20 */ +⋮---- +/** Volume (number of contracts) */ +⋮---- +/** buy or sell */ +⋮---- +/** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ +⋮---- +/** Leverage. Long = short leverage. High leverage = high risk */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_trigger_cancelall. [Isolated] Cancel All Trigger Orders. Isolated margin only. Trade. 5/s. Can fill only one of direction and offset to filter. */ +export interface FuturesCancelAllTriggerOrdersReq { + /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** buy or sell. Omit for all */ + /** Transaction direction; omit for all */ direction?: FuturesDirection; - /** open or close. Omit for all */ + /** open, close; omit for all */ offset?: FuturesOffset; } ⋮---- -/** Contract code (e.g. BTC-USDT). Required */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** buy or sell. Omit for all */ +/** Transaction direction; omit for all */ ⋮---- -/** open or close. Omit for all */ +/** open, close; omit for all */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_cancelall. Cross. One of contract_code or (pair+contract_type) required. */ -export interface FuturesCancelCrossAllOrdersReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Req for POST /linear-swap-api/v1/swap_cross_trigger_cancelall. [Cross] Cancel All Trigger Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. Can fill only one of direction and offset to filter. */ +export interface FuturesCancelAllCrossTriggerOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; - /** Pair (e.g. BTC-USDT) */ + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** buy or sell. Omit for all */ + /** Transaction direction; omit for all */ direction?: FuturesDirection; - /** open or close. Omit for all */ + /** open, close; omit for all */ offset?: FuturesOffset; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** buy or sell. Omit for all */ +/** Transaction direction; omit for all */ ⋮---- -/** open or close. Omit for all */ +/** open, close; omit for all */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_switch_lever_rate. Cross margin only. One of contract_code or (pair+contract_type) required. */ -export interface FuturesUpdateCrossLeverageReq { - /** Leverage multiple. Required */ - lever_rate: number; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Req for POST /linear-swap-api/v1/swap_cross_trigger_cancel. [Cross] Cancel Trigger Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesCancelCrossTriggerOrderReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; - /** Pair (e.g. BTC-USDT) */ + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; + /** Order ID(s). Comma-separated, max 10 */ + order_id: string; } ⋮---- -/** Leverage multiple. Required */ -⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_order_info. Isolated. One of order_id or client_order_id required. Max 50 IDs. */ -export interface FuturesGetOrderInfoReq { - /** Contract code (e.g. BTC-USDT). Required */ +/** Order ID(s). Comma-separated, max 10 */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_trigger_openorders. [Isolated] Query Trigger Order Open Orders. Isolated margin only. Read. 5/s. */ +export interface FuturesGetTriggerOpenOrdersReq { + /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** Order IDs, comma-separated. Max 50 */ - order_id?: string; - /** Client order IDs, comma-separated. Max 50 */ - client_order_id?: string; -} -⋮---- -/** Contract code (e.g. BTC-USDT). Required */ -⋮---- -/** Order IDs, comma-separated. Max 50 */ -⋮---- -/** Client order IDs, comma-separated. Max 50 */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_order_info. Cross. One of order_id/client_order_id and one of contract_code/pair required. */ -export interface FuturesGetCrossOrderInfoReq { - /** Order IDs, comma-separated. Max 50 */ - order_id?: string; - /** Client order IDs, comma-separated. Max 50 */ - client_order_id?: string; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; -} -⋮---- -/** Order IDs, comma-separated. Max 50 */ -⋮---- -/** Client order IDs, comma-separated. Max 50 */ -⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ -⋮---- -/** Pair (e.g. BTC-USDT) */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_order_detail. Isolated. Order details with trades. */ -export interface FuturesGetOrderDetailReq { - /** Contract code (e.g. BTC-USDT). Required */ - contract_code: string; - /** Order ID. Required */ - order_id: number | string; - /** Created timestamp (ms). Improves query performance. Cannot be 0 */ - created_at?: number; - /** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ - order_type?: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; -} -⋮---- -/** Contract code (e.g. BTC-USDT). Required */ -⋮---- -/** Order ID. Required */ -⋮---- -/** Created timestamp (ms). Improves query performance. Cannot be 0 */ -⋮---- -/** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ -⋮---- -/** Page index. Default 1 */ -⋮---- -/** Page size. Default 20, max 50 */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_order_detail. Cross. One of contract_code or pair required. */ -export interface FuturesGetCrossOrderDetailReq { - /** Order ID. Required */ - order_id: number | string; - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Created timestamp (ms). Cannot be 0 */ - created_at?: number; - /** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ - order_type?: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; -} -⋮---- -/** Order ID. Required */ -⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ -⋮---- -/** Pair (e.g. BTC-USDT) */ -⋮---- -/** Created timestamp (ms). Cannot be 0 */ -⋮---- -/** 1: Quotation, 2: Cancelled, 3: Forced liquidation, 4: Delivery, 22: ADL */ -⋮---- -/** Page index. Default 1 */ -⋮---- -/** Page size. Default 20, max 50 */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_openorders. Isolated. Current unfilled orders. */ -export interface FuturesGetOpenOrdersReq { - /** Contract code (e.g. BTC-USDT). Omit for all */ - contract_code?: string; /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; - /** created_at or update_time. Default created_at */ - sort_by?: FuturesSortBy; /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- -/** Contract code (e.g. BTC-USDT). Omit for all */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** created_at or update_time. Default created_at */ -⋮---- /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_openorders. Cross. Omit all for all contracts. */ -export interface FuturesGetCrossOpenOrdersReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Req for POST /linear-swap-api/v1/swap_cross_trigger_openorders. [Cross] Query Trigger Order Open Orders. Cross margin only. When both pair and contract_code filled, contract_code preferred; when none, all open orders. Read. */ +export interface FuturesGetCrossTriggerOpenOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; @@ -8452,13 +7670,11 @@ export interface FuturesGetCrossOpenOrdersReq { page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; - /** created_at or update_time */ - sort_by?: FuturesSortBy; /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- @@ -8466,440 +7682,420 @@ export interface FuturesGetCrossOpenOrdersReq { ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** created_at or update_time */ -⋮---- /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_hisorders. Isolated. History orders. */ -export interface FuturesGetHistoryOrdersReq { - /** Contract code (e.g. BTC-USDT). Required */ - contract: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** 1: All Orders, 2: Order in Finished Status */ - type: 1 | 2; - /** 0: all, or comma-separated e.g. "3,4,5" */ +/** Req for POST /linear-swap-api/v1/swap_trigger_hisorders. getTriggerHistoryOrders. Isolated. Read. Default query completed (status 4,5,6). */ +export interface FuturesGetTriggerHistoryOrdersReq { + /** Contract code (e.g. BTC-USDT) */ + contract_code: string; + /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; + /** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ status: string; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; + /** Days. Positive integer, max 90; beyond 90 returns last 90 days */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** created_at (default) or update_time; descending */ + sort_by?: FuturesSortBy; } ⋮---- -/** Contract code (e.g. BTC-USDT). Required */ -⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** 1: All Orders, 2: Order in Finished Status */ +/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** 0: all, or comma-separated e.g. "3,4,5" */ +/** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Days. Positive integer, max 90; beyond 90 returns last 90 days */ ⋮---- -/** End time (ms). Default now */ +/** Page index. Default 1 */ ⋮---- -/** next or prev. Default prev */ +/** Page size. Default 20, max 50 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** created_at (default) or update_time; descending */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_hisorders_exact. Isolated. History orders via multiple fields; adds price_type filter. */ -export interface FuturesGetHistoryOrdersExactReq { - /** Contract code (e.g. BTC-USDT). Required */ - contract: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** 1: All Orders, 2: Order in Finished Status */ - type: 1 | 2; - /** 0: all, or comma-separated e.g. "3,4,5" */ - status: string; - /** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ - price_type?: string; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; +/** Req for POST /linear-swap-api/v1/swap_tpsl_order. [Isolated] Set Take-profit and Stop-loss for existing position. Isolated margin only. At least one of tp_trigger_price and sl_trigger_price required. Trade. 5/s. */ +export interface FuturesSubmitTpslOrderReq { + /** Contract code (e.g. BTC-USDT) */ + contract_code: string; + /** buy or sell */ + direction: FuturesDirection; + /** Volume (number of contracts) */ + volume: number | string; + /** Take-profit trigger price */ + tp_trigger_price?: number | string; + /** Take-profit order price (not required for optimal_5/10/20) */ + tp_order_price?: number | string; + /** market (default), limit, optimal_5, optimal_10, optimal_20 */ + tp_order_price_type?: + | 'market' + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; + /** Stop-loss trigger price */ + sl_trigger_price?: number | string; + /** Stop-loss order price (not required for optimal_5/10/20) */ + sl_order_price?: number | string; + /** market (default), limit, optimal_5, optimal_10, optimal_20 */ + sl_order_price_type?: + | 'market' + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; + /** Price protection. Default false. Only when setting tp/sl */ + price_protect?: boolean; } ⋮---- -/** Contract code (e.g. BTC-USDT). Required */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** buy or sell */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Volume (number of contracts) */ ⋮---- -/** 1: All Orders, 2: Order in Finished Status */ +/** Take-profit trigger price */ ⋮---- -/** 0: all, or comma-separated e.g. "3,4,5" */ +/** Take-profit order price (not required for optimal_5/10/20) */ ⋮---- -/** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ +/** market (default), limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Stop-loss trigger price */ ⋮---- -/** End time (ms). Default now */ +/** Stop-loss order price (not required for optimal_5/10/20) */ ⋮---- -/** next or prev. Default prev */ +/** market (default), limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** Price protection. Default false. Only when setting tp/sl */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_cross_hisorders_exact. Cross. History orders via multiple fields; adds price_type filter. */ -export interface FuturesGetCrossHistoryOrdersExactReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. When both pair and contract filled, contract preferred */ - contract: string; - /** Pair (e.g. BTC-USDT) */ +/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_order. [Cross] Set Take-profit and Stop-loss for existing position. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. At least one of tp_trigger_price and sl_trigger_price required. Trade. 5/s. */ +export interface FuturesSubmitCrossTpslOrderReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ + contract_code?: string; + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** 1: All Orders, 2: Order in Finished Status */ - type: 1 | 2; - /** 0: all, or comma-separated e.g. "3,4,5" */ - status: string; - /** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ - price_type?: string; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** buy or sell */ + direction: FuturesDirection; + /** Volume (number of contracts) */ + volume: number | string; + /** Take-profit trigger price */ + tp_trigger_price?: number | string; + /** Take-profit order price (not required for optimal_5/10/20) */ + tp_order_price?: number | string; + /** market (default), limit, optimal_5, optimal_10, optimal_20 */ + tp_order_price_type?: + | 'market' + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; + /** Stop-loss trigger price */ + sl_trigger_price?: number | string; + /** Stop-loss order price (not required for optimal_5/10/20) */ + sl_order_price?: number | string; + /** market (default), limit, optimal_5, optimal_10, optimal_20 */ + sl_order_price_type?: + | 'market' + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; + /** Price protection. Default false. Only when setting tp/sl */ + price_protect?: boolean; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. When both pair and contract filled, contract preferred */ -⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- -/** 1: All Orders, 2: Order in Finished Status */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** 0: all, or comma-separated e.g. "3,4,5" */ +/** buy or sell */ ⋮---- -/** Order price type filter: limit, opponent, post_only, optimal_5, optimal_10, optimal_20, ioc, fok, opponent_ioc, optimal_5_ioc, optimal_10_ioc, optimal_20_ioc, opponent_fok, optimal_5_fok, optimal_10_fok, optimal_20_fok */ +/** Volume (number of contracts) */ ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Take-profit trigger price */ ⋮---- -/** End time (ms). Default now */ +/** Take-profit order price (not required for optimal_5/10/20) */ ⋮---- -/** next or prev. Default prev */ +/** market (default), limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** Stop-loss trigger price */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_cross_hisorders. Cross. One of contract or pair required. */ -export interface FuturesGetCrossHistoryOrdersReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ - contract?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** 1: All Orders, 2: Order in Finished Status */ - type: 1 | 2; - /** 0: all, or comma-separated e.g. "3,4,5" */ - status: string; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; -} +/** Stop-loss order price (not required for optimal_5/10/20) */ ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** market (default), limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Price protection. Default false. Only when setting tp/sl */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Req for POST /linear-swap-api/v1/swap_tpsl_cancel. [Isolated] Cancel a Take-profit and Stop-loss Order. Isolated margin only. Trade. 5/s. Inlined in cancelTpslOrder - params: { contract_code, order_id } */ ⋮---- -/** 1: All Orders, 2: Order in Finished Status */ +/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_cancel. [Cross] Cancel a Take-profit and Stop-loss Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesCancelCrossTpslOrderReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ + contract_code?: string; + /** Pair (e.g. BTC-USDT). Use with contract_type */ + pair?: string; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** Order ID(s). Comma-separated, max 10 */ + order_id: string; +} ⋮---- -/** 0: all, or comma-separated e.g. "3,4,5" */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- -/** End time (ms). Default now */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** next or prev. Default prev */ +/** Order ID(s). Comma-separated, max 10 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** Req for POST /linear-swap-api/v1/swap_tpsl_cancelall. [Isolated] Cancel all Take-profit and Stop-loss Orders. Isolated margin only. Trade. 5/s. Inlined in cancelAllTpslOrders - params: { contract_code, direction? } */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_matchresults. getFills. Isolated. One of contract or pair required. */ -export interface FuturesGetFillsReq { - /** Contract code (e.g. BTC-USDT) */ - contract?: string; - /** Pair (e.g. BTC-USDT) */ +/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_cancelall. [Cross] Cancel all Take-profit and Stop-loss Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesCancelAllCrossTpslOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ + contract_code?: string; + /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; + /** swap, this_week, next_week, quarter, next_quarter */ + contract_type?: string; + /** buy or sell; omit for all */ + direction?: FuturesDirection; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ -⋮---- -/** Pair (e.g. BTC-USDT) */ -⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ ⋮---- -/** End time (ms). Default now */ +/** Pair (e.g. BTC-USDT). Use with contract_type */ ⋮---- -/** next or prev. Default prev */ +/** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** buy or sell; omit for all */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_cross_matchresults. getCrossFills. Cross. One of contract or pair required. */ -export interface FuturesGetCrossFillsReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ - contract?: string; +/** Req for POST /linear-swap-api/v1/swap_cross_trigger_hisorders. getCrossTriggerHistoryOrders. Cross. One of pair or contract_code required. Read. */ +export interface FuturesGetCrossTriggerHistoryOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; + /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; + /** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ + status: string; + /** Days. Positive integer, max 90 */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** created_at (default) or update_time; descending */ + sort_by?: FuturesSortBy; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** End time (ms). Default now */ +/** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ ⋮---- -/** next or prev. Default prev */ +/** Days. Positive integer, max 90 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** Page index. Default 1 */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_matchresults_exact. getFillsExact. Isolated. No pair param. */ -export interface FuturesGetFillsExactReq { - /** Contract code (e.g. BTC-USDT). Required */ - contract: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; -} +/** Page size. Default 20, max 50 */ ⋮---- -/** Contract code (e.g. BTC-USDT). Required */ +/** created_at (default) or update_time; descending */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Req for POST /linear-swap-api/v1/swap_tpsl_openorders. [Isolated] Query Open Take-profit and Stop-loss Orders. Isolated margin only. Read. */ +export interface FuturesGetTpslOpenOrdersReq { + /** Contract code (e.g. BTC-USDT) */ + contract_code: string; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** 0: all, 3: buy short, 4: sell long */ + trade_type?: 0 | 3 | 4; +} ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** End time (ms). Default now */ +/** Page index. Default 1 */ ⋮---- -/** next or prev. Default prev */ +/** Page size. Default 20, max 50 */ ⋮---- -/** Pagination: min/max query_id from last result */ +/** 0: all, 3: buy short, 4: sell long */ ⋮---- -/** Req for POST /linear-swap-api/v3/swap_cross_matchresults_exact. getCrossFillsExact. Cross. When both filled, contract preferred. */ -export interface FuturesGetCrossFillsExactReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ - contract: string; +/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_openorders. [Cross] Query Open Take-profit and Stop-loss Orders. Cross margin only. When both filled, contract_code preferred; when none, all data. Read. */ +export interface FuturesGetCrossTpslOpenOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18; - /** Start time (ms). Window max 48h, within 90 days */ - start_time?: number; - /** End time (ms). Default now */ - end_time?: number; - /** next or prev. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result */ - from_id?: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** 0: all, 3: buy short, 4: sell long */ + trade_type?: 0 | 3 | 4; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625 */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** 0: All, 1: Open long, 2: Open short, 3: Close short, 4: Close long, 5: Liquidate long, 6: Liquidate short, 17: buy(one-way), 18: sell(one-way) */ +/** Page index. Default 1 */ ⋮---- -/** Start time (ms). Window max 48h, within 90 days */ +/** Page size. Default 20, max 50 */ ⋮---- -/** End time (ms). Default now */ +/** 0: all, 3: buy short, 4: sell long */ ⋮---- -/** next or prev. Default prev */ -⋮---- -/** Pagination: min/max query_id from last result */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_lightning_close_position. Isolated. Lightning close order. */ -export interface FuturesSubmitLightningCloseOrderReq { - /** Contract code (e.g. BTC-USDT). Case-insensitive */ +/** Req for POST /linear-swap-api/v1/swap_tpsl_hisorders. [Isolated] Query Take-profit and Stop-loss History Orders. Isolated margin only. Read. */ +export interface FuturesGetTpslHistoryOrdersReq { + /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** buy: open, sell: close */ - direction: FuturesDirection; - /** Client order ID. Unique per API, user-maintained */ - client_order_id?: number; - /** market (default), lightning_fok, lightning_ioc */ - order_price_type?: FuturesLightningOrderPriceType; + /** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ + status: string; + /** Days. Positive integer, max 90 */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** created_at (default) or update_time; descending */ + sort_by?: FuturesSortBy; } ⋮---- -/** Contract code (e.g. BTC-USDT). Case-insensitive */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** buy: open, sell: close */ +/** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ ⋮---- -/** Client order ID. Unique per API, user-maintained */ +/** Days. Positive integer, max 90 */ ⋮---- -/** market (default), lightning_fok, lightning_ioc */ +/** Page index. Default 1 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_lightning_close_position. Cross. One of (pair+contract_type) or contract_code required. */ -export interface FuturesSubmitCrossLightningCloseOrderReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Preferred when all filled */ +/** Page size. Default 20, max 50 */ +⋮---- +/** created_at (default) or update_time; descending */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_hisorders. [Cross] Query Take-profit and Stop-loss History Orders. Cross margin only. One of pair or contract_code required; contract_code preferred when both filled. Read. */ +export interface FuturesGetCrossTpslHistoryOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** buy or sell */ - direction: FuturesDirection; - /** Client order ID [1, 9223372036854775807] */ - client_order_id?: number; - /** market (default), lightning_fok, lightning_ioc */ - order_price_type?: FuturesLightningOrderPriceType; + /** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ + status: string; + /** Days. Positive integer, max 90 */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** created_at (default) or update_time; descending */ + sort_by?: FuturesSortBy; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Preferred when all filled */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ ⋮---- -/** buy or sell */ +/** Days. Positive integer, max 90 */ ⋮---- -/** Client order ID [1, 9223372036854775807] */ +/** Page index. Default 1 */ ⋮---- -/** market (default), lightning_fok, lightning_ioc */ +/** Page size. Default 20, max 50 */ ⋮---- -/** Req for GET /linear-swap-api/v1/swap_cross_trade_state. Cross margin only. */ -export interface FuturesGetCrossTradeStateReq { - /** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** created_at (default) or update_time; descending */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_relation_tpsl_order. getCrossRelationTpslOrder. Cross. One of pair or contract_code required. Read. */ +export interface FuturesGetCrossRelationTpslOrderReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** futures, swap, all. Required for futures. Default swap */ - business_type?: FuturesBusinessType; + /** Position opening order ID */ + order_id: number | string; } ⋮---- -/** Contract code. swap: BTC-USDT, future: BTC-USDT-210625. Omit for all */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ -⋮---- -/** futures, swap, all. Required for futures. Default swap */ -⋮---- -/** - * Swap Strategy Order Interface - */ +/** Position opening order ID */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_trigger_order. [Isolated] Submit Trigger Order. Isolated margin only. Trade. 5/s. */ -export interface FuturesSubmitTriggerOrderReq { - /** Contract type (e.g. BTC-USDT) */ +/** Req for POST /linear-swap-api/v1/swap_track_order. [Isolated] Submit a Trailing Order. Isolated margin only. Trade. 5/s. */ +export interface FuturesSubmitTrailingOrderReq { + /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** ge: Equal to or Greater than; le: Less than or Equal to */ - trigger_type: FuturesTriggerType; - /** Trigger price */ - trigger_price: number | string; - /** Order price (required when order_price_type is limit) */ - order_price?: number | string; - /** limit (default), optimal_5, optimal_10, optimal_20 */ - order_price_type?: FuturesTriggerOrderPriceType; - /** Volume (number of contracts) */ - volume: number; + /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ + reduce_only?: 0 | 1; /** buy or sell */ direction: FuturesDirection; - /** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ + /** open, close, both. Hedge mode required; one-way optional, must be both when filled */ offset?: FuturesOffsetBoth; - /** Leverage. Must match current position leverage when holding. High leverage = high risk */ + /** Leverage. Required when open, optional when close */ lever_rate?: number; - /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ - reduce_only?: 0 | 1; + /** Volume (contracts) */ + volume: number | string; + /** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ + callback_rate: number | string; + /** Active price */ + active_price: number | string; + /** optimal_5, optimal_10, optimal_20, formula_price */ + order_price_type: FuturesTrailingOrderPriceType; } ⋮---- -/** Contract type (e.g. BTC-USDT) */ -⋮---- -/** ge: Equal to or Greater than; le: Less than or Equal to */ +/** Contract code (e.g. BTC-USDT) */ ⋮---- -/** Trigger price */ +/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ ⋮---- -/** Order price (required when order_price_type is limit) */ +/** buy or sell */ ⋮---- -/** limit (default), optimal_5, optimal_10, optimal_20 */ +/** open, close, both. Hedge mode required; one-way optional, must be both when filled */ ⋮---- -/** Volume (number of contracts) */ +/** Leverage. Required when open, optional when close */ ⋮---- -/** buy or sell */ +/** Volume (contracts) */ ⋮---- -/** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ +/** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ ⋮---- -/** Leverage. Must match current position leverage when holding. High leverage = high risk */ +/** Active price */ ⋮---- -/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ +/** optimal_5, optimal_10, optimal_20, formula_price */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_trigger_order. [Cross] Submit Trigger Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesSubmitCrossTriggerOrderReq { +/** Req for POST /linear-swap-api/v1/swap_cross_track_order. [Cross] Submit a Trailing Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesSubmitCrossTrailingOrderReq { /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ + /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ reduce_only?: 0 | 1; - /** ge: Equal to or Greater than; le: Less than or Equal to */ - trigger_type: FuturesTriggerType; - /** Trigger price */ - trigger_price: number | string; - /** Order price (required when order_price_type is limit) */ - order_price?: number | string; - /** limit (default), optimal_5, optimal_10, optimal_20 */ - order_price_type?: FuturesTriggerOrderPriceType; - /** Volume (number of contracts) */ - volume: number; /** buy or sell */ direction: FuturesDirection; - /** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ + /** open, close, both. Hedge mode required; one-way optional, must be both when filled */ offset?: FuturesOffsetBoth; - /** Leverage. Long = short leverage. High leverage = high risk */ + /** Leverage. Required when open, optional when close */ lever_rate?: number; + /** Volume (contracts) */ + volume: number | string; + /** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ + callback_rate: number | string; + /** Active price */ + active_price: number | string; + /** optimal_5, optimal_10, optimal_20, formula_price */ + order_price_type: FuturesTrailingOrderPriceType; } ⋮---- /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ @@ -8908,52 +8104,34 @@ export interface FuturesSubmitCrossTriggerOrderReq { ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open in one-way triggers error 1492 */ -⋮---- -/** ge: Equal to or Greater than; le: Less than or Equal to */ -⋮---- -/** Trigger price */ -⋮---- -/** Order price (required when order_price_type is limit) */ -⋮---- -/** limit (default), optimal_5, optimal_10, optimal_20 */ -⋮---- -/** Volume (number of contracts) */ +/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ ⋮---- /** buy or sell */ ⋮---- -/** open, close, both. In hedge mode required; in one-way mode optional, must be both when filled */ +/** open, close, both. Hedge mode required; one-way optional, must be both when filled */ ⋮---- -/** Leverage. Long = short leverage. High leverage = high risk */ +/** Leverage. Required when open, optional when close */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_trigger_cancelall. [Isolated] Cancel All Trigger Orders. Isolated margin only. Trade. 5/s. Can fill only one of direction and offset to filter. */ -export interface FuturesCancelAllTriggerOrdersReq { - /** Contract code (e.g. BTC-USDT) */ - contract_code: string; - /** Transaction direction; omit for all */ - direction?: FuturesDirection; - /** open, close; omit for all */ - offset?: FuturesOffset; -} +/** Volume (contracts) */ ⋮---- -/** Contract code (e.g. BTC-USDT) */ +/** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ ⋮---- -/** Transaction direction; omit for all */ +/** Active price */ ⋮---- -/** open, close; omit for all */ +/** optimal_5, optimal_10, optimal_20, formula_price */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_trigger_cancelall. [Cross] Cancel All Trigger Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. Can fill only one of direction and offset to filter. */ -export interface FuturesCancelAllCrossTriggerOrdersReq { +/** Req for POST /linear-swap-api/v1/swap_track_cancel. [Isolated] Cancel a Trailing Order. Isolated margin only. Trade. 5/s. Inlined in cancelTrailingOrder - params: { contract_code, order_id } */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_track_cancel. [Cross] Cancel a Trailing Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ +export interface FuturesCancelCrossTrailingOrderReq { /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** Transaction direction; omit for all */ - direction?: FuturesDirection; - /** open, close; omit for all */ - offset?: FuturesOffset; + /** Trailing order ID(s). Comma-separated, max 10 */ + order_id: string; } ⋮---- /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ @@ -8962,20 +8140,36 @@ export interface FuturesCancelAllCrossTriggerOrdersReq { ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Transaction direction; omit for all */ +/** Trailing order ID(s). Comma-separated, max 10 */ ⋮---- -/** open, close; omit for all */ +/** Req for POST /linear-swap-api/v1/swap_track_cancelall. [Isolated] Cancel All Trailing Orders. Isolated margin only. Can fill only one of direction and offset to filter. Trade. 5/s. */ +export interface FuturesCancelAllTrailingOrdersReq { + /** Contract code (e.g. BTC-USDT) */ + contract_code: string; + /** buy or sell; omit for all */ + direction?: FuturesDirection; + /** open or close; omit for all */ + offset?: FuturesOffset; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_trigger_cancel. [Cross] Cancel Trigger Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesCancelCrossTriggerOrderReq { +/** Contract code (e.g. BTC-USDT) */ +⋮---- +/** buy or sell; omit for all */ +⋮---- +/** open or close; omit for all */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_cross_track_cancelall. [Cross] Cancel All Trailing Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Can fill only one of direction and offset to filter. Trade. 5/s. */ +export interface FuturesCancelAllCrossTrailingOrdersReq { /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ contract_code?: string; /** Pair (e.g. BTC-USDT). Use with contract_type */ pair?: string; /** swap, this_week, next_week, quarter, next_quarter */ contract_type?: string; - /** Order ID(s). Comma-separated, max 10 */ - order_id: string; + /** buy or sell; omit for all */ + direction?: FuturesDirection; + /** open or close; omit for all */ + offset?: FuturesOffset; } ⋮---- /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ @@ -8984,2192 +8178,1686 @@ export interface FuturesCancelCrossTriggerOrderReq { ⋮---- /** swap, this_week, next_week, quarter, next_quarter */ ⋮---- -/** Order ID(s). Comma-separated, max 10 */ +/** buy or sell; omit for all */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_trigger_openorders. [Isolated] Query Trigger Order Open Orders. Isolated margin only. Read. 5/s. */ -export interface FuturesGetTriggerOpenOrdersReq { +/** open or close; omit for all */ +⋮---- +/** Req for POST /linear-swap-api/v1/swap_track_openorders. [Isolated] Current unfilled trailing orders. Isolated margin only. Read. */ +export interface FuturesGetTrailingOpenOrdersReq { /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** Page index. Default 1 */ + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; + /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- /** Contract code (e.g. BTC-USDT) */ ⋮---- +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_trigger_openorders. [Cross] Query Trigger Order Open Orders. Cross margin only. When both pair and contract_code filled, contract_code preferred; when none, all open orders. Read. */ -export interface FuturesGetCrossTriggerOpenOrdersReq { +/** Req for POST /linear-swap-api/v1/swap_cross_track_openorders. [Cross] Current unfilled trailing orders. Cross margin only. When both filled, contract_code preferred; when none, all open orders. Read. */ +export interface FuturesGetCrossTrailingOpenOrdersReq { /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ contract_code?: string; /** Pair (e.g. BTC-USDT) */ pair?: string; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; } ⋮---- /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- /** Pair (e.g. BTC-USDT) */ ⋮---- +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_trigger_hisorders. getTriggerHistoryOrders. Isolated. Read. Default query completed (status 4,5,6). */ -export interface FuturesGetTriggerHistoryOrdersReq { +/** Req for POST /linear-swap-api/v1/swap_track_hisorders. [Isolated] Get History Trailing Orders. Isolated margin only. Read. */ +export interface FuturesGetTrailingHistoryOrdersReq { /** Contract code (e.g. BTC-USDT) */ contract_code: string; - /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ + /** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ status: string; - /** Days. Positive integer, max 90; beyond 90 returns last 90 days */ + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; + /** Days. Positive integer, max 90 */ create_date: number; /** Page index. Default 1 */ page_index?: number; /** Page size. Default 20, max 50 */ page_size?: number; - /** created_at (default) or update_time; descending */ - sort_by?: FuturesSortBy; + /** create_date or update_time; descending */ + sort_by?: FuturesSortByExtended; } ⋮---- /** Contract code (e.g. BTC-USDT) */ ⋮---- -/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ +/** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ ⋮---- -/** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** Days. Positive integer, max 90; beyond 90 returns last 90 days */ +/** Days. Positive integer, max 90 */ ⋮---- /** Page index. Default 1 */ ⋮---- /** Page size. Default 20, max 50 */ ⋮---- -/** created_at (default) or update_time; descending */ +/** create_date or update_time; descending */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_tpsl_order. [Isolated] Set Take-profit and Stop-loss for existing position. Isolated margin only. At least one of tp_trigger_price and sl_trigger_price required. Trade. 5/s. */ -export interface FuturesSubmitTpslOrderReq { - /** Contract code (e.g. BTC-USDT) */ - contract_code: string; - /** buy or sell */ - direction: FuturesDirection; - /** Volume (number of contracts) */ - volume: number | string; - /** Take-profit trigger price */ - tp_trigger_price?: number | string; - /** Take-profit order price (not required for optimal_5/10/20) */ - tp_order_price?: number | string; - /** market (default), limit, optimal_5, optimal_10, optimal_20 */ - tp_order_price_type?: - | 'market' - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; - /** Stop-loss trigger price */ - sl_trigger_price?: number | string; - /** Stop-loss order price (not required for optimal_5/10/20) */ - sl_order_price?: number | string; - /** market (default), limit, optimal_5, optimal_10, optimal_20 */ - sl_order_price_type?: - | 'market' - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; - /** Price protection. Default false. Only when setting tp/sl */ - price_protect?: boolean; +/** Req for POST /linear-swap-api/v1/swap_cross_track_hisorders. [Cross] Get History Trailing Orders. Cross margin only. One of pair or contract_code required; contract_code preferred when both filled. Read. */ +export interface FuturesGetCrossTrailingHistoryOrdersReq { + /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ + contract_code?: string; + /** Pair (e.g. BTC-USDT) */ + pair?: string; + /** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ + status: string; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ + trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; + /** Days. Positive integer, max 90 */ + create_date: number; + /** Page index. Default 1 */ + page_index?: number; + /** Page size. Default 20, max 50 */ + page_size?: number; + /** create_date or update_time; descending */ + sort_by?: FuturesSortByExtended; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ -⋮---- -/** buy or sell */ +/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ ⋮---- -/** Volume (number of contracts) */ +/** Pair (e.g. BTC-USDT) */ ⋮---- -/** Take-profit trigger price */ +/** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ ⋮---- -/** Take-profit order price (not required for optimal_5/10/20) */ +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ ⋮---- -/** market (default), limit, optimal_5, optimal_10, optimal_20 */ +/** Days. Positive integer, max 90 */ ⋮---- -/** Stop-loss trigger price */ +/** Page index. Default 1 */ ⋮---- -/** Stop-loss order price (not required for optimal_5/10/20) */ +/** Page size. Default 20, max 50 */ ⋮---- -/** market (default), limit, optimal_5, optimal_10, optimal_20 */ +/** create_date or update_time; descending */ ⋮---- -/** Price protection. Default false. Only when setting tp/sl */ +/** + * Unified Account + */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_order. [Cross] Set Take-profit and Stop-loss for existing position. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. At least one of tp_trigger_price and sl_trigger_price required. Trade. 5/s. */ -export interface FuturesSubmitCrossTpslOrderReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ - contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** buy or sell */ - direction: FuturesDirection; - /** Volume (number of contracts) */ - volume: number | string; - /** Take-profit trigger price */ - tp_trigger_price?: number | string; - /** Take-profit order price (not required for optimal_5/10/20) */ - tp_order_price?: number | string; - /** market (default), limit, optimal_5, optimal_10, optimal_20 */ - tp_order_price_type?: - | 'market' - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; - /** Stop-loss trigger price */ - sl_trigger_price?: number | string; - /** Stop-loss order price (not required for optimal_5/10/20) */ - sl_order_price?: number | string; - /** market (default), limit, optimal_5, optimal_10, optimal_20 */ - sl_order_price_type?: - | 'market' - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; - /** Price protection. Default false. Only when setting tp/sl */ - price_protect?: boolean; +/** Req for POST /linear-swap-api/v3/fix_position_margin_change. Adjust margin for isolated positions. Trade. */ +export interface FuturesUpdateUnifiedMarginReq { + /** Adjustment amount */ + amount: number | string; + /** Currency (e.g. USDT) */ + asset: string; + /** Contract code (e.g. BTC-USDT, ETH-USDT) */ + contract_code: string; + /** 1: increase isolated margin; 2: reduce isolated margin */ + type: 1 | 2; + /** 1: buy; 2: sell */ + direction: 1 | 2; + /** Client order ID */ + clientOrderId?: number | string; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Adjustment amount */ ⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** Currency (e.g. USDT) */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Contract code (e.g. BTC-USDT, ETH-USDT) */ ⋮---- -/** buy or sell */ +/** 1: increase isolated margin; 2: reduce isolated margin */ ⋮---- -/** Volume (number of contracts) */ +/** 1: buy; 2: sell */ ⋮---- -/** Take-profit trigger price */ +/** Client order ID */ ⋮---- -/** Take-profit order price (not required for optimal_5/10/20) */ +/** Req for GET /linear-swap-api/v3/fix_position_margin_change_record. Query margin adjustment records of isolated positions. Read. */ +export interface FuturesGetUnifiedMarginAdjustmentsReq { + /** Currency (e.g. USDT) */ + asset: string; + /** Contract code (e.g. BTC-USDT, ETH-USDT) */ + contract_code: string; + /** Query start time (ms). Window max 48h, within 90 days. [(end_time - 48h), end_time] */ + start_time?: number; + /** Query end time (ms). [(present-90d), present] */ + end_time?: number; + /** prev: forward query; next: backward query */ + direct?: FuturesDirect; + /** prev: min query_id from last result; next: max query_id from last result */ + from_id?: number; +} ⋮---- -/** market (default), limit, optimal_5, optimal_10, optimal_20 */ +/** Currency (e.g. USDT) */ ⋮---- -/** Stop-loss trigger price */ +/** Contract code (e.g. BTC-USDT, ETH-USDT) */ ⋮---- -/** Stop-loss order price (not required for optimal_5/10/20) */ +/** Query start time (ms). Window max 48h, within 90 days. [(end_time - 48h), end_time] */ ⋮---- -/** market (default), limit, optimal_5, optimal_10, optimal_20 */ +/** Query end time (ms). [(present-90d), present] */ ⋮---- -/** Price protection. Default false. Only when setting tp/sl */ +/** prev: forward query; next: backward query */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_tpsl_cancel. [Isolated] Cancel a Take-profit and Stop-loss Order. Isolated margin only. Trade. 5/s. Inlined in cancelTpslOrder - params: { contract_code, order_id } */ +/** prev: min query_id from last result; next: max query_id from last result */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_cancel. [Cross] Cancel a Take-profit and Stop-loss Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesCancelCrossTpslOrderReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Req for GET /v5/account/bills. Query financial records. */ +export interface FuturesV5BillsReq { + /** Contract code (e.g. BTC-USDT, ETH-USDT) */ contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** Order ID(s). Comma-separated, max 10 */ - order_id: string; + /** cross: Cross margin; isolated: Isolated margin */ + margin_mode?: FuturesMarginMode; + /** + * Financial type code. Comma-separated for multiple, e.g. 3,4,30,160. + * 160: dividend settlement income. 161: dividend settlement expense. + */ + type?: string; + /** Start time (ms). Default: now - 48h */ + start_time?: string | number; + /** End time (ms). Default: now */ + end_time?: string | number; + /** Query offset, default 0 */ + from?: number; + /** Page size, default 10, max 100 */ + limit?: number; + /** prev | next */ + direct?: FuturesDirect; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Contract code (e.g. BTC-USDT, ETH-USDT) */ ⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** cross: Cross margin; isolated: Isolated margin */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** + * Financial type code. Comma-separated for multiple, e.g. 3,4,30,160. + * 160: dividend settlement income. 161: dividend settlement expense. + */ ⋮---- -/** Order ID(s). Comma-separated, max 10 */ +/** Start time (ms). Default: now - 48h */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_tpsl_cancelall. [Isolated] Cancel all Take-profit and Stop-loss Orders. Isolated margin only. Trade. 5/s. Inlined in cancelAllTpslOrders - params: { contract_code, direction? } */ +/** End time (ms). Default: now */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_cancelall. [Cross] Cancel all Take-profit and Stop-loss Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesCancelAllCrossTpslOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ - contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** buy or sell; omit for all */ - direction?: FuturesDirection; -} -⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ -⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** Query offset, default 0 */ ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Page size, default 10, max 100 */ ⋮---- -/** buy or sell; omit for all */ +/** prev | next */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_trigger_hisorders. getCrossTriggerHistoryOrders. Cross. One of pair or contract_code required. Read. */ -export interface FuturesGetCrossTriggerHistoryOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ - status: string; - /** Days. Positive integer, max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** created_at (default) or update_time; descending */ - sort_by?: FuturesSortBy; +/** Req for POST /v5/trade/cancel_order. Cancel a single order. */ +export interface FuturesV5CancelOrderReq { + contract_code: string; + /** Order ID. One of order_id or client_order_id required */ + order_id?: string; + /** Client order ID. One of order_id or client_order_id required */ + client_order_id?: string; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ -⋮---- -/** Pair (e.g. BTC-USDT) */ -⋮---- -/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Order status: 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated allowed */ -⋮---- -/** Days. Positive integer, max 90 */ -⋮---- -/** Page index. Default 1 */ -⋮---- -/** Page size. Default 20, max 50 */ +/** Order ID. One of order_id or client_order_id required */ ⋮---- -/** created_at (default) or update_time; descending */ +/** Client order ID. One of order_id or client_order_id required */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_tpsl_openorders. [Isolated] Query Open Take-profit and Stop-loss Orders. Isolated margin only. Read. */ -export interface FuturesGetTpslOpenOrdersReq { - /** Contract code (e.g. BTC-USDT) */ +/** Req for POST /v5/trade/cancel_batch_orders. Max 10 orders per request. */ +export interface FuturesV5CancelBatchOrdersReq { contract_code: string; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** 0: all, 3: buy short, 4: sell long */ - trade_type?: 0 | 3 | 4; + /** Order IDs. One of order_id or client_order_id required */ + order_id?: string[]; + /** Client order IDs. One of order_id or client_order_id required */ + client_order_id?: string[]; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ +/** Order IDs. One of order_id or client_order_id required */ ⋮---- -/** Page index. Default 1 */ +/** Client order IDs. One of order_id or client_order_id required */ ⋮---- -/** Page size. Default 20, max 50 */ +/** Req for POST /v5/trade/cancel_all_orders. Cancel all open orders. */ +export interface FuturesV5CancelAllOrdersReq { + contract_code?: string; + side?: FuturesDirection; + position_side?: FuturesPositionSide; +} ⋮---- -/** 0: all, 3: buy short, 4: sell long */ +/** Req for POST /v5/trade/position. Close all of a symbol at market price. */ +export interface FuturesV5ClosePositionReq { + contract_code: string; + margin_mode: FuturesMarginMode; + position_side: FuturesPositionSide; + client_order_id?: string; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_openorders. [Cross] Query Open Take-profit and Stop-loss Orders. Cross margin only. When both filled, contract_code preferred; when none, all data. Read. */ -export interface FuturesGetCrossTpslOpenOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Req for GET /v5/trade/order/opens. Get unfilled orders. */ +export interface FuturesV5OpenOrdersReq { contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** 0: all, 3: buy short, 4: sell long */ - trade_type?: 0 | 3 | 4; + margin_mode?: FuturesMarginMode; + order_id?: string; + client_order_id?: string; + from?: number; + limit?: number; + direct?: FuturesDirect; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ -⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Req for GET /v5/trade/order/details. Execution details (last 3 days). */ +export interface FuturesV5OrderDetailsReq { + contract_code?: string; + order_id?: string; + start_time?: string | number; + end_time?: string | number; + from?: number; + limit?: number; + direct?: FuturesDirect; +} ⋮---- -/** Page index. Default 1 */ +/** Req for GET /v5/trade/order/history. Get order history. */ +export interface FuturesV5OrderHistoryReq { + contract_code: string; + margin_mode: FuturesMarginMode; + state?: string; + type?: FuturesV5OrderType; + price_match?: string; + start_time?: string | number; + end_time?: string | number; + from?: number; + limit?: number; + direct?: FuturesDirect; +} ⋮---- -/** Page size. Default 20, max 50 */ +/** Req for GET /v5/trade/order. Get single order info. */ +export interface FuturesV5OrderInfoReq { + contract_code: string; + margin_mode?: FuturesMarginMode; + order_id?: string; + client_order_id?: string; +} ⋮---- -/** 0: all, 3: buy short, 4: sell long */ +/** Req for POST /v5/trade/cancel-after. Automatic order cancellation (Dead Man's Switch). */ +export interface FuturesV5CancelAfterReq { + on_off: '0' | '1'; + time_out?: number | string; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_tpsl_hisorders. [Isolated] Query Take-profit and Stop-loss History Orders. Isolated margin only. Read. */ -export interface FuturesGetTpslHistoryOrdersReq { - /** Contract code (e.g. BTC-USDT) */ +/** Req for POST /v5/trade/order. Place a single order. */ +export interface FuturesV5SubmitOrderReq { contract_code: string; - /** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ - status: string; - /** Days. Positive integer, max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** created_at (default) or update_time; descending */ - sort_by?: FuturesSortBy; + margin_mode: FuturesMarginMode; + side: FuturesDirection; + type: FuturesV5OrderType; + volume: string; + position_side?: FuturesPositionSide; + price_match?: FuturesPriceMatch; + client_order_id?: string; + price?: string | number; + reduce_only?: 0 | 1; + time_in_force?: FuturesTimeInForce; + tp_trigger_price?: string; + tp_order_price?: string; + tp_type?: FuturesTriggerOrderPriceType | 'market'; + tp_trigger_price_type?: FuturesTriggerPriceType; + sl_trigger_price?: string; + sl_order_price?: string; + sl_type?: FuturesTriggerOrderPriceType | 'market'; + sl_trigger_price_type?: FuturesTriggerPriceType; + price_protect?: boolean; + self_match_prevent?: FuturesSelfMatchPrevent; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ +/** + * USDT Margined Futures Multi Asset - Positions (v5 API) + */ ⋮---- -/** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ +/** Req for GET /v5/trade/position/opens. Get current positions. Inlined in getMultiAssetPositions - params?: { contract_code? } */ ⋮---- -/** Days. Positive integer, max 90 */ +/** Req for GET /v5/position/lever. Get leverage list. */ +export interface FuturesV5LeverListReq { + contract_code?: string; + margin_mode?: FuturesMarginMode; + position_side?: FuturesPositionSide; +} ⋮---- -/** Page index. Default 1 */ +/** Req for POST /v5/position/lever. Set leverage. */ +export interface FuturesV5SetLeverageReq { + contract_code: string; + margin_mode: FuturesMarginMode; + lever_rate: string | number; + /** Required when isolated margin in two-way position mode */ + position_side?: FuturesPositionSide; +} ⋮---- -/** Page size. Default 20, max 50 */ +/** Required when isolated margin in two-way position mode */ ⋮---- -/** created_at (default) or update_time; descending */ +/** Req for POST /v5/position/mode. Set position mode. Inlined in updateMultiAssetPositionMode - params: { position_mode } */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_tpsl_hisorders. [Cross] Query Take-profit and Stop-loss History Orders. Cross margin only. One of pair or contract_code required; contract_code preferred when both filled. Read. */ -export interface FuturesGetCrossTpslHistoryOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Req for GET /v5/position/risk/limit. Get current position risk limit. */ +export interface FuturesV5RiskLimitReq { contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ - status: string; - /** Days. Positive integer, max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** created_at (default) or update_time; descending */ - sort_by?: FuturesSortBy; + margin_mode?: FuturesMarginMode; + position_side?: FuturesPositionSide; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Req for GET /v5/position/risk/limit_tier. Query risk limit tiers. Inlined in getMultiAssetRiskLimitTiers - params: { contract_code, margin_mode? } */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Req for POST /v5/position/margin. Adjust margin for isolated positions. */ +export interface FuturesV5AdjustMarginReq { + contract_code: string; + position_side: FuturesPositionSide; + type: FuturesMarginAdjustType; + amount: string; + currency?: string; +} ⋮---- -/** Status: 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated allowed */ +/** V5 algo order type */ +export type FuturesV5AlgoOrderType = + | 'tp' + | 'sl' + | 'tp_sl' + | 'tpsl' + | 'trigger' + | 'trailing_stop'; ⋮---- -/** Days. Positive integer, max 90 */ +/** V5 algo trigger price type */ +export type FuturesV5AlgoTriggerPriceType = 'last' | 'mark' | 'index'; ⋮---- -/** Page index. Default 1 */ +/** V5 algo TP/SL order type */ +export type FuturesV5AlgoTpSlType = + | 'market' + | 'limit' + | 'optimal_5' + | 'optimal_10' + | 'optimal_20'; ⋮---- -/** Page size. Default 20, max 50 */ +/** Req for POST /v5/algo/order. Place an algo order. */ +export interface FuturesV5SubmitAlgoOrderReq { + contract_code: string; + type: FuturesV5AlgoOrderType; + position_side: FuturesPositionSide; + side: FuturesDirection; + margin_mode: FuturesMarginMode; + algo_client_order_id?: string; + volume?: string; + tp_trigger_price?: string; + tp_order_price?: string; + tp_type?: FuturesV5AlgoTpSlType; + tp_trigger_price_type?: FuturesV5AlgoTriggerPriceType; + sl_trigger_price?: string; + sl_order_price?: string; + sl_type?: FuturesV5AlgoTpSlType; + sl_trigger_price_type?: FuturesV5AlgoTriggerPriceType; + price?: string; + price_type?: 'optimal_5' | 'optimal_10' | 'optimal_20'; + trigger_price?: string; + trigger_price_type?: FuturesV5AlgoTriggerPriceType; + activation_price?: string; + active_price?: string; + order_price_type?: + | 'optimal_5' + | 'optimal_10' + | 'optimal_20' + | 'trailing_mark'; + callback_rate?: string; + reduce_only?: boolean; +} ⋮---- -/** created_at (default) or update_time; descending */ +/** Req for POST /v5/algo/cancel_orders. Cancel unfilled algo orders. Max 10 per request. */ +export interface FuturesV5CancelAlgoOrderReq { + contract_code: string; + algo_id?: string; + algo_client_order_id?: string; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_relation_tpsl_order. getCrossRelationTpslOrder. Cross. One of pair or contract_code required. Read. */ -export interface FuturesGetCrossRelationTpslOrderReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Position opening order ID */ - order_id: number | string; +/** Req for GET /v5/algo/order. Query one algo order. */ +export interface FuturesV5AlgoOrderInfoReq { + type: FuturesV5AlgoOrderType; + algo_id?: string; + algo_client_order_id?: string; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Req for GET /v5/algo/order/opens. Untriggered algo orders. */ +export interface FuturesV5AlgoOpenOrdersReq { + type: FuturesV5AlgoOrderType; + contract_code?: string; + algo_id?: string; + algo_client_order_id?: string; + from?: number | string; + limit?: number; + direct?: FuturesDirect; +} ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Req for GET /v5/algo/order/history. Algo order history. */ +export interface FuturesV5AlgoOrderHistoryReq { + type: FuturesV5AlgoOrderType; + contract_code?: string; + margin_mode?: FuturesMarginMode; + states?: string; + start_time?: string | number; + end_time?: string | number; + from?: number | string; + limit?: number; + direct?: FuturesDirect; +} ⋮---- -/** Position opening order ID */ +/** + * USDT Margined Futures Multi Asset - Basic Information (v5 API) + */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_track_order. [Isolated] Submit a Trailing Order. Isolated margin only. Trade. 5/s. */ -export interface FuturesSubmitTrailingOrderReq { - /** Contract code (e.g. BTC-USDT) */ +/** Req for GET /v5/market/funding_rate_history. Historical funding rates. No signature. */ +export interface FuturesV5FundingRateHistoryReq { + /** Perpetual (e.g. BTC-USDT) or delivery (e.g. BTC-USDT-210625) */ contract_code: string; - /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ - reduce_only?: 0 | 1; - /** buy or sell */ - direction: FuturesDirection; - /** open, close, both. Hedge mode required; one-way optional, must be both when filled */ - offset?: FuturesOffsetBoth; - /** Leverage. Required when open, optional when close */ - lever_rate?: number; - /** Volume (contracts) */ - volume: number | string; - /** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ - callback_rate: number | string; - /** Active price */ - active_price: number | string; - /** optimal_5, optimal_10, optimal_20, formula_price */ - order_price_type: FuturesTrailingOrderPriceType; + /** Start time (ms). Default: now - 48h */ + start_time?: string | number; + /** End time (ms). Default: now */ + end_time?: string | number; + /** Query id. Default 0 */ + from?: string | number; + /** Page size. Default 10, max 100 */ + limit?: number; + /** prev | next */ + direct?: FuturesDirect; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ -⋮---- -/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ -⋮---- -/** buy or sell */ -⋮---- -/** open, close, both. Hedge mode required; one-way optional, must be both when filled */ +/** Perpetual (e.g. BTC-USDT) or delivery (e.g. BTC-USDT-210625) */ ⋮---- -/** Leverage. Required when open, optional when close */ +/** Start time (ms). Default: now - 48h */ ⋮---- -/** Volume (contracts) */ +/** End time (ms). Default: now */ ⋮---- -/** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ +/** Query id. Default 0 */ ⋮---- -/** Active price */ +/** Page size. Default 10, max 100 */ ⋮---- -/** optimal_5, optimal_10, optimal_20, formula_price */ +/** prev | next */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_track_order. [Cross] Submit a Trailing Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesSubmitCrossTrailingOrderReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Req for GET /v5/market/risk/limit. Get futures risk limit table. */ +export interface FuturesV5MarketRiskLimitReq { contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ - reduce_only?: 0 | 1; - /** buy or sell */ - direction: FuturesDirection; - /** open, close, both. Hedge mode required; one-way optional, must be both when filled */ - offset?: FuturesOffsetBoth; - /** Leverage. Required when open, optional when close */ - lever_rate?: number; - /** Volume (contracts) */ - volume: number | string; - /** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ - callback_rate: number | string; - /** Active price */ - active_price: number | string; - /** optimal_5, optimal_10, optimal_20, formula_price */ - order_price_type: FuturesTrailingOrderPriceType; + margin_mode?: FuturesMarginMode; + tier?: string | number; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ -⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ -⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** + * Coin-M Delivery - Reference Data (FuturesCmDelivery) + */ ⋮---- -/** 0: no, 1: yes. In hedge mode invalid; one-way: 0 when not filled. reduce_only=1 for open triggers error 1492 */ +/** Req for GET /api/v1/contract_adjustfactor. Tiered adjustment factor. Inlined in getCoinMDeliveryAdjustFactor - params?: { symbol?: string } */ +/** Req for GET /api/v1/contract_ladder_margin. Tiered margin. Inlined in getCoinMDeliveryTieredMargin - params?: { symbol?: string } */ ⋮---- -/** buy or sell */ +/** Req for GET /api/v1/contract_his_open_interest. Historical open interest. */ +export interface FuturesCmDeliveryOpenInterestReq { + symbol: string; + contract_type: FuturesContractType; + period: FuturesOpenInterestPeriod; + amount_type: 1 | 2; + size?: number; +} ⋮---- -/** open, close, both. Hedge mode required; one-way optional, must be both when filled */ +/** Req for GET /api/v1/contract_elite_account_ratio. Top trader sentiment - account. Inlined in getCoinMDeliveryAccountRatio - params: { symbol, period } */ +/** Req for GET /api/v1/contract_elite_position_ratio. Top trader sentiment - position. Inlined in getCoinMDeliveryPositionRatio - params: { symbol, period } */ ⋮---- -/** Leverage. Required when open, optional when close */ +/** Req for GET /api/v3/contract_liquidation_orders. Liquidation orders. */ +export interface FuturesCmDeliveryLiquidationOrdersReq { + symbol: string; + trade_type: 0 | 5 | 6; + start_time?: number; + end_time?: number; + direct?: FuturesDirect; + from_id?: number; +} ⋮---- -/** Volume (contracts) */ +/** Req for GET /api/v1/contract_settlement_records. Historical settlement records. */ +export interface FuturesCmDeliverySettlementRecordsReq { + symbol: string; + start_time?: number; + end_time?: number; + page_index?: number; + page_size?: number; +} ⋮---- -/** Callback rate (e.g. 0.01 = 1%). Min 0.001 (0.1%) */ +/** Req for GET /v1/insurance_fund_history. Historical risk reserves. Aligned with getCoinMDeliveryRiskReserveHistory. */ +export interface FuturesCmDeliveryRiskReserveHistoryReq { + start_time?: number; + end_time?: number; + direct?: FuturesDirect; + from_id?: number; + limit?: number; +} ⋮---- -/** Active price */ +/** Req for GET /api/v1/contract_price_limit. Contract price limits. Aligned with getCoinMDeliveryContractLimit. */ +export interface FuturesCmDeliveryContractLimitReq { + symbol?: string; + contract_type?: FuturesContractType; + contract_code?: string; +} ⋮---- -/** optimal_5, optimal_10, optimal_20, formula_price */ +/** Req for GET /api/v1/contract_open_interest. Current open interest. */ +export interface FuturesCmDeliveryContractOpenInterestReq { + symbol?: string; + contract_type?: FuturesContractType; + contract_code?: string; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_track_cancel. [Isolated] Cancel a Trailing Order. Isolated margin only. Trade. 5/s. Inlined in cancelTrailingOrder - params: { contract_code, order_id } */ +/** Req for GET /api/v1/contract_delivery_price. Estimated delivery price. Inlined in getCoinMDeliveryDeliveryPrice - params: { symbol: string } */ +/** Req for GET /api/v1/contract_estimated_settlement_price. Estimated settlement price. Inlined in getCoinMDeliveryEstimatedSettlementPrice - params?: { symbol?: string } */ +/** Req for GET /api/v1/contract_api_state. System status. Inlined in getCoinMDeliverySystemStatus - params?: { symbol?: string } */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_track_cancel. [Cross] Cancel a Trailing Order. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Trade. 5/s. */ -export interface FuturesCancelCrossTrailingOrderReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Req for GET /api/v1/contract_contract_info. Contract info. */ +export interface FuturesCmDeliveryContractInfoReq { + symbol?: string; + contract_type?: FuturesContractType; contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** Trailing order ID(s). Comma-separated, max 10 */ - order_id: string; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ +/** Req for GET /market/depth. Inlined in getCoinMDeliveryMarketDepth - params: { symbol, type } (type: step0–15) */ +/** Req for GET /market/bbo. Inlined in getCoinMDeliveryMarketBbo - params?: { symbol?: string } */ ⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ +/** Req for GET /market/history/kline. Either size or (from+to) required. Aligned with getCoinMDeliveryKlines. */ +export interface FuturesCmDeliveryKlinesReq { + symbol: string; + period: FuturesKlinePeriod; + size?: number; + from?: number; + to?: number; +} ⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ +/** Req for GET /index/market/history/mark_price_kline. Aligned with getCoinMDeliveryMarkKlines. */ +export interface FuturesCmDeliveryMarkPriceKlinesReq { + symbol: string; + period: FuturesKlinePeriod; + size: number; +} ⋮---- -/** Trailing order ID(s). Comma-separated, max 10 */ +/** Req for GET /api/v1/contract_index. Index price. Inlined in getCoinMDeliveryIndexPrice - params?: { symbol?: string } */ +/** Req for GET /api/market/contract_constituents. Index constituents. Inlined in getCoinMDeliveryIndexConstituents - params: { symbol: string } */ +/** Req for GET /api/v1/contract_query_elements. Contract elements. Inlined in getCoinMDeliveryContractElements - params?: { contract_code?: string } */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_track_cancelall. [Isolated] Cancel All Trailing Orders. Isolated margin only. Can fill only one of direction and offset to filter. Trade. 5/s. */ -export interface FuturesCancelAllTrailingOrdersReq { - /** Contract code (e.g. BTC-USDT) */ - contract_code: string; - /** buy or sell; omit for all */ - direction?: FuturesDirection; - /** open or close; omit for all */ - offset?: FuturesOffset; +/** Req for GET /index/market/history/index. Index kline data. */ +export interface FuturesCmDeliveryIndexKlinesReq { + symbol: string; + period: FuturesKlinePeriod; + size: number; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ -⋮---- -/** buy or sell; omit for all */ -⋮---- -/** open or close; omit for all */ -⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_track_cancelall. [Cross] Cancel All Trailing Orders. Cross margin only. One of (pair+contract_type) or contract_code required; contract_code preferred when all filled. Can fill only one of direction and offset to filter. Trade. 5/s. */ -export interface FuturesCancelAllCrossTrailingOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ - contract_code?: string; - /** Pair (e.g. BTC-USDT). Use with contract_type */ - pair?: string; - /** swap, this_week, next_week, quarter, next_quarter */ - contract_type?: string; - /** buy or sell; omit for all */ - direction?: FuturesDirection; - /** open or close; omit for all */ - offset?: FuturesOffset; +/** Req for GET /api/v1/contract_sub_auth_list. getCoinMDeliverySubPermissions. */ +export interface FuturesCmDeliverySubPermissionsReq { + sub_uid?: string; + start_time?: number; + end_time?: number; + direct?: FuturesDirect; + from_id?: number; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625. Preferred when all filled */ -⋮---- -/** Pair (e.g. BTC-USDT). Use with contract_type */ -⋮---- -/** swap, this_week, next_week, quarter, next_quarter */ -⋮---- -/** buy or sell; omit for all */ +/** Req for POST /api/v3/contract_financial_record. Account financial records. */ +export interface FuturesCmDeliveryFinancialRecordReq { + symbol: string; + type?: string; + start_time?: number; + end_time?: number; + direct?: FuturesDirect; + from_id?: number; +} ⋮---- -/** open or close; omit for all */ +/** Req for POST /api/v3/contract_financial_record_exact. Same as contract_financial_record; from_id for pagination. */ +export type FuturesCmDeliveryFinancialRecordExactReq = + FuturesCmDeliveryFinancialRecordReq; ⋮---- -/** Req for POST /linear-swap-api/v1/swap_track_openorders. [Isolated] Current unfilled trailing orders. Isolated margin only. Read. */ -export interface FuturesGetTrailingOpenOrdersReq { - /** Contract code (e.g. BTC-USDT) */ - contract_code: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Page index. Default 1 */ +/** Req for POST /api/v1/contract_user_settlement_records. User settlement records. */ +export interface FuturesCmDeliveryUserSettlementRecordsReq { + symbol: string; + start_time?: number; + end_time?: number; page_index?: number; - /** Page size. Default 20, max 50 */ page_size?: number; } ⋮---- -/** Contract code (e.g. BTC-USDT) */ -⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ -⋮---- -/** Page index. Default 1 */ -⋮---- -/** Page size. Default 20, max 50 */ +/** Req for POST /api/v1/contract_order_limit */ +export interface FuturesCmDeliveryOrderLimitReq { + order_price_type: FuturesCmDeliveryOrderLimitPriceType; + symbol?: string; +} ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_track_openorders. [Cross] Current unfilled trailing orders. Cross margin only. When both filled, contract_code preferred; when none, all open orders. Read. */ -export interface FuturesGetCrossTrailingOpenOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Req for POST /api/v1/contract_order. Place order. Delivery futures. One of contract_code or (symbol+contract_type). */ +export interface FuturesCmDeliverySubmitOrderReq { + /** Contract code (e.g. bch210326). Use if known. */ contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type?: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; + /** Symbol (e.g. BTC, ETH). Case-insensitive. Use with contract_type. */ + symbol?: string; + /** this_week, next_week, quarter, next_quarter. Use with symbol. */ + contract_type?: FuturesContractType; + /** Client order ID [1, 9223372036854775807] */ + client_order_id?: number; + /** Price. Required for limit, post_only, ioc, fok */ + price?: number | string; + /** Order quantity. Required */ + volume: number; + /** buy or sell. Required */ + direction: FuturesDirection; + /** open or close. Required */ + offset: FuturesOffset; + /** Leverage rate. Required */ + lever_rate: number; + /** Order price type. Required */ + order_price_type: FuturesCmDeliverySubmitOrderPriceType; + /** Take-profit trigger price */ + tp_trigger_price?: number | string; + /** Take-profit order price */ + tp_order_price?: number | string; + /** Take-profit order type: limit, optimal_5, optimal_10, optimal_20 */ + tp_order_price_type?: string; + /** Stop-loss trigger price */ + sl_trigger_price?: number | string; + /** Stop-loss order price */ + sl_order_price?: number | string; + /** Stop-loss order type: limit, optimal_5, optimal_10, optimal_20 */ + sl_order_price_type?: string; + /** Price protection when setting tp/sl. Default false. */ + price_protect?: boolean; + /** 0: allow self-trade, 1: prevent. Default 1 */ + self_match_prevent?: 0 | 1; } ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Contract code (e.g. bch210326). Use if known. */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Symbol (e.g. BTC, ETH). Case-insensitive. Use with contract_type. */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +/** this_week, next_week, quarter, next_quarter. Use with symbol. */ ⋮---- -/** Page index. Default 1 */ +/** Client order ID [1, 9223372036854775807] */ ⋮---- -/** Page size. Default 20, max 50 */ +/** Price. Required for limit, post_only, ioc, fok */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_track_hisorders. [Isolated] Get History Trailing Orders. Isolated margin only. Read. */ -export interface FuturesGetTrailingHistoryOrdersReq { - /** Contract code (e.g. BTC-USDT) */ - contract_code: string; - /** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ - status: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Days. Positive integer, max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** create_date or update_time; descending */ - sort_by?: FuturesSortByExtended; -} +/** Order quantity. Required */ ⋮---- -/** Contract code (e.g. BTC-USDT) */ +/** buy or sell. Required */ ⋮---- -/** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ +/** open or close. Required */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +/** Leverage rate. Required */ ⋮---- -/** Days. Positive integer, max 90 */ +/** Order price type. Required */ ⋮---- -/** Page index. Default 1 */ +/** Take-profit trigger price */ ⋮---- -/** Page size. Default 20, max 50 */ +/** Take-profit order price */ ⋮---- -/** create_date or update_time; descending */ +/** Take-profit order type: limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Req for POST /linear-swap-api/v1/swap_cross_track_hisorders. [Cross] Get History Trailing Orders. Cross margin only. One of pair or contract_code required; contract_code preferred when both filled. Read. */ -export interface FuturesGetCrossTrailingHistoryOrdersReq { - /** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ - contract_code?: string; - /** Pair (e.g. BTC-USDT) */ - pair?: string; - /** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ - status: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ - trade_type: 0 | 1 | 2 | 3 | 4 | 17 | 18; - /** Days. Positive integer, max 90 */ - create_date: number; - /** Page index. Default 1 */ - page_index?: number; - /** Page size. Default 20, max 50 */ - page_size?: number; - /** create_date or update_time; descending */ - sort_by?: FuturesSortByExtended; -} +/** Stop-loss trigger price */ ⋮---- -/** Contract code. swap: BTC-USDT; future: BTC-USDT-210625 */ +/** Stop-loss order price */ ⋮---- -/** Pair (e.g. BTC-USDT) */ +/** Stop-loss order type: limit, optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Status: 0: all, 4: submitted success, 5: failed, 6: cancelled. Comma-separated allowed */ +/** Price protection when setting tp/sl. Default false. */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 17: buy(one-way), 18: sell(one-way) */ +/** 0: allow self-trade, 1: prevent. Default 1 */ ⋮---- -/** Days. Positive integer, max 90 */ +/** Req for POST /api/v1/contract_batchorder. Max 25 orders. */ +export interface FuturesCmDeliverySubmitBatchOrderReq { + orders_data: FuturesCmDeliverySubmitOrderReq[]; +} ⋮---- -/** Page index. Default 1 */ +/** Req for POST /api/v1/contract_cancel. One of order_id or client_order_id. Max 10 IDs. Symbol required. */ +export interface FuturesCmDeliveryCancelOrderReq { + symbol: string; + /** Order IDs, comma-separated. Max 10 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 10 */ + client_order_id?: string; +} ⋮---- -/** Page size. Default 20, max 50 */ +/** Order IDs, comma-separated. Max 10 */ ⋮---- -/** create_date or update_time; descending */ +/** Client order IDs, comma-separated. Max 10 */ ⋮---- -/** - * Unified Account - */ +/** Req for POST /api/v1/contract_switch_lever_rate. Inlined in updateCoinMDeliveryLeverage - params: { symbol, lever_rate } */ ⋮---- -/** Req for POST /linear-swap-api/v3/fix_position_margin_change. Adjust margin for isolated positions. Trade. */ -export interface FuturesUpdateUnifiedMarginReq { - /** Adjustment amount */ - amount: number | string; - /** Currency (e.g. USDT) */ - asset: string; - /** Contract code (e.g. BTC-USDT, ETH-USDT) */ - contract_code: string; - /** 1: increase isolated margin; 2: reduce isolated margin */ - type: 1 | 2; - /** 1: buy; 2: sell */ - direction: 1 | 2; - /** Client order ID */ - clientOrderId?: number | string; +/** Req for POST /api/v1/contract_order_info. One of order_id or client_order_id. Max 50 IDs. Symbol required. */ +export interface FuturesCmDeliveryGetOrderInfoReq { + symbol: string; + /** Order IDs, comma-separated. Max 50 */ + order_id?: string; + /** Client order IDs, comma-separated. Max 50 */ + client_order_id?: string; } ⋮---- -/** Adjustment amount */ -⋮---- -/** Currency (e.g. USDT) */ +/** Order IDs, comma-separated. Max 50 */ ⋮---- -/** Contract code (e.g. BTC-USDT, ETH-USDT) */ +/** Client order IDs, comma-separated. Max 50 */ ⋮---- -/** 1: increase isolated margin; 2: reduce isolated margin */ +/** Req for POST /api/v1/contract_order_detail. created_at cannot be 0. */ +export interface FuturesCmDeliveryGetOrderDetailReq { + symbol: string; + order_id: number | string; + created_at: number; + order_type: number; + page_index?: number; + page_size?: number; +} ⋮---- -/** 1: buy; 2: sell */ +/** Req for POST /api/v1/contract_openorders. Omit symbol to query all. */ +export interface FuturesCmDeliveryGetOpenOrdersReq { + symbol?: string; + page_index?: number; + page_size?: number; + sort_by?: FuturesSortBy; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ + trade_type?: 0 | 1 | 2 | 3 | 4; +} ⋮---- -/** Client order ID */ +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ ⋮---- -/** Req for GET /linear-swap-api/v3/fix_position_margin_change_record. Query margin adjustment records of isolated positions. Read. */ -export interface FuturesGetUnifiedMarginAdjustmentsReq { - /** Currency (e.g. USDT) */ - asset: string; - /** Contract code (e.g. BTC-USDT, ETH-USDT) */ - contract_code: string; - /** Query start time (ms). Window max 48h, within 90 days. [(end_time - 48h), end_time] */ +/** Req for POST /api/v3/contract_hisorders. Window max 48h, within 90 days. */ +export interface FuturesCmDeliveryGetHistoryOrdersReq { + symbol: string; + /** 0:all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 5: sell liq, 6: buy liq, 7: delivery long, 8: delivery short, 11: reduce close long, 12: reduce close short */ + trade_type: number; + /** 1: All Orders, 2: Order in Finished Status */ + type: 1 | 2; + /** 0: all, or comma-separated: 3,4,5,6,7 */ + status: string; + contract_code?: string; + order_type?: string; start_time?: number; - /** Query end time (ms). [(present-90d), present] */ end_time?: number; - /** prev: forward query; next: backward query */ direct?: FuturesDirect; - /** prev: min query_id from last result; next: max query_id from last result */ from_id?: number; + limit?: number; } ⋮---- -/** Currency (e.g. USDT) */ -⋮---- -/** Contract code (e.g. BTC-USDT, ETH-USDT) */ -⋮---- -/** Query start time (ms). Window max 48h, within 90 days. [(end_time - 48h), end_time] */ -⋮---- -/** Query end time (ms). [(present-90d), present] */ +/** 0:all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 5: sell liq, 6: buy liq, 7: delivery long, 8: delivery short, 11: reduce close long, 12: reduce close short */ ⋮---- -/** prev: forward query; next: backward query */ +/** 1: All Orders, 2: Order in Finished Status */ ⋮---- -/** prev: min query_id from last result; next: max query_id from last result */ +/** 0: all, or comma-separated: 3,4,5,6,7 */ ⋮---- -/** Req for GET /v5/account/bills. Query financial records. */ -export interface FuturesV5BillsReq { - /** Contract code (e.g. BTC-USDT, ETH-USDT) */ +/** Req for POST /api/v3/contract_hisorders_exact. type filters by trade type. Window max 48h, within 90 days. */ +export interface FuturesCmDeliveryGetHistoryOrdersExactReq { + symbol: string; + /** Same as trade_type */ + trade_type: number; + /** Same values as trade_type (0-12) */ + type: number; + /** 0: all, or comma-separated: 3,4,5,6,7 */ + status: string; contract_code?: string; - /** cross: Cross margin; isolated: Isolated margin */ - margin_mode?: FuturesMarginMode; - /** Financial type; comma-separated for multiple. e.g. 3,4,5,6 */ - type?: string; - /** Start time (ms). Default: now - 48h */ - start_time?: string | number; - /** End time (ms). Default: now */ - end_time?: string | number; - /** Query offset, default 0 */ - from?: number; - /** Page size, default 10, max 100 */ - limit?: number; - /** prev | next */ + order_type?: string; + start_time?: number; + end_time?: number; direct?: FuturesDirect; + from_id?: number; } ⋮---- -/** Contract code (e.g. BTC-USDT, ETH-USDT) */ +/** Same as trade_type */ ⋮---- -/** cross: Cross margin; isolated: Isolated margin */ +/** Same values as trade_type (0-12) */ ⋮---- -/** Financial type; comma-separated for multiple. e.g. 3,4,5,6 */ +/** 0: all, or comma-separated: 3,4,5,6,7 */ ⋮---- -/** Start time (ms). Default: now - 48h */ +/** Req for POST /api/v3/contract_matchresults. Window max 48h, within 90 days. */ +export interface FuturesCmDeliveryGetFillsReq { + symbol: string; + /** Contract code (e.g. BTC-USD) */ + contract: string; + /** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ + trade_type: number; + start_time?: number; + end_time?: number; + direct?: FuturesDirect; + from_id?: number; +} ⋮---- -/** End time (ms). Default: now */ +/** Contract code (e.g. BTC-USD) */ ⋮---- -/** Query offset, default 0 */ +/** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ ⋮---- -/** Page size, default 10, max 100 */ +/** Req for POST /api/v3/contract_matchresults_exact. Within 90 days. */ +export interface FuturesCmDeliveryGetFillsExactReq { + symbol: string; + /** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ + trade_type: number; + contract_code?: string; + start_time?: number; + end_time?: number; + from_id?: number; + /** Default 20, max 50 */ + size?: number; + direct?: FuturesDirect; +} ⋮---- -/** prev | next */ +/** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ ⋮---- -/** Req for POST /v5/trade/cancel_order. Cancel a single order. */ -export interface FuturesV5CancelOrderReq { - contract_code: string; - /** Order ID. One of order_id or client_order_id required */ - order_id?: string; - /** Client order ID. One of order_id or client_order_id required */ - client_order_id?: string; -} +/** Default 20, max 50 */ ⋮---- -/** Order ID. One of order_id or client_order_id required */ +/** Req for POST /api/v1/lightning_close_position. One of contract_code or (symbol+contract_type). */ +export interface FuturesCmDeliverySubmitFlashCloseOrderReq { + volume: number; + direction: FuturesDirection; + contract_code?: string; + symbol?: string; + contract_type?: FuturesContractType; + client_order_id?: number; + /** lightning (default), lightning_fok, lightning_ioc */ + order_price_type?: FuturesLightningOrderPriceTypeCm; +} ⋮---- -/** Client order ID. One of order_id or client_order_id required */ +/** lightning (default), lightning_fok, lightning_ioc */ ⋮---- -/** Req for POST /v5/trade/cancel_batch_orders. Max 10 orders per request. */ -export interface FuturesV5CancelBatchOrdersReq { - contract_code: string; - /** Order IDs. One of order_id or client_order_id required */ - order_id?: string[]; - /** Client order IDs. One of order_id or client_order_id required */ - client_order_id?: string[]; +/** Req for POST /api/v1/contract_trigger_order. One of contract_code or (symbol+contract_type). */ +export interface FuturesCmDeliverySubmitTriggerOrderReq { + trigger_type: FuturesTriggerType; + trigger_price: number | string; + volume: number; + direction: FuturesDirection; + offset: FuturesOffset; + lever_rate: number; + contract_code?: string; + symbol?: string; + contract_type?: FuturesContractType; + order_price?: number | string; + /** limit (default), optimal_5, optimal_10, optimal_20 */ + order_price_type?: FuturesTriggerOrderPriceType; } ⋮---- -/** Order IDs. One of order_id or client_order_id required */ +/** limit (default), optimal_5, optimal_10, optimal_20 */ ⋮---- -/** Client order IDs. One of order_id or client_order_id required */ +/** Req for POST /api/v1/contract_trigger_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTriggerOrder - params: { symbol, order_id } */ ⋮---- -/** Req for POST /v5/trade/cancel_all_orders. Cancel all open orders. */ -export interface FuturesV5CancelAllOrdersReq { +/** Req for POST /api/v1/contract_trigger_cancelall. symbol required. */ +export interface FuturesCmDeliveryCancelAllTriggerOrdersReq { + symbol: string; contract_code?: string; - side?: FuturesDirection; - position_side?: FuturesPositionSide; + contract_type?: FuturesContractType; + direction?: FuturesDirection; + offset?: FuturesOffset; } ⋮---- -/** Req for POST /v5/trade/position. Close all of a symbol at market price. */ -export interface FuturesV5ClosePositionReq { - contract_code: string; - margin_mode: FuturesMarginMode; - position_side: FuturesPositionSide; - client_order_id?: string; +/** Req for POST /api/v1/contract_trigger_openorders. Symbol required. */ +export interface FuturesCmDeliveryGetTriggerOpenOrdersReq { + symbol: string; + contract_code?: string; + page_index?: number; + page_size?: number; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ + trade_type?: 0 | 1 | 2 | 3 | 4; } ⋮---- -/** Req for GET /v5/trade/order/opens. Get unfilled orders. */ -export interface FuturesV5OpenOrdersReq { +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ +⋮---- +/** Req for POST /api/v1/contract_trigger_hisorders. Days within 90. */ +export interface FuturesCmDeliveryGetTriggerHistoryOrdersReq { + symbol: string; + /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long */ + trade_type: 0 | 1 | 2 | 3 | 4; + /** 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated for multiple */ + status: string; + /** Days to query. Within 90. */ + create_date: number; contract_code?: string; - margin_mode?: FuturesMarginMode; - order_id?: string; - client_order_id?: string; - from?: number; - limit?: number; - direct?: FuturesDirect; + page_index?: number; + page_size?: number; + sort_by?: FuturesSortBy; } ⋮---- -/** Req for GET /v5/trade/order/details. Execution details (last 3 days). */ -export interface FuturesV5OrderDetailsReq { +/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long */ +⋮---- +/** 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated for multiple */ +⋮---- +/** Days to query. Within 90. */ +⋮---- +/** Req for POST /api/v1/contract_tpsl_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTpslOrder - params: { symbol, order_id } */ +⋮---- +/** Req for POST /api/v1/contract_tpsl_cancelall. One of: symbol, contract_code, or (symbol+contract_type). */ +export interface FuturesCmDeliveryCancelAllTpslOrdersReq { + symbol?: string; contract_code?: string; - order_id?: string; - start_time?: string | number; - end_time?: string | number; - from?: number; - limit?: number; - direct?: FuturesDirect; + contract_type?: FuturesContractType; + direction?: FuturesDirection; } ⋮---- -/** Req for GET /v5/trade/order/history. Get order history. */ -export interface FuturesV5OrderHistoryReq { - contract_code: string; - margin_mode: FuturesMarginMode; - state?: string; - type?: FuturesV5OrderType; - price_match?: string; - start_time?: string | number; - end_time?: string | number; - from?: number; - limit?: number; - direct?: FuturesDirect; +/** Req for POST /api/v1/contract_tpsl_openorders. Symbol required. */ +export interface FuturesCmDeliveryGetTpslOpenOrdersReq { + symbol: string; + contract_code?: string; + page_index?: number; + page_size?: number; + /** 0: all, 3: buy short, 4: sell long */ + trade_type?: 0 | 3 | 4; } ⋮---- -/** Req for GET /v5/trade/order. Get single order info. */ -export interface FuturesV5OrderInfoReq { - contract_code: string; - margin_mode?: FuturesMarginMode; - order_id?: string; - client_order_id?: string; -} +/** 0: all, 3: buy short, 4: sell long */ ⋮---- -/** Req for POST /v5/trade/cancel-after. Automatic order cancellation (Dead Man's Switch). */ -export interface FuturesV5CancelAfterReq { - on_off: '0' | '1'; - time_out?: number | string; -} -⋮---- -/** Req for POST /v5/trade/order. Place a single order. */ -export interface FuturesV5SubmitOrderReq { +/** Req for POST /api/v1/contract_tpsl_hisorders. Days within 90. */ +export interface FuturesCmDeliveryGetTpslHistoryOrdersReq { + symbol: string; contract_code: string; - margin_mode: FuturesMarginMode; - side: FuturesDirection; - type: FuturesV5OrderType; - volume: string; - position_side?: FuturesPositionSide; - price_match?: FuturesPriceMatch; - client_order_id?: string; - price?: string | number; - reduce_only?: 0 | 1; - time_in_force?: FuturesTimeInForce; - tp_trigger_price?: string; - tp_order_price?: string; - tp_type?: FuturesTriggerOrderPriceType | 'market'; - tp_trigger_price_type?: FuturesTriggerPriceType; - sl_trigger_price?: string; - sl_order_price?: string; - sl_type?: FuturesTriggerOrderPriceType | 'market'; - sl_trigger_price_type?: FuturesTriggerPriceType; - price_protect?: boolean; - self_match_prevent?: FuturesSelfMatchPrevent; + /** 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated for multiple */ + status: string; + /** Days to query. Within 90. */ + create_date: number; + page_index?: number; + page_size?: number; + sort_by?: FuturesSortBy; } ⋮---- -/** - * USDT Margined Futures Multi Asset - Positions (v5 API) - */ -⋮---- -/** Req for GET /v5/trade/position/opens. Get current positions. Inlined in getMultiAssetPositions - params?: { contract_code? } */ +/** 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated for multiple */ ⋮---- -/** Req for GET /v5/position/lever. Get leverage list. */ -export interface FuturesV5LeverListReq { - contract_code?: string; - margin_mode?: FuturesMarginMode; - position_side?: FuturesPositionSide; -} +/** Days to query. Within 90. */ ⋮---- -/** Req for POST /v5/position/lever. Set leverage. */ -export interface FuturesV5SetLeverageReq { - contract_code: string; - margin_mode: FuturesMarginMode; - lever_rate: string | number; - /** Required when isolated margin in two-way position mode */ - position_side?: FuturesPositionSide; -} +/** Req for POST /api/v1/contract_relation_tpsl_order. TPSL orders related to position-opening order. Inlined in getCoinMDeliveryRelationTpslOrder - params: { symbol, order_id } */ ⋮---- -/** Required when isolated margin in two-way position mode */ +/** Req for POST /api/v1/contract_track_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTrailingOrder - params: { symbol, order_id } */ ⋮---- -/** Req for POST /v5/position/mode. Set position mode. Inlined in updateMultiAssetPositionMode - params: { position_mode } */ +/** Req for POST /api/v1/contract_track_cancelall. symbol required. */ +export interface FuturesCmDeliveryCancelAllTrailingOrdersReq { + symbol: string; + contract_code?: string; + contract_type?: FuturesContractType; + direction?: FuturesDirection; + offset?: FuturesOffset; +} ⋮---- -/** Req for GET /v5/position/risk/limit. Get current position risk limit. */ -export interface FuturesV5RiskLimitReq { +/** Req for POST /api/v1/contract_track_openorders. Symbol required. */ +export interface FuturesCmDeliveryGetTrailingOpenOrdersReq { + symbol: string; contract_code?: string; - margin_mode?: FuturesMarginMode; - position_side?: FuturesPositionSide; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ + trade_type?: 0 | 1 | 2 | 3 | 4; + page_index?: number; + page_size?: number; } ⋮---- -/** Req for GET /v5/position/risk/limit_tier. Query risk limit tiers. Inlined in getMultiAssetRiskLimitTiers - params: { contract_code, margin_mode? } */ +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ ⋮---- -/** Req for POST /v5/position/margin. Adjust margin for isolated positions. */ -export interface FuturesV5AdjustMarginReq { - contract_code: string; - position_side: FuturesPositionSide; - type: FuturesMarginAdjustType; - amount: string; - currency?: string; +/** Req for POST /api/v1/contract_track_hisorders. Days within 90. */ +export interface FuturesCmDeliveryGetTrailingHistoryOrdersReq { + symbol: string; + /** 0: all, 4: success, 5: failed, 6: cancelled. Comma-separated for multiple */ + status: string; + /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ + trade_type: 0 | 1 | 2 | 3 | 4; + /** Days to query. Within 90. */ + create_date: number; + contract_code?: string; + page_index?: number; + page_size?: number; + sort_by?: FuturesSortBy; } ⋮---- -/** V5 algo order type */ -export type FuturesV5AlgoOrderType = - | 'tp' - | 'sl' - | 'tp_sl' - | 'tpsl' - | 'trigger' - | 'trailing_stop'; -⋮---- -/** V5 algo trigger price type */ -export type FuturesV5AlgoTriggerPriceType = 'last' | 'mark' | 'index'; +/** 0: all, 4: success, 5: failed, 6: cancelled. Comma-separated for multiple */ ⋮---- -/** V5 algo TP/SL order type */ -export type FuturesV5AlgoTpSlType = - | 'market' - | 'limit' - | 'optimal_5' - | 'optimal_10' - | 'optimal_20'; +/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ ⋮---- -/** Req for POST /v5/algo/order. Place an algo order. */ -export interface FuturesV5SubmitAlgoOrderReq { - contract_code: string; - type: FuturesV5AlgoOrderType; - position_side: FuturesPositionSide; - side: FuturesDirection; - margin_mode: FuturesMarginMode; - algo_client_order_id?: string; - volume?: string; - tp_trigger_price?: string; - tp_order_price?: string; - tp_type?: FuturesV5AlgoTpSlType; - tp_trigger_price_type?: FuturesV5AlgoTriggerPriceType; - sl_trigger_price?: string; - sl_order_price?: string; - sl_type?: FuturesV5AlgoTpSlType; - sl_trigger_price_type?: FuturesV5AlgoTriggerPriceType; - price?: string; - price_type?: 'optimal_5' | 'optimal_10' | 'optimal_20'; - trigger_price?: string; - trigger_price_type?: FuturesV5AlgoTriggerPriceType; - activation_price?: string; - active_price?: string; - order_price_type?: - | 'optimal_5' - | 'optimal_10' - | 'optimal_20' - | 'trailing_mark'; - callback_rate?: string; - reduce_only?: boolean; -} +/** Days to query. Within 90. */ ⋮---- -/** Req for POST /v5/algo/cancel_orders. Cancel unfilled algo orders. Max 10 per request. */ -export interface FuturesV5CancelAlgoOrderReq { - contract_code: string; - algo_id?: string; - algo_client_order_id?: string; +/** Req for POST /api/v1/contract_track_order. One of contract_code or (symbol+contract_type). lever_rate required when offset=open. */ +export interface FuturesCmDeliverySubmitTrailingOrderReq { + direction: FuturesDirection; + offset: FuturesOffset; + volume: number; + callback_rate: number; + active_price: number | string; + /** optimal_5, optimal_10, optimal_20, formula_price */ + order_price_type: FuturesTrailingOrderPriceType; + contract_code?: string; + symbol?: string; + contract_type?: FuturesContractType; + lever_rate?: number; } ⋮---- -/** Req for GET /v5/algo/order. Query one algo order. */ -export interface FuturesV5AlgoOrderInfoReq { - type: FuturesV5AlgoOrderType; - algo_id?: string; - algo_client_order_id?: string; -} +/** optimal_5, optimal_10, optimal_20, formula_price */ ⋮---- -/** Req for GET /v5/algo/order/opens. Untriggered algo orders. */ -export interface FuturesV5AlgoOpenOrdersReq { - type: FuturesV5AlgoOrderType; +/** Req for POST /api/v1/contract_tpsl_order. One of contract_code or (symbol+contract_type). At least one of tp or sl required. */ +export interface FuturesCmDeliverySubmitTpslOrderReq { + direction: FuturesDirection; + volume: number; contract_code?: string; - algo_id?: string; - algo_client_order_id?: string; - from?: number | string; - limit?: number; - direct?: FuturesDirect; + symbol?: string; + contract_type?: FuturesContractType; + tp_trigger_price?: number | string; + tp_order_price?: number | string; + tp_order_price_type?: FuturesTriggerOrderPriceType; + sl_trigger_price?: number | string; + sl_order_price?: number | string; + sl_order_price_type?: FuturesTriggerOrderPriceType; + price_protect?: boolean; } ⋮---- -/** Req for GET /v5/algo/order/history. Algo order history. */ -export interface FuturesV5AlgoOrderHistoryReq { - type: FuturesV5AlgoOrderType; +/** Req for POST /api/v1/contract_cancelall. One of: symbol, contract_code, or (symbol+contract_type). */ +export interface FuturesCmDeliveryCancelAllOrdersReq { + /** Symbol (e.g. BTC). Cancel all contracts of this symbol. */ + symbol?: string; + /** Contract code (e.g. btc200925). Cancel orders for this contract. */ contract_code?: string; - margin_mode?: FuturesMarginMode; - states?: string; - start_time?: string | number; - end_time?: string | number; - from?: number | string; - limit?: number; - direct?: FuturesDirect; + /** this_week, next_week, quarter, next_quarter. Use with symbol. */ + contract_type?: FuturesContractType; + /** buy or sell. Omit for all */ + direction?: FuturesDirection; + /** open or close. Omit for all */ + offset?: FuturesOffset; } ⋮---- -/** - * USDT Margined Futures Multi Asset - Basic Information (v5 API) - */ +/** Symbol (e.g. BTC). Cancel all contracts of this symbol. */ ⋮---- -/** Req for GET /v5/market/risk/limit. Get futures risk limit table. */ -export interface FuturesV5MarketRiskLimitReq { - contract_code?: string; - margin_mode?: FuturesMarginMode; - tier?: string | number; -} +/** Contract code (e.g. btc200925). Cancel orders for this contract. */ ⋮---- -/** - * Coin-M Delivery - Reference Data (FuturesCmDelivery) - */ +/** this_week, next_week, quarter, next_quarter. Use with symbol. */ ⋮---- -/** Req for GET /api/v1/contract_adjustfactor. Tiered adjustment factor. Inlined in getCoinMDeliveryAdjustFactor - params?: { symbol?: string } */ -/** Req for GET /api/v1/contract_ladder_margin. Tiered margin. Inlined in getCoinMDeliveryTieredMargin - params?: { symbol?: string } */ +/** buy or sell. Omit for all */ ⋮---- -/** Req for GET /api/v1/contract_his_open_interest. Historical open interest. */ -export interface FuturesCmDeliveryOpenInterestReq { +/** open or close. Omit for all */ +⋮---- +/** Req for POST /api/v1/contract_master_sub_transfer_record */ +export interface FuturesCmDeliveryMasterSubTransferRecordReq { symbol: string; - contract_type: FuturesContractType; - period: FuturesOpenInterestPeriod; - amount_type: 1 | 2; - size?: number; + transfer_type?: string; + create_date: number; + page_index?: number; + page_size?: number; } ⋮---- -/** Req for GET /api/v1/contract_elite_account_ratio. Top trader sentiment - account. Inlined in getCoinMDeliveryAccountRatio - params: { symbol, period } */ -/** Req for GET /api/v1/contract_elite_position_ratio. Top trader sentiment - position. Inlined in getCoinMDeliveryPositionRatio - params: { symbol, period } */ -⋮---- -/** Req for GET /api/v3/contract_liquidation_orders. Liquidation orders. */ -export interface FuturesCmDeliveryLiquidationOrdersReq { +/** Req for POST /api/v1/contract_master_sub_transfer */ +export interface FuturesCmDeliveryMasterSubTransferReq { + sub_uid: number; symbol: string; - trade_type: 0 | 5 | 6; - start_time?: number; - end_time?: number; - direct?: FuturesDirect; - from_id?: number; + amount: number | string; + type: FuturesTransferType; + client_order_id?: number; } ⋮---- -/** Req for GET /api/v1/contract_settlement_records. Historical settlement records. */ -export interface FuturesCmDeliverySettlementRecordsReq { - symbol: string; - start_time?: number; - end_time?: number; +/** Req for POST /api/v1/contract_sub_account_info_list. Batch of sub-account assets with pagination. */ +export interface FuturesCmDeliverySubAccountInfoListReq { + symbol?: string; page_index?: number; page_size?: number; } ⋮---- -/** Req for GET /v1/insurance_fund_history. Historical risk reserves. Aligned with getCoinMDeliveryRiskReserveHistory. */ -export interface FuturesCmDeliveryRiskReserveHistoryReq { - start_time?: number; - end_time?: number; +/** Req for POST /api/v1/contract_sub_account_list. Sub-account assets. */ +export interface FuturesCmDeliverySubAccountListReq { + symbol?: string; direct?: FuturesDirect; from_id?: number; - limit?: number; -} -⋮---- -/** Req for GET /api/v1/contract_price_limit. Contract price limits. Aligned with getCoinMDeliveryContractLimit. */ -export interface FuturesCmDeliveryContractLimitReq { - symbol?: string; - contract_type?: FuturesContractType; - contract_code?: string; -} -⋮---- -/** Req for GET /api/v1/contract_open_interest. Current open interest. */ -export interface FuturesCmDeliveryContractOpenInterestReq { - symbol?: string; - contract_type?: FuturesContractType; - contract_code?: string; -} -⋮---- -/** Req for GET /api/v1/contract_delivery_price. Estimated delivery price. Inlined in getCoinMDeliveryDeliveryPrice - params: { symbol: string } */ -/** Req for GET /api/v1/contract_estimated_settlement_price. Estimated settlement price. Inlined in getCoinMDeliveryEstimatedSettlementPrice - params?: { symbol?: string } */ -/** Req for GET /api/v1/contract_api_state. System status. Inlined in getCoinMDeliverySystemStatus - params?: { symbol?: string } */ -⋮---- -/** Req for GET /api/v1/contract_contract_info. Contract info. */ -export interface FuturesCmDeliveryContractInfoReq { - symbol?: string; - contract_type?: FuturesContractType; - contract_code?: string; -} -⋮---- -/** Req for GET /market/depth. Inlined in getCoinMDeliveryMarketDepth - params: { symbol, type } (type: step0–15) */ -/** Req for GET /market/bbo. Inlined in getCoinMDeliveryMarketBbo - params?: { symbol?: string } */ -⋮---- -/** Req for GET /market/history/kline. Either size or (from+to) required. Aligned with getCoinMDeliveryKlines. */ -export interface FuturesCmDeliveryKlinesReq { - symbol: string; - period: FuturesKlinePeriod; - size?: number; - from?: number; - to?: number; -} -⋮---- -/** Req for GET /index/market/history/mark_price_kline. Aligned with getCoinMDeliveryMarkKlines. */ -export interface FuturesCmDeliveryMarkPriceKlinesReq { - symbol: string; - period: FuturesKlinePeriod; - size: number; } ⋮---- -/** Req for GET /api/v1/contract_index. Index price. Inlined in getCoinMDeliveryIndexPrice - params?: { symbol?: string } */ -/** Req for GET /api/market/contract_constituents. Index constituents. Inlined in getCoinMDeliveryIndexConstituents - params: { symbol: string } */ -/** Req for GET /api/v1/contract_query_elements. Contract elements. Inlined in getCoinMDeliveryContractElements - params?: { contract_code?: string } */ -⋮---- -/** Req for GET /index/market/history/index. Index kline data. */ -export interface FuturesCmDeliveryIndexKlinesReq { +/** Req for GET /index/market/history/basis. Basis (contract - index) data. */ +export interface FuturesCmDeliveryBasisDataReq { symbol: string; period: FuturesKlinePeriod; size: number; + basis_price_type?: FuturesBasisPriceType; } ⋮---- -/** Req for GET /api/v1/contract_sub_auth_list. getCoinMDeliverySubPermissions. */ -export interface FuturesCmDeliverySubPermissionsReq { - sub_uid?: string; +/** Req for GET /v1/insurance_fund_history (CMPerp). Historical risk reserves. */ +export interface FuturesCmPerpRiskReserveHistoryReq { start_time?: number; end_time?: number; direct?: FuturesDirect; from_id?: number; + limit?: number; } ⋮---- -/** Req for POST /api/v3/contract_financial_record. Account financial records. */ -export interface FuturesCmDeliveryFinancialRecordReq { - symbol: string; - type?: string; - start_time?: number; - end_time?: number; +/** Req for POST /swap-api/v1/swap_sub_account_list */ +export interface FuturesCmPerpSubAccountsReq { + contract_code?: string; direct?: FuturesDirect; from_id?: number; } ⋮---- -/** Req for POST /api/v3/contract_financial_record_exact. Same as contract_financial_record; from_id for pagination. */ -export type FuturesCmDeliveryFinancialRecordExactReq = - FuturesCmDeliveryFinancialRecordReq; -⋮---- -/** Req for POST /api/v1/contract_user_settlement_records. User settlement records. */ -export interface FuturesCmDeliveryUserSettlementRecordsReq { - symbol: string; - start_time?: number; - end_time?: number; +/** Req for POST /swap-api/v1/swap_sub_account_info_list */ +export interface FuturesCmPerpSubAccountsAssetsReq { + contract_code?: string; page_index?: number; page_size?: number; } ⋮---- -/** Req for POST /api/v1/contract_order_limit */ -export interface FuturesCmDeliveryOrderLimitReq { - order_price_type: FuturesCmDeliveryOrderLimitPriceType; - symbol?: string; +/** Req for POST /swap-api/v1/swap_order_limit */ +export interface FuturesCmPerpOrderLimitReq { + contract_code?: string; + order_price_type: string; } ⋮---- -/** Req for POST /api/v1/contract_order. Place order. Delivery futures. One of contract_code or (symbol+contract_type). */ -export interface FuturesCmDeliverySubmitOrderReq { - /** Contract code (e.g. bch210326). Use if known. */ - contract_code?: string; - /** Symbol (e.g. BTC, ETH). Case-insensitive. Use with contract_type. */ - symbol?: string; - /** this_week, next_week, quarter, next_quarter. Use with symbol. */ - contract_type?: FuturesContractType; - /** Client order ID [1, 9223372036854775807] */ - client_order_id?: number; - /** Price. Required for limit, post_only, ioc, fok */ - price?: number | string; - /** Order quantity. Required */ - volume: number; - /** buy or sell. Required */ +/** Req for POST /swap-api/v1/swap_cancel_after. Dead Man's Switch: auto-cancel pending orders if not refreshed. Inlined in setCoinMPerpCancelAfter - params: { on_off: 0|1, time_out? } */ +⋮---- +/** Req for POST /swap-api/v1/swap_order. Place order (CMPerp). */ +export interface FuturesCmPerpSubmitOrderReq { + contract_code: string; direction: FuturesDirection; - /** open or close. Required */ offset: FuturesOffset; - /** Leverage rate. Required */ + volume: number; lever_rate: number; - /** Order price type. Required */ - order_price_type: FuturesCmDeliverySubmitOrderPriceType; - /** Take-profit trigger price */ + order_price_type: FuturesCmPerpSubmitOrderPriceType; + price?: number | string; + client_order_id?: number; tp_trigger_price?: number | string; - /** Take-profit order price */ tp_order_price?: number | string; - /** Take-profit order type: limit, optimal_5, optimal_10, optimal_20 */ tp_order_price_type?: string; - /** Stop-loss trigger price */ sl_trigger_price?: number | string; - /** Stop-loss order price */ sl_order_price?: number | string; - /** Stop-loss order type: limit, optimal_5, optimal_10, optimal_20 */ sl_order_price_type?: string; - /** Price protection when setting tp/sl. Default false. */ price_protect?: boolean; - /** 0: allow self-trade, 1: prevent. Default 1 */ self_match_prevent?: 0 | 1; } ⋮---- -/** Contract code (e.g. bch210326). Use if known. */ -⋮---- -/** Symbol (e.g. BTC, ETH). Case-insensitive. Use with contract_type. */ -⋮---- -/** this_week, next_week, quarter, next_quarter. Use with symbol. */ -⋮---- -/** Client order ID [1, 9223372036854775807] */ -⋮---- -/** Price. Required for limit, post_only, ioc, fok */ -⋮---- -/** Order quantity. Required */ -⋮---- -/** buy or sell. Required */ -⋮---- -/** open or close. Required */ -⋮---- -/** Leverage rate. Required */ -⋮---- -/** Order price type. Required */ -⋮---- -/** Take-profit trigger price */ -⋮---- -/** Take-profit order price */ -⋮---- -/** Take-profit order type: limit, optimal_5, optimal_10, optimal_20 */ -⋮---- -/** Stop-loss trigger price */ -⋮---- -/** Stop-loss order price */ -⋮---- -/** Stop-loss order type: limit, optimal_5, optimal_10, optimal_20 */ -⋮---- -/** Price protection when setting tp/sl. Default false. */ -⋮---- -/** 0: allow self-trade, 1: prevent. Default 1 */ -⋮---- -/** Req for POST /api/v1/contract_batchorder. Max 25 orders. */ -export interface FuturesCmDeliverySubmitBatchOrderReq { - orders_data: FuturesCmDeliverySubmitOrderReq[]; +/** Req for POST /swap-api/v1/swap_batchorder. Max 25 orders (CMPerp). */ +export interface FuturesCmPerpSubmitBatchOrderReq { + orders_data: FuturesCmPerpSubmitOrderReq[]; } ⋮---- -/** Req for POST /api/v1/contract_cancel. One of order_id or client_order_id. Max 10 IDs. Symbol required. */ -export interface FuturesCmDeliveryCancelOrderReq { - symbol: string; - /** Order IDs, comma-separated. Max 10 */ +/** Req for cancelCoinMPerpOrder. One of order_id or client_order_id required. Max 10. */ +export interface FuturesCmPerpCancelOrderReq { + contract_code: string; order_id?: string; - /** Client order IDs, comma-separated. Max 10 */ client_order_id?: string; } ⋮---- -/** Order IDs, comma-separated. Max 10 */ -⋮---- -/** Client order IDs, comma-separated. Max 10 */ +/** Req for cancelCoinMPerpAllOrders. Optional direction/offset filter. */ +export interface FuturesCmPerpCancelAllOrdersReq { + contract_code: string; + direction?: FuturesDirection; + offset?: FuturesOffset; +} ⋮---- -/** Req for POST /api/v1/contract_switch_lever_rate. Inlined in updateCoinMDeliveryLeverage - params: { symbol, lever_rate } */ +/** Req for updateCoinMPerpLeverage. Rate limit 1/3s. Inlined in updateCoinMPerpLeverage - params: { contract_code, lever_rate } */ ⋮---- -/** Req for POST /api/v1/contract_order_info. One of order_id or client_order_id. Max 50 IDs. Symbol required. */ -export interface FuturesCmDeliveryGetOrderInfoReq { - symbol: string; - /** Order IDs, comma-separated. Max 50 */ +/** Req for getCoinMPerpOrderInfo. One of order_id or client_order_id required. Max 50. */ +export interface FuturesCmPerpOrderInfoReq { + contract_code: string; order_id?: string; - /** Client order IDs, comma-separated. Max 50 */ client_order_id?: string; } ⋮---- -/** Order IDs, comma-separated. Max 50 */ -⋮---- -/** Client order IDs, comma-separated. Max 50 */ -⋮---- -/** Req for POST /api/v1/contract_order_detail. created_at cannot be 0. */ -export interface FuturesCmDeliveryGetOrderDetailReq { - symbol: string; +/** Req for getCoinMPerpOrderDetail. created_at improves query performance, cannot be 0. */ +export interface FuturesCmPerpOrderDetailReq { + contract_code: string; order_id: number | string; - created_at: number; - order_type: number; + created_at?: number; + order_type?: number; page_index?: number; page_size?: number; } ⋮---- -/** Req for POST /api/v1/contract_openorders. Omit symbol to query all. */ -export interface FuturesCmDeliveryGetOpenOrdersReq { - symbol?: string; +/** Req for getCoinMPerpOpenOrders. Omit contract_code for all. */ +export interface FuturesCmPerpOpenOrdersReq { + contract_code?: string; page_index?: number; page_size?: number; sort_by?: FuturesSortBy; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ trade_type?: 0 | 1 | 2 | 3 | 4; } ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ -⋮---- -/** Req for POST /api/v3/contract_hisorders. Window max 48h, within 90 days. */ -export interface FuturesCmDeliveryGetHistoryOrdersReq { - symbol: string; - /** 0:all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 5: sell liq, 6: buy liq, 7: delivery long, 8: delivery short, 11: reduce close long, 12: reduce close short */ - trade_type: number; - /** 1: All Orders, 2: Order in Finished Status */ - type: 1 | 2; - /** 0: all, or comma-separated: 3,4,5,6,7 */ - status: string; - contract_code?: string; - order_type?: string; +/** Req for getCoinMPerpHistoryOrders. contract required. Window max 48h, within 90d. Cancel info: last 2h. */ +export interface FuturesCmPerpHistoryOrdersReq { + contract: string; + /** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long, 5:sell liq, 6:buy liq, 7:Delivery long, 8:Delivery short, 11:reduce close long, 12:reduce close short */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12; + /** 1:All Orders, 2:Order in Finished Status */ + type: 1 | 2; + /** 0:all, or comma-separated e.g. "3,4,5" */ + status: string; start_time?: number; end_time?: number; direct?: FuturesDirect; from_id?: number; - limit?: number; } ⋮---- -/** 0:all, 1: buy long, 2: sell short, 3: buy short, 4: sell long, 5: sell liq, 6: buy liq, 7: delivery long, 8: delivery short, 11: reduce close long, 12: reduce close short */ +/** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long, 5:sell liq, 6:buy liq, 7:Delivery long, 8:Delivery short, 11:reduce close long, 12:reduce close short */ ⋮---- -/** 1: All Orders, 2: Order in Finished Status */ +/** 1:All Orders, 2:Order in Finished Status */ ⋮---- -/** 0: all, or comma-separated: 3,4,5,6,7 */ +/** 0:all, or comma-separated e.g. "3,4,5" */ ⋮---- -/** Req for POST /api/v3/contract_hisorders_exact. type filters by trade type. Window max 48h, within 90 days. */ -export interface FuturesCmDeliveryGetHistoryOrdersExactReq { - symbol: string; - /** Same as trade_type */ - trade_type: number; - /** Same values as trade_type (0-12) */ - type: number; - /** 0: all, or comma-separated: 3,4,5,6,7 */ +/** Req for getCoinMPerpHistoryOrdersExact. Same as HistoryOrdersReq + price_type filter. */ +export interface FuturesCmPerpHistoryOrdersExactReq { + contract: string; + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12; + type: 1 | 2; status: string; - contract_code?: string; - order_type?: string; + price_type?: string; start_time?: number; end_time?: number; direct?: FuturesDirect; from_id?: number; } ⋮---- -/** Same as trade_type */ -⋮---- -/** Same values as trade_type (0-12) */ -⋮---- -/** 0: all, or comma-separated: 3,4,5,6,7 */ -⋮---- -/** Req for POST /api/v3/contract_matchresults. Window max 48h, within 90 days. */ -export interface FuturesCmDeliveryGetFillsReq { - symbol: string; - /** Contract code (e.g. BTC-USD) */ +/** Req for getCoinMPerpFills. Window max 48h, within 90d. */ +export interface FuturesCmPerpFillsReq { contract: string; - /** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ - trade_type: number; + /** 0:All, 1:Open long, 2:Open short, 3:Close short, 4:Close long, 5:Liquidate long, 6:Liquidate short */ + trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6; start_time?: number; end_time?: number; direct?: FuturesDirect; from_id?: number; } ⋮---- -/** Contract code (e.g. BTC-USD) */ -⋮---- -/** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ -⋮---- -/** Req for POST /api/v3/contract_matchresults_exact. Within 90 days. */ -export interface FuturesCmDeliveryGetFillsExactReq { - symbol: string; - /** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ - trade_type: number; - contract_code?: string; - start_time?: number; - end_time?: number; - from_id?: number; - /** Default 20, max 50 */ - size?: number; - direct?: FuturesDirect; -} -⋮---- -/** 0: all, 1: open long, 2: open short, 3: close short, 4: close long, 5: liq long, 6: liq short */ +/** 0:All, 1:Open long, 2:Open short, 3:Close short, 4:Close long, 5:Liquidate long, 6:Liquidate short */ ⋮---- -/** Default 20, max 50 */ +/** Req for getCoinMPerpFillsExact. Same params as FillsReq. */ +export type FuturesCmPerpFillsExactReq = FuturesCmPerpFillsReq; ⋮---- -/** Req for POST /api/v1/lightning_close_position. One of contract_code or (symbol+contract_type). */ -export interface FuturesCmDeliverySubmitFlashCloseOrderReq { +/** Req for submitCoinMPerpLightningClose. Lightning close = rival price + optimal 30 levels; unfilled becomes limit. */ +export interface FuturesCmPerpLightningCloseReq { + contract_code: string; volume: number; direction: FuturesDirection; - contract_code?: string; - symbol?: string; - contract_type?: FuturesContractType; client_order_id?: number; - /** lightning (default), lightning_fok, lightning_ioc */ order_price_type?: FuturesLightningOrderPriceTypeCm; } ⋮---- -/** lightning (default), lightning_fok, lightning_ioc */ -⋮---- -/** Req for POST /api/v1/contract_trigger_order. One of contract_code or (symbol+contract_type). */ -export interface FuturesCmDeliverySubmitTriggerOrderReq { +/** Req for submitCoinMPerpTriggerOrder. Rate limit 5/s. */ +export interface FuturesCmPerpTriggerOrderReq { + contract_code: string; trigger_type: FuturesTriggerType; trigger_price: number | string; + order_price?: number | string; + order_price_type?: FuturesTriggerOrderPriceType; volume: number; direction: FuturesDirection; offset: FuturesOffset; - lever_rate: number; - contract_code?: string; - symbol?: string; - contract_type?: FuturesContractType; - order_price?: number | string; - /** limit (default), optimal_5, optimal_10, optimal_20 */ - order_price_type?: FuturesTriggerOrderPriceType; + lever_rate?: number; } ⋮---- -/** limit (default), optimal_5, optimal_10, optimal_20 */ -⋮---- -/** Req for POST /api/v1/contract_trigger_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTriggerOrder - params: { symbol, order_id } */ +/** Req for cancelCoinMPerpTriggerOrder. Max 10 order_ids. Rate limit 5/s. Inlined in cancelCoinMPerpTriggerOrder - params: { contract_code, order_id } */ ⋮---- -/** Req for POST /api/v1/contract_trigger_cancelall. symbol required. */ -export interface FuturesCmDeliveryCancelAllTriggerOrdersReq { - symbol: string; - contract_code?: string; - contract_type?: FuturesContractType; +/** Req for cancelCoinMPerpAllTriggerOrders. Optional direction/offset filter. Rate limit 5/s. */ +export interface FuturesCmPerpCancelAllTriggerOrdersReq { + contract_code: string; direction?: FuturesDirection; offset?: FuturesOffset; } ⋮---- -/** Req for POST /api/v1/contract_trigger_openorders. Symbol required. */ -export interface FuturesCmDeliveryGetTriggerOpenOrdersReq { - symbol: string; - contract_code?: string; +/** Req for getCoinMPerpTriggerOpenOrders. */ +export interface FuturesCmPerpTriggerOpenOrdersReq { + contract_code: string; page_index?: number; page_size?: number; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ trade_type?: 0 | 1 | 2 | 3 | 4; } ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ -⋮---- -/** Req for POST /api/v1/contract_trigger_hisorders. Days within 90. */ -export interface FuturesCmDeliveryGetTriggerHistoryOrdersReq { - symbol: string; - /** 0: all, 1: open long, 2: close short, 3: open short, 4: close long */ +/** Req for getCoinMPerpTriggerHistoryOrders. create_date: days, max 90. Default query completed (status 4,5,6). */ +export interface FuturesCmPerpTriggerHistoryOrdersReq { + contract_code: string; + /** 0:All, 1:Open Long, 2:Close Short, 3:Open Short, 4:Close Long */ trade_type: 0 | 1 | 2 | 3 | 4; - /** 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated for multiple */ + /** 0:all, 4:submitted, 5:failed, 6:cancelled. Comma-separated allowed */ status: string; - /** Days to query. Within 90. */ create_date: number; - contract_code?: string; page_index?: number; page_size?: number; sort_by?: FuturesSortBy; } ⋮---- -/** 0: all, 1: open long, 2: close short, 3: open short, 4: close long */ +/** 0:All, 1:Open Long, 2:Close Short, 3:Open Short, 4:Close Long */ ⋮---- -/** 0: all, 4: submitted, 5: failed, 6: cancelled. Comma-separated for multiple */ +/** 0:all, 4:submitted, 5:failed, 6:cancelled. Comma-separated allowed */ ⋮---- -/** Days to query. Within 90. */ +/** Req for submitCoinMPerpTpslOrder. At least one of tp_trigger_price or sl_trigger_price required. Rate limit 5/s. */ +export interface FuturesCmPerpTpslOrderReq { + contract_code: string; + direction: FuturesDirection; + volume: number | string; + tp_trigger_price?: number | string; + tp_order_price?: number | string; + tp_order_price_type?: FuturesTriggerOrderPriceType; + sl_trigger_price?: number | string; + sl_order_price?: number | string; + sl_order_price_type?: FuturesTriggerOrderPriceType; + price_protect?: boolean; +} ⋮---- -/** Req for POST /api/v1/contract_tpsl_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTpslOrder - params: { symbol, order_id } */ +/** Req for cancelCoinMPerpTpslOrder. Max 10 order_ids. Rate limit 5/s. */ +export interface FuturesCmPerpCancelTpslOrderReq { + contract_code: string; + order_id: string; +} ⋮---- -/** Req for POST /api/v1/contract_tpsl_cancelall. One of: symbol, contract_code, or (symbol+contract_type). */ -export interface FuturesCmDeliveryCancelAllTpslOrdersReq { - symbol?: string; - contract_code?: string; - contract_type?: FuturesContractType; +/** Req for cancelCoinMPerpAllTpslOrders. Optional direction filter. Rate limit 5/s. */ +export interface FuturesCmPerpCancelAllTpslOrdersReq { + contract_code: string; direction?: FuturesDirection; } ⋮---- -/** Req for POST /api/v1/contract_tpsl_openorders. Symbol required. */ -export interface FuturesCmDeliveryGetTpslOpenOrdersReq { - symbol: string; - contract_code?: string; +/** Req for getCoinMPerpTpslOpenOrders. */ +export interface FuturesCmPerpTpslOpenOrdersReq { + contract_code: string; page_index?: number; page_size?: number; - /** 0: all, 3: buy short, 4: sell long */ trade_type?: 0 | 3 | 4; } ⋮---- -/** 0: all, 3: buy short, 4: sell long */ -⋮---- -/** Req for POST /api/v1/contract_tpsl_hisorders. Days within 90. */ -export interface FuturesCmDeliveryGetTpslHistoryOrdersReq { - symbol: string; +/** Req for getCoinMPerpTpslHistoryOrders. create_date: days, max 90. */ +export interface FuturesCmPerpTpslHisOrdersReq { contract_code: string; - /** 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated for multiple */ + /** 0:all, 4:submitted, 5:failed, 6:cancelled, 11:expired. Comma-separated allowed */ status: string; - /** Days to query. Within 90. */ create_date: number; page_index?: number; page_size?: number; sort_by?: FuturesSortBy; } ⋮---- -/** 0: all, 4: submitted, 5: failed, 6: cancelled, 11: expired. Comma-separated for multiple */ +/** 0:all, 4:submitted, 5:failed, 6:cancelled, 11:expired. Comma-separated allowed */ ⋮---- -/** Days to query. Within 90. */ +/** Req for getCoinMPerpRelationTpslOrder. order_id = open order id. */ +export interface FuturesCmPerpRelationTpslOrderReq { + contract_code: string; + order_id: number | string; +} ⋮---- -/** Req for POST /api/v1/contract_relation_tpsl_order. TPSL orders related to position-opening order. Inlined in getCoinMDeliveryRelationTpslOrder - params: { symbol, order_id } */ +/** Req for submitCoinMPerpTrailingOrder. callback_rate min 0.001 (0.1%). Rate limit 5/s. */ +export interface FuturesCmPerpTrailingOrderReq { + contract_code: string; + direction: FuturesDirection; + offset: FuturesOffset; + volume: number | string; + callback_rate: number | string; + active_price: number | string; + order_price_type: FuturesTrailingOrderPriceType; + lever_rate?: number; +} ⋮---- -/** Req for POST /api/v1/contract_track_cancel. Max 10 order_ids. Inlined in cancelCoinMDeliveryTrailingOrder - params: { symbol, order_id } */ +/** Req for cancelCoinMPerpTrailingOrder. Max 10 order_ids. Rate limit 5/s. */ +export interface FuturesCmPerpCancelTrailingOrderReq { + contract_code: string; + order_id: string; +} ⋮---- -/** Req for POST /api/v1/contract_track_cancelall. symbol required. */ -export interface FuturesCmDeliveryCancelAllTrailingOrdersReq { - symbol: string; - contract_code?: string; - contract_type?: FuturesContractType; +/** Req for cancelCoinMPerpAllTrailingOrders. Optional direction/offset filter. Rate limit 5/s. */ +export interface FuturesCmPerpCancelAllTrailingOrdersReq { + contract_code: string; direction?: FuturesDirection; offset?: FuturesOffset; } ⋮---- -/** Req for POST /api/v1/contract_track_openorders. Symbol required. */ -export interface FuturesCmDeliveryGetTrailingOpenOrdersReq { - symbol: string; - contract_code?: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ +/** Req for getCoinMPerpTrailingOpenOrders. */ +export interface FuturesCmPerpTrailingOpenOrdersReq { + contract_code: string; trade_type?: 0 | 1 | 2 | 3 | 4; page_index?: number; page_size?: number; } ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ -⋮---- -/** Req for POST /api/v1/contract_track_hisorders. Days within 90. */ -export interface FuturesCmDeliveryGetTrailingHistoryOrdersReq { - symbol: string; - /** 0: all, 4: success, 5: failed, 6: cancelled. Comma-separated for multiple */ +/** Req for getCoinMPerpTrailingHistoryOrders. create_date: days, max 90. */ +export interface FuturesCmPerpTrailingHisOrdersReq { + contract_code: string; + /** 0:all, 4:success, 5:failed, 6:cancelled. Comma-separated allowed */ status: string; - /** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ + /** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long */ trade_type: 0 | 1 | 2 | 3 | 4; - /** Days to query. Within 90. */ create_date: number; - contract_code?: string; page_index?: number; page_size?: number; - sort_by?: FuturesSortBy; + sort_by?: FuturesSortByCmPerp; } ⋮---- -/** 0: all, 4: success, 5: failed, 6: cancelled. Comma-separated for multiple */ +/** 0:all, 4:success, 5:failed, 6:cancelled. Comma-separated allowed */ ⋮---- -/** 0: all, 1: buy long, 2: sell short, 3: buy short, 4: sell long */ +/** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long */ ⋮---- -/** Days to query. Within 90. */ +/** Req for POST /swap-api/v1/swap_master_sub_transfer */ +export interface FuturesCmPerpMasterSubTransferReq { + sub_uid: number; + contract_code: string; + amount: number | string; + type: FuturesTransferType; + client_order_id?: number; +} ⋮---- -/** Req for POST /api/v1/contract_track_order. One of contract_code or (symbol+contract_type). lever_rate required when offset=open. */ -export interface FuturesCmDeliverySubmitTrailingOrderReq { - direction: FuturesDirection; - offset: FuturesOffset; - volume: number; - callback_rate: number; - active_price: number | string; - /** optimal_5, optimal_10, optimal_20, formula_price */ - order_price_type: FuturesTrailingOrderPriceType; - contract_code?: string; - symbol?: string; - contract_type?: FuturesContractType; - lever_rate?: number; -} -⋮---- -/** optimal_5, optimal_10, optimal_20, formula_price */ -⋮---- -/** Req for POST /api/v1/contract_tpsl_order. One of contract_code or (symbol+contract_type). At least one of tp or sl required. */ -export interface FuturesCmDeliverySubmitTpslOrderReq { - direction: FuturesDirection; - volume: number; - contract_code?: string; - symbol?: string; - contract_type?: FuturesContractType; - tp_trigger_price?: number | string; - tp_order_price?: number | string; - tp_order_price_type?: FuturesTriggerOrderPriceType; - sl_trigger_price?: number | string; - sl_order_price?: number | string; - sl_order_price_type?: FuturesTriggerOrderPriceType; - price_protect?: boolean; -} -⋮---- -/** Req for POST /api/v1/contract_cancelall. One of: symbol, contract_code, or (symbol+contract_type). */ -export interface FuturesCmDeliveryCancelAllOrdersReq { - /** Symbol (e.g. BTC). Cancel all contracts of this symbol. */ - symbol?: string; - /** Contract code (e.g. btc200925). Cancel orders for this contract. */ - contract_code?: string; - /** this_week, next_week, quarter, next_quarter. Use with symbol. */ - contract_type?: FuturesContractType; - /** buy or sell. Omit for all */ - direction?: FuturesDirection; - /** open or close. Omit for all */ - offset?: FuturesOffset; -} -⋮---- -/** Symbol (e.g. BTC). Cancel all contracts of this symbol. */ -⋮---- -/** Contract code (e.g. btc200925). Cancel orders for this contract. */ -⋮---- -/** this_week, next_week, quarter, next_quarter. Use with symbol. */ -⋮---- -/** buy or sell. Omit for all */ -⋮---- -/** open or close. Omit for all */ -⋮---- -/** Req for POST /api/v1/contract_master_sub_transfer_record */ -export interface FuturesCmDeliveryMasterSubTransferRecordReq { - symbol: string; +/** Req for getCoinMPerpMasterSubTransfers */ +export interface FuturesCmPerpMasterSubTransfersReq { + contract_code: string; transfer_type?: string; create_date: number; page_index?: number; page_size?: number; } ⋮---- -/** Req for POST /api/v1/contract_master_sub_transfer */ -export interface FuturesCmDeliveryMasterSubTransferReq { - sub_uid: number; - symbol: string; - amount: number | string; - type: FuturesTransferType; - client_order_id?: number; -} -⋮---- -/** Req for POST /api/v1/contract_sub_account_info_list. Batch of sub-account assets with pagination. */ -export interface FuturesCmDeliverySubAccountInfoListReq { - symbol?: string; - page_index?: number; - page_size?: number; -} -⋮---- -/** Req for POST /api/v1/contract_sub_account_list. Sub-account assets. */ -export interface FuturesCmDeliverySubAccountListReq { - symbol?: string; +/** Req for POST /swap-api/v3/swap_financial_record */ +export interface FuturesCmPerpFinancialRecordReq { + contract: string; + type?: string; + start_time?: number; + end_time?: number; direct?: FuturesDirect; from_id?: number; } ⋮---- -/** Req for GET /index/market/history/basis. Basis (contract - index) data. */ -export interface FuturesCmDeliveryBasisDataReq { - symbol: string; - period: FuturesKlinePeriod; - size: number; - basis_price_type?: FuturesBasisPriceType; -} +/** Req for POST /swap-api/v3/swap_financial_record_exact. Same params as swap_financial_record. */ +export type FuturesCmPerpFinancialRecordExactReq = + FuturesCmPerpFinancialRecordReq; ⋮---- -/** Req for GET /v1/insurance_fund_history (CMPerp). Historical risk reserves. */ -export interface FuturesCmPerpRiskReserveHistoryReq { +/** Req for GET /swap-api/v1/swap_sub_auth_list */ +export interface FuturesCmPerpSubPermissionsReq { + sub_uid?: string; start_time?: number; end_time?: number; direct?: FuturesDirect; from_id?: number; - limit?: number; -} -⋮---- -/** Req for POST /swap-api/v1/swap_sub_account_list */ -export interface FuturesCmPerpSubAccountsReq { - contract_code?: string; - direct?: FuturesDirect; - from_id?: number; -} -⋮---- -/** Req for POST /swap-api/v1/swap_sub_account_info_list */ -export interface FuturesCmPerpSubAccountsAssetsReq { - contract_code?: string; - page_index?: number; - page_size?: number; -} -⋮---- -/** Req for POST /swap-api/v1/swap_order_limit */ -export interface FuturesCmPerpOrderLimitReq { - contract_code?: string; - order_price_type: string; } ⋮---- -/** Req for POST /swap-api/v1/swap_cancel_after. Dead Man's Switch: auto-cancel pending orders if not refreshed. Inlined in setCoinMPerpCancelAfter - params: { on_off: 0|1, time_out? } */ -⋮---- -/** Req for POST /swap-api/v1/swap_order. Place order (CMPerp). */ -export interface FuturesCmPerpSubmitOrderReq { +/** Req for GET /index/market/history/swap_estimated_rate_kline */ +export interface FuturesCmPerpFundingRateKlinesReq { contract_code: string; - direction: FuturesDirection; - offset: FuturesOffset; - volume: number; - lever_rate: number; - order_price_type: FuturesCmPerpSubmitOrderPriceType; - price?: number | string; - client_order_id?: number; - tp_trigger_price?: number | string; - tp_order_price?: number | string; - tp_order_price_type?: string; - sl_trigger_price?: number | string; - sl_order_price?: number | string; - sl_order_price_type?: string; - price_protect?: boolean; - self_match_prevent?: 0 | 1; + period: FuturesKlinePeriod; + size: number; } ⋮---- -/** Req for POST /swap-api/v1/swap_batchorder. Max 25 orders (CMPerp). */ -export interface FuturesCmPerpSubmitBatchOrderReq { - orders_data: FuturesCmPerpSubmitOrderReq[]; +/** Req for GET /index/market/history/swap_basis */ +export interface FuturesCmPerpBasisDataReq { + contract_code: string; + period: FuturesKlinePeriod; + size: number; + basis_price_type?: FuturesBasisPriceType; } ⋮---- -/** Req for cancelCoinMPerpOrder. One of order_id or client_order_id required. Max 10. */ -export interface FuturesCmPerpCancelOrderReq { +/** Req for GET /index/market/history/swap_premium_index_kline */ +export interface FuturesCmPerpPremiumIndexKlinesReq { contract_code: string; - order_id?: string; - client_order_id?: string; + period: FuturesKlinePeriod; + size: number; } ⋮---- -/** Req for cancelCoinMPerpAllOrders. Optional direction/offset filter. */ -export interface FuturesCmPerpCancelAllOrdersReq { +/** Req for GET /index/market/history/swap_mark_price_kline */ +export interface FuturesCmPerpMarkPriceKlinesReq { contract_code: string; - direction?: FuturesDirection; - offset?: FuturesOffset; + period: FuturesKlinePeriod; + size: number; } ⋮---- -/** Req for updateCoinMPerpLeverage. Rate limit 1/3s. Inlined in updateCoinMPerpLeverage - params: { contract_code, lever_rate } */ -⋮---- -/** Req for getCoinMPerpOrderInfo. One of order_id or client_order_id required. Max 50. */ -export interface FuturesCmPerpOrderInfoReq { +/** Req for GET /swap-ex/market/history/kline. Either size or (from+to) required. */ +export interface FuturesCmPerpKlinesReq { contract_code: string; - order_id?: string; - client_order_id?: string; + period: FuturesKlinePeriod; + size?: number; + from?: number; + to?: number; } ⋮---- -/** Req for getCoinMPerpOrderDetail. created_at improves query performance, cannot be 0. */ -export interface FuturesCmPerpOrderDetailReq { +/** Req for GET /swap-api/v1/swap_historical_funding_rate */ +export interface FuturesCmPerpHistoricalFundingRateReq { contract_code: string; - order_id: number | string; - created_at?: number; - order_type?: number; page_index?: number; page_size?: number; } ⋮---- -/** Req for getCoinMPerpOpenOrders. Omit contract_code for all. */ -export interface FuturesCmPerpOpenOrdersReq { - contract_code?: string; - page_index?: number; - page_size?: number; - sort_by?: FuturesSortBy; - trade_type?: 0 | 1 | 2 | 3 | 4; +/** Req for GET /swap-api/v1/swap_his_open_interest */ +export interface FuturesCmPerpGetOpenInterestReq { + contract_code: string; + /** 60min, 4hour, 12hour, 1day */ + period: FuturesOpenInterestPeriod; + /** 1: cont, 2: cryptocurrency */ + amount_type: 1 | 2; + /** Default 48, [1, 200] */ + size?: number; } ⋮---- -/** Req for getCoinMPerpHistoryOrders. contract required. Window max 48h, within 90d. Cancel info: last 2h. */ -export interface FuturesCmPerpHistoryOrdersReq { +/** 60min, 4hour, 12hour, 1day */ +⋮---- +/** 1: cont, 2: cryptocurrency */ +⋮---- +/** Default 48, [1, 200] */ +⋮---- +/** Req for GET /swap-api/v3/swap_liquidation_orders. 0=fully filled, 5=liquidated close, 6=liquidated open. */ +export interface FuturesCmPerpLiquidationOrdersReq { + /** Contract code. Case-insensitive */ contract: string; - /** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long, 5:sell liq, 6:buy liq, 7:Delivery long, 8:Delivery short, 11:reduce close long, 12:reduce close short */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12; - /** 1:All Orders, 2:Order in Finished Status */ - type: 1 | 2; - /** 0:all, or comma-separated e.g. "3,4,5" */ - status: string; + /** 0: fully filled liquidated; 5: liquidated close; 6: liquidated open */ + trade_type: 0 | 5 | 6; + /** Start time (ms). Window max 2h, within 90 days */ start_time?: number; + /** End time (ms). Default now. Within 90 days */ end_time?: number; + /** next=chronological, prev=reverse. Default prev */ direct?: FuturesDirect; + /** Pagination: min/max query_id from last result depending on direct */ from_id?: number; } ⋮---- -/** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long, 5:sell liq, 6:buy liq, 7:Delivery long, 8:Delivery short, 11:reduce close long, 12:reduce close short */ +/** Contract code. Case-insensitive */ ⋮---- -/** 1:All Orders, 2:Order in Finished Status */ +/** 0: fully filled liquidated; 5: liquidated close; 6: liquidated open */ ⋮---- -/** 0:all, or comma-separated e.g. "3,4,5" */ +/** Start time (ms). Window max 2h, within 90 days */ ⋮---- -/** Req for getCoinMPerpHistoryOrdersExact. Same as HistoryOrdersReq + price_type filter. */ -export interface FuturesCmPerpHistoryOrdersExactReq { - contract: string; - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12; - type: 1 | 2; - status: string; - price_type?: string; +/** End time (ms). Default now. Within 90 days */ +⋮---- +/** next=chronological, prev=reverse. Default prev */ +⋮---- +/** Pagination: min/max query_id from last result depending on direct */ +⋮---- +/** Req for GET /swap-api/v1/swap_settlement_records */ +export interface FuturesCmPerpSettlementRecordsReq { + contract_code: string; + /** Start time (ms). Default: now - 90 days */ start_time?: number; + /** End time (ms). Default: now */ end_time?: number; - direct?: FuturesDirect; - from_id?: number; + page_index?: number; + page_size?: number; } ⋮---- -/** Req for getCoinMPerpFills. Window max 48h, within 90d. */ -export interface FuturesCmPerpFillsReq { - contract: string; - /** 0:All, 1:Open long, 2:Open short, 3:Close short, 4:Close long, 5:Liquidate long, 6:Liquidate short */ - trade_type: 0 | 1 | 2 | 3 | 4 | 5 | 6; - start_time?: number; - end_time?: number; - direct?: FuturesDirect; - from_id?: number; -} -⋮---- -/** 0:All, 1:Open long, 2:Open short, 3:Close short, 4:Close long, 5:Liquidate long, 6:Liquidate short */ +/** Start time (ms). Default: now - 90 days */ ⋮---- -/** Req for getCoinMPerpFillsExact. Same params as FillsReq. */ -export type FuturesCmPerpFillsExactReq = FuturesCmPerpFillsReq; +/** End time (ms). Default: now */ ⋮---- -/** Req for submitCoinMPerpLightningClose. Lightning close = rival price + optimal 30 levels; unfilled becomes limit. */ -export interface FuturesCmPerpLightningCloseReq { - contract_code: string; - volume: number; - direction: FuturesDirection; - client_order_id?: number; - order_price_type?: FuturesLightningOrderPriceTypeCm; -} +/** + * Copy Trading + */ ⋮---- -/** Req for submitCoinMPerpTriggerOrder. Rate limit 5/s. */ -export interface FuturesCmPerpTriggerOrderReq { - contract_code: string; - trigger_type: FuturesTriggerType; - trigger_price: number | string; - order_price?: number | string; - order_price_type?: FuturesTriggerOrderPriceType; - volume: number; - direction: FuturesDirection; - offset: FuturesOffset; - lever_rate?: number; +/** Req for GET /api/v6/copyTrading/trader/instruments. Product type PERP or omit for all. */ +export interface FuturesCopyTraderInstrumentsReq { + /** Product type. PERP = Perpetual Swap. Omit to return all. */ + instType?: 'PERP'; } ⋮---- -/** Req for cancelCoinMPerpTriggerOrder. Max 10 order_ids. Rate limit 5/s. Inlined in cancelCoinMPerpTriggerOrder - params: { contract_code, order_id } */ +/** Product type. PERP = Perpetual Swap. Omit to return all. */ ⋮---- -/** Req for cancelCoinMPerpAllTriggerOrders. Optional direction/offset filter. Rate limit 5/s. */ -export interface FuturesCmPerpCancelAllTriggerOrdersReq { - contract_code: string; - direction?: FuturesDirection; - offset?: FuturesOffset; +/** Req for GET /api/v6/copyTrading/trader/statistics. Product type required. */ +export interface FuturesCopyTraderStatisticsReq { + /** Product type. PERP = Perpetual Swap */ + instType: 'PERP'; } ⋮---- -/** Req for getCoinMPerpTriggerOpenOrders. */ -export interface FuturesCmPerpTriggerOpenOrdersReq { - contract_code: string; - page_index?: number; - page_size?: number; - trade_type?: 0 | 1 | 2 | 3 | 4; -} +/** Product type. PERP = Perpetual Swap */ ⋮---- -/** Req for getCoinMPerpTriggerHistoryOrders. create_date: days, max 90. Default query completed (status 4,5,6). */ -export interface FuturesCmPerpTriggerHistoryOrdersReq { - contract_code: string; - /** 0:All, 1:Open Long, 2:Close Short, 3:Open Short, 4:Close Long */ - trade_type: 0 | 1 | 2 | 3 | 4; - /** 0:all, 4:submitted, 5:failed, 6:cancelled. Comma-separated allowed */ - status: string; - create_date: number; - page_index?: number; - page_size?: number; - sort_by?: FuturesSortBy; +/** Req for GET /api/v6/copyTrading/trader/profit-sharing-history. Historical profit sharing details. */ +export interface FuturesCopyTraderProfitSharingHistoryReq { + /** Product type. PERP = Perpetual Swap */ + instType: 'PERP'; + /** Product ID e.g. BTC-USDT-PERP */ + instId?: string; + /** Filter start time (inclusive), Unix timestamp in microseconds */ + begin?: string; + /** Filter end time (inclusive), Unix timestamp in microseconds */ + end?: string; + /** Paginate content before (older data) this ID (exclusive) */ + after?: string; + /** Paginate content after (newer data) this ID (exclusive) */ + before?: string; + /** Number of results to return, max 100, default 100 */ + limit?: string; } ⋮---- -/** 0:All, 1:Open Long, 2:Close Short, 3:Open Short, 4:Close Long */ +/** Product type. PERP = Perpetual Swap */ ⋮---- -/** 0:all, 4:submitted, 5:failed, 6:cancelled. Comma-separated allowed */ +/** Product ID e.g. BTC-USDT-PERP */ ⋮---- -/** Req for submitCoinMPerpTpslOrder. At least one of tp_trigger_price or sl_trigger_price required. Rate limit 5/s. */ -export interface FuturesCmPerpTpslOrderReq { - contract_code: string; - direction: FuturesDirection; - volume: number | string; - tp_trigger_price?: number | string; - tp_order_price?: number | string; - tp_order_price_type?: FuturesTriggerOrderPriceType; - sl_trigger_price?: number | string; - sl_order_price?: number | string; - sl_order_price_type?: FuturesTriggerOrderPriceType; - price_protect?: boolean; -} +/** Filter start time (inclusive), Unix timestamp in microseconds */ ⋮---- -/** Req for cancelCoinMPerpTpslOrder. Max 10 order_ids. Rate limit 5/s. */ -export interface FuturesCmPerpCancelTpslOrderReq { - contract_code: string; - order_id: string; -} +/** Filter end time (inclusive), Unix timestamp in microseconds */ ⋮---- -/** Req for cancelCoinMPerpAllTpslOrders. Optional direction filter. Rate limit 5/s. */ -export interface FuturesCmPerpCancelAllTpslOrdersReq { - contract_code: string; - direction?: FuturesDirection; -} +/** Paginate content before (older data) this ID (exclusive) */ ⋮---- -/** Req for getCoinMPerpTpslOpenOrders. */ -export interface FuturesCmPerpTpslOpenOrdersReq { - contract_code: string; - page_index?: number; - page_size?: number; - trade_type?: 0 | 3 | 4; -} +/** Paginate content after (newer data) this ID (exclusive) */ ⋮---- -/** Req for getCoinMPerpTpslHistoryOrders. create_date: days, max 90. */ -export interface FuturesCmPerpTpslHisOrdersReq { - contract_code: string; - /** 0:all, 4:submitted, 5:failed, 6:cancelled, 11:expired. Comma-separated allowed */ - status: string; - create_date: number; - page_index?: number; - page_size?: number; - sort_by?: FuturesSortBy; +/** Number of results to return, max 100, default 100 */ +⋮---- +/** Req for GET /api/v6/copyTrading/trader/profit-sharing-history-summary. Historical profit sharing summary. */ +export interface FuturesCopyTraderProfitSharingHistorySummaryReq { + /** Product type. PERP = Perpetual Swap */ + instType: 'PERP'; } ⋮---- -/** 0:all, 4:submitted, 5:failed, 6:cancelled, 11:expired. Comma-separated allowed */ +/** Product type. PERP = Perpetual Swap */ ⋮---- -/** Req for getCoinMPerpRelationTpslOrder. order_id = open order id. */ -export interface FuturesCmPerpRelationTpslOrderReq { - contract_code: string; - order_id: number | string; +/** Req for GET /api/v6/copyTrading/trader/unrealized-profit-sharing-summary. Unrealized profit sharing summary. */ +export interface FuturesCopyTraderUnrealizedProfitSharingSummaryReq { + /** Product type. PERP = Perpetual Swap */ + instType: 'PERP'; + /** Profit sharing currency */ + ccy?: string; } ⋮---- -/** Req for submitCoinMPerpTrailingOrder. callback_rate min 0.001 (0.1%). Rate limit 5/s. */ -export interface FuturesCmPerpTrailingOrderReq { - contract_code: string; - direction: FuturesDirection; - offset: FuturesOffset; - volume: number | string; - callback_rate: number | string; - active_price: number | string; - order_price_type: FuturesTrailingOrderPriceType; - lever_rate?: number; -} +/** Product type. PERP = Perpetual Swap */ ⋮---- -/** Req for cancelCoinMPerpTrailingOrder. Max 10 order_ids. Rate limit 5/s. */ -export interface FuturesCmPerpCancelTrailingOrderReq { - contract_code: string; - order_id: string; -} +/** Profit sharing currency */ ⋮---- -/** Req for cancelCoinMPerpAllTrailingOrders. Optional direction/offset filter. Rate limit 5/s. */ -export interface FuturesCmPerpCancelAllTrailingOrdersReq { - contract_code: string; - direction?: FuturesDirection; - offset?: FuturesOffset; +/** Req for GET /api/v6/copyTrading/trader/followers. Trader query followers. */ +export interface FuturesCopyTraderFollowersReq { + /** Product type. PERP = Perpetual Swap. Omit to return all. */ + instType?: 'PERP'; + /** Filter start time (inclusive), Unix timestamp in microseconds */ + begin?: string; + /** Filter end time (inclusive), Unix timestamp in microseconds */ + end?: string; + /** Paginate content before (older data) this ID (exclusive) */ + after?: string; + /** Paginate content after (newer data) this ID (exclusive) */ + before?: string; + /** Number of results to return, max 100, default 100 */ + limit?: string; } ⋮---- -/** Req for getCoinMPerpTrailingOpenOrders. */ -export interface FuturesCmPerpTrailingOpenOrdersReq { - contract_code: string; - trade_type?: 0 | 1 | 2 | 3 | 4; - page_index?: number; - page_size?: number; -} +/** Product type. PERP = Perpetual Swap. Omit to return all. */ ⋮---- -/** Req for getCoinMPerpTrailingHistoryOrders. create_date: days, max 90. */ -export interface FuturesCmPerpTrailingHisOrdersReq { - contract_code: string; - /** 0:all, 4:success, 5:failed, 6:cancelled. Comma-separated allowed */ - status: string; - /** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long */ - trade_type: 0 | 1 | 2 | 3 | 4; - create_date: number; - page_index?: number; - page_size?: number; - sort_by?: FuturesSortByCmPerp; -} +/** Filter start time (inclusive), Unix timestamp in microseconds */ ⋮---- -/** 0:all, 4:success, 5:failed, 6:cancelled. Comma-separated allowed */ +/** Filter end time (inclusive), Unix timestamp in microseconds */ ⋮---- -/** 0:all, 1:buy long, 2:sell short, 3:buy short, 4:sell long */ +/** Paginate content before (older data) this ID (exclusive) */ ⋮---- -/** Req for POST /swap-api/v1/swap_master_sub_transfer */ -export interface FuturesCmPerpMasterSubTransferReq { - sub_uid: number; - contract_code: string; - amount: number | string; - type: FuturesTransferType; - client_order_id?: number; -} +/** Paginate content after (newer data) this ID (exclusive) */ ⋮---- -/** Req for getCoinMPerpMasterSubTransfers */ -export interface FuturesCmPerpMasterSubTransfersReq { - contract_code: string; - transfer_type?: string; - create_date: number; - page_index?: number; - page_size?: number; -} +/** Number of results to return, max 100, default 100 */ ⋮---- -/** Req for POST /swap-api/v3/swap_financial_record */ -export interface FuturesCmPerpFinancialRecordReq { - contract: string; - type?: string; - start_time?: number; - end_time?: number; - direct?: FuturesDirect; - from_id?: number; +/** Req for POST /api/v6/copyTrading/trader/follower. Trader remove follower. Max 10 followers at once. */ +export interface FuturesCopyTraderFollowerRemoveReq { + /** Follower user IDs */ + followerUids: string[]; + /** Product type. PERP = Perpetual Swap */ + instType: 'PERP'; } ⋮---- -/** Req for POST /swap-api/v3/swap_financial_record_exact. Same params as swap_financial_record. */ -export type FuturesCmPerpFinancialRecordExactReq = - FuturesCmPerpFinancialRecordReq; -⋮---- -/** Req for GET /swap-api/v1/swap_sub_auth_list */ -export interface FuturesCmPerpSubPermissionsReq { - sub_uid?: string; - start_time?: number; - end_time?: number; - direct?: FuturesDirect; - from_id?: number; -} -⋮---- -/** Req for GET /index/market/history/swap_estimated_rate_kline */ -export interface FuturesCmPerpFundingRateKlinesReq { - contract_code: string; - period: FuturesKlinePeriod; - size: number; -} -⋮---- -/** Req for GET /index/market/history/swap_basis */ -export interface FuturesCmPerpBasisDataReq { - contract_code: string; - period: FuturesKlinePeriod; - size: number; - basis_price_type?: FuturesBasisPriceType; -} -⋮---- -/** Req for GET /index/market/history/swap_premium_index_kline */ -export interface FuturesCmPerpPremiumIndexKlinesReq { - contract_code: string; - period: FuturesKlinePeriod; - size: number; -} -⋮---- -/** Req for GET /index/market/history/swap_mark_price_kline */ -export interface FuturesCmPerpMarkPriceKlinesReq { - contract_code: string; - period: FuturesKlinePeriod; - size: number; -} -⋮---- -/** Req for GET /swap-ex/market/history/kline. Either size or (from+to) required. */ -export interface FuturesCmPerpKlinesReq { - contract_code: string; - period: FuturesKlinePeriod; - size?: number; - from?: number; - to?: number; -} -⋮---- -/** Req for GET /swap-api/v1/swap_historical_funding_rate */ -export interface FuturesCmPerpHistoricalFundingRateReq { - contract_code: string; - page_index?: number; - page_size?: number; -} -⋮---- -/** Req for GET /swap-api/v1/swap_his_open_interest */ -export interface FuturesCmPerpGetOpenInterestReq { - contract_code: string; - /** 60min, 4hour, 12hour, 1day */ - period: FuturesOpenInterestPeriod; - /** 1: cont, 2: cryptocurrency */ - amount_type: 1 | 2; - /** Default 48, [1, 200] */ - size?: number; -} -⋮---- -/** 60min, 4hour, 12hour, 1day */ -⋮---- -/** 1: cont, 2: cryptocurrency */ -⋮---- -/** Default 48, [1, 200] */ -⋮---- -/** Req for GET /swap-api/v3/swap_liquidation_orders. 0=fully filled, 5=liquidated close, 6=liquidated open. */ -export interface FuturesCmPerpLiquidationOrdersReq { - /** Contract code. Case-insensitive */ - contract: string; - /** 0: fully filled liquidated; 5: liquidated close; 6: liquidated open */ - trade_type: 0 | 5 | 6; - /** Start time (ms). Window max 2h, within 90 days */ - start_time?: number; - /** End time (ms). Default now. Within 90 days */ - end_time?: number; - /** next=chronological, prev=reverse. Default prev */ - direct?: FuturesDirect; - /** Pagination: min/max query_id from last result depending on direct */ - from_id?: number; -} -⋮---- -/** Contract code. Case-insensitive */ -⋮---- -/** 0: fully filled liquidated; 5: liquidated close; 6: liquidated open */ -⋮---- -/** Start time (ms). Window max 2h, within 90 days */ -⋮---- -/** End time (ms). Default now. Within 90 days */ -⋮---- -/** next=chronological, prev=reverse. Default prev */ -⋮---- -/** Pagination: min/max query_id from last result depending on direct */ -⋮---- -/** Req for GET /swap-api/v1/swap_settlement_records */ -export interface FuturesCmPerpSettlementRecordsReq { - contract_code: string; - /** Start time (ms). Default: now - 90 days */ - start_time?: number; - /** End time (ms). Default: now */ - end_time?: number; - page_index?: number; - page_size?: number; -} -⋮---- -/** Start time (ms). Default: now - 90 days */ -⋮---- -/** End time (ms). Default: now */ -⋮---- -/** - * Copy Trading - */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/instruments. Product type PERP or omit for all. */ -export interface FuturesCopyTraderInstrumentsReq { - /** Product type. PERP = Perpetual Swap. Omit to return all. */ - instType?: 'PERP'; -} -⋮---- -/** Product type. PERP = Perpetual Swap. Omit to return all. */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/statistics. Product type required. */ -export interface FuturesCopyTraderStatisticsReq { - /** Product type. PERP = Perpetual Swap */ - instType: 'PERP'; -} -⋮---- -/** Product type. PERP = Perpetual Swap */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/profit-sharing-history. Historical profit sharing details. */ -export interface FuturesCopyTraderProfitSharingHistoryReq { - /** Product type. PERP = Perpetual Swap */ - instType: 'PERP'; - /** Product ID e.g. BTC-USDT-PERP */ - instId?: string; - /** Filter start time (inclusive), Unix timestamp in microseconds */ - begin?: string; - /** Filter end time (inclusive), Unix timestamp in microseconds */ - end?: string; - /** Paginate content before (older data) this ID (exclusive) */ - after?: string; - /** Paginate content after (newer data) this ID (exclusive) */ - before?: string; - /** Number of results to return, max 100, default 100 */ - limit?: string; -} -⋮---- -/** Product type. PERP = Perpetual Swap */ -⋮---- -/** Product ID e.g. BTC-USDT-PERP */ -⋮---- -/** Filter start time (inclusive), Unix timestamp in microseconds */ -⋮---- -/** Filter end time (inclusive), Unix timestamp in microseconds */ -⋮---- -/** Paginate content before (older data) this ID (exclusive) */ -⋮---- -/** Paginate content after (newer data) this ID (exclusive) */ -⋮---- -/** Number of results to return, max 100, default 100 */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/profit-sharing-history-summary. Historical profit sharing summary. */ -export interface FuturesCopyTraderProfitSharingHistorySummaryReq { - /** Product type. PERP = Perpetual Swap */ - instType: 'PERP'; -} -⋮---- -/** Product type. PERP = Perpetual Swap */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/unrealized-profit-sharing-summary. Unrealized profit sharing summary. */ -export interface FuturesCopyTraderUnrealizedProfitSharingSummaryReq { - /** Product type. PERP = Perpetual Swap */ - instType: 'PERP'; - /** Profit sharing currency */ - ccy?: string; -} -⋮---- -/** Product type. PERP = Perpetual Swap */ -⋮---- -/** Profit sharing currency */ -⋮---- -/** Req for GET /api/v6/copyTrading/trader/followers. Trader query followers. */ -export interface FuturesCopyTraderFollowersReq { - /** Product type. PERP = Perpetual Swap. Omit to return all. */ - instType?: 'PERP'; - /** Filter start time (inclusive), Unix timestamp in microseconds */ - begin?: string; - /** Filter end time (inclusive), Unix timestamp in microseconds */ - end?: string; - /** Paginate content before (older data) this ID (exclusive) */ - after?: string; - /** Paginate content after (newer data) this ID (exclusive) */ - before?: string; - /** Number of results to return, max 100, default 100 */ - limit?: string; -} -⋮---- -/** Product type. PERP = Perpetual Swap. Omit to return all. */ -⋮---- -/** Filter start time (inclusive), Unix timestamp in microseconds */ -⋮---- -/** Filter end time (inclusive), Unix timestamp in microseconds */ -⋮---- -/** Paginate content before (older data) this ID (exclusive) */ -⋮---- -/** Paginate content after (newer data) this ID (exclusive) */ -⋮---- -/** Number of results to return, max 100, default 100 */ -⋮---- -/** Req for POST /api/v6/copyTrading/trader/follower. Trader remove follower. Max 10 followers at once. */ -export interface FuturesCopyTraderFollowerRemoveReq { - /** Follower user IDs */ - followerUids: string[]; - /** Product type. PERP = Perpetual Swap */ - instType: 'PERP'; -} -⋮---- -/** Follower user IDs */ +/** Follower user IDs */ ⋮---- /** Product type. PERP = Perpetual Swap */ ⋮---- @@ -11230,1962 +9918,3199 @@ export interface FuturesCopyTraderApikeyReq { /** Product type. PERP = Perpetual Swap */ ================ -File: src/types/request/spot.types.ts +File: .gitignore ================ -/** - * Reference Data - */ -⋮---- -export interface SpotGetChainsReq { - /** Show desc: 0=no, 1=all, 2=suspend deposit/withdrawal and chain exchange */ - 'show-desc'?: string; - /** Currency filter */ - currency?: string; - /** Timestamp for incremental data. Returns updates from ts to now. If no update, data is []. */ - ts?: number; -} -⋮---- -/** Show desc: 0=no, 1=all, 2=suspend deposit/withdrawal and chain exchange */ -⋮---- -/** Currency filter */ -⋮---- -/** Timestamp for incremental data. Returns updates from ts to now. If no update, data is []. */ -⋮---- -/** - * Market Data - */ -⋮---- -/** Req for /market/history/kline */ -export interface SpotGetKlineReq { - /** Trading symbol (e.g. btcusdt, btc3lusdtnav for ETP NAV) */ - symbol: string; - /** Candle period. Default 1day. */ - period?: string; - /** Number of data points [1-2000]. Default 150. */ - size?: number; -} -⋮---- -/** Trading symbol (e.g. btcusdt, btc3lusdtnav for ETP NAV) */ -⋮---- -/** Candle period. Default 1day. */ -⋮---- -/** Number of data points [1-2000]. Default 150. */ +!.gitkeep +.DS_Store +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json +pids +*.pid +*.seed +*.pid.lock +node_modules/ +.npm +.eslintcache +.node_repl_history +*.tgz +.yarn-integrity +.env +.env.test +.cache +dist +bundleReport.html +.history/ +examples/ignoreme +localtest.sh +repomix.sh +doc +.cursor/ +futuresOrder2.ts +.vscode/ +WSWIP.md +.tmp-packed* + +================ +File: src/types/response/futures.types.ts +================ +/** + * Reference + */ ⋮---- -export interface SpotGetDepthReq { - /** Trading symbol (e.g. btcusdt) */ - symbol: string; - /** Depth levels per side. 5, 10, 20, 30. Default 20. step0 uses 150 if omitted. */ - depth?: number; - /** step0=no agg, step1-5=aggregation levels. Default step0. */ - type?: string; +/** Paginated response base. Use FuturesPaginatedData or FuturesPaginatedSettlement for specific data keys. */ +export interface FuturesPaginatedBase { + total_page: number; + current_page: number; + total_size: number; } ⋮---- -/** Trading symbol (e.g. btcusdt) */ +/** Paginated response with `data` array (e.g. historical funding rate, liquidation orders). */ +export type FuturesPaginatedData = FuturesPaginatedBase & { data: T[] }; ⋮---- -/** Depth levels per side. 5, 10, 20, 30. Default 20. step0 uses 150 if omitted. */ +/** Paginated response with `settlement_record` array. */ +export type FuturesPaginatedSettlement = FuturesPaginatedBase & { + settlement_record: T[]; +}; ⋮---- -/** step0=no agg, step1-5=aggregation levels. Default step0. */ +/** Paginated response with `sub_list` array (sub-account info list). */ +export type FuturesPaginatedSubList = FuturesPaginatedBase & { + sub_list: T[]; +}; ⋮---- -/** - * Account - */ export interface SpotGetAssetValuationReq { +/** Paginated response with `transfer_record` array (master-sub transfers). */ +export type FuturesPaginatedTransferRecord = FuturesPaginatedBase & { + transfer_record: T[]; +}; ⋮---- -*/ export interface SpotGetAssetValuationReq { - /** Account type: spot, margin, otc, super-margin. Default spot. */ - accountType?: string; - /** Valuation currency: BTC, CNY, USD, JPY, etc. Case sensitive. Default BTC. */ - valuationCurrency?: string; - /** Sub user UID. Omit for API key owner. */ - subUid?: number; -} +/** Paginated response with `orders` array (open orders, trigger orders, etc.). */ +export type FuturesPaginatedOrders = FuturesPaginatedBase & { orders: T[] }; ⋮---- -/** Account type: spot, margin, otc, super-margin. Default spot. */ +/** Funding rate from swap_funding_rate and swap_batch_funding_rate */ +export interface FuturesFundingRate { + funding_rate: string; + contract_code: string; + symbol: string; + fee_asset: string; + funding_time: string; + /** Deprecated, default null */ + estimated_rate?: string | null; + /** Deprecated, default null */ + next_funding_time?: string | null; +} ⋮---- -/** Valuation currency: BTC, CNY, USD, JPY, etc. Case sensitive. Default BTC. */ +/** Deprecated, default null */ ⋮---- -/** Sub user UID. Omit for API key owner. */ +/** Deprecated, default null */ ⋮---- -/** Req for POST /v2/account/transfer - transfer between spot, linear-swap, otc, futures, swap */ -export interface SpotV2AccountTransferReq { - /** Source: spot, linear-swap, otc, futures, swap */ - from: string; - /** Destination: spot, linear-swap, otc, futures, swap */ - to: string; - /** Currency (e.g. usdt). Upper/lowercase supported. */ - currency: string; - /** Transfer amount */ - amount: string; - /** Margin account (e.g. btc-usdt, eth-usdt, USDT) */ - 'margin-account': string; +/** Historical funding rate item from swap_historical_funding_rate */ +export interface FuturesHistoricalFundingRate { + avg_premium_index: string; + funding_rate: string; + funding_time: string; + /** Deprecated, default null */ + realized_rate?: string | null; + contract_code: string; + symbol: string; + fee_asset: string; } ⋮---- -/** Source: spot, linear-swap, otc, futures, swap */ -⋮---- -/** Destination: spot, linear-swap, otc, futures, swap */ -⋮---- -/** Currency (e.g. usdt). Upper/lowercase supported. */ +/** Deprecated, default null */ ⋮---- -/** Transfer amount */ +/** Paginated wrapper for swap_historical_funding_rate data */ +export type FuturesHistoricalFundingRatePage = + FuturesPaginatedData; ⋮---- -/** Margin account (e.g. btc-usdt, eth-usdt, USDT) */ +/** Liquidation order item from swap_liquidation_orders */ +export interface FuturesLiquidationOrder { + query_id: number; + symbol: string; + contract_code: string; + created_at: number; + direction: string; + offset: string; + volume: number; + amount: number; + price: number; + trade_turnover: number; + pair: string; + business_type: string; +} ⋮---- -/** Req for POST /v1/futures/transfer - transfer between spot and future contract account */ -export interface SpotV1FuturesTransferReq { - /** Currency name */ - currency: string; - /** Amount to transfer */ - amount: string; - /** futures-to-pro (contract -> spot) or pro-to-futures (spot -> contract) */ - type: 'futures-to-pro' | 'pro-to-futures'; +/** Settlement record item from swap_settlement_records */ +export interface FuturesSettlementRecord { + symbol: string; + contract_code: string; + settlement_time: number; + clawback_ratio: number; + settlement_price: number; + settlement_type: string; + business_type: string; + pair: string; } ⋮---- -/** Currency name */ +/** Paginated settlement records from swap_settlement_records */ +export type FuturesSettlementRecordsPage = + FuturesPaginatedSettlement; ⋮---- -/** Amount to transfer */ +/** Elite ratio list item (account and position) */ +export interface FuturesEliteRatioList { + buy_ratio: number; + sell_ratio: number; + /** Account ratio only */ + locked_ratio?: number; + ts: number; +} ⋮---- -/** futures-to-pro (contract -> spot) or pro-to-futures (spot -> contract) */ +/** Account ratio only */ ⋮---- -/** Req for POST /v1/account/transfer */ -export interface SpotAccountTransferReq { - /** Transfer out user uid */ - 'from-user': number; - /** Transfer out account type: spot, margin */ - 'from-account-type': string; - /** Transfer out account id */ - 'from-account': number; - /** Transfer in user uid */ - 'to-user': number; - /** Transfer in account type: spot, margin */ - 'to-account-type': string; - /** Transfer in account id */ - 'to-account': number; - /** Currency name */ - currency: string; - /** Amount to transfer */ - amount: string; +/** Elite account/position ratio data from swap_elite_account_ratio and swap_elite_position_ratio */ +export interface FuturesEliteRatio { + symbol: string; + contract_code: string; + pair: string; + business_type: string; + list: FuturesEliteRatioList[]; } ⋮---- -/** Transfer out user uid */ -⋮---- -/** Transfer out account type: spot, margin */ +/** System status item from swap_api_state. 1=available, 0=unavailable */ +export interface FuturesApiState { + symbol: string; + contract_code: string; + margin_mode: string; + margin_account: string; + open: number; + close: number; + cancel: number; + transfer_in: number; + transfer_out: number; + master_transfer_sub: number; + sub_transfer_master: number; + master_transfer_sub_inner_in: number; + master_transfer_sub_inner_out: number; + sub_transfer_master_inner_in: number; + sub_transfer_master_inner_out: number; + transfer_inner_in: number; + transfer_inner_out: number; +} ⋮---- -/** Transfer out account id */ +/** Cross ladder margin tier from swap_cross_ladder_margin */ +export interface FuturesLadderMarginTier { + min_margin_balance: number | null; + max_margin_balance: number | null; + min_margin_available: number | null; + max_margin_available: number | null; +} ⋮---- -/** Transfer in user uid */ +/** Cross ladder margin list item */ +export interface FuturesCrossLadderMarginList { + lever_rate: number; + ladders: FuturesLadderMarginTier[]; +} ⋮---- -/** Transfer in account type: spot, margin */ +/** Cross tiered margin item from swap_cross_ladder_margin. Isolated (swap_ladder_margin) omits business_type, pair, contract_type. */ +export interface FuturesCrossLadderMargin { + margin_account: string; + symbol: string; + contract_code: string; + margin_mode: string; + list: FuturesCrossLadderMarginList[]; + business_type?: string; + pair?: string; + contract_type?: string; +} ⋮---- -/** Transfer in account id */ -⋮---- -/** Currency name */ -⋮---- -/** Amount to transfer */ -⋮---- -/** Req for GET /v1/account/history */ -export interface SpotGetAccountHistoryReq { - /** Account ID from GET /v1/account/accounts */ - 'account-id': string | number; - /** Currency filter */ - currency?: string; - /** Amount change types, comma-separated. Default all. Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ - 'transact-types'?: string; - /** Start time (unix ms). Query window max 1 hour. */ - 'start-time'?: number; - /** End time (unix ms). Query window within 30 days. */ - 'end-time'?: number; - /** Sort order: asc, desc. Default asc. */ - sort?: string; - /** Max items [1-500]. Default 100. */ - size?: number; - /** First record ID for pagination (next page) */ - 'from-id'?: number; +/** Estimated settlement price item from swap_estimated_settlement_price. Empty around settlement/delivery. */ +export interface FuturesEstimatedSettlementPrice { + contract_code: string; + estimated_settlement_price: number | null; + settlement_type: string; + contract_type: string; + pair: string; + business_type: string; } ⋮---- -/** Account ID from GET /v1/account/accounts */ -⋮---- -/** Currency filter */ -⋮---- -/** Amount change types, comma-separated. Default all. Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ -⋮---- -/** Start time (unix ms). Query window max 1 hour. */ -⋮---- -/** End time (unix ms). Query window within 30 days. */ -⋮---- -/** Sort order: asc, desc. Default asc. */ -⋮---- -/** Max items [1-500]. Default 100. */ -⋮---- -/** First record ID for pagination (next page) */ +/** Tiered adjustment factor ladder from swap_adjustfactor and swap_cross_adjustfactor */ +export interface FuturesAdjustFactorLadder { + ladder: number; + min_size: number; + max_size: number | null; + adjust_factor: number; +} ⋮---- -export interface SpotV2PointTransferReq { - /** Transferer UID */ - fromUid: string; - /** Transferee UID */ - toUid: string; - /** Group ID. 0 = termless points. For terminable points, query sub user balance first. */ - groupId: number; - /** Transfer amount (max 8 decimal places) */ - amount: string; +/** Adjust factor list item */ +export interface FuturesAdjustFactorList { + lever_rate: number; + ladders: FuturesAdjustFactorLadder[]; } ⋮---- -/** Transferer UID */ +/** Tiered adjustment factor item from swap_adjustfactor and swap_cross_adjustfactor. Cross includes business_type, pair, contract_type. */ +export interface FuturesAdjustFactor { + symbol: string; + contract_code: string; + margin_mode: string; + list: FuturesAdjustFactorList[]; + business_type?: string; + pair?: string; + contract_type?: string; +} ⋮---- -/** Transferee UID */ +/** Risk reserve balance from /v1/insurance_fund_info */ +export interface FuturesInsuranceFundInfo { + insurance_fund: string; + quote_currency?: string; +} ⋮---- -/** Group ID. 0 = termless points. For terminable points, query sub user balance first. */ +/** Historical risk reserve item from /v1/insurance_fund_history */ +export interface FuturesInsuranceFundHistory { + query_id: number; + insurance_fund: string; + date: string; +} ⋮---- -/** Transfer amount (max 8 decimal places) */ +/** Price limit item from swap_price_limit. business_type, pair, contract_type optional for CM products. */ +export interface FuturesPriceLimit { + symbol: string; + contract_code: string; + high_limit: number; + low_limit: number; + business_type?: string; + pair?: string; + contract_type?: string; +} ⋮---- -/** - * Trading - */ +/** Open interest item from swap_open_interest */ +export interface FuturesOpenInterest { + symbol: string; + volume: number; + amount: number; + contract_code: string; + value: number; + trade_amount: number; + trade_volume: number; + trade_turnover: number; + contract_type: string; + pair: string; + business_type: string; +} ⋮---- -/** Order type: direction-type. market=no price; limit=price+amount; limit-maker=maker only; ioc=immediately or cancel; limit-fok=fill or kill; stop-*=trigger price */ -export type SpotOrderType = - | 'buy-market' - | 'sell-market' - | 'buy-limit' - | 'sell-limit' - | 'buy-ioc' - | 'sell-ioc' - | 'buy-limit-maker' - | 'sell-limit-maker' - | 'buy-stop-limit' - | 'sell-stop-limit' - | 'buy-limit-fok' - | 'sell-limit-fok' - | 'buy-stop-limit-fok' - | 'sell-stop-limit-fok'; +/** Contract info item from swap_contract_info */ +export interface FuturesContractInfo { + symbol: string; + contract_code: string; + contract_size: number; + price_tick: number; + settlement_date: string; + settlement_period: string; + create_date: string; + delivery_time: string; + contract_status: number; + support_margin_mode?: string; + contract_type: string; + pair: string; + business_type: string; + delivery_date: string; + adjust?: unknown[]; + price_estimated?: unknown[]; + open_type?: number; + trade_partition?: string; + labels?: string[]; + tradfi_labels?: string[]; +} ⋮---- -/** Order source: spot-api, margin-api, super-margin-api, c2c-margin-api */ -export type SpotOrderSource = - | 'spot-api' - | 'margin-api' - | 'super-margin-api' - | 'c2c-margin-api'; +/** Index price item from swap_index. symbol optional (CM Delivery uses symbol). */ +export interface FuturesIndexPrice { + contract_code?: string; + symbol?: string; + index_price: number; + index_ts: number; +} ⋮---- -/** Req for POST /v1/order/orders/place */ -export interface SpotV1OrderPlaceReq { - /** Account ID from GET /v1/account/accounts. Required for trading. */ - 'account-id': string | number; - /** Trading symbol (e.g. ethusdt) */ +/** Index constituent component from swap_contract_constituents */ +export interface FuturesIndexConstituentComponent { + exchange: string; symbol: string; - /** Order type (e.g. buy-limit, sell-market) */ - type: SpotOrderType; - /** Order size. For buy-market = order value in quote currency. */ - amount: string; - /** Order price. Not used for market orders. Required for limit types. */ - price?: string; - /** Order source. Default spot-api */ - source?: SpotOrderSource; - /** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ - 'client-order-id'?: string; - /** 0=allow self-trade, 1=prevent. Default 0 */ - 'self-match-prevent'?: 0 | 1; - /** Trigger price for stop-limit orders */ - 'stop-price'?: string; - /** Operator for stop price (lte, gte, etc) */ - operator?: string; - /** RPI order - type must be buy-limit or sell-limit */ - 'time-in-force'?: 'rpi'; + /** Price as string. -1 means HTX masked proprietary third-party index pricing. */ + symbol_price: string; + weights: string; } ⋮---- -/** Account ID from GET /v1/account/accounts. Required for trading. */ -⋮---- -/** Trading symbol (e.g. ethusdt) */ +/** Price as string. -1 means HTX masked proprietary third-party index pricing. */ ⋮---- -/** Order type (e.g. buy-limit, sell-market) */ +/** Index constituents data from swap_contract_constituents. contract_code or symbol per product. */ +export interface FuturesIndexConstituents { + contract_code?: string; + symbol?: string; + index_price: string; + ts: number; + components: FuturesIndexConstituentComponent[]; +} ⋮---- -/** Order size. For buy-market = order value in quote currency. */ +/** Contract elements price tick / value item */ +export interface FuturesContractElementsPrice { + business_type: number; + price: string; +} ⋮---- -/** Order price. Not used for market orders. Required for limit types. */ +/** Contract elements order limit item */ +export interface FuturesContractElementsOrderLimit { + instrument_type: number; + open: string; + close: string; + order_type?: number; + open_after_closing?: string; +} ⋮---- -/** Order source. Default spot-api */ +/** Contract elements contract info item */ +export interface FuturesContractElementsContractInfo { + contract_code: string; + instrument_type: number; + settlement_date: string; + delivery_time: string; + create_date: string; + contract_status: number; + delivery_date: string; + trigger_protect?: number; +} ⋮---- -/** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ +/** Timestamp response from /api/v1/timestamp. No data field. */ +export interface FuturesTimestamp { + status: string; + ts: number; +} ⋮---- -/** 0=allow self-trade, 1=prevent. Default 0 */ +/** Heartbeat data from /heartbeat/ - system availability */ +export interface FuturesHeartbeat { + heartbeat?: number; + swap_heartbeat?: number; + estimated_recovery_time?: number | null; + swap_estimated_recovery_time?: number | null; + linear_swap_heartbeat?: number; + linear_swap_estimated_recovery_time?: number | null; +} ⋮---- -/** Trigger price for stop-limit orders */ -⋮---- -/** Operator for stop price (lte, gte, etc) */ +/** Contract elements item from swap_query_elements */ +export interface FuturesContractElements { + contract_code: string; + mode_type: number; + swap_delivery_type: number; + instrument_index_code: string; + real_time_settlement: number; + transfer_profit_ratio: number; + cross_transfer_profit_ratio: number; + instrument_type: number[]; + trade_partition: string; + min_level: string; + max_level: string; + settle_period: number; + funding_rate_cap: string; + funding_rate_floor: string; + trigger_protect?: number; + long_position_limit?: string; + offset_order_limit?: string; + open_order_limit?: string; + short_position_limit?: string; + price_tick?: string; + instrument_value?: string; + price_ticks?: FuturesContractElementsPrice[]; + instrument_values?: FuturesContractElementsPrice[]; + order_limits?: FuturesContractElementsOrderLimit[]; + normal_limits?: { + instrument_type: number; + open: string; + close: string; + }[]; + open_limits?: { instrument_type: number; open: string; close: string }[]; + trade_limits?: { + instrument_type: number; + open: string; + close: string; + }[]; + contract_infos?: FuturesContractElementsContractInfo[]; +} ⋮---- -/** RPI order - type must be buy-limit or sell-limit */ +/** + * Market + */ ⋮---- -/** Margin order with auto borrow/repay for POST /v1/order/auto/place. Sub-accounts not supported. */ -export interface SpotV1OrderAutoPlaceReq { - symbol: string; - 'account-id': string | number; - type: SpotOrderType; - /** 1: automatic loan, 2: automatic repayment */ - 'trade-purpose': '1' | '2'; - source: SpotOrderSource; - /** Order volume. For market buy = order value. Use amount or market-amount, not both. */ - amount?: string; - /** Market buy = order volume, market sell = order amount. Use amount or market-amount, not both. */ - 'market-amount'?: string; - /** Amount/quantity to borrow when trade-purpose=1. Max 3 decimal precision. */ - 'borrow-amount'?: string; - price?: string; - /** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ - 'client-order-id'?: string; - 'stop-price'?: string; - operator?: string; +/** Market depth tick from market/depth. ch, id, mrid, version optional per product. Payload in "tick". */ +export interface FuturesMarketDepthTick { + asks: [number, number][]; + bids: [number, number][]; + ch?: string; + id?: number; + mrid?: number; + ts: number; + version?: number; } ⋮---- -/** 1: automatic loan, 2: automatic repayment */ +/** BBO tick from market/bbo. contract_code or symbol per product. ask/bid: [price, qty]. */ +export interface FuturesBboTick { + contract_code?: string; + symbol?: string; + business_type?: string; + mrid: number; + ask: [number, number]; + bid: [number, number]; + ts: number; +} ⋮---- -/** Order volume. For market buy = order value. Use amount or market-amount, not both. */ +/** Kline item from market/history/kline. trade_turnover optional per product. */ +export interface FuturesKline { + id: number; + vol: number; + count: number; + open: number; + close: number; + low: number; + high: number; + amount: number; + trade_turnover?: number; +} ⋮---- -/** Market buy = order volume, market sell = order amount. Use amount or market-amount, not both. */ +/** Basis data item from /index/market/history/linear_swap_basis and /index/market/history/basis */ +export interface FuturesBasis { + id: number; + contract_price: string; + index_price: string; + basis: string; + basis_rate: string; +} ⋮---- -/** Amount/quantity to borrow when trade-purpose=1. Max 3 decimal precision. */ +/** Mark price kline item. Also used for premium index and estimated rate kline. trade_turnover optional. */ +export interface FuturesMarkPriceKline { + id: number; + vol: string; + count: string; + open: string; + close: string; + low: string; + high: string; + amount: string; + trade_turnover?: string; +} ⋮---- -/** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ +/** 24h ticker from market detail/merged. contract_code, symbol, business_type optional per product. */ +export interface FuturesTicker { + id: number; + ts: number; + amount: string; + count: number; + vol: string; + open: string; + close: string; + low: string; + high: string; + trade_turnover?: string; + ask: [number, number]; + bid: [number, number]; + contract_code?: string; + symbol?: string; + business_type?: string; + number_of?: string; +} ⋮---- -/** Req for POST /v1/order/orders/batchCancelOpenOrders */ -export interface SpotV1OrderBatchCancelOpenOrdersReq { - /** Account ID from GET /v1/account/accounts */ - 'account-id'?: string; - /** Comma-separated symbols (max 10). Default all */ +/** Trade item from last trade and history trade. symbol, contract_code, business_type, trade_turnover optional per product. */ +export interface FuturesTrade { + id: number; + price: string | number; + amount: string | number; + direction: string; + ts: number; + quantity?: string | number; + contract_code?: string; + business_type?: string; + trade_turnover?: string | number; symbol?: string; - /** Order types comma-separated */ - types?: string; - /** Filter: buy, sell */ - side?: 'buy' | 'sell'; - /** Orders to cancel [1-100]. Default 100 */ - size?: number; + /** Whether the trade involved an RPI order. USDT-M uses snake_case. */ + is_rpi_trade?: boolean | number | string; + /** Whether the trade is an RPI trade. Coin-M uses the hyphenated name. */ + 'is-rpi-trade'?: boolean | number | string; } ⋮---- -/** Account ID from GET /v1/account/accounts */ +/** Whether the trade involved an RPI order. USDT-M uses snake_case. */ ⋮---- -/** Comma-separated symbols (max 10). Default all */ +/** Whether the trade is an RPI trade. Coin-M uses the hyphenated name. */ ⋮---- -/** Order types comma-separated */ +/** Last trade tick from market/trade. Payload in "tick". */ +export interface FuturesLastTrade { + id: number; + ts: number; + data: FuturesTrade[]; +} ⋮---- -/** Filter: buy, sell */ +/** Trade history group from market/history/trade. Each group has trades by timestamp. */ +export interface FuturesTradeHistory { + id: number; + ts: number; + data: FuturesTrade[]; +} ⋮---- -/** Orders to cancel [1-100]. Default 100 */ +/** Open interest tick item from swap_his_open_interest */ +export interface FuturesOpenInterestTick { + volume: number; + amount_type: number; + ts: number; + value: number; +} ⋮---- -/** Req for GET /v1/order/orders (search past orders) */ -export interface SpotGetOrderHistoryReq { - /** Trading symbol (required) */ +/** Open interest data from swap_his_open_interest. data is object with tick array. */ +export interface FuturesHistoricalOpenInterest { symbol: string; - /** Order types comma-separated */ - types?: string; - /** Start time (unix ms). Max 48h window. */ - 'start-time'?: number; - /** End time (unix ms). Max 48h window, within 180 days. */ - 'end-time'?: number; - /** States: filled, partial-canceled, canceled (comma-separated, required) */ - states: string; - /** Start order ID for pagination */ - from?: string; - /** next=desc, prev=asc. Default both */ - direct?: 'next' | 'prev'; - /** Orders to return [1-100]. Default 100 */ - size?: number; + contract_code: string; + contract_type: string; + pair: string; + business_type: string; + tick: FuturesOpenInterestTick[]; } ⋮---- -/** Trading symbol (required) */ -⋮---- -/** Order types comma-separated */ -⋮---- -/** Start time (unix ms). Max 48h window. */ -⋮---- -/** End time (unix ms). Max 48h window, within 180 days. */ -⋮---- -/** States: filled, partial-canceled, canceled (comma-separated, required) */ -⋮---- -/** Start order ID for pagination */ -⋮---- -/** next=desc, prev=asc. Default both */ -⋮---- -/** Orders to return [1-100]. Default 100 */ +/** + * Account + */ ⋮---- -/** Req for GET /v1/order/history (48h historical orders) */ -export interface SpotGetOrderHistory48hReq { - /** Trading symbol */ - symbol?: string; - /** Start time (unix ms). Default 48h ago */ - 'start-time'?: number; - /** End time (unix ms). Default now */ - 'end-time'?: number; - /** prev=asc, next=desc. Default next */ - direct?: 'prev' | 'next'; - /** Items per response [10-1000]. Default 100 */ - size?: number; +/** Asset valuation item from swap_balance_valuation */ +export interface FuturesBalanceValuation { + valuation_asset: string; + balance: string; } ⋮---- -/** Trading symbol */ -⋮---- -/** Start time (unix ms). Default 48h ago */ -⋮---- -/** End time (unix ms). Default now */ -⋮---- -/** prev=asc, next=desc. Default next */ -⋮---- -/** Items per response [10-1000]. Default 100 */ -⋮---- -/** Req for GET /v1/order/matchresults (search match results) */ -export interface SpotGetMatchResultsReq { - /** Trading symbol */ - symbol?: string; - /** Order types comma-separated */ - types?: string; - /** Start time (unix ms). 48h window, 120 days range */ - 'start-time'?: number; - /** End time (unix ms). 48h window */ - 'end-time'?: number; - /** Internal id to begin pagination (use last id of prev page) */ - from?: string; - /** next or prev. Default next */ - direct?: 'next' | 'prev'; - /** Items to return [1-500]. Default 100 */ - size?: number; +/** Isolated account info item from swap_account_info */ +export interface FuturesIsolatedAccountInfo { + symbol: string; + contract_code: string; + margin_asset: string; + margin_balance: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | null; + new_risk_rate?: string | null; + trade_partition?: string; + withdraw_available: number; + liquidation_price: number | null; + lever_rate: number; + adjust_factor: number; + margin_static: number; + margin_mode: string; + margin_account: string; + position_mode: string; } ⋮---- -/** Trading symbol */ -⋮---- -/** Order types comma-separated */ -⋮---- -/** Start time (unix ms). 48h window, 120 days range */ -⋮---- -/** End time (unix ms). 48h window */ -⋮---- -/** Internal id to begin pagination (use last id of prev page) */ +/** Cross account contract detail (swap + futures) from swap_cross_account_info */ +export interface FuturesCrossAccountContractDetail { + symbol: string; + contract_code: string; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_unreal: number; + liquidation_price: number | null; + lever_rate: number; + adjust_factor: number; + contract_type: string; + cross_max_available?: string; + trade_partition?: string; + pair: string; + business_type: string; +} ⋮---- -/** next or prev. Default next */ +/** Cross account info item from swap_cross_account_info */ +export interface FuturesCrossAccountInfo { + margin_mode: string; + margin_account: string; + margin_asset: string; + margin_balance: number; + margin_static: number; + margin_position: number; + margin_frozen: number; + profit_unreal: number; + withdraw_available: number; + risk_rate: number | null; + money_in?: string; + money_out?: string; + new_risk_rate?: string | null; + position_mode: string; + contract_detail: FuturesCrossAccountContractDetail[]; + futures_contract_detail: FuturesCrossAccountContractDetail[]; +} ⋮---- -/** Items to return [1-500]. Default 100 */ +/** Position info item from swap_position_info and swap_cross_position_info */ +export interface FuturesPositionInfo { + symbol: string; + contract_code: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + margin_asset: string; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + margin_mode: string; + margin_account: string; + position_mode: string; + withdraw_available?: number; + risk_rate?: number | null; + liquidation_price?: number | null; + adl_risk_percent?: string | number; + contract_type?: string; + pair?: string; + business_type?: string; + margin?: number | string; +} ⋮---- -/** Req for GET /v1/order/openOrders */ -export interface SpotGetOpenOrdersReq { - /** Account ID from GET /v1/account/accounts */ - 'account-id'?: string; - /** Trading symbol (e.g. ethusdt) */ - symbol?: string; - /** Filter: buy, sell */ - side?: 'buy' | 'sell'; - /** Order types comma-separated */ - types?: string; - /** Start order ID for pagination */ - from?: string; - /** prev=asc from start, next=desc from start */ - direct?: 'prev' | 'next'; - /** Orders to return [1-500]. Default 100 */ - size?: number; +/** Nested position in swap_account_position_info */ +export interface FuturesAccountPosition { + symbol: string; + contract_code: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + margin_asset: string; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + margin_mode: string; + margin_account: string; + position_mode: string; + adl_risk_percent?: string | number; + new_risk_rate?: string | null; + trade_partition?: string; } ⋮---- -/** Account ID from GET /v1/account/accounts */ +/** Account + positions from swap_account_position_info (Isolated) */ +export interface FuturesIsolatedAccountPosition { + symbol: string; + contract_code: string; + margin_asset: string; + margin_balance: number; + margin_static: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | null; + new_risk_rate?: string | null; + trade_partition?: string; + liquidation_price: number | null; + withdraw_available: number; + lever_rate: number; + adjust_factor: number; + margin_mode: string; + margin_account: string; + position_mode: string; + positions: FuturesAccountPosition[]; + adl_risk_percent?: string | number; +} ⋮---- -/** Trading symbol (e.g. ethusdt) */ +/** Cross position item (in positions array) from swap_cross_account_position_info */ +export interface FuturesCrossAccountPositionItem { + symbol: string; + contract_code: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + margin_asset: string; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + margin_mode: string; + margin_account: string; + contract_type: string; + pair: string; + business_type: string; + position_mode: string; + new_risk_rate?: string | null; + trade_partition?: string; +} ⋮---- -/** Filter: buy, sell */ +/** Cross account + positions from swap_cross_account_position_info. data is object, not array. */ +export interface FuturesCrossAccountPosition { + margin_mode: string; + margin_account: string; + margin_asset: string; + margin_balance: number; + margin_static: number; + margin_position: number; + margin_frozen: number; + profit_real?: number; + profit_unreal: number; + withdraw_available: number; + risk_rate: number | null; + money_in?: string; + money_out?: string; + new_risk_rate?: string | null; + position_mode: string; + contract_detail: FuturesCrossAccountContractDetail[]; + futures_contract_detail: FuturesCrossAccountContractDetail[]; + positions: FuturesCrossAccountPositionItem[]; + adl_risk_percent?: string | number; +} ⋮---- -/** Order types comma-separated */ +/** Sub auth error from swap_sub_auth and swap_sub_auth_list */ +export interface FuturesSubAuthError { + sub_uid: string; + err_code: number | string; + err_msg: string; +} ⋮---- -/** Start order ID for pagination */ +/** Sub auth response data from swap_sub_auth */ +export interface FuturesSubAuth { + errors: FuturesSubAuthError[]; + successes: string; +} ⋮---- -/** prev=asc from start, next=desc from start */ +/** Sub auth success item from swap_sub_auth_list */ +export interface FuturesSubAuthSuccess { + query_id?: number; + sub_uid: string; + sub_auth: number | string; +} ⋮---- -/** Orders to return [1-500]. Default 100 */ +/** Sub permissions response from getSubPermissions */ +export interface FuturesSubPermissions { + errors: FuturesSubAuthError[]; + successes: FuturesSubAuthSuccess[]; +} ⋮---- -/** - * Conditional Order - */ -⋮---- -/** Req for POST /v2/algo-orders (Place a conditional order). Conditional orders only via this endpoint, not Trading section. */ -export interface SpotV2AlgoOrdersPlaceReq { - /** Account ID. Spot, margin, super-margin. C2C margin not supported. */ - accountId?: number; - /** Trading symbol */ - symbol?: string; - /** Order price (invalid for market order) */ - orderPrice?: string; - /** Order side: buy, sell */ - orderSide?: 'buy' | 'sell'; - /** Order size (invalid for market buy order) */ - orderSize?: string; - /** Order value (only valid for market buy order) */ - orderValue?: string; - /** Time in force: gtc, boc, ioc, fok. gtc=good till cancel, boc=book or cancel, ioc=immediate or cancel, fok=fill or kill. gtc for limit; ioc for market. */ - timeInForce?: 'gtc' | 'boc' | 'ioc' | 'fok'; - /** Order type: limit, market */ - orderType?: 'limit' | 'market'; - /** Client order ID (max 64 chars). Must be unique within 24h for same user. */ - clientOrderId?: string; - /** Stop price */ - stopPrice?: string; - /** Trailing rate [0.001-0.050]. Only valid for trailing stop order */ - trailingRate?: string; +/** Isolated sub-account list item from swap_sub_account_list */ +export interface FuturesIsolatedSubAccountList { + symbol: string; + contract_code: string; + margin_asset: string; + margin_balance: number; + liquidation_price: number | null; + risk_rate: number | string | null; + margin_mode: string; + margin_account: string; + /** Used as from_id for next/prev pagination */ + query_id?: number; } ⋮---- -/** Account ID. Spot, margin, super-margin. C2C margin not supported. */ -⋮---- -/** Trading symbol */ +/** Used as from_id for next/prev pagination */ ⋮---- -/** Order price (invalid for market order) */ +/** Isolated sub-account entry from swap_sub_account_list (data array element) */ +export interface FuturesIsolatedSubAccountListEntry { + sub_uid: number; + list: FuturesIsolatedSubAccountList[]; +} ⋮---- -/** Order side: buy, sell */ +/** Cross sub-account list item from swap_cross_sub_account_list */ +export interface FuturesCrossSubAccountList { + margin_mode: string; + margin_account: string; + margin_asset: string; + margin_balance: number; + risk_rate: number | string | null; + trade_partition?: string; +} ⋮---- -/** Order size (invalid for market buy order) */ +/** Asset multi-sub object from swap_cross_sub_account_list. Can be null. */ +export interface FuturesCrossSubAccountAssetMultiSub { + state: string; + equity: string; + initial_margin: string; + maintenance_margin: string; + maintenance_margin_rate: string; + profit_unreal: string; + available_margin: string; + created_time: number | string; + updated_time: number | string; + details: unknown[]; +} ⋮---- -/** Order value (only valid for market buy order) */ +/** Cross sub-account entry from swap_cross_sub_account_list (data array element) */ +export interface FuturesCrossSubAccountListEntry { + query_id: number; + sub_uid: number; + list: FuturesCrossSubAccountList[]; + asset_multi_sub: FuturesCrossSubAccountAssetMultiSub | null; +} ⋮---- -/** Time in force: gtc, boc, ioc, fok. gtc=good till cancel, boc=book or cancel, ioc=immediate or cancel, fok=fill or kill. gtc for limit; ioc for market. */ +/** Account info item from swap_sub_account_info_list */ +export interface FuturesSubAccountInfoAccount { + symbol: string; + contract_code: string; + margin_account: string; + margin_mode: string; + margin_asset: string; + margin_balance: number; + liquidation_price: number | null; + risk_rate: number | string | null; +} ⋮---- -/** Order type: limit, market */ +/** Sub-account item in swap_sub_account_info_list data.sub_list */ +export interface FuturesSubAccountInfoSub { + sub_uid: number; + account_info_list: FuturesSubAccountInfoAccount[]; +} ⋮---- -/** Client order ID (max 64 chars). Must be unique within 24h for same user. */ +/** object from swap_sub_account_info_list */ +export type FuturesSubAccountInfoList = + FuturesPaginatedSubList; ⋮---- -/** Stop price */ +/** Cross sub-account info list: account_info_list item (no symbol/contract_code) */ +export interface FuturesCrossSubAccountInfoListAccount { + margin_mode: string; + margin_account: string; + margin_asset: string; + margin_balance: number; + risk_rate: number | string | null; + trade_partition?: string; +} ⋮---- -/** Trailing rate [0.001-0.050]. Only valid for trailing stop order */ +/** Cross sub-account info list: sub_list item */ +export interface FuturesCrossSubAccountInfoListSub { + sub_uid: number; + account_info_list: FuturesCrossSubAccountInfoListAccount[]; +} ⋮---- -export interface SpotV2AlgoOrdersOpeningReq { - /** Account ID */ - accountId?: number; - /** Trading symbol */ - symbol?: string; - /** Order side: buy, sell */ - orderSide?: 'buy' | 'sell'; - /** Order type: limit, market */ - orderType?: 'limit' | 'market'; - /** Sort: asc, desc. Default desc */ - sort?: 'asc' | 'desc'; - /** Max items [1-500]. Default 100 */ - limit?: number; - /** First record ID for next-page pagination */ - fromId?: number; +/** Cross sub-account info list: unite_sub_list item */ +export interface FuturesCrossSubAccountInfoListUnite { + sub_uid: number; + asset_multi_sub: FuturesCrossSubAccountAssetMultiSub; } ⋮---- -/** Account ID */ +/** object from swap_cross_sub_account_info_list */ +export type FuturesCrossSubAccountInfoList = + FuturesPaginatedSubList & { + unite_sub_list: FuturesCrossSubAccountInfoListUnite[]; + }; ⋮---- -/** Trading symbol */ +/** Isolated sub-account info item from swap_sub_account_info (single sub, data array element) */ +export interface FuturesIsolatedSubAccountInfo { + symbol: string; + contract_code: string; + margin_asset: string; + margin_balance: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | string | null; + new_risk_rate?: string | null; + trade_partition?: string; + liquidation_price: number | null; + withdraw_available: number; + lever_rate: number; + adjust_factor: number; + margin_static: number; + margin_mode: string; + margin_account: string; + position_mode: string; +} ⋮---- -/** Order side: buy, sell */ +/** Cross sub-account info item from swap_cross_sub_account_info (single sub, data array element) */ +export interface FuturesCrossSubAccountInfo { + margin_mode: string; + margin_account: string; + margin_asset: string; + margin_balance: number; + margin_static: number; + margin_position: number; + margin_frozen: number; + profit_real?: number; + profit_unreal: number; + withdraw_available: number; + risk_rate: number | string | null; + money_in?: string; + money_out?: string; + new_risk_rate?: string | null; + position_mode: string; + contract_detail: FuturesCrossAccountContractDetail[]; + futures_contract_detail: FuturesCrossAccountContractDetail[]; +} ⋮---- -/** Order type: limit, market */ +/** Financial record item from swap_financial_record and swap_financial_record_exact */ +export interface FuturesFinancialRecord { + query_id: number; + id: number; + ts: number; + asset: string; + contract_code: string; + margin_account: string; + face_margin_account: string; + type: number; + amount: number | string; +} ⋮---- -/** Sort: asc, desc. Default desc */ +/** Available leverage item from swap_available_level_rate */ +export interface FuturesAvailableLevelRate { + contract_code: string; + margin_mode: string; + available_level_rate: string; +} ⋮---- -/** Max items [1-500]. Default 100 */ +/** Available leverage item from swap_cross_available_level_rate */ +export interface FuturesCrossAvailableLevelRate { + contract_code: string; + margin_mode: string; + available_level_rate: string; + contract_type: string; + pair: string; + business_type: string; +} ⋮---- -/** First record ID for next-page pagination */ +/** Order limit list item from swap_order_limit */ +export interface FuturesOrderLimitList { + symbol: string; + contract_code: string; + open_limit: number; + close_limit: number; + contract_type: string; + pair: string; + business_type: string; +} ⋮---- -/** Req for GET /v2/algo-orders/history (Query conditional order history). orderStatus: canceled, rejected, triggered. */ -export interface SpotV2AlgoOrdersHistoryReq { - /** Account ID */ - accountId?: number; - /** Trading symbol */ - symbol?: string; - /** Order side: buy, sell */ - orderSide?: 'buy' | 'sell'; - /** Order type: limit, market */ - orderType?: 'limit' | 'market'; - /** Order status: canceled, rejected, triggered */ - orderStatus?: 'canceled' | 'rejected' | 'triggered'; - /** Start time (unix ms) */ - startTime?: number; - /** End time (unix ms) */ - endTime?: number; - /** Sort: asc, desc */ - sort?: 'asc' | 'desc'; - /** Max items [1-500] */ - limit?: number; - /** First record ID for next-page pagination */ - fromId?: number; +/** from swap_order_limit */ +export interface FuturesOrderLimit { + order_price_type: string; + list: FuturesOrderLimitList[]; } ⋮---- -/** Account ID */ -⋮---- -/** Trading symbol */ -⋮---- -/** Order side: buy, sell */ -⋮---- -/** Order type: limit, market */ -⋮---- -/** Order status: canceled, rejected, triggered */ -⋮---- -/** Start time (unix ms) */ -⋮---- -/** End time (unix ms) */ -⋮---- -/** Sort: asc, desc */ +/** Fee item from swap_fee */ +export interface FuturesFee { + symbol: string; + contract_code: string; + open_maker_fee: string; + open_taker_fee: string; + close_maker_fee: string; + close_taker_fee: string; + fee_asset: string; + contract_type: string; + pair: string; + business_type: string; + delivery_fee: string; +} ⋮---- -/** Max items [1-500] */ +/** Transfer limit item from swap_transfer_limit */ +export interface FuturesTransferLimit { + symbol: string; + contract_code: string; + margin_mode: string; + margin_account: string; + transfer_in_max_each: number; + transfer_in_min_each: number; + transfer_out_max_each: number; + transfer_out_min_each: number; + transfer_in_max_daily: number; + transfer_out_max_daily: number; + net_transfer_in_max_daily: number; + net_transfer_out_max_daily: number; +} ⋮---- -/** First record ID for next-page pagination */ +/** Transfer limit item from swap_cross_transfer_limit */ +export interface FuturesCrossTransferLimit { + margin_mode: string; + margin_account: string; + transfer_in_max_each: number; + transfer_in_min_each: number; + transfer_out_max_each: number; + transfer_out_min_each: number; + transfer_in_max_daily: number; + transfer_out_max_daily: number; + net_transfer_in_max_daily: number; + net_transfer_out_max_daily: number; +} ⋮---- -/** - * Margin Loan (Cross/Isolated) - */ +/** Position limit item from swap_position_limit */ +export interface FuturesPositionLimit { + symbol: string; + contract_code: string; + margin_mode: string; + buy_limit: number; + sell_limit: number; + lever_rate: number; + buy_limit_value: number; + sell_limit_value: number; + mark_price: number; +} ⋮---- -/** Req for GET /v2/account/repayment (Repayment Record Reference). Sorted by repayTime. */ -export interface SpotRepaymentRecordReq { - /** Repayment transaction ID */ - repayId?: string; - /** Account ID. Default all accounts */ - accountId?: string; - /** Borrowing/lending currency. Default all currencies */ - currency?: string; - /** Start time (unix ms). Range: [(endTime – x D), endTime] */ - startTime?: number; - /** End time (unix ms). Range: [(now – y D), now]. Default now */ - endTime?: number; - /** Sort: asc, desc. Default desc */ - sort?: 'asc' | 'desc'; - /** Max items [1-100]. Default 50 */ - limit?: number; - /** Search ID for next-page pagination */ - fromId?: number; +/** Position limit item from swap_cross_position_limit */ +export interface FuturesCrossPositionLimit { + symbol: string; + contract_code: string; + margin_mode: string; + buy_limit: number; + sell_limit: number; + lever_rate: number; + buy_limit_value: number; + sell_limit_value: number; + mark_price: number; + contract_type: string; + pair: string; + business_type: string; } ⋮---- -/** Repayment transaction ID */ +/** Lever position limit list item (per leverage) from swap_lever_position_limit */ +export interface FuturesLeverPositionLimitList { + lever_rate: number; + buy_limit_value: number; + sell_limit_value: number; +} ⋮---- -/** Account ID. Default all accounts */ +/** Lever position limit item from swap_lever_position_limit */ +export interface FuturesLeverPositionLimit { + symbol: string; + contract_code: string; + margin_mode: string; + list: FuturesLeverPositionLimitList[]; +} ⋮---- -/** Borrowing/lending currency. Default all currencies */ +/** Lever position limit item from swap_cross_lever_position_limit */ +export interface FuturesCrossLeverPositionLimit { + symbol: string; + contract_code: string; + margin_mode: string; + business_type: string; + contract_type: string; + pair: string; + list: FuturesLeverPositionLimitList[]; +} ⋮---- -/** Start time (unix ms). Range: [(endTime – x D), endTime] */ +/** Master-sub transfer response from transfer*MasterSub */ +export interface FuturesMasterSubTransfer { + order_id: string; + client_order_id?: number; +} ⋮---- -/** End time (unix ms). Range: [(now – y D), now]. Default now */ +/** Transfer record item from master_sub_transfer_record. asset, margin_account, symbol, contract_code optional per product. */ +export interface FuturesMasterSubTransferRecordItem { + id: number; + ts: number; + sub_uid: string; + sub_account_name: string; + transfer_type: number; + amount: number | string; + asset?: string; + margin_account?: string; + from_margin_account?: string; + to_margin_account?: string; + symbol?: string; + contract_code?: string; +} ⋮---- -/** Sort: asc, desc. Default desc */ +/** Master-sub transfer records from swap_master_sub_transfer_record */ +export type FuturesMasterSubTransferRecords = + FuturesPaginatedTransferRecord; ⋮---- -/** Max items [1-100]. Default 50 */ +/** Cancel-after response data from linear-cancel-after */ +export interface FuturesCancelAfter { + current_time: number; + trigger_time: number; +} ⋮---- -/** Search ID for next-page pagination */ +/** Submit order response data from swap_order and swap_cross_order. order_id may exceed JS safe integer - use order_id_str. */ +export interface FuturesSubmitOrder { + order_id: number | string; + order_id_str: string; + client_order_id?: number; +} ⋮---- -/** Req for POST /v2/account/repayment (Repay Margin Loan). Loan interest paid first if no transactId. */ -export interface SpotMarginRepaymentReq { - /** Repayment account ID */ - accountId?: string; - /** Repayment currency */ - currency?: string; - /** Repayment amount */ - amount?: string; - /** Loan transaction ID. When specified, repay that loan; otherwise interest paid first. */ - transactId?: string; +/** Batch order error item from swap_batchorder and swap_cross_batchorder */ +export interface FuturesBatchOrderError { + index: number; + err_code: number; + err_msg: string; } ⋮---- -/** Repayment account ID */ +/** Batch order success item from swap_batchorder and swap_cross_batchorder */ +export interface FuturesBatchOrderSuccess { + index: number; + order_id: number | string; + order_id_str: string; + client_order_id?: number; +} ⋮---- -/** Repayment currency */ +/** Cancel order error item from swap_cancel and swap_cross_cancel */ +export interface FuturesCancelOrderError { + order_id: string; + err_code: number; + err_msg: string; +} ⋮---- -/** Repayment amount */ +/** Cancel order response data from swap_cancel, swap_cross_cancel, swap_cancelall, swap_cross_cancelall */ +export interface FuturesCancelOrder { + errors: FuturesCancelOrderError[]; + /** Comma-separated list of successfully cancelled order_id or client_order_id */ + successes: string; +} ⋮---- -/** Loan transaction ID. When specified, repay that loan; otherwise interest paid first. */ +/** Comma-separated list of successfully cancelled order_id or client_order_id */ ⋮---- -/** Req for POST /v1/dw/transfer-in/margin (Transfer Spot -> Isolated Margin). */ -export interface SpotMarginTransferInIsolatedReq { - /** Trading symbol (e.g. btcusdt, ethusdt) */ - symbol?: string; - /** Currency to transfer */ - currency?: string; - /** Amount to transfer */ - amount?: string; +/** Switch leverage response data from swap_switch_lever_rate */ +export interface FuturesSwitchLeverRate { + contract_code: string; + margin_mode: string; + lever_rate: number; } ⋮---- -/** Trading symbol (e.g. btcusdt, ethusdt) */ -⋮---- -/** Currency to transfer */ +/** Switch leverage response data from swap_cross_switch_lever_rate */ +export interface FuturesCrossSwitchLeverRate { + contract_code: string; + margin_mode: string; + lever_rate: number; + contract_type: string; + pair: string; + business_type: string; +} ⋮---- -/** Amount to transfer */ +/** + * Batch order response data from swap_batchorder and swap_cross_batchorder. + * A successful request can contain both accepted and rejected orders. + */ +export interface FuturesBatchOrder { + errors: FuturesBatchOrderError[]; + success: FuturesBatchOrderSuccess[]; +} ⋮---- -/** Req for POST /v1/dw/transfer-out/margin (Transfer Isolated Margin -> Spot). */ -export interface SpotMarginTransferOutIsolatedReq { - /** Trading symbol (e.g. btcusdt, ethusdt) */ - symbol?: string; - /** Currency to transfer */ - currency?: string; - /** Amount to transfer */ - amount?: string; +/** Position mode item from swap_switch_position_mode and swap_cross_switch_position_mode */ +export interface FuturesSwitchPositionMode { + margin_account: string; + position_mode: string; } ⋮---- -/** Trading symbol (e.g. btcusdt, ethusdt) */ -⋮---- -/** Currency to transfer */ -⋮---- -/** Amount to transfer */ -⋮---- -/** Req for POST /v1/margin/orders (Request a Margin Loan, Isolated) */ -export interface SpotMarginLoanOrderReq { - /** Trading symbol to borrow margin (e.g. btcusdt, ethusdt) */ - symbol?: string; - /** Currency to borrow */ - currency?: string; - /** Amount to borrow (max 3 decimal places) */ - amount?: string; +/** Order info item from getOrderInfo, getCoinMDeliveryOrderInfo, getCoinMPerpOrderInfo. Product-specific fields optional. */ +export interface FuturesOrderInfo { + symbol: string; + contract_code: string; + volume: number; + price: number; + order_price_type: string; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + created_at: number; + canceled_at: number | null; + trade_volume: number; + trade_turnover: number; + fee: number; + trade_avg_price: number | null; + margin_frozen: number; + profit: number; + status: number; + order_source: string; + fee_asset: string; + liquidation_type: string | null; + is_tpsl: number; + real_profit: number; + update_time?: number; + /** USDM only */ + margin_asset?: string; + margin_mode?: string; + margin_account?: string; + reduce_only?: number; + fee_amount?: number; + fee_quote_amount?: number; + self_match_prevent_new?: string; + /** CM Delivery: required; USDM/CM Perp: optional */ + contract_type?: string; + pair?: string; + business_type?: string; + canceled_source?: string; + self_match_prevent?: number; } ⋮---- -/** Trading symbol to borrow margin (e.g. btcusdt, ethusdt) */ +/** USDM only */ ⋮---- -/** Currency to borrow */ +/** CM Delivery: required; USDM/CM Perp: optional */ ⋮---- -/** Amount to borrow (max 3 decimal places) */ +/** Order detail trade item (trades array) from getOrderDetail, getCoinMDeliveryOrderDetail, getCoinMPerpOrderDetail */ +export interface FuturesOrderDetailTrade { + id: string; + trade_id: number | string; + trade_price: number; + trade_volume: number; + trade_turnover: number; + trade_fee: number; + role: string; + created_at: number; + profit: number; + real_profit: number; + fee_asse?: string; + price?: string; + fee_asset?: string; + canceled_source?: string; + self_match_prevent?: string | number; +} ⋮---- -/** Req for GET /v1/margin/loan-orders (Search Past Margin Orders, Isolated) */ -export interface SpotMarginLoanOrdersReq { - /** Trading symbol (e.g. btcusdt) */ - symbol?: string; - /** Order states comma-separated: created, accrual, cleared, invalid, failed */ - states?: string; - /** Start date yyyy-mm-dd. Default -61d */ - 'start-date'?: string; - /** End date yyyy-mm-dd. Default today */ - 'end-date'?: string; - /** Search order id to begin with */ - from?: string; - /** Search direction when from is used: next, prev */ - direct?: 'next' | 'prev'; - /** Orders to return [1-100]. Default 100 */ - size?: number; - /** Sub user ID (required when parent queries sub user's orders) */ - 'sub-uid'?: number; +/** Order detail from getOrderDetail, getCoinMDeliveryOrderDetail, getCoinMPerpOrderDetail. Product-specific fields optional. */ +export interface FuturesOrderDetail { + symbol: string; + contract_code: string; + lever_rate: number; + direction: string; + offset: string; + volume: number; + price: number; + created_at: number; + canceled_at: number; + order_source: string; + order_price_type: string; + margin_frozen: number; + profit: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + order_type: number | string; + status: number; + trade_volume: number; + trade_turnover: number; + trade_avg_price: number; + total_page: number; + current_page: number; + total_size: number; + instrument_price: number; + final_interest: number; + adjust_value: number; + fee_asset: string; + fee: number; + liquidation_type: string; + is_tpsl: number; + real_profit: number; + trades: FuturesOrderDetailTrade[]; + /** USDM only */ + margin_asset?: string; + margin_mode?: string; + margin_account?: string; + reduce_only?: number; + self_match_prevent_new?: string; + /** CM Delivery: required; USDM/CM Perp: optional */ + contract_type?: string; + pair?: string; + business_type?: string; + canceled_source?: string; + self_match_prevent?: number; } ⋮---- -/** Trading symbol (e.g. btcusdt) */ +/** USDM only */ ⋮---- -/** Order states comma-separated: created, accrual, cleared, invalid, failed */ +/** CM Delivery: required; USDM/CM Perp: optional */ ⋮---- -/** Start date yyyy-mm-dd. Default -61d */ +/** Open order item from swap_openorders and swap_cross_openorders */ +export interface FuturesOpenOrder { + symbol: string; + contract_code: string; + volume: number; + price: number; + order_price_type: string; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + created_at: number; + trade_volume: number; + trade_turnover: number; + fee: number; + trade_avg_price: number | null; + margin_frozen: number; + margin_asset: string; + profit: number; + status: number; + order_source: string; + fee_asset: string; + liquidation_type: string | null; + canceled_at: number | null; + margin_mode: string; + margin_account: string; + is_tpsl: number; + real_profit: number; + update_time: number; + reduce_only: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; +} ⋮---- -/** End date yyyy-mm-dd. Default today */ +/** Cross margin only */ ⋮---- -/** Search order id to begin with */ +/** Open orders response from swap_openorders and swap_cross_openorders */ +export type FuturesOpenOrders = FuturesPaginatedOrders & { + self_match_prevent_new: string; + self_match_prevent?: number; + canceled_source?: string; +}; ⋮---- -/** Search direction when from is used: next, prev */ +/** History order from getHistoryOrders, getCoinMDeliveryHistoryOrders, getCoinMPerpHistoryOrders. Product-specific optional. */ +export interface FuturesHistoryOrder { + query_id: number; + order_id: number | string; + order_id_str: string; + symbol: string; + contract_code: string; + lever_rate: number; + direction: string; + offset: string; + volume: number; + price: number; + create_date: number; + update_time: number; + order_source: string; + order_price_type: string | number; + order_type: number; + margin_frozen: number; + profit: number; + trade_volume: number; + trade_turnover: number; + fee: number; + trade_avg_price: number; + status: number; + fee_asset: string; + liquidation_type: string; + is_tpsl: number; + real_profit: number; + /** USDM only */ + margin_mode?: string; + margin_account?: string; + margin_asset?: string; + reduce_only?: number; + self_match_prevent_new?: string; + /** CM Delivery: required; USDM/CM Perp: optional */ + contract_type?: string; + pair?: string; + business_type?: string; + canceled_source?: string; + self_match_prevent?: number; +} ⋮---- -/** Orders to return [1-100]. Default 100 */ +/** USDM only */ ⋮---- -/** Sub user ID (required when parent queries sub user's orders) */ +/** CM Delivery: required; USDM/CM Perp: optional */ ⋮---- -/** Req for GET /v1/cross-margin/loan-orders (Search Past Margin Orders, Cross) */ -export interface SpotCrossMarginLoanOrdersReq { - /** Start date yyyy-mm-dd. Default -61d */ - 'start-date'?: string; - /** End date yyyy-mm-dd. Default today */ - 'end-date'?: string; - /** Currency filter */ - currency?: string; - /** Order state: created, accrual, cleared, invalid. Default all */ - state?: string; - /** Search order id to begin with. Default 0 */ - from?: string; - /** Search direction when from is used: next, prev. Default next */ - direct?: 'next' | 'prev'; - /** Orders to return [10-100]. Default 10 */ - size?: number; - /** Sub user UID */ - 'sub-uid'?: number; +/** Fill / match result from getFills, getCoinMDeliveryFills, getCoinMPerpFills. Product-specific optional. */ +export interface FuturesMatchResult { + id: string; + query_id: number; + match_id: number | string; + order_id: number | string; + order_id_str: string; + symbol: string; + contract_code: string; + direction: string; + offset: string; + trade_volume: number; + trade_price: number; + trade_turnover: number; + create_date: number; + offset_profitloss: number; + trade_fee: number; + role: string; + real_profit: number; + fee_asset: string; + order_source: string; + /** USDM only */ + margin_mode?: string; + margin_account?: string; + reduce_only?: number; + /** CM Delivery: required; USDM/CM Perp: optional */ + contract_type?: string; + pair?: string; + business_type?: string; + /** getFillsExact only */ + ht_price?: string; } ⋮---- -/** Start date yyyy-mm-dd. Default -61d */ -⋮---- -/** End date yyyy-mm-dd. Default today */ -⋮---- -/** Currency filter */ -⋮---- -/** Order state: created, accrual, cleared, invalid. Default all */ -⋮---- -/** Search order id to begin with. Default 0 */ -⋮---- -/** Search direction when from is used: next, prev. Default next */ +/** USDM only */ ⋮---- -/** Orders to return [10-100]. Default 10 */ +/** CM Delivery: required; USDM/CM Perp: optional */ ⋮---- -/** Sub user UID */ +/** getFillsExact only */ ⋮---- -/** Req for POST /v1/dw/withdraw/api/create. Create withdraw request. */ -export interface SpotWithdrawCreateReq { - /** - * Destination address. - * On-chain: chain address. - * Internal: UID:1234567, PHONE:xxx, MAIL:xxx. - * Poloniex zero-fee cross-exchange: POLOUSER:{UUID} (linked on HTX first). - */ - address: string; - /** Crypto currency */ - currency: string; - /** Amount to withdraw */ - amount: string; - /** Fee. Use 0 for UID withdraw and Poloniex cross-exchange transfers. */ - fee?: number; - /** - * Chain. Required for multi-chain coins. - * For internal withdraw or Poloniex cross-exchange transfer, use t397342. - */ - chain?: string; - /** Address tag. For UID withdraw, use recipient UID. */ - 'addr-tag'?: string; - /** Client order id for idempotency (max 32 char) */ - 'client-order-id'?: string; - /** Exchange VASP id from /v1/query/vasp-list */ - 'exchange-vasp'?: string; - /** Recipient name for Korean/English: "SURNAME##FIRSTNAME" */ - 'user-name-vasp'?: string; +/** Position mode item from swap_position_side and swap_cross_position_side */ +export interface FuturesPositionSideInfo { + margin_account: string; + position_mode: 'single_side' | 'dual_side'; } ⋮---- -/** - * Destination address. - * On-chain: chain address. - * Internal: UID:1234567, PHONE:xxx, MAIL:xxx. - * Poloniex zero-fee cross-exchange: POLOUSER:{UUID} (linked on HTX first). - */ +/** Transfer state item from swap_cross_transfer_state */ +export interface FuturesCrossTransferState { + margin_mode: string; + margin_account: string; + /** 1: available, 0: unavailable */ + transfer_in: number; + /** 1: available, 0: unavailable */ + transfer_out: number; + /** 1: available, 0: unavailable */ + master_transfer_sub: number; + /** 1: available, 0: unavailable */ + sub_transfer_master: number; + master_transfer_sub_inner_in: number; + master_transfer_sub_inner_out: number; + sub_transfer_master_inner_in: number; + sub_transfer_master_inner_out: number; + transfer_inner_in: number; + transfer_inner_out: number; +} ⋮---- -/** Crypto currency */ +/** 1: available, 0: unavailable */ ⋮---- -/** Amount to withdraw */ +/** 1: available, 0: unavailable */ ⋮---- -/** Fee. Use 0 for UID withdraw and Poloniex cross-exchange transfers. */ +/** 1: available, 0: unavailable */ ⋮---- -/** - * Chain. Required for multi-chain coins. - * For internal withdraw or Poloniex cross-exchange transfer, use t397342. - */ +/** 1: available, 0: unavailable */ ⋮---- -/** Address tag. For UID withdraw, use recipient UID. */ +/** Trade state item from swap_cross_trade_state */ +export interface FuturesCrossTradeState { + symbol: string; + contract_code: string; + margin_mode: string; + margin_account: string; + contract_type: string; + pair: string; + business_type: string; + /** 1=available, 0=unavailable */ + open: number; + /** 1=available, 0=unavailable */ + close: number; + /** 1=available, 0=unavailable */ + cancel: number; +} ⋮---- -/** Client order id for idempotency (max 32 char) */ +/** 1=available, 0=unavailable */ ⋮---- -/** Exchange VASP id from /v1/query/vasp-list */ +/** 1=available, 0=unavailable */ ⋮---- -/** Recipient name for Korean/English: "SURNAME##FIRSTNAME" */ +/** 1=available, 0=unavailable */ ⋮---- -/** Req for GET /v1/query/deposit-withdraw. Search deposit/withdraw records. */ -export interface SpotDepositWithdrawQueryReq { - /** Crypto currency. Omit for all. */ - currency?: string; - /** deposit or withdraw */ - type: 'deposit' | 'withdraw'; - /** Transfer id to begin search */ - from?: string; - /** Items to return [1-50]. Default 50. */ - size?: string; - /** prev (asc) or next (desc). Default next. */ - direct?: 'prev' | 'next'; +/** Trigger order open order item from swap_trigger_openorders and swap_cross_trigger_openorders */ +export interface FuturesTriggerOrderOpenOrder { + symbol: string; + contract_code: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_price: number | string; + order_price: number | string; + created_at: number; + order_price_type: string; + status: number; + margin_mode: string; + margin_account: string; + reduce_only: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; } ⋮---- -/** Crypto currency. Omit for all. */ +/** Cross margin only */ ⋮---- -/** deposit or withdraw */ +/** Trigger open orders response from swap_trigger_openorders and swap_cross_trigger_openorders */ +export type FuturesTriggerOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Transfer id to begin search */ +/** Trigger order history item from swap_trigger_hisorders and swap_cross_trigger_hisorders */ +export interface FuturesTriggerOrderHisOrder { + symbol: string; + contract_code: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + relation_order_id: string; + order_price_type: string; + status: number; + order_source: string; + trigger_price: number | string; + triggered_price: number | string | null; + order_price: number | string; + created_at: number; + triggered_at: number | null; + order_insert_at: number; + canceled_at: number | null; + update_time: number; + fail_code: number | null; + fail_reason: string | null; + margin_mode: string; + margin_account: string; + reduce_only?: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; +} ⋮---- -/** Items to return [1-50]. Default 50. */ +/** Cross margin only */ ⋮---- -/** prev (asc) or next (desc). Default next. */ +/** Trigger history orders response from getTriggerHistoryOrders, getCrossTriggerHistoryOrders */ +export type FuturesTriggerHistoryOrders = + FuturesPaginatedOrders; ⋮---- -/** Req for GET /v2/account/withdraw/address. Query withdraw address. */ -export interface SpotWithdrawAddressReq { - /** - * Crypto currency. - * Use "t247117" for universal address. - * Use "t397342" to query Poloniex UID withdraw addresses added on platform. - */ - currency?: string; - /** Block chain name. Omit for all chains. */ - chain?: string; - /** Note of withdraw address. Omit for all. */ - note?: string; - /** Items to return [1-500]. Default 100. */ - limit?: number; - /** First record ID for next page. */ - fromId?: number; +/** TP/SL order result; when only TP or only SL is set, the other is empty */ +export interface FuturesTpslOrderResult { + order_id: number | string; + order_id_str: string; } ⋮---- -/** - * Crypto currency. - * Use "t247117" for universal address. - * Use "t397342" to query Poloniex UID withdraw addresses added on platform. - */ +/** TPSL order response data from swap_tpsl_order and swap_cross_tpsl_order. tp_order or sl_order empty when only the other is set */ +export interface FuturesTpslOrder { + tp_order?: FuturesTpslOrderResult; + sl_order?: FuturesTpslOrderResult; +} ⋮---- -/** Block chain name. Omit for all chains. */ -⋮---- -/** Note of withdraw address. Omit for all. */ -⋮---- -/** Items to return [1-500]. Default 100. */ -⋮---- -/** First record ID for next page. */ -⋮---- -/** Req for POST /broker/v1/sub-user/fee_rate/add. Set sub-user trading fee rate. */ -export interface SpotBrokerSubUserFeeRateAddReq { - /** Sub-account ids, max 10 */ - subUids: number[]; - /** 0 all, 1 Spot, 2 U-standard linear, 3 Coin-Margined swap */ - bizType: number; - /** Type: 1 fixed (0.001-0.5), 2 percent (1-1000) */ - type: number; - /** Additional taker fee. Either taker or maker required. */ - taker?: string; - /** Additional maker fee. Either taker or maker required. */ - maker?: string; - /** YYYYMMDD effect date. Omit for T+1. */ - effectAt?: string; +/** TPSL open order item from swap_tpsl_openorders and swap_cross_tpsl_openorders */ +export interface FuturesTpslOpenOrder { + symbol: string; + contract_code: string; + margin_mode: string; + margin_account: string; + volume: number; + order_type: number; + tpsl_order_type: string; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number | string; + price_protect?: boolean; + created_at: number; + order_price_type: string; + order_price: number | string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; } ⋮---- -/** Sub-account ids, max 10 */ -⋮---- -/** 0 all, 1 Spot, 2 U-standard linear, 3 Coin-Margined swap */ +/** Cross margin only */ ⋮---- -/** Type: 1 fixed (0.001-0.5), 2 percent (1-1000) */ +/** TPSL open orders response from swap_tpsl_openorders and swap_cross_tpsl_openorders */ +export type FuturesTpslOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Additional taker fee. Either taker or maker required. */ +/** TPSL history order item from swap_tpsl_hisorders and swap_cross_tpsl_hisorders */ +export interface FuturesTpslHisOrder { + symbol: string; + contract_code: string; + margin_mode: string; + margin_account: string; + volume: number; + order_type: number; + tpsl_order_type: string; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number | string; + price_protect?: boolean; + created_at: number; + order_price_type: string; + order_price: number | string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; + canceled_at: number | null; + fail_code: number | null; + fail_reason: string | null; + triggered_price: number | string | null; + relation_order_id: string; + update_time: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; +} ⋮---- -/** Additional maker fee. Either taker or maker required. */ +/** Cross margin only */ ⋮---- -/** YYYYMMDD effect date. Omit for T+1. */ +/** TPSL history orders response from swap_tpsl_hisorders and swap_cross_tpsl_hisorders */ +export type FuturesTpslHisOrders = FuturesPaginatedOrders; ⋮---- -/** Req for POST /broker/v1/account_capital_snapshot_everyday. Account asset snapshot. */ -export interface SpotBrokerAccountCapitalSnapshotReq { - /** Account type: spot, margin-api, super-margin-api, delivery, swap, linear */ - account_type: string; - /** Start time (ms). Omit with end_time for last 7 days. */ - start_time?: number; - /** End time (ms). Max 30 days from start. */ - end_time?: number; +/** TPSL order info item within relation_tpsl_order response. getRelationTpslOrder, getCoinMDeliveryRelationTpslOrder, getCoinMPerpRelationTpslOrder. */ +export interface FuturesRelationTpslOrderTpslInfo { + volume: number; + tpsl_order_type: string; + direction: string; + order_id: number | string; + order_id_str: string; + trigger_type: string; + trigger_price: number | string; + created_at: number; + order_price: number | string; + status: number; + relation_tpsl_order_id: string; + relation_order_id: string; + order_price_type?: string; + price_protect?: boolean; + canceled_at: number | null; + fail_code: number | null; + fail_reason: string | null; + triggered_price: number | string | null; } ⋮---- -/** Account type: spot, margin-api, super-margin-api, delivery, swap, linear */ +/** Relation TPSL order from getRelationTpslOrder, getCoinMDeliveryRelationTpslOrder, getCoinMPerpRelationTpslOrder. Product-specific optional. */ +export interface FuturesRelationTpslOrder { + symbol: string; + contract_code: string; + volume: number; + price: number | string; + order_price_type: string; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + created_at: number; + trade_volume: number; + trade_turnover: number | string; + fee: number | string; + trade_avg_price: number | string; + margin_frozen: number | string; + profit: number | string; + status: number; + order_type: number | null; + order_source: string; + fee_asset: string; + canceled_at: number; + tpsl_order_info: FuturesRelationTpslOrderTpslInfo[]; + /** USDM only */ + margin_mode?: string; + margin_account?: string; + /** CM Delivery: required; USDM/CM Perp: optional */ + contract_type?: string; + pair?: string; + business_type?: string; +} ⋮---- -/** Start time (ms). Omit with end_time for last 7 days. */ +/** USDM only */ ⋮---- -/** End time (ms). Max 30 days from start. */ +/** CM Delivery: required; USDM/CM Perp: optional */ ⋮---- -/** Req for POST /v2/sub-user/tradable-market. Set tradable market for sub users. */ -export interface SpotSubUserTradableMarketReq { - /** Sub user UIDs, comma-separated, max 50 */ - subUids: string; - /** isolated-margin or cross-margin */ - accountType: 'isolated-margin' | 'cross-margin'; - /** activated or deactivated */ - activation: 'activated' | 'deactivated'; +/** Trailing order open order item from swap_track_openorders and swap_cross_track_openorders */ +export interface FuturesTrackOpenOrder { + symbol: string; + contract_code: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + order_price_type: string; + status: number; + callback_rate: number | string; + active_price: number | string; + is_active: number; + margin_mode: string; + margin_account: string; + reduce_only: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; } ⋮---- -/** Sub user UIDs, comma-separated, max 50 */ -⋮---- -/** isolated-margin or cross-margin */ +/** Cross margin only */ ⋮---- -/** activated or deactivated */ +/** Trailing open orders response data from swap_track_openorders and swap_cross_track_openorders */ +export type FuturesTrackOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Req for setSubUserTransferPermissions. Set asset transfer permission. */ -export interface SpotSubUserTransferPermissionsReq { - /** Sub user UIDs, comma-separated, max 50 */ - subUids: string; - /** true or false */ - transferrable: boolean; - /** Account type. Default spot. */ - accountType?: 'spot'; +/** Trailing order history item from swap_track_hisorders and swap_cross_track_hisorders */ +export interface FuturesTrackHisOrder { + symbol: string; + contract_code: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + update_time: number; + order_price_type: string; + status: number; + canceled_at: number | null; + fail_code: number | null; + fail_reason: string | null; + callback_rate: number | string; + active_price: number | string; + is_active: number; + market_limit_price: number | string | null; + formula_price: number | string | null; + real_volume: number | string; + triggered_price: number | string | null; + relation_order_id: string; + margin_mode: string; + margin_account: string; + reduce_only: number; + /** Cross margin only */ + contract_type?: string; + pair?: string; + business_type?: string; } ⋮---- -/** Sub user UIDs, comma-separated, max 50 */ -⋮---- -/** true or false */ +/** Cross margin only */ ⋮---- -/** Account type. Default spot. */ +/** Trailing history orders response from swap_track_hisorders and swap_cross_track_hisorders */ +export type FuturesTrackHisOrders = + FuturesPaginatedOrders; ⋮---- -/** Req for POST /v1/subuser/transfer. Transfer asset between parent and sub account. */ -export interface SpotSubUserTransferReq { - /** Sub account UID */ - 'sub-uid': number; - /** Currency e.g. btc, usdt */ - currency: string; - /** Amount to transfer */ - amount: string; - /** master-transfer-in, master-transfer-out, master-point-transfer-in, master-point-transfer-out */ - type: - | 'master-transfer-in' - | 'master-transfer-out' - | 'master-point-transfer-in' - | 'master-point-transfer-out'; - /** Client order id for idempotency */ - 'client-order-id'?: string; +/** Cross swap item within unified_account_info */ +export interface FuturesUnifiedAccountCrossSwap { + symbol: string; + contract_code: string; + margin_mode: string; + margin_available: number | string; + cross_max_available?: number | string; + lever_rate: number | string; + contract_type: string; + business_type: string; } ⋮---- -/** Sub account UID */ -⋮---- -/** Currency e.g. btc, usdt */ -⋮---- -/** Amount to transfer */ -⋮---- -/** master-transfer-in, master-transfer-out, master-point-transfer-in, master-point-transfer-out */ -⋮---- -/** Client order id for idempotency */ -⋮---- -/** Req for getSubUserDepositHistory. Query sub user deposit history. */ -export interface SpotSubUserDepositHistoryReq { - /** Sub user UID */ - subUid: number; - /** Crypto currency. Omit for all. */ - currency?: string; - /** Start time (ms). Default endTime - 30 days. */ - startTime?: number; - /** End time (ms). Default now. */ - endTime?: number; - /** asc or desc */ - sort?: 'asc' | 'desc'; - /** Items per page [1-500]. Default 100. */ - limit?: number; - /** First record ID for next page. */ - fromId?: number; +/** Cross futures item within unified_account_info */ +export interface FuturesUnifiedAccountCrossFuture { + symbol: string; + contract_code: string; + margin_mode: string; + margin_available: number | string; + cross_max_available?: number | string; + lever_rate: number | string; + contract_type: string; + business_type: string; } ⋮---- -/** Sub user UID */ +/** Isolated swap item within unified_account_info */ +export interface FuturesUnifiedAccountIsolatedSwap { + symbol: string; + contract_code: string; + margin_mode: string; + margin_available: number | string; + withdraw_available?: number | string; + lever_rate: number | string; + position_mode?: string; +} ⋮---- -/** Crypto currency. Omit for all. */ +/** Unified account info item from unified_account_info */ +export interface FuturesUnifiedAccountInfo { + margin_balance: number | string; + margin_static: number | string; + cross_profit_unreal: number | string; + cross_margin_static: number | string; + margin_asset: string; + margin_frozen: number | string; + withdraw_available: number | string; + cross_risk_rate: number | string | null; + cross_swap: FuturesUnifiedAccountCrossSwap[]; + cross_future: FuturesUnifiedAccountCrossFuture[]; + isolated_swap: FuturesUnifiedAccountIsolatedSwap[]; + userId?: string | null; +} ⋮---- -/** Start time (ms). Default endTime - 30 days. */ +/** Linear swap overview account info item from linear_swap_overview_account_info */ +export interface FuturesLinearSwapOverviewAccountInfo { + margin_asset: string; + margin_balance: number | string; + margin_available: number | string; +} ⋮---- -/** End time (ms). Default now. */ +/** Fix position margin change record item from fix_position_margin_change_record */ +export interface FuturesFixPositionMarginChangeRecord { + query_id: number; + order_id: string; + amount: number | string; + asset: string; + symbol: string; + type: number; + direction: number; +} ⋮---- -/** asc or desc */ +/** Fix position margin change response data from fix_position_margin_change */ +export interface FuturesFixPositionMarginChange { + amount: number | string; + asset: string; + contract_code: string; + type: number; + direction: number; + order_id: string; + client_order_id: number | string | null; +} ⋮---- -/** Items per page [1-500]. Default 100. */ +/** + * USDT Margined Futures Multi Asset - Account (v5 API) + */ ⋮---- -/** First record ID for next page. */ +/** Currency detail from /v5/account/balance */ +export interface FuturesV5AccountBalanceDetail { + currency: string; + equity: string; + isolated_equity: string; + available: string; + isolated_available?: string; + withdraw_available: string; + profit_unreal: string; + isolated_profit_unreal: string; + initial_margin: string; + maintenance_margin: string; + maintenance_margin_rate: string; + initial_margin_rate: string; + voucher: string; + voucher_value: string; + created_time: number; + updated_time: number; +} ⋮---- -/** Req for GET /v2/sub-user/managed-transfer-history. Managed sub-account transfer history. */ -export interface SpotSubUserManagedTransferHistoryReq { - /** Sub user UID. Omit for all managed sub-accounts. */ - uid?: number; - /** Currency filter */ - currency?: string; - /** 0: master to sub, 1: sub to master */ - type?: string; - /** Start time (ms). Max 48h window, within 120 days. */ - startTime?: number; - /** End time (ms). */ - endTime?: number; - /** Search id to begin with. */ - from?: string; - /** next or prev. Default next. */ - direct?: 'next' | 'prev'; - /** Items to return [1-100]. Default 100. */ - size?: string; +/** Account balance data from /v5/account/balance */ +export interface FuturesV5AccountBalance { + /** "normal" | "liquidating" | "adl" | "open_limit" */ + state: string; + equity: string; + initial_margin: string; + maintenance_margin: string; + maintenance_margin_rate: string; + profit_unreal: string; + available_margin: string; + voucher_value: string; + created_time: number; + updated_time: number; + details: FuturesV5AccountBalanceDetail[]; } ⋮---- -/** Sub user UID. Omit for all managed sub-accounts. */ +/** "normal" | "liquidating" | "adl" | "open_limit" */ ⋮---- -/** Currency filter */ +/** Set asset mode response data from POST /v5/account/asset_mode */ +export interface FuturesV5AssetMode { + /** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ + assets_mode: 0 | 1 | 2; +} ⋮---- -/** 0: master to sub, 1: sub to master */ +/** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ ⋮---- -/** Start time (ms). Max 48h window, within 120 days. */ +/** Get asset mode response data from GET /v5/account/asset_mode */ +export interface FuturesV5AssetModeGet { + /** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ + asset_mode: 0 | 1 | 2; +} ⋮---- -/** End time (ms). */ +/** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ ⋮---- -/** Search id to begin with. */ +/** Fee deduction crypto from /v5/account/fee_deduction_currency */ +export interface FuturesV5FeeDeductionCurrency { + /** 1: Yes; 0: No */ + fee_option: 0 | 1; + /** Deduction currency (e.g. htx, trx). Not returned when fee_option = 0 */ + deduction_currency?: string; +} ⋮---- -/** next or prev. Default next. */ +/** 1: Yes; 0: No */ ⋮---- -/** Items to return [1-100]. Default 100. */ +/** Deduction currency (e.g. htx, trx). Not returned when fee_option = 0 */ ⋮---- -/** Req for createSubUserApiKey. Create sub user API key. */ -export interface SpotSubUserApiKeyCreationReq { - /** Sub user UID */ - subUid: number; - /** Google OTP (6 digits) if parent has 2FA */ - otpToken?: string; - /** API key note, max 255 chars */ - note?: string; - /** readOnly, trade. readOnly required. Comma-separated. */ - permission?: string; - /** IP addresses, comma-separated, max 20 */ - ipAddresses?: string; +/** Financial record item from /v5/account/bills */ +export interface FuturesV5Bill { + id: string; + contract_code: string; + margin_mode: string; + /** + * Financial type code. + * 160: dividend settlement income. 161: dividend settlement expense. + */ + type: string; + currency: string; + amount: string; + created_time: string; } ⋮---- -/** Sub user UID */ +/** + * Financial type code. + * 160: dividend settlement income. 161: dividend settlement expense. + */ ⋮---- -/** Google OTP (6 digits) if parent has 2FA */ +/** + * USDT Margined Futures Multi Asset - Orders (v5 API) + */ ⋮---- -/** API key note, max 255 chars */ +/** Place order response from POST /v5/trade/order */ +export interface FuturesV5PlaceOrderResp { + order_id: string; + client_order_id?: string; +} ⋮---- -/** readOnly, trade. readOnly required. Comma-separated. */ +/** Batch place order item from POST /v5/trade/batch_orders */ +export interface FuturesV5PlaceBatchOrderRespItem { + order_id: string; + client_order_id?: string; + code: number; + message: string; +} ⋮---- -/** IP addresses, comma-separated, max 20 */ +/** Close position response from POST /v5/trade/position */ +export interface FuturesV5ClosePositionResp { + order_id: string | number; + client_order_id?: string; +} ⋮---- -/** Req for updateSubUserApiKey. Modify sub user API key. */ -export interface SpotSubUserApiKeyUpdateReq { - /** Sub user UID */ - subUid: number; - /** Access key to modify */ - accessKey: string; - /** API key note, max 255 chars */ - note?: string; - /** readOnly, trade. Comma-separated. */ - permission?: string; - /** IP addresses, comma-separated, max 20 */ - ipAddresses?: string; +/** Open order / order info / order history item from v5 trade endpoints */ +export interface FuturesV5Order { + id: string; + contract_code: string; + contract_type?: string; + side: string; + position_side: string; + type: string; + price_match?: string | null; + order_id: string; + client_order_id: string; + margin_mode: string; + price?: string; + volume: string; + lever_rate?: number; + state: string | number; + order_source: string; + reduce_only?: boolean | string; + time_in_force: string; + tp_trigger_price?: string; + tp_order_price?: string; + tp_type?: string | null; + tp_trigger_price_type?: string | null; + sl_trigger_price?: string; + sl_order_price?: string; + sl_type?: string | null; + sl_trigger_price_type?: string | null; + trade_avg_price?: string; + trade_volume?: string; + trade_turnover?: string; + fee_currency?: string; + fee?: string; + profit?: string | null; + price_protect?: boolean | string; + cancel_reason?: string | null; + created_time?: string; + updated_time?: string; + self_match_prevent?: string; + cancel_volume?: string; } ⋮---- -/** Sub user UID */ -⋮---- -/** Access key to modify */ -⋮---- -/** API key note, max 255 chars */ -⋮---- -/** readOnly, trade. Comma-separated. */ +/** Execution/trade detail from GET /v5/trade/order/details */ +export interface FuturesV5OrderExecutionDetail { + id?: string; + contract_code?: string; + order_id?: string; + trade_id?: string; + side?: string; + position_side?: string; + order_type?: string; + margin_mode?: string; + type?: string; + client_order_id?: string; + role?: string; + trade_price?: string; + trade_volume?: string; + trade_turnover?: string; + created_time?: string; + updated_time?: string; + order_source?: string; + fee_currency?: string; + trade_fee?: string; + deduction_price?: string; + profit?: string; + contract_type?: string; +} ⋮---- -/** IP addresses, comma-separated, max 20 */ +/** Cancel-after response from POST /v5/trade/cancel-after */ +export interface FuturesV5CancelAfterResp { + current_time: string; + trigger_time?: string; +} ⋮---- -/** Req for GET /v2/account/ledger */ -export interface SpotGetAccountLedgerReq { - /** Account ID */ - accountId: string; - /** Currency. Default all. */ - currency?: string; - /** Transaction types, comma-separated. Phase 1: transfer only. */ - transactTypes?: string; - /** Start time (unix ms). Max 10-day window, within 180 days. */ - startTime?: number; - /** End time (unix ms). */ - endTime?: number; - /** Sort order: asc, desc. Deprecated. */ - sort?: string; - /** Max items [1-500]. Default 100. */ - limit?: number; - /** First record ID for pagination (next page) */ - fromId?: number; +/** Place algo order item from POST /v5/algo/order */ +export interface FuturesV5PlaceAlgoOrderResp { + algo_id: string; + algo_client_order_id?: string; } ⋮---- -/** Account ID */ +/** Cancel algo order item from POST /v5/algo/cancel_orders */ +export interface FuturesV5CancelAlgoOrderResp { + algo_id: string; + algo_client_order_id?: string; + code?: number; + message?: string; +} ⋮---- -/** Currency. Default all. */ +/** Algo order from GET /v5/algo/order, /opens, /history */ +export interface FuturesV5AlgoOrder { + id?: string | number; + algo_id: string; + algo_client_order_id?: string; + contract_code: string; + volume?: string; + type: string; + state: string; + position_side: string; + margin_mode: string; + side: string; + tp_trigger_price?: string; + tp_order_price?: string; + tp_type?: string; + tp_trigger_price_type?: string; + sl_trigger_price?: string; + sl_order_price?: string; + sl_type?: string; + sl_trigger_price_type?: string; + price?: string; + price_match?: string; + trigger_price?: string; + trigger_price_type?: string; + active_price?: string; + order_price_type?: string; + callback_rate?: string; + reduce_only?: boolean | string; + actual_volume?: string; + actual_price?: string; + actual_time?: string; + relation_order_id?: string; + created_time?: string; + updated_time?: string; + order_source?: string; +} ⋮---- -/** Transaction types, comma-separated. Phase 1: transfer only. */ +/** + * USDT Margined Futures Multi Asset - Positions (v5 API) + */ ⋮---- -/** Start time (unix ms). Max 10-day window, within 180 days. */ +/** Position from GET /v5/trade/position/opens */ +export interface FuturesV5Position { + contract_code: string; + position_side: string; + direction: string; + margin_mode: string; + open_avg_price: string; + volume: string; + available: string; + lever_rate: string | number; + adl_risk_percent?: number | null; + liquidation_price: string; + initial_margin: string; + maintenance_margin: string; + profit_unreal: string; + profit_rate: string; + margin_rate: string; + margin_currency: string; + last_price?: string; + mark_price?: string; + contract_type: string; + created_time: string; + updated_time: string; +} ⋮---- -/** End time (unix ms). */ +/** Leverage list entry from GET /v5/position/lever */ +export interface FuturesV5LeverListEntry { + contract_code: string; + contract_type: string; + margin_mode: string; + position_side: string; + lever_rate: number; + available_lever: string | string[]; +} ⋮---- -/** Sort order: asc, desc. Deprecated. */ +/** Set leverage response from POST /v5/position/lever */ +export interface FuturesV5SetLeverageResp { + contract_code: string; + margin_mode: string; + position_side?: string; + lever_rate: number; +} ⋮---- -/** Max items [1-500]. Default 100. */ +/** Position mode from GET/POST /v5/position/mode */ +export interface FuturesV5PositionModeResp { + position_mode: 'single_side' | 'dual_side'; +} ⋮---- -/** First record ID for pagination (next page) */ +/** Risk limit entry from GET /v5/position/risk/limit */ +export interface FuturesV5RiskLimitEntry { + contract_code: string; + contract_type?: string; + margin_mode: string; + position_side: string; + max_lever: string; + maintenance_margin_rate: string; + max_volume: string; + min_volume: string; + volume_unit: string; +} ⋮---- -/** Req for GET /v2/invitee/rebate/history. Referral rebate history. */ -export interface SpotReferralRebateHistoryReq { - /** Invitee UID */ - inviteeUid: number; - /** Start date yyyy-MM-dd. Last 90 days. */ - startTime?: string; - /** End date yyyy-MM-dd. Last 90 days. */ - endTime?: string; - /** next or prev. Default prev. */ - direct?: 'next' | 'prev'; - /** Pagination cursor. Min query_id for prev, max for next. */ - fromId?: string; - /** Items per page, max 100. Default 100. */ - limit?: number; +/** Risk limit tier entry from GET /v5/position/risk/limit_tier */ +export interface FuturesV5RiskLimitTierEntry { + contract_code: string; + margin_mode: string; + tier: number; + max_lever: string; + maintenance_margin_rate: string; + max_volume: string; + min_volume: string; + volume_unit: string; } ⋮---- -/** Invitee UID */ +/** + * USDT Margined Futures Multi Asset - Basic Information (v5 API) + */ ⋮---- -/** Start date yyyy-MM-dd. Last 90 days. */ +/** Funding fee type on GET /v5/market/funding_rate_history */ +export type FuturesV5FundingFeeType = 'normal' | 'dividend_settlement'; ⋮---- -/** End date yyyy-MM-dd. Last 90 days. */ +/** Historical funding rate item from GET /v5/market/funding_rate_history */ +export interface FuturesV5FundingRateHistory { + id: string; + /** Perpetual (e.g. BTC-USDT) or delivery (e.g. BTC-USDT-210625) */ + contract_code: string; + funding_rate: string; + /** Funding time, unix ms */ + funding_time: string; + /** `normal`: normal funding fee. `dividend_settlement`: dividend settlement. */ + funding_fee_type: FuturesV5FundingFeeType; +} ⋮---- -/** next or prev. Default prev. */ +/** Perpetual (e.g. BTC-USDT) or delivery (e.g. BTC-USDT-210625) */ ⋮---- -/** Pagination cursor. Min query_id for prev, max for next. */ +/** Funding time, unix ms */ ⋮---- -/** Items per page, max 100. Default 100. */ +/** `normal`: normal funding fee. `dividend_settlement`: dividend settlement. */ ⋮---- -/** Req for GET /v2/invitee/rebate/all_rebate/detail. All rebate detail. */ -export interface SpotReferralAllRebateDetailReq { - /** next or prev. Default prev. */ - direct?: 'next' | 'prev'; - /** Pagination cursor. */ - fromId?: string; - /** Items per page, max 100. Default 100. */ - limit?: number; +/** Risk limit entry from GET /v5/market/risk/limit */ +export interface FuturesV5MarketRiskLimitEntry { + contract_code: string; + margin_mode: string; + tier: number; + max_lever: string; + maintenance_margin_rate: string; + max_volume: string; + min_volume: string; + volume_unit?: string; } ⋮---- -/** next or prev. Default prev. */ +/** Assets deduction currency from GET /v5/market/assets_deduction_currency */ +export interface FuturesV5AssetsDeductionCurrencyResp { + currency: string[]; +} ⋮---- -/** Pagination cursor. */ +/** Multi-assets margin from GET /v5/market/multi_assets_margin */ +export interface FuturesV5MultiAssetsMarginResp { + multi_assets: string[]; +} ⋮---- -/** Items per page, max 100. Default 100. */ +/** + * Coin-M Delivery - Reference Data (FuturesCmDelivery) + */ ⋮---- -/** Req for GET /v2/invitee/rebate/referrals. Invited user list. */ -export interface SpotReferralReferralsReq { - /** Invitee UIDs, comma-separated, max 50. */ - inviteeUidList?: string; - /** Referral code used at registration. */ - referralCode?: string; - /** Start date yyyy-MM-dd. Last 14 days. */ - startTime?: string; - /** End date yyyy-MM-dd. Last 14 days. */ - endTime?: string; - /** prev or next. Default next. */ - direct?: 'prev' | 'next'; - /** Pagination cursor. */ - fromId?: string; - /** Items per page, max 100. Default 30. */ - limit?: number; +/** Ladder item from contract_adjustfactor */ +export interface FuturesCmDeliveryAdjustFactorLadder { + ladder: number; + min_size: number; + max_size: number | null; + adjust_factor: number; } ⋮---- -/** Invitee UIDs, comma-separated, max 50. */ +/** Lever item in adjust factor list */ +export interface FuturesCmDeliveryAdjustFactorLeverItem { + lever_rate: number; + ladders: FuturesCmDeliveryAdjustFactorLadder[]; +} ⋮---- -/** Referral code used at registration. */ +/** GET /api/v1/contract_adjustfactor */ +export interface FuturesCmDeliveryAdjustFactor { + symbol: string; + list: FuturesCmDeliveryAdjustFactorLeverItem[]; +} ⋮---- -/** Start date yyyy-MM-dd. Last 14 days. */ +/** Tick from contract_his_open_interest */ +export interface FuturesCmDeliveryOpenInterestTick { + volume: string; + amount_type: number; + ts: number; +} ⋮---- -/** End date yyyy-MM-dd. Last 14 days. */ +/** GET /api/v1/contract_his_open_interest */ +export interface FuturesCmDeliveryOpenInterest { + symbol: string; + contract_type: string; + tick: FuturesCmDeliveryOpenInterestTick[]; +} ⋮---- -/** prev or next. Default next. */ +/** Ladder item from contract_ladder_margin */ +export interface FuturesCmDeliveryLadderMarginLadder { + min_margin_balance: number; + max_margin_balance: number | null; + min_margin_available: number; + max_margin_available: number | null; +} ⋮---- -/** Pagination cursor. */ +/** Lever item in ladder margin list */ +export interface FuturesCmDeliveryLadderMarginLeverItem { + lever_rate: number; + ladders: FuturesCmDeliveryLadderMarginLadder[]; +} ⋮---- -/** Items per page, max 100. Default 30. */ +/** GET /api/v1/contract_ladder_margin */ +export interface FuturesCmDeliveryLadderMargin { + symbol: string; + list: FuturesCmDeliveryLadderMarginLeverItem[]; +} ⋮---- -/** Req for GET /v1/api/c2c/order/history. P2P order history. */ -export interface SpotP2POrderHistoryReq { - /** 0: buy, 1: sell */ - side?: string; - /** Start time (ms). Last 90 days. */ - startTime?: number; - /** End time (ms). Last 90 days. */ - endTime?: number; - /** next or prev. Default prev. */ - direct?: 'next' | 'prev'; - /** Pagination cursor. Min query_id for prev, max for next. */ - fromId?: number; - /** Items per page, max 100. Default 100. */ - limit?: number; +/** Ladder from GET /swap-api/v1/swap_adjustfactor */ +export interface FuturesCmPerpAdjustFactorLadder { + ladder: number; + min_size: number; + max_size: number | null; + adjust_factor: number; } ⋮---- -/** 0: buy, 1: sell */ +/** Lever item from swap_adjustfactor list */ +export interface FuturesCmPerpAdjustFactorLeverItem { + lever_rate: number; + ladders: FuturesCmPerpAdjustFactorLadder[]; +} ⋮---- -/** Start time (ms). Last 90 days. */ +/** GET /swap-api/v1/swap_adjustfactor */ +export interface FuturesCmPerpAdjustFactor { + symbol: string; + contract_code: string; + list: FuturesCmPerpAdjustFactorLeverItem[]; +} ⋮---- -/** End time (ms). Last 90 days. */ +/** Tick from GET /swap-api/v1/swap_his_open_interest */ +export interface FuturesCmPerpOpenInterestTick { + volume: number; + amount_type: number; + ts: number; +} ⋮---- -/** next or prev. Default prev. */ +/** GET /swap-api/v1/swap_his_open_interest */ +export interface FuturesCmPerpOpenInterest { + symbol: string; + contract_code: string; + tick: FuturesCmPerpOpenInterestTick[]; +} ⋮---- -/** Pagination cursor. Min query_id for prev, max for next. */ +/** Ladder from GET /swap-api/v1/swap_ladder_margin */ +export interface FuturesCmPerpTieredMarginLadder { + min_margin_balance: number; + max_margin_balance: number | null; + min_margin_available: number; + max_margin_available: number | null; +} ⋮---- -/** Items per page, max 100. Default 100. */ +/** Lever item from swap_ladder_margin list */ +export interface FuturesCmPerpTieredMarginLeverItem { + lever_rate: number; + ladders: FuturesCmPerpTieredMarginLadder[]; +} ⋮---- -/** Req for GET /v1/earn/project/queryEarnProjectList. Earn product query. */ -export interface SpotEarnProjectListReq { - /** Crypto currency filter */ - currency?: string; - /** Page number. Default 1. */ - pageNum: number; - /** Items per page, max 100. Default 10. */ - pageSize: number; +/** GET /swap-api/v1/swap_ladder_margin */ +export interface FuturesCmPerpTieredMargin { + symbol: string; + contract_code: string; + list: FuturesCmPerpTieredMarginLeverItem[]; } ⋮---- -/** Crypto currency filter */ +/** List item from GET /swap-api/v1/swap_elite_account_ratio */ +export interface FuturesCmPerpAccountRatioItem { + buy_ratio: number; + sell_ratio: number; + locked_ratio: number; + ts: number; +} ⋮---- -/** Page number. Default 1. */ +/** GET /swap-api/v1/swap_elite_account_ratio */ +export interface FuturesCmPerpAccountRatio { + symbol: string; + contract_code: string; + list: FuturesCmPerpAccountRatioItem[]; +} ⋮---- -/** Items per page, max 100. Default 10. */ +/** List item from GET /swap-api/v1/swap_elite_position_ratio */ +export interface FuturesCmPerpPositionRatioItem { + buy_ratio: number; + sell_ratio: number; + ts: number; +} ⋮---- -/** Req for POST /v1/earn/order/demand/add. Earn subscription. */ -export interface SpotEarnSubscribeReq { - /** Project ID */ - id: number; - /** Subscription amount */ - amount: string; - /** Idempotent ID (e.g. Snowflake). */ - requestId: string; +/** GET /swap-api/v1/swap_elite_position_ratio */ +export interface FuturesCmPerpPositionRatio { + symbol: string; + contract_code: string; + list: FuturesCmPerpPositionRatioItem[]; } ⋮---- -/** Project ID */ +/** Item from GET /swap-api/v1/swap_estimated_settlement_price data[] */ +export interface FuturesCmPerpEstimatedSettlementPrice { + contract_code: string; + estimated_settlement_price: number | null; + settlement_type: 'delivery' | 'settlement'; +} ⋮---- -/** Subscription amount */ +/** GET /swap-api/v1/swap_api_state */ +export interface FuturesCmPerpSystemStatus { + symbol: string; + contract_code: string; + open: number; + close: number; + cancel: number; + transfer_in: number; + transfer_out: number; + master_transfer_sub: number; + sub_transfer_master: number; +} ⋮---- -/** Idempotent ID (e.g. Snowflake). */ +/** GET /swap-api/v1/swap_funding_rate */ +export interface FuturesCmPerpFundingRate { + symbol: string; + contract_code: string; + fee_asset: string; + funding_time: string; + funding_rate: string; + estimated_rate: string | null; + next_funding_time: string | null; +} ⋮---- -/** Req for POST /v1/earn/order/demand/redeem-order. Earn redemption. */ -export interface SpotEarnRedeemReq { - /** Order ID */ - orderId: number; - /** Redemption amount */ - amount: string; - /** Idempotent ID (e.g. Snowflake). */ - requestId?: string; +/** Item from GET /swap-api/v1/swap_historical_funding_rate data[] */ +export interface FuturesCmPerpHistoricalFundingRate { + symbol: string; + contract_code: string; + fee_asset: string; + funding_time: string; + funding_rate: string; + /** Deprecated, default null */ + realized_rate?: string | null; + avg_premium_index: string; } ⋮---- -/** Order ID */ -⋮---- -/** Redemption amount */ +/** Deprecated, default null */ ⋮---- -/** Idempotent ID (e.g. Snowflake). */ +/** Paginated wrapper for GET /swap-api/v1/swap_historical_funding_rate */ +export type FuturesCmPerpHistoricalFundingRatePage = + FuturesPaginatedData; ⋮---- -/** Req for GET /v1/earn/order/user/assets/list. Earn position query. */ -export interface SpotEarnUserAssetsReq { - /** Project type: 0 = Flexible */ - projectType?: number; - /** Crypto currency filter */ - currency?: string; - /** Page number. Default 1. */ - pageNum: number; - /** Items per page, max 100. Default 10. */ - pageSize: number; +/** Item from GET /swap-api/v3/swap_liquidation_orders data[] */ +export interface FuturesCmPerpLiquidationOrder { + query_id?: number; + contract_code: string; + symbol: string; + direction: string; + offset: string; + volume: number; + price: number; + created_at: number; + amount: number; } ⋮---- -/** Project type: 0 = Flexible */ -⋮---- -/** Crypto currency filter */ +/** Item from GET /swap-api/v1/swap_settlement_records settlement_record[] */ +export interface FuturesCmPerpSettlementRecord { + symbol: string; + contract_code: string; + settlement_time: number; + clawback_ratio: number; + settlement_price: number; + settlement_type: string; +} ⋮---- -/** Page number. Default 1. */ +/** Paginated wrapper for GET /swap-api/v1/swap_settlement_records */ +export type FuturesCmPerpSettlementRecordsPage = + FuturesPaginatedSettlement; ⋮---- -/** Items per page, max 100. Default 10. */ +/** Index constituents from GET /swap-api/market/swap_constituents. data is object. */ +export interface FuturesCmPerpIndexConstituents { + contract_code: string; + ts: number; + index_price: string; + components: FuturesIndexConstituentComponent[]; +} ⋮---- -/** Account type for POST /v5/account/universal_transfer */ -export type SpotUniversalTransferAccountType = - | 'otc' - | 'spot' - | 'linear-swap' - | 'futures' - | 'swap' - | 'margin' - | 'super-margin' - | 'otc-options'; +/** Item from GET /swap-api/v1/swap_contract_info data[] */ +export interface FuturesCmPerpContractInfo { + symbol: string; + contract_code: string; + contract_size: number; + price_tick: number; + settlement_date: string; + settlement_period: string; + create_date: string; + delivery_time: string; + contract_status: number; + labels?: string[]; +} ⋮---- -/** Req for POST /v5/account/universal_transfer. Create universal transfer. */ -export interface SpotUniversalTransferReq { - amount: number | string; - currency: string; - from_account_type: SpotUniversalTransferAccountType; - to_account_type: SpotUniversalTransferAccountType; - from_asset_type?: string; - to_asset_type?: string; +/** Item from GET /swap-api/v1/swap_open_interest data[] */ +export interface FuturesCmPerpOpenInterestCurrent { + symbol: string; + contract_code: string; + volume: number; + amount: number; + trade_amount: number; + trade_volume: number; + trade_turnover: number; } ⋮---- -/** Req for GET /v5/account/universal_transfer_records. Universal transfer history. */ -export interface SpotUniversalTransferRecordsReq { - transfer_id?: number | string; - currency?: string; - status?: 'success' | 'pending' | 'failed'; - start_time?: number; - end_time?: number; - from?: number; - limit?: number; - direct?: 'prev' | 'next'; +/** contract_infos[] item from GET /swap-api/v1/swap_query_elements */ +export interface FuturesCmPerpContractElementsContractInfo { + contract_code: string; + settlement_date: string; + /** Empty string when no delivery */ + delivery_time: string; + create_date: string; + contract_status: number; + instrument_type?: number; } - -================ -File: src/lib/requestUtils.ts -================ -/* eslint-disable @typescript-eslint/no-explicit-any */ ⋮---- -import { - OrderIdProperty, - SpotOrderIdProperty, -} from '../types/response/shared.types.js'; -import { - HTXWSAPIRequest, - WSAPIDerivativesOperation, - WSAPISpotOperation, -} from '../types/websockets/ws-api.js'; -import { - isDerivativesWSAPIRequest, - isSpotWSAPIRequest, -} from './websocket/type-guards.js'; -import { WS_KEY_MAP, WsKey } from './websocket/websocket-util.js'; +/** Empty string when no delivery */ ⋮---- -/** - * Used to switch how authentication/requests work under the hood - */ +/** Market depth tick from GET /swap-ex/market/depth. Payload in "tick". */ +export interface FuturesCmPerpMarketDepth { + mrid: number; + id: number; + asks: [number, number][]; + bids: [number, number][]; + ts: number; + version: number; + ch: string; +} ⋮---- -/** Spot */ +/** BBO tick from GET /swap-ex/market/bbo. ask/bid: [price, qty]. Payload in "ticks". */ +export interface FuturesCmPerpMarketBbo { + contract_code: string; + mrid: number; + ask: [number, number]; + bid: [number, number]; + ts: number; +} ⋮---- -/** Spot AWS */ +/** Kline item from GET /swap-ex/market/history/kline */ +export interface FuturesCmPerpKline { + id: number; + vol: number; + count: number; + open: number; + close: number; + low: number; + high: number; + amount: number; +} ⋮---- -/** - * Futures Cloudflare CDN (default for futures clients) - */ +/** Mark price kline item from GET /index/market/history/swap_mark_price_kline */ +export interface FuturesCmPerpMarkPriceKline { + id: number; + vol: string; + count: string; + open: string; + close: string; + low: string; + high: string; + amount: string; + trade_turnover: string; +} ⋮---- -/** - * Futures - * - * If you can't connect "https://api.hbdm.com", please use "https://api.btcgateway.pro" for debug purpose. If your server is deployed in AWS, we recommend using "https://api.hbdm.vn". - */ +/** 24h ticker from GET /swap-ex/market/detail/merged. Payload in "tick". */ +export interface FuturesCmPerp24hTicker { + id: number; + ts: number; + vol: string; + count: number; + open: string; + close: string; + low: string; + high: string; + amount: string; + ask: [number, number]; + bid: [number, number]; +} ⋮---- -/** - * Futures AWS CDN - */ +/** 24h ticker item from GET /v2/swap-ex/market/detail/batch_merged */ +export interface FuturesCmPerp24hTickers { + contract_code: string; + id: number; + ts: number; + amount: string; + count: number; + vol: string; + number_of: string; + open: string; + close: string; + low: string; + high: string; + ask: [number, number]; + bid: [number, number]; +} ⋮---- -export type RestClientType = - (typeof REST_CLIENT_TYPE_ENUM)[keyof typeof REST_CLIENT_TYPE_ENUM]; +/** Trade item from GET /swap-ex/market/trade and history/trade */ +export interface FuturesCmPerpTrade { + id: number; + price: string; + amount: string; + direction: string; + ts: number; + quantity: string; + contract_code?: string; +} ⋮---- -[REST_CLIENT_TYPE_ENUM.futures]: 'https://api.hbdm.com', // Cloudflare's CDN -// If you can't connect "https://api.hbdm.com", please use "https://api.btcgateway.pro" for debug purpose. If your server is deployed in AWS, HTX recommend using "https://api.hbdm.vn". +/** Last trade tick from GET /swap-ex/market/trade. Payload in "tick". */ +export interface FuturesCmPerpLastTrade { + id: number; + ts: number; + data: FuturesCmPerpTrade[]; +} ⋮---- -[REST_CLIENT_TYPE_ENUM.futuresAWS]: 'https://api.hbdm.vn', // AWS's CDN +/** Trade history group from GET /swap-ex/market/history/trade. Each group has trades by timestamp. */ +export interface FuturesCmPerpTradeHistory { + id: number; + ts: number; + data: FuturesCmPerpTrade[]; +} ⋮---- -export interface RestClientOptions { - /** Your API key */ - apiKey?: string; - - /** Your API secret */ - apiSecret?: string; - - /** - * Use access token instead of sign, if this is provided. - * For guidance refer to: https://github.com/tiagosiebler/kucoin-api/issues/2 - */ - apiAccessToken?: string; - - /** Default: false. If true, we'll throw errors if any params are undefined */ - strictParamValidation?: boolean; - - /** - * Optionally override API protocol + domain - * e.g baseUrl: 'https://api.huobi.pro' - **/ - baseUrl?: string; - - /** - * Advanced: force a specific base URL. - * - For AWS deployments, use REST_CLIENT_TYPE_ENUM.spotAWS for spot or REST_CLIENT_TYPE_ENUM.futuresAWS for futures. - * - If you can't connect to the default futures endpoint (Cloudflare's CDN), you can use REST_CLIENT_TYPE_ENUM.futuresAlt1 to connect to the alternative endpoint (btcgateway.pro). https://www.htx.com/en-us/opend/newApiPages/?id=707 - */ - baseUrlKey?: RestClientType; - - /** Default: true. whether to try and post-process request exceptions (and throw them). */ - parseExceptions?: boolean; - - customTimestampFn?: () => number; - - /** - * Enable keep alive for REST API requests (via axios). - */ - keepAlive?: boolean; - - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - * Default: 1000 (defaults comes from https agent) - */ - keepAliveMsecs?: number; - - /** - * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method - * - * Look in the examples folder for a demonstration on using node's createHmac instead. - */ - customSignMessageFn?: (message: string, secret: string) => Promise; +/** Estimated funding rate kline item from GET /index/market/history/swap_estimated_rate_kline */ +export interface FuturesCmPerpFundingRateKline { + id: number; + vol: string; + count: string; + open: string; + close: string; + low: string; + high: string; + amount: string; } ⋮---- -/** Your API key */ -⋮---- -/** Your API secret */ -⋮---- -/** - * Use access token instead of sign, if this is provided. - * For guidance refer to: https://github.com/tiagosiebler/kucoin-api/issues/2 - */ +/** Premium index kline item from GET /index/market/history/swap_premium_index_kline */ +export interface FuturesCmPerpPremiumIndexKline { + id: number; + vol: string; + count: string; + open: string; + close: string; + low: string; + high: string; + amount: string; +} ⋮---- -/** Default: false. If true, we'll throw errors if any params are undefined */ +/** Basis data item from GET /index/market/history/swap_basis */ +export interface FuturesCmPerpBasisData { + id: number; + contract_price: string; + index_price: string; + basis: string; + basis_rate: string; +} ⋮---- -/** - * Optionally override API protocol + domain - * e.g baseUrl: 'https://api.huobi.pro' - **/ +/** Account info from POST /swap-api/v1/swap_account_info */ +export interface FuturesCmPerpAccountInfo { + symbol: string; + contract_code: string; + margin_balance: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | null; + new_risk_rate?: string | null; + trade_partition?: string; + withdraw_available: number; + liquidation_price: number | null; + lever_rate: number; + adjust_factor: number; + margin_static: number; +} ⋮---- -/** - * Advanced: force a specific base URL. - * - For AWS deployments, use REST_CLIENT_TYPE_ENUM.spotAWS for spot or REST_CLIENT_TYPE_ENUM.futuresAWS for futures. - * - If you can't connect to the default futures endpoint (Cloudflare's CDN), you can use REST_CLIENT_TYPE_ENUM.futuresAlt1 to connect to the alternative endpoint (btcgateway.pro). https://www.htx.com/en-us/opend/newApiPages/?id=707 - */ +/** Position info from POST /swap-api/v1/swap_position_info */ +export interface FuturesCmPerpPositionInfo { + symbol: string; + contract_code: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + adl_risk_percent?: string | number; + liq_px: string; + new_risk_rate?: string | null; + trade_partition?: string; +} ⋮---- -/** Default: true. whether to try and post-process request exceptions (and throw them). */ +/** Position item in getCoinMPerpAccountFull positions[] */ +export interface FuturesCmPerpAccountFullPosition { + symbol: string; + contract_code: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + adl_risk_percent?: string | number; +} ⋮---- -/** - * Enable keep alive for REST API requests (via axios). - */ +/** Account + positions from getCoinMPerpAccountFull */ +/** Account + positions from getCoinMPerpAccountFull */ +export interface FuturesCmPerpAccountFull { + symbol: string; + contract_code: string; + margin_balance: number; + margin_static: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | null; + withdraw_available: number; + liquidation_price: number | null; + lever_rate: number; + adjust_factor: number; + new_risk_rate?: string | null; + trade_partition?: string; + positions: FuturesCmPerpAccountFullPosition[]; +} ⋮---- -/** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - * Default: 1000 (defaults comes from https agent) - */ +/** Sub-auth error from swap_sub_auth and swap_sub_auth_list */ +export interface FuturesCmPerpSubPermissionsError { + sub_uid: string; + err_code: number | string; + err_msg: string; +} ⋮---- -/** - * Allows you to provide a custom "signMessage" function, e.g. to use node's much faster createHmac method - * - * Look in the examples folder for a demonstration on using node's createHmac instead. - */ +/** Sub-auth response from updateCoinMPerpSubPermissions */ +export interface FuturesCmPerpUpdateSubPermissions { + errors: FuturesCmPerpSubPermissionsError[]; + successes: string; +} ⋮---- -export type GenericAPIResponse = Promise; +/** Sub-auth success item from swap_sub_auth_list */ +export interface FuturesCmPerpSubPermissionsSuccess { + query_id?: number; + sub_uid: string; + sub_auth: number | string; +} ⋮---- -export function serializeParams< - T extends Record | undefined = object, ->( - params: T, - strict_validation: boolean | undefined, - encodeValues: boolean, - prefixWith: string, - repeatArrayValuesAsKVPairs: boolean, -): string +/** Sub-auth list from getCoinMPerpSubPermissions */ +export interface FuturesCmPerpSubPermissions { + errors: FuturesCmPerpSubPermissionsError[]; + successes: FuturesCmPerpSubPermissionsSuccess[]; +} ⋮---- -// Only prefix if there's a value +/** Sub-account list item from getCoinMPerpSubAccounts list[] */ +export interface FuturesCmPerpSubAccountsItem { + symbol: string; + contract_code: string; + margin_balance: number; + liquidation_price: number | null; + risk_rate: number | null; + query_id?: number; +} ⋮---- -export function logInvalidOrderId( - orderIdProperty: SpotOrderIdProperty, - expectedOrderIdPrefix: string, - params: object, -) +/** Sub-account entry from getCoinMPerpSubAccounts (data array element) */ +export interface FuturesCmPerpSubAccounts { + sub_uid: number; + list: FuturesCmPerpSubAccountsItem[]; +} ⋮---- -function getWSAPICustomOrderIdProperties( - operation: WSAPISpotOperation | string, - wsKey: WsKey, -): OrderIdProperty[] +/** Account info item from getCoinMPerpSubAccountsAssets account_info_list[] */ +export interface FuturesCmPerpSubAccountsAssetsAccount { + symbol: string; + contract_code: string; + margin_balance: number; + liquidation_price: number | null; + risk_rate: number | null; +} ⋮---- -function isOrderParamRecord(value: unknown): value is Record +/** Sub-list item from getCoinMPerpSubAccountsAssets sub_list[] */ +export interface FuturesCmPerpSubAccountsAssetsSub { + sub_uid: number; + account_info_list: FuturesCmPerpSubAccountsAssetsAccount[]; +} ⋮---- -function getOrderParamRecords(params: unknown): Record[] +/** Response from getCoinMPerpSubAccounts */ +export type FuturesCmPerpSubAccountsAssets = + FuturesPaginatedSubList; ⋮---- -export function requiresWSAPINewCustomOID( - request: HTXWSAPIRequest, - wsKey: WsKey, -): boolean -⋮---- -export function validateWSAPICustomOrderID( - request: HTXWSAPIRequest, - wsKey: WsKey, -): void -⋮---- -function isDerivativesWSAPIOrderPlacementOperation( - operation: WSAPIDerivativesOperation | string, -): boolean -⋮---- -export function validateWSAPIDerivativesChannelKey( - request: HTXWSAPIRequest, - wsKey: WsKey, -): void -⋮---- -export function isEmptyObject(obj: any, acceptStringIfNotEmpty: boolean) -⋮---- -export function getRestBaseUrl( - restClientOptions: RestClientOptions, - restClientType: RestClientType, -): string -⋮---- -/** - * Iterates to extract pure domain from URL. - * https://example.com/v1/endpoint -> example.com - */ -export function getBaseDomain(url: string): string -⋮---- -export function generateNewOrderID(): string -⋮---- -export function getOrderIdPrefix(): string - -================ -File: src/types/response/futures.types.ts -================ -/** - * Reference - */ -⋮---- -/** Paginated response base. Use FuturesPaginatedData or FuturesPaginatedSettlement for specific data keys. */ -export interface FuturesPaginatedBase { - total_page: number; - current_page: number; - total_size: number; -} -⋮---- -/** Paginated response with `data` array (e.g. historical funding rate, liquidation orders). */ -export type FuturesPaginatedData = FuturesPaginatedBase & { data: T[] }; -⋮---- -/** Paginated response with `settlement_record` array. */ -export type FuturesPaginatedSettlement = FuturesPaginatedBase & { - settlement_record: T[]; -}; -⋮---- -/** Paginated response with `sub_list` array (sub-account info list). */ -export type FuturesPaginatedSubList = FuturesPaginatedBase & { - sub_list: T[]; -}; -⋮---- -/** Paginated response with `transfer_record` array (master-sub transfers). */ -export type FuturesPaginatedTransferRecord = FuturesPaginatedBase & { - transfer_record: T[]; -}; -⋮---- -/** Paginated response with `orders` array (open orders, trigger orders, etc.). */ -export type FuturesPaginatedOrders = FuturesPaginatedBase & { orders: T[] }; -⋮---- -/** Funding rate from swap_funding_rate and swap_batch_funding_rate */ -export interface FuturesFundingRate { - funding_rate: string; - contract_code: string; +/** Sub-account account info from getCoinMPerpSubAccountAssets (data array element) */ +export interface FuturesCmPerpSubAccountAssets { symbol: string; - fee_asset: string; - funding_time: string; - /** Deprecated, default null */ - estimated_rate?: string | null; - /** Deprecated, default null */ - next_funding_time?: string | null; -} -⋮---- -/** Deprecated, default null */ -⋮---- -/** Deprecated, default null */ -⋮---- -/** Historical funding rate item from swap_historical_funding_rate */ -export interface FuturesHistoricalFundingRate { - avg_premium_index: string; - funding_rate: string; - funding_time: string; - /** Deprecated, default null */ - realized_rate?: string | null; contract_code: string; - symbol: string; - fee_asset: string; + margin_balance: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real?: number; + profit_unreal: number; + risk_rate: number | null; + liquidation_price: number | null; + withdraw_available: number; + lever_rate: number; + adjust_factor: number; + margin_static: number; + new_risk_rate?: string | null; + trade_partition?: string; } ⋮---- -/** Deprecated, default null */ -⋮---- -/** Paginated wrapper for swap_historical_funding_rate data */ -export type FuturesHistoricalFundingRatePage = - FuturesPaginatedData; -⋮---- -/** Liquidation order item from swap_liquidation_orders */ -export interface FuturesLiquidationOrder { - query_id: number; +/** Sub-account position from getCoinMPerpSubPositions (data array element) */ +export interface FuturesCmPerpSubPositions { symbol: string; contract_code: string; - created_at: number; - direction: string; - offset: string; volume: number; - amount: number; - price: number; - trade_turnover: number; - pair: string; - business_type: string; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + adl_risk_percent?: string | number; + liq_px: string; + new_risk_rate?: string | null; + trade_partition?: string; } ⋮---- -/** Settlement record item from swap_settlement_records */ -export interface FuturesSettlementRecord { +/** Financial record from POST /swap-api/v3/swap_financial_record and swap_financial_record_exact */ +export interface FuturesCmPerpFinancialRecord { + query_id: number; + id: number | string; + ts: number; symbol: string; contract_code: string; - settlement_time: number; - clawback_ratio: number; - settlement_price: number; - settlement_type: string; - business_type: string; - pair: string; -} -⋮---- -/** Paginated settlement records from swap_settlement_records */ -export type FuturesSettlementRecordsPage = - FuturesPaginatedSettlement; -⋮---- -/** Elite ratio list item (account and position) */ -export interface FuturesEliteRatioList { - buy_ratio: number; - sell_ratio: number; - /** Account ratio only */ - locked_ratio?: number; - ts: number; + type: number; + amount: number | string; } ⋮---- -/** Account ratio only */ -⋮---- -/** Elite account/position ratio data from swap_elite_account_ratio and swap_elite_position_ratio */ -export interface FuturesEliteRatio { - symbol: string; +/** Available leverage from getCoinMPerpAvailableLeverage */ +export interface FuturesCmPerpAvailableLeverage { contract_code: string; - pair: string; - business_type: string; - list: FuturesEliteRatioList[]; + available_level_rate: string; } ⋮---- -/** System status item from swap_api_state. 1=available, 0=unavailable */ -export interface FuturesApiState { +/** Order limit list item from swap_order_limit list[] */ +export interface FuturesCmPerpOrderLimitList { symbol: string; contract_code: string; - margin_mode: string; - margin_account: string; - open: number; - close: number; - cancel: number; - transfer_in: number; - transfer_out: number; - master_transfer_sub: number; - sub_transfer_master: number; - master_transfer_sub_inner_in: number; - master_transfer_sub_inner_out: number; - sub_transfer_master_inner_in: number; - sub_transfer_master_inner_out: number; - transfer_inner_in: number; - transfer_inner_out: number; -} -⋮---- -/** Cross ladder margin tier from swap_cross_ladder_margin */ -export interface FuturesLadderMarginTier { - min_margin_balance: number | null; - max_margin_balance: number | null; - min_margin_available: number | null; - max_margin_available: number | null; + open_limit: number; + close_limit: number; } ⋮---- -/** Cross ladder margin list item */ -export interface FuturesCrossLadderMarginList { - lever_rate: number; - ladders: FuturesLadderMarginTier[]; +/** Order limit from POST /swap-api/v1/swap_order_limit */ +export interface FuturesCmPerpOrderLimit { + order_price_type: string; + list: FuturesCmPerpOrderLimitList[]; } ⋮---- -/** Cross tiered margin item from swap_cross_ladder_margin. Isolated (swap_ladder_margin) omits business_type, pair, contract_type. */ -export interface FuturesCrossLadderMargin { - margin_account: string; +/** Fee from POST /swap-api/v1/swap_fee */ +export interface FuturesCmPerpFee { symbol: string; contract_code: string; - margin_mode: string; - list: FuturesCrossLadderMarginList[]; - business_type?: string; - pair?: string; - contract_type?: string; + open_maker_fee: string; + open_taker_fee: string; + close_maker_fee: string; + close_taker_fee: string; + fee_asset: string; + delivery_fee?: string; } ⋮---- -/** Estimated settlement price item from swap_estimated_settlement_price. Empty around settlement/delivery. */ -export interface FuturesEstimatedSettlementPrice { +/** Transfer limit from POST /swap-api/v1/swap_transfer_limit */ +export interface FuturesCmPerpTransferLimit { + symbol: string; contract_code: string; - estimated_settlement_price: number | null; - settlement_type: string; - contract_type: string; - pair: string; - business_type: string; + transfer_in_max_each: number; + transfer_in_min_each: number; + transfer_out_max_each: number; + transfer_out_min_each: number; + transfer_in_max_daily: number; + transfer_out_max_daily: number; + net_transfer_in_max_daily: number; + net_transfer_out_max_daily: number; } ⋮---- -/** Tiered adjustment factor ladder from swap_adjustfactor and swap_cross_adjustfactor */ -export interface FuturesAdjustFactorLadder { - ladder: number; - min_size: number; - max_size: number | null; - adjust_factor: number; +/** Position limit from POST /swap-api/v1/swap_position_limit */ +export interface FuturesCmPerpPositionLimit { + symbol: string; + contract_code: string; + buy_limit: number; + sell_limit: number; } ⋮---- -/** Adjust factor list item */ -export interface FuturesAdjustFactorList { - lever_rate: number; - ladders: FuturesAdjustFactorLadder[]; +/** API trading status COR from getCoinMPerpApiStatus */ +export interface FuturesCmPerpApiStatusCor { + orders_threshold: number; + orders: number; + invalid_cancel_orders: number; + cancel_ratio_threshold: number; + cancel_ratio: number; + is_trigger: number; + is_active: number; } ⋮---- -/** Tiered adjustment factor item from swap_adjustfactor and swap_cross_adjustfactor. Cross includes business_type, pair, contract_type. */ -export interface FuturesAdjustFactor { - symbol: string; - contract_code: string; - margin_mode: string; - list: FuturesAdjustFactorList[]; - business_type?: string; - pair?: string; - contract_type?: string; +/** API trading status TDN from getCoinMPerpApiStatus */ +export interface FuturesCmPerpApiStatusTdn { + disables_threshold: number; + disables: number; + is_trigger: number; + is_active: number; } ⋮---- -/** Risk reserve balance from /v1/insurance_fund_info */ -export interface FuturesInsuranceFundInfo { - insurance_fund: string; - quote_currency?: string; +/** API trading status from getCoinMPerpApiStatus */ +export interface FuturesCmPerpApiStatus { + is_disable: number; + order_price_types: string; + disable_reason: string; + disable_interval: number; + recovery_time: number; + COR: FuturesCmPerpApiStatusCor; + TDN: FuturesCmPerpApiStatusTdn; } ⋮---- -/** Historical risk reserve item from /v1/insurance_fund_history */ -export interface FuturesInsuranceFundHistory { - query_id: number; - insurance_fund: string; - date: string; +/** Cancel-after response from setCoinMPerpCancelAfter */ +export interface FuturesCmPerpCancelAfter { + current_time: number; + trigger_time: number; } ⋮---- -/** Price limit item from swap_price_limit. business_type, pair, contract_type optional for CM products. */ -export interface FuturesPriceLimit { +/** Trigger open order item from getCoinMPerpTriggerOpenOrders */ +export interface FuturesCmPerpTriggerOpenOrder { symbol: string; contract_code: string; - high_limit: number; - low_limit: number; - business_type?: string; - pair?: string; - contract_type?: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_price: number | string; + order_price: number | string; + created_at: number; + order_price_type: string; + status: number; } ⋮---- -/** Open interest item from swap_open_interest */ -export interface FuturesOpenInterest { +/** Trigger open orders response from getCoinMPerpTriggerOpenOrders */ +export type FuturesCmPerpTriggerOpenOrders = + FuturesPaginatedOrders; +⋮---- +/** Trigger history order item from getCoinMPerpTriggerHisOrders */ +export interface FuturesCmPerpTriggerHisOrder { symbol: string; - volume: number; - amount: number; contract_code: string; - value: number; - trade_amount: number; - trade_volume: number; - trade_turnover: number; - contract_type: string; - pair: string; - business_type: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + relation_order_id: string; + order_price_type: string; + status: number; + order_source: string; + trigger_price: number | string; + triggered_price: number | string | null; + order_price: number | string; + created_at: number; + triggered_at: number | null; + order_insert_at: number; + canceled_at: number | null; + update_time: number; + fail_code: number | null; + fail_reason: string | null; } ⋮---- -/** Contract info item from swap_contract_info */ -export interface FuturesContractInfo { +/** Trigger history orders response from getCoinMPerpTriggerHistoryOrders */ +export type FuturesCmPerpTriggerHistoryOrders = + FuturesPaginatedOrders; +⋮---- +/** TPSL open order item from getCoinMPerpTpslOpenOrders */ +export interface FuturesCmPerpTpslOpenOrder { symbol: string; contract_code: string; - contract_size: number; - price_tick: number; - settlement_date: string; - settlement_period: string; - create_date: string; - delivery_time: string; - contract_status: number; - support_margin_mode?: string; - contract_type: string; - pair: string; - business_type: string; - delivery_date: string; - adjust?: unknown[]; - price_estimated?: unknown[]; - open_type?: number; - trade_partition?: string; - labels?: string[]; - tradfi_labels?: string[]; + volume: number; + order_type: number; + tpsl_order_type: string; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number | string; + price_protect?: boolean; + created_at: number; + order_price_type: string; + order_price: number | string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; } ⋮---- -/** Index price item from swap_index. symbol optional (CM Delivery uses symbol). */ -export interface FuturesIndexPrice { - contract_code?: string; - symbol?: string; - index_price: number; - index_ts: number; -} +/** TPSL open orders response from getCoinMPerpTpslOpenOrders */ +export type FuturesCmPerpTpslOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Index constituent component from swap_contract_constituents */ -export interface FuturesIndexConstituentComponent { - exchange: string; +/** TPSL history order item from getCoinMPerpTpslHistoryOrders */ +export interface FuturesCmPerpTpslHisOrder { symbol: string; - /** Price as string. -1 means HTX masked proprietary third-party index pricing. */ - symbol_price: string; - weights: string; + contract_code: string; + volume: number; + order_type: number; + tpsl_order_type: string; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number | string; + price_protect?: boolean; + created_at: number; + order_price_type: string; + order_price: number | string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; + canceled_at: number | null; + fail_code: number | null; + fail_reason: string | null; + triggered_price: number | string | null; + relation_order_id: string; + update_time: number; } ⋮---- -/** Price as string. -1 means HTX masked proprietary third-party index pricing. */ -⋮---- -/** Index constituents data from swap_contract_constituents. contract_code or symbol per product. */ -export interface FuturesIndexConstituents { - contract_code?: string; - symbol?: string; - index_price: string; - ts: number; - components: FuturesIndexConstituentComponent[]; -} +/** TPSL history orders response from getCoinMPerpTpslHistoryOrders */ +export type FuturesCmPerpTpslHisOrders = + FuturesPaginatedOrders; ⋮---- -/** Contract elements price tick / value item */ -export interface FuturesContractElementsPrice { - business_type: number; - price: string; +/** Trailing open order item from getCoinMPerpTrailingOpenOrders */ +export interface FuturesCmPerpTrailingOpenOrder { + symbol: string; + contract_code: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + order_price_type: string; + status: number; + callback_rate: number | string; + active_price: number | string; + is_active: number; } ⋮---- -/** Contract elements order limit item */ -export interface FuturesContractElementsOrderLimit { - instrument_type: number; - open: string; - close: string; - order_type?: number; - open_after_closing?: string; -} +/** Trailing open orders response from getCoinMPerpTrailingOpenOrders */ +export type FuturesCmPerpTrailingOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Contract elements contract info item */ -export interface FuturesContractElementsContractInfo { - contract_code: string; - instrument_type: number; - settlement_date: string; - delivery_time: string; - create_date: string; - contract_status: number; - delivery_date: string; - trigger_protect?: number; +/** Trailing history order item from getCoinMPerpTrailingHistoryOrders */ +export interface FuturesCmPerpTrailingHisOrder { + symbol: string; + contract_code: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + update_time: number; + order_price_type: string; + status: number; + canceled_at: number | null; + fail_code: number | null; + fail_reason: string | null; + callback_rate: number | string; + active_price: number | string; + is_active: number; + market_limit_price: number | string | null; + formula_price: number | string | null; + real_volume: number | string; + triggered_price: number | string | null; + relation_order_id: string; } ⋮---- -/** Timestamp response from /api/v1/timestamp. No data field. */ -export interface FuturesTimestamp { - status: string; - ts: number; +/** Trailing history orders response from getCoinMPerpTrailingHistoryOrders */ +export type FuturesCmPerpTrailingHisOrders = + FuturesPaginatedOrders; +⋮---- +/** Update leverage response from updateCoinMPerpLeverage */ +export interface FuturesCmPerpUpdateLeverage { + contract_code: string; + lever_rate: number; } ⋮---- -/** Heartbeat data from /heartbeat/ - system availability */ -export interface FuturesHeartbeat { - heartbeat?: number; - swap_heartbeat?: number; - estimated_recovery_time?: number | null; - swap_estimated_recovery_time?: number | null; - linear_swap_heartbeat?: number; - linear_swap_estimated_recovery_time?: number | null; +/** Open order item from getCoinMPerpOpenOrders */ +export interface FuturesCmPerpOpenOrder { + symbol: string; + contract_code: string; + volume: number; + price: number; + order_price_type: string; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + created_at: number; + trade_volume: number; + trade_turnover: number; + fee: number; + trade_avg_price: number | null; + margin_frozen: number; + profit: number; + status: number; + order_source: string; + fee_asset: string; + liquidation_type: string | null; + canceled_at: number | null; + is_tpsl: number; + update_time: number; + real_profit: number; + canceled_source?: string; + self_match_prevent?: number; } ⋮---- -/** Contract elements item from swap_query_elements */ -export interface FuturesContractElements { +/** Open orders response from getCoinMPerpOpenOrders */ +export type FuturesCmPerpOpenOrders = + FuturesPaginatedOrders & { + canceled_source?: string; + self_match_prevent?: number; + }; +⋮---- +/** Item from GET /swap-api/v1/swap_query_elements data[] */ +export interface FuturesCmPerpContractElements { contract_code: string; - mode_type: number; - swap_delivery_type: number; instrument_index_code: string; real_time_settlement: number; transfer_profit_ratio: number; - cross_transfer_profit_ratio: number; - instrument_type: number[]; - trade_partition: string; min_level: string; max_level: string; + open_order_limit: string; + offset_order_limit: string; + long_position_limit: string; + short_position_limit: string; + price_tick: string; + instrument_value: string; settle_period: number; funding_rate_cap: string; funding_rate_floor: string; trigger_protect?: number; - long_position_limit?: string; - offset_order_limit?: string; - open_order_limit?: string; - short_position_limit?: string; - price_tick?: string; - instrument_value?: string; - price_ticks?: FuturesContractElementsPrice[]; - instrument_values?: FuturesContractElementsPrice[]; - order_limits?: FuturesContractElementsOrderLimit[]; - normal_limits?: { - instrument_type: number; - open: string; - close: string; - }[]; - open_limits?: { instrument_type: number; open: string; close: string }[]; - trade_limits?: { - instrument_type: number; - open: string; - close: string; - }[]; - contract_infos?: FuturesContractElementsContractInfo[]; + hig_normal_limit: string; + min_normal_limit: string; + hig_open_limit: string; + min_open_limit: string; + hig_trade_limit: string; + min_trade_limit: string; + contract_infos: FuturesCmPerpContractElementsContractInfo[]; } ⋮---- -/** - * Market - */ +/** List item from contract_elite_account_ratio */ +export interface FuturesCmDeliveryEliteAccountRatioItem { + buy_ratio: number; + sell_ratio: number; + locked_ratio: number; + ts: number; +} ⋮---- -/** Market depth tick from market/depth. ch, id, mrid, version optional per product. Payload in "tick". */ -export interface FuturesMarketDepthTick { - asks: [number, number][]; - bids: [number, number][]; - ch?: string; - id?: number; - mrid?: number; +/** GET /api/v1/contract_elite_account_ratio */ +export interface FuturesCmDeliveryEliteAccountRatio { + symbol: string; + list: FuturesCmDeliveryEliteAccountRatioItem[]; +} +⋮---- +/** List item from contract_elite_position_ratio */ +export interface FuturesCmDeliveryElitePositionRatioItem { + buy_ratio: number; + sell_ratio: number; ts: number; - version?: number; } ⋮---- -/** BBO tick from market/bbo. contract_code or symbol per product. ask/bid: [price, qty]. */ -export interface FuturesBboTick { - contract_code?: string; - symbol?: string; - business_type?: string; +/** GET /api/v1/contract_elite_position_ratio */ +export interface FuturesCmDeliveryElitePositionRatio { + symbol: string; + list: FuturesCmDeliveryElitePositionRatioItem[]; +} +⋮---- +/** BBO tick from GET /market/bbo. ask/bid: [price, qty]. Uses symbol (e.g. BTC_CW). */ +export interface FuturesCmDeliveryMarketBbo { + symbol: string; mrid: number; ask: [number, number]; bid: [number, number]; ts: number; } ⋮---- -/** Kline item from market/history/kline. trade_turnover optional per product. */ -export interface FuturesKline { +/** Kline item from GET /market/history/kline */ +export interface FuturesCmDeliveryKline { id: number; vol: number; count: number; @@ -13194,20 +13119,10 @@ export interface FuturesKline { low: number; high: number; amount: number; - trade_turnover?: number; -} -⋮---- -/** Basis data item from /index/market/history/linear_swap_basis and /index/market/history/basis */ -export interface FuturesBasis { - id: number; - contract_price: string; - index_price: string; - basis: string; - basis_rate: string; } ⋮---- -/** Mark price kline item. Also used for premium index and estimated rate kline. trade_turnover optional. */ -export interface FuturesMarkPriceKline { +/** Mark price kline item from GET /index/market/history/mark_price_kline */ +export interface FuturesCmDeliveryMarkPriceKline { id: number; vol: string; count: string; @@ -13216,151 +13131,153 @@ export interface FuturesMarkPriceKline { low: string; high: string; amount: string; - trade_turnover?: string; } ⋮---- -/** 24h ticker from market detail/merged. contract_code, symbol, business_type optional per product. */ -export interface FuturesTicker { +/** Ticker from GET /market/detail/merged. 24h summary + best bid/ask. Payload in "tick". Alias: getCoinMDeliveryTicker/getCoinMDeliveryTickers. */ +export interface FuturesCmDeliveryTicker { id: number; ts: number; - amount: string; - count: number; vol: string; + count: number; open: string; close: string; low: string; high: string; - trade_turnover?: string; + amount: string; ask: [number, number]; bid: [number, number]; - contract_code?: string; - symbol?: string; - business_type?: string; - number_of?: string; } ⋮---- -/** Trade item from last trade and history trade. symbol, contract_code, business_type, trade_turnover optional per product. */ -export interface FuturesTrade { +export interface FuturesCmDeliveryTrade { id: number; - price: string | number; - amount: string | number; + price: string; + amount: string; direction: string; ts: number; - quantity?: string | number; - contract_code?: string; - business_type?: string; - trade_turnover?: string | number; - symbol?: string; + quantity: string; + symbol: string; + /** Whether the trade is an RPI trade */ + 'is-rpi-trade'?: boolean | number | string; } ⋮---- -/** Last trade tick from market/trade. Payload in "tick". */ -export interface FuturesLastTrade { +/** Whether the trade is an RPI trade */ +⋮---- +/** Last trade tick from GET /market/trade. Payload in "tick". */ +export interface FuturesCmDeliveryLastTrade { id: number; ts: number; - data: FuturesTrade[]; + data: FuturesCmDeliveryTrade[]; } ⋮---- -/** Trade history group from market/history/trade. Each group has trades by timestamp. */ -export interface FuturesTradeHistory { +/** Trade item from GET /market/history/trade data array. No symbol in response. */ +export interface FuturesCmDeliveryTradeHistoryItem { id: number; + price: string | number; + amount: string | number; + direction: string; ts: number; - data: FuturesTrade[]; + quantity?: string | number; + /** Whether the trade is an RPI trade */ + 'is-rpi-trade'?: boolean | number | string; } ⋮---- -/** Open interest tick item from swap_his_open_interest */ -export interface FuturesOpenInterestTick { - volume: number; - amount_type: number; +/** Whether the trade is an RPI trade */ +⋮---- +/** Trade history from GET /market/history/trade. Each group has trades by timestamp. Payload in "data". Alias: getCoinMDeliveryTradeHistory. */ +export interface FuturesCmDeliveryTradeHistory { + id: number; ts: number; - value: number; + data: FuturesCmDeliveryTradeHistoryItem[]; } ⋮---- -/** Open interest data from swap_his_open_interest. data is object with tick array. */ -export interface FuturesHistoricalOpenInterest { - symbol: string; - contract_code: string; - contract_type: string; - pair: string; - business_type: string; - tick: FuturesOpenInterestTick[]; -} -⋮---- -/** - * Account - */ -⋮---- -/** Asset valuation item from swap_balance_valuation */ -export interface FuturesBalanceValuation { - valuation_asset: string; - balance: string; +/** Index kline item from GET /index/market/history/index. vol/count/amount typically 0. Alias: getCoinMDeliveryIndexKlines. */ +export interface FuturesCmDeliveryIndexKline { + id: number; + vol: number; + count: number; + open: number; + close: number; + low: number; + high: number; + amount: number; } ⋮---- -/** Isolated account info item from swap_account_info */ -export interface FuturesIsolatedAccountInfo { +/** Account info from POST /api/v1/contract_account_info. Per-symbol margin account. */ +export interface FuturesCmDeliveryAccountInfo { symbol: string; - contract_code: string; - margin_asset: string; margin_balance: number; margin_position: number; margin_frozen: number; margin_available: number; - profit_real?: number; + profit_real: number; profit_unreal: number; risk_rate: number | null; - new_risk_rate?: string | null; - trade_partition?: string; - withdraw_available: number; + new_risk_rate: string; + trade_partition: string; liquidation_price: number | null; + withdraw_available: number; lever_rate: number; adjust_factor: number; margin_static: number; - margin_mode: string; - margin_account: string; - position_mode: string; } ⋮---- -/** Cross account contract detail (swap + futures) from swap_cross_account_info */ -export interface FuturesCrossAccountContractDetail { +/** Sub-account list item from POST /api/v1/contract_sub_account_list. Per-symbol margin info. */ +export interface FuturesCmDeliverySubAccountListItem { symbol: string; - contract_code: string; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_unreal: number; + margin_balance: number; liquidation_price: number | null; - lever_rate: number; - adjust_factor: number; - contract_type: string; - cross_max_available?: string; - trade_partition?: string; - pair: string; - business_type: string; + risk_rate: number | string | null; + query_id: number; } ⋮---- -/** Cross account info item from swap_cross_account_info */ -export interface FuturesCrossAccountInfo { - margin_mode: string; - margin_account: string; - margin_asset: string; +/** All sub-account from POST /api/v1/contract_sub_account_list. Alias: getCoinMDeliveryAllSubAccounts. */ +export interface FuturesCmDeliveryAllSubAccount { + sub_uid: number; + list: FuturesCmDeliverySubAccountListItem[]; +} +⋮---- +/** Account info item from POST /api/v1/contract_sub_account_info_list sub_list[].account_info_list */ +export interface FuturesCmDeliverySubAccountInfoListItem { + symbol: string; + margin_balance: number; + liquidation_price: number | null; + risk_rate: number | string | null; +} +⋮---- +/** Sub-list item from POST /api/v1/contract_sub_account_info_list */ +export interface FuturesCmDeliverySubAccountInfoListSub { + sub_uid: number; + account_info_list: FuturesCmDeliverySubAccountInfoListItem[]; +} +⋮---- +/** Sub-accounts assets from POST /api/v1/contract_sub_account_info_list. Alias: getCoinMDeliverySubAccounts. */ +export type FuturesCmDeliverySubAccountsAssets = + FuturesPaginatedSubList; +⋮---- +/** Sub-account assets from POST /api/v1/contract_sub_account_info. Alias: getCoinMDeliverySubAccountAssets. */ +export interface FuturesCmDeliverySubAccountAssets { + symbol: string; margin_balance: number; - margin_static: number; margin_position: number; margin_frozen: number; + margin_available: number; + profit_real: number; profit_unreal: number; + risk_rate: number | string | null; + liquidation_price: number | null; withdraw_available: number; - risk_rate: number | null; - money_in?: string; - money_out?: string; - new_risk_rate?: string | null; - position_mode: string; - contract_detail: FuturesCrossAccountContractDetail[]; - futures_contract_detail: FuturesCrossAccountContractDetail[]; + lever_rate: number; + adjust_factor: number; + margin_static: number; + new_risk_rate: string; + trade_partition: string; } ⋮---- -/** Position info item from swap_position_info and swap_cross_position_info */ -export interface FuturesPositionInfo { +/** Position info from POST /api/v1/contract_sub_position_info. Single sub-account positions, data array element. */ +export interface FuturesCmDeliverySubPositionInfo { symbol: string; contract_code: string; + contract_type: string; volume: number; available: number; frozen: number; @@ -13369,28 +13286,21 @@ export interface FuturesPositionInfo { profit_unreal: number; profit_rate: number; profit: number; - margin_asset: string; position_margin: number; lever_rate: number; direction: string; last_price: number; - margin_mode: string; - margin_account: string; - position_mode: string; - withdraw_available?: number; - risk_rate?: number | null; - liquidation_price?: number | null; adl_risk_percent?: string | number; - contract_type?: string; - pair?: string; - business_type?: string; - margin?: number | string; + liq_px: string; + new_risk_rate: string; + trade_partition: string; } ⋮---- -/** Nested position in swap_account_position_info */ -export interface FuturesAccountPosition { +/** Position info from POST /api/v1/contract_position_info. */ +export interface FuturesCmDeliveryPositionInfo { symbol: string; contract_code: string; + contract_type: string; volume: number; available: number; frozen: number; @@ -13399,338 +13309,355 @@ export interface FuturesAccountPosition { profit_unreal: number; profit_rate: number; profit: number; - margin_asset: string; position_margin: number; lever_rate: number; direction: string; last_price: number; - margin_mode: string; - margin_account: string; - position_mode: string; adl_risk_percent?: string | number; - new_risk_rate?: string | null; - trade_partition?: string; + liq_px: string; + new_risk_rate: string; + trade_partition: string; } ⋮---- -/** Account + positions from swap_account_position_info (Isolated) */ -export interface FuturesIsolatedAccountPosition { +/** Liquidation order from GET /api/v3/contract_liquidation_orders */ +export interface FuturesCmDeliveryLiquidationOrder { + query_id: number; symbol: string; contract_code: string; - margin_asset: string; - margin_balance: number; - margin_static: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real?: number; - profit_unreal: number; - risk_rate: number | null; - new_risk_rate?: string | null; - trade_partition?: string; - liquidation_price: number | null; - withdraw_available: number; - lever_rate: number; - adjust_factor: number; - margin_mode: string; - margin_account: string; - position_mode: string; - positions: FuturesAccountPosition[]; - adl_risk_percent?: string | number; + direction: string; + offset: string; + volume: number; + amount: number; + price: number; + created_at: number; } ⋮---- -/** Cross position item (in positions array) from swap_cross_account_position_info */ -export interface FuturesCrossAccountPositionItem { - symbol: string; +/** Settlement record list item from contract_settlement_records */ +export interface FuturesCmDeliverySettlementRecordItem { contract_code: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - margin_asset: string; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - margin_mode: string; - margin_account: string; - contract_type: string; - pair: string; - business_type: string; - position_mode: string; - new_risk_rate?: string | null; - trade_partition?: string; + settlement_price: number; + settlement_type: string; } ⋮---- -/** Cross account + positions from swap_cross_account_position_info. data is object, not array. */ -export interface FuturesCrossAccountPosition { - margin_mode: string; - margin_account: string; - margin_asset: string; - margin_balance: number; - margin_static: number; - margin_position: number; - margin_frozen: number; - profit_real?: number; - profit_unreal: number; - withdraw_available: number; - risk_rate: number | null; - money_in?: string; - money_out?: string; - new_risk_rate?: string | null; - position_mode: string; - contract_detail: FuturesCrossAccountContractDetail[]; - futures_contract_detail: FuturesCrossAccountContractDetail[]; - positions: FuturesCrossAccountPositionItem[]; - adl_risk_percent?: string | number; +/** Settlement record from GET /api/v1/contract_settlement_records */ +export interface FuturesCmDeliverySettlementRecord { + symbol: string; + settlement_time: number; + clawback_ratio: number; + list: FuturesCmDeliverySettlementRecordItem[]; } ⋮---- -/** Sub auth error from swap_sub_auth and swap_sub_auth_list */ -export interface FuturesSubAuthError { - sub_uid: string; - err_code: number | string; - err_msg: string; +/** GET /api/v1/contract_settlement_records */ +export interface FuturesCmDeliverySettlementRecords { + total_page: number; + current_page: number; + total_size: number; + settlement_record: FuturesCmDeliverySettlementRecord[]; } ⋮---- -/** Sub auth response data from swap_sub_auth */ -export interface FuturesSubAuth { - errors: FuturesSubAuthError[]; - successes: string; +/** Financial record from POST /api/v3/contract_financial_record and contract_financial_record_exact */ +export interface FuturesCmDeliveryFinancialRecord { + query_id?: number; + id: number; + ts: number; + symbol: string; + contract_code: string; + type: number; + amount: number | string; } ⋮---- -/** Sub auth success item from swap_sub_auth_list */ -export interface FuturesSubAuthSuccess { - query_id?: number; - sub_uid: string; - sub_auth: number | string; -} -⋮---- -/** Sub permissions response from getSubPermissions */ -export interface FuturesSubPermissions { - errors: FuturesSubAuthError[]; - successes: FuturesSubAuthSuccess[]; +/** Position in user settlement record from POST /api/v1/contract_user_settlement_records */ +export interface FuturesCmDeliveryUserSettlementRecordPosition { + symbol: string; + contract_code: string; + direction: string; + volume: number; + cost_open: number; + cost_hold_pre: number; + cost_hold: number; + settlement_profit_unreal: number; + settlement_price: number; + settlement_type: string; } ⋮---- -/** Isolated sub-account list item from swap_sub_account_list */ -export interface FuturesIsolatedSubAccountList { +/** User settlement record from POST /api/v1/contract_user_settlement_records */ +export interface FuturesCmDeliveryUserSettlementRecord { symbol: string; - contract_code: string; - margin_asset: string; + margin_balance_init: number; margin_balance: number; - liquidation_price: number | null; - risk_rate: number | string | null; - margin_mode: string; - margin_account: string; - /** Used as from_id for next/prev pagination */ - query_id?: number; + settlement_profit_real: number; + settlement_time: number; + clawback: number; + delivery_fee: number; + offset_profitloss: number; + fee: number; + fee_asset: string; + positions: FuturesCmDeliveryUserSettlementRecordPosition[]; } ⋮---- -/** Used as from_id for next/prev pagination */ +/** Response from POST /api/v1/contract_user_settlement_records */ +export interface FuturesCmDeliveryUserSettlementRecords { + total_page: number; + current_page: number; + total_size: number; + settlement_records: FuturesCmDeliveryUserSettlementRecord[]; +} ⋮---- -/** Isolated sub-account entry from swap_sub_account_list (data array element) */ -export interface FuturesIsolatedSubAccountListEntry { - sub_uid: number; - list: FuturesIsolatedSubAccountList[]; +/** Order limit type from POST /api/v1/contract_order_limit list[].types */ +export interface FuturesCmDeliveryOrderLimitType { + contract_type: string; + open_limit: number; + close_limit: number; } ⋮---- -/** Cross sub-account list item from swap_cross_sub_account_list */ -export interface FuturesCrossSubAccountList { - margin_mode: string; - margin_account: string; - margin_asset: string; - margin_balance: number; - risk_rate: number | string | null; - trade_partition?: string; +/** Order limit list item from POST /api/v1/contract_order_limit */ +export interface FuturesCmDeliveryOrderLimitListItem { + symbol: string; + types: FuturesCmDeliveryOrderLimitType[]; } ⋮---- -/** Asset multi-sub object from swap_cross_sub_account_list. Can be null. */ -export interface FuturesCrossSubAccountAssetMultiSub { - state: string; - equity: string; - initial_margin: string; - maintenance_margin: string; - maintenance_margin_rate: string; - profit_unreal: string; - available_margin: string; - created_time: number | string; - updated_time: number | string; - details: unknown[]; +/** Response from POST /api/v1/contract_order_limit */ +export interface FuturesCmDeliveryOrderLimit { + order_price_type: string; + list: FuturesCmDeliveryOrderLimitListItem[]; } ⋮---- -/** Cross sub-account entry from swap_cross_sub_account_list (data array element) */ -export interface FuturesCrossSubAccountListEntry { - query_id: number; - sub_uid: number; - list: FuturesCrossSubAccountList[]; - asset_multi_sub: FuturesCrossSubAccountAssetMultiSub | null; +/** Response from POST /api/v1/contract_switch_lever_rate */ +export interface FuturesCmDeliverySwitchLeverRate { + symbol: string; + lever_rate: number; } ⋮---- -/** Account info item from swap_sub_account_info_list */ -export interface FuturesSubAccountInfoAccount { +/** Open order item from POST /api/v1/contract_openorders data.orders[] */ +export interface FuturesCmDeliveryOpenOrder { symbol: string; contract_code: string; - margin_account: string; - margin_mode: string; - margin_asset: string; - margin_balance: number; - liquidation_price: number | null; - risk_rate: number | string | null; + contract_type: string; + volume: number; + price: number; + order_price_type: string; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + client_order_id: number | string | null; + created_at: number; + trade_volume: number; + trade_turnover: number; + fee: number; + trade_avg_price: number | null; + margin_frozen: number; + profit: number; + status: number; + order_source: string; + fee_asset: string; + is_tpsl: number; + update_time: number; + real_profit: number; + liquidation_type?: string | null; + canceled_at?: number | null; } ⋮---- -/** Sub-account item in swap_sub_account_info_list data.sub_list */ -export interface FuturesSubAccountInfoSub { - sub_uid: number; - account_info_list: FuturesSubAccountInfoAccount[]; +/** Response from POST /api/v1/contract_openorders */ +export type FuturesCmDeliveryOpenOrders = + FuturesPaginatedOrders & { + self_match_prevent?: number; + canceled_source?: string; + }; +⋮---- +/** Trigger open order item from POST /api/v1/contract_trigger_openorders data.orders[] */ +export interface FuturesCmDeliveryTriggerOpenOrder { + symbol: string; + contract_code: string; + contract_type: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_price: number; + order_price: number; + created_at: number; + order_price_type: string; + status: number; } ⋮---- -/** object from swap_sub_account_info_list */ -export type FuturesSubAccountInfoList = - FuturesPaginatedSubList; +/** Response from POST /api/v1/contract_trigger_openorders */ +export type FuturesCmDeliveryTriggerOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Cross sub-account info list: account_info_list item (no symbol/contract_code) */ -export interface FuturesCrossSubAccountInfoListAccount { - margin_mode: string; - margin_account: string; - margin_asset: string; - margin_balance: number; - risk_rate: number | string | null; - trade_partition?: string; +/** Trigger history order item from POST /api/v1/contract_trigger_hisorders data.orders[] */ +export interface FuturesCmDeliveryTriggerHistoryOrder { + symbol: string; + contract_code: string; + contract_type: string; + trigger_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + relation_order_id: string; + order_price_type: string; + status: number; + order_source: string; + trigger_price: number; + triggered_price: number; + order_price: number; + created_at: number; + triggered_at: number; + order_insert_at: number; + canceled_at: number; + fail_code: number | null; + fail_reason: string | null; + update_time?: number; } ⋮---- -/** Cross sub-account info list: sub_list item */ -export interface FuturesCrossSubAccountInfoListSub { - sub_uid: number; - account_info_list: FuturesCrossSubAccountInfoListAccount[]; -} +/** Response from POST /api/v1/contract_trigger_hisorders */ +export type FuturesCmDeliveryTriggerHistoryOrders = + FuturesPaginatedOrders; ⋮---- -/** Cross sub-account info list: unite_sub_list item */ -export interface FuturesCrossSubAccountInfoListUnite { - sub_uid: number; - asset_multi_sub: FuturesCrossSubAccountAssetMultiSub; +/** TPSL open order item from POST /api/v1/contract_tpsl_openorders data.orders[] */ +export interface FuturesCmDeliveryTpslOpenOrder { + symbol: string; + contract_code: string; + contract_type: string; + volume: number; + order_type: number; + tpsl_order_type: 'tp' | 'sl'; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number; + order_price: number; + created_at: number; + order_price_type: string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; + price_protect?: boolean; } ⋮---- -/** object from swap_cross_sub_account_info_list */ -export type FuturesCrossSubAccountInfoList = - FuturesPaginatedSubList & { - unite_sub_list: FuturesCrossSubAccountInfoListUnite[]; - }; +/** Response from POST /api/v1/contract_tpsl_openorders */ +export type FuturesCmDeliveryTpslOpenOrders = + FuturesPaginatedOrders; ⋮---- -/** Isolated sub-account info item from swap_sub_account_info (single sub, data array element) */ -export interface FuturesIsolatedSubAccountInfo { +/** TPSL history order item from POST /api/v1/contract_tpsl_hisorders data.orders[] */ +export interface FuturesCmDeliveryTpslHistoryOrder { symbol: string; contract_code: string; - margin_asset: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real?: number; - profit_unreal: number; - risk_rate: number | string | null; - new_risk_rate?: string | null; - trade_partition?: string; - liquidation_price: number | null; - withdraw_available: number; - lever_rate: number; - adjust_factor: number; - margin_static: number; - margin_mode: string; - margin_account: string; - position_mode: string; -} -⋮---- -/** Cross sub-account info item from swap_cross_sub_account_info (single sub, data array element) */ -export interface FuturesCrossSubAccountInfo { - margin_mode: string; - margin_account: string; - margin_asset: string; - margin_balance: number; - margin_static: number; - margin_position: number; - margin_frozen: number; - profit_real?: number; - profit_unreal: number; - withdraw_available: number; - risk_rate: number | string | null; - money_in?: string; - money_out?: string; - new_risk_rate?: string | null; - position_mode: string; - contract_detail: FuturesCrossAccountContractDetail[]; - futures_contract_detail: FuturesCrossAccountContractDetail[]; -} -⋮---- -/** Financial record item from swap_financial_record and swap_financial_record_exact */ -export interface FuturesFinancialRecord { - query_id: number; - id: number; - ts: number; - asset: string; - contract_code: string; - margin_account: string; - face_margin_account: string; - type: number; - amount: number | string; + contract_type: string; + volume: number; + order_type: number; + tpsl_order_type: 'tp' | 'sl'; + direction: string; + order_id: number | string; + order_id_str: string; + order_source: string; + trigger_type: string; + trigger_price: number; + order_price: number; + created_at: number; + order_price_type: string; + status: number; + source_order_id: string | null; + relation_tpsl_order_id: string; + canceled_at: number; + fail_code: number | null; + fail_reason: string | null; + triggered_price: number | null; + relation_order_id: string; + update_time: number; + price_protect?: boolean; } ⋮---- -/** Available leverage item from swap_available_level_rate */ -export interface FuturesAvailableLevelRate { - contract_code: string; - margin_mode: string; - available_level_rate: string; -} +/** Response from POST /api/v1/contract_tpsl_hisorders */ +export type FuturesCmDeliveryTpslHistoryOrders = + FuturesPaginatedOrders; ⋮---- -/** Available leverage item from swap_cross_available_level_rate */ -export interface FuturesCrossAvailableLevelRate { +/** Trailing open order item from POST /api/v1/contract_track_openorders data.orders[] */ +export interface FuturesCmDeliveryTrailingOpenOrder { + symbol: string; contract_code: string; - margin_mode: string; - available_level_rate: string; contract_type: string; - pair: string; - business_type: string; + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + order_price_type: string; + status: number; + callback_rate: number; + active_price: number; + is_active: number; } ⋮---- -/** Order limit list item from swap_order_limit */ -export interface FuturesOrderLimitList { +/** Response from POST /api/v1/contract_track_openorders */ +export type FuturesCmDeliveryTrailingOpenOrders = + FuturesPaginatedOrders; +⋮---- +/** Trailing history order item from POST /api/v1/contract_track_hisorders data.orders[] */ +export interface FuturesCmDeliveryTrailingHistoryOrder { symbol: string; contract_code: string; - open_limit: number; - close_limit: number; contract_type: string; - pair: string; - business_type: string; -} -⋮---- -/** from swap_order_limit */ -export interface FuturesOrderLimit { + volume: number; + order_type: number; + direction: string; + offset: string; + lever_rate: number; + order_id: number | string; + order_id_str: string; + order_source: string; + created_at: number; + update_time: number; order_price_type: string; - list: FuturesOrderLimitList[]; + status: number; + canceled_at: number; + fail_code: number | null; + fail_reason: string | null; + callback_rate: number; + active_price: number; + is_active: number; + market_limit_price: number | null; + formula_price: number | null; + real_volume: number; + triggered_price: number | null; + relation_order_id: string; } ⋮---- -/** Fee item from swap_fee */ -export interface FuturesFee { +/** Response from POST /api/v1/contract_track_hisorders */ +export type FuturesCmDeliveryTrailingHistoryOrders = + FuturesPaginatedOrders; +⋮---- +/** Fee from POST /api/v1/contract_fee */ +export interface FuturesCmDeliveryFee { symbol: string; - contract_code: string; open_maker_fee: string; open_taker_fee: string; close_maker_fee: string; close_taker_fee: string; - fee_asset: string; - contract_type: string; - pair: string; - business_type: string; delivery_fee: string; + fee_asset: string; } ⋮---- -/** Transfer limit item from swap_transfer_limit */ -export interface FuturesTransferLimit { +/** Transfer limit from POST /api/v1/contract_transfer_limit */ +export interface FuturesCmDeliveryTransferLimit { symbol: string; - contract_code: string; - margin_mode: string; - margin_account: string; transfer_in_max_each: number; transfer_in_min_each: number; transfer_out_max_each: number; @@ -13741,5555 +13668,4305 @@ export interface FuturesTransferLimit { net_transfer_out_max_daily: number; } ⋮---- -/** Transfer limit item from swap_cross_transfer_limit */ -export interface FuturesCrossTransferLimit { - margin_mode: string; - margin_account: string; - transfer_in_max_each: number; - transfer_in_min_each: number; - transfer_out_max_each: number; - transfer_out_min_each: number; - transfer_in_max_daily: number; - transfer_out_max_daily: number; - net_transfer_in_max_daily: number; - net_transfer_out_max_daily: number; +/** Position limit list item from POST /api/v1/contract_position_limit data[].list */ +export interface FuturesCmDeliveryPositionLimitListItem { + contract_type: string; + buy_limit: number; + sell_limit: number; } ⋮---- -/** Position limit item from swap_position_limit */ -export interface FuturesPositionLimit { +/** Position limit from POST /api/v1/contract_position_limit */ +export interface FuturesCmDeliveryPositionLimit { symbol: string; - contract_code: string; - margin_mode: string; - buy_limit: number; - sell_limit: number; - lever_rate: number; - buy_limit_value: number; - sell_limit_value: number; - mark_price: number; + list: FuturesCmDeliveryPositionLimitListItem[]; } ⋮---- -/** Position limit item from swap_cross_position_limit */ -export interface FuturesCrossPositionLimit { +/** Position in asset_position_info from POST /api/v1/contract_account_position_info */ +export interface FuturesCmDeliveryAssetPositionInfoPosition { symbol: string; contract_code: string; - margin_mode: string; - buy_limit: number; - sell_limit: number; - lever_rate: number; - buy_limit_value: number; - sell_limit_value: number; - mark_price: number; contract_type: string; - pair: string; - business_type: string; + volume: number; + available: number; + frozen: number; + cost_open: number; + cost_hold: number; + profit_unreal: number; + profit_rate: number; + profit: number; + position_margin: number; + lever_rate: number; + direction: string; + last_price: number; + adl_risk_percent?: string | number; } ⋮---- -/** Lever position limit list item (per leverage) from swap_lever_position_limit */ -export interface FuturesLeverPositionLimitList { +/** Asset + positions from POST /api/v1/contract_account_position_info. Alias: getCoinMDeliveryAssetPositionInfo. */ +export interface FuturesCmDeliveryAssetPositionInfo { + symbol: string; + margin_balance: number; + margin_position: number; + margin_frozen: number; + margin_available: number; + profit_real: number; + profit_unreal: number; + risk_rate: number | string | null; + withdraw_available: number; + liquidation_price: number | null; lever_rate: number; - buy_limit_value: number; - sell_limit_value: number; + adjust_factor: number; + margin_static: number; + new_risk_rate: string; + trade_partition: string; + positions: FuturesCmDeliveryAssetPositionInfoPosition[]; } ⋮---- -/** Lever position limit item from swap_lever_position_limit */ -export interface FuturesLeverPositionLimit { - symbol: string; - contract_code: string; - margin_mode: string; - list: FuturesLeverPositionLimitList[]; +/** API trading status item from GET /api/v1/contract_api_trading_status */ +export interface FuturesCmDeliveryApiTradingStatusCor { + orders_threshold: number; + orders: number; + invalid_cancel_orders: number; + cancel_ratio_threshold: number; + cancel_ratio: number; + is_trigger: number; + is_active: number; } ⋮---- -/** Lever position limit item from swap_cross_lever_position_limit */ -export interface FuturesCrossLeverPositionLimit { - symbol: string; - contract_code: string; - margin_mode: string; - business_type: string; - contract_type: string; - pair: string; - list: FuturesLeverPositionLimitList[]; +/** API trading status TDN from GET /api/v1/contract_api_trading_status */ +export interface FuturesCmDeliveryApiTradingStatusTdn { + disables_threshold: number; + disables: number; + is_trigger: number; + is_active: number; } ⋮---- -/** Master-sub transfer response from transfer*MasterSub */ -export interface FuturesMasterSubTransfer { - order_id: string; - client_order_id?: number; +/** API trading status from GET /api/v1/contract_api_trading_status */ +export interface FuturesCmDeliveryApiTradingStatus { + is_disable: number; + order_price_types: string; + disable_reason: string; + disable_interval: number; + recovery_time: number; + COR: FuturesCmDeliveryApiTradingStatusCor; + TDN: FuturesCmDeliveryApiTradingStatusTdn; } ⋮---- -/** Transfer record item from master_sub_transfer_record. asset, margin_account, symbol, contract_code optional per product. */ -export interface FuturesMasterSubTransferRecordItem { - id: number; - ts: number; - sub_uid: string; - sub_account_name: string; - transfer_type: number; - amount: number | string; - asset?: string; - margin_account?: string; - from_margin_account?: string; - to_margin_account?: string; - symbol?: string; - contract_code?: string; +/** Leverage rate from POST /api/v1/contract_available_level_rate. Alias: getCoinMDeliveryLeverageRate. */ +export interface FuturesCmDeliveryLeverageRate { + symbol: string; + available_level_rate: string; } ⋮---- -/** Master-sub transfer records from swap_master_sub_transfer_record */ -export type FuturesMasterSubTransferRecords = - FuturesPaginatedTransferRecord; -⋮---- -/** Cancel-after response data from linear-cancel-after */ -export interface FuturesCancelAfter { - current_time: number; - trigger_time: number; +/** GET /api/v1/contract_open_interest */ +export interface FuturesCmDeliveryContractOpenInterest { + symbol: string; + contract_type: string; + contract_code: string; + volume: number; + amount: number; + trade_amount: number; + trade_volume: number; + trade_turnover: number; } ⋮---- -/** Submit order response data from swap_order and swap_cross_order. order_id may exceed JS safe integer - use order_id_str. */ -export interface FuturesSubmitOrder { - order_id: number | string; - order_id_str: string; - client_order_id?: number; +/** Delivery price from GET /api/v1/contract_delivery_price */ +export interface FuturesCmDeliveryDeliveryPrice { + delivery_price: number; } ⋮---- -/** Batch order error item from swap_batchorder and swap_cross_batchorder */ -export interface FuturesBatchOrderError { - index: number; - err_code: number; - err_msg: string; +/** Estimated settlement price list item */ +export interface FuturesCmDeliveryEstimatedSettlementPriceItem { + contract_type: string; + contract_code: string; + estimated_settlement_price: number | null; + settlement_type: string; } ⋮---- -/** Batch order success item from swap_batchorder and swap_cross_batchorder */ -export interface FuturesBatchOrderSuccess { - index: number; - order_id: number | string; - order_id_str: string; - client_order_id?: number; +/** GET /api/v1/contract_estimated_settlement_price */ +export interface FuturesCmDeliveryEstimatedSettlementPrice { + symbol: string; + list: FuturesCmDeliveryEstimatedSettlementPriceItem[]; } ⋮---- -/** Cancel order error item from swap_cancel and swap_cross_cancel */ -export interface FuturesCancelOrderError { - order_id: string; - err_code: number; - err_msg: string; +/** GET /api/v1/contract_api_state */ +export interface FuturesCmDeliveryApiState { + symbol: string; + open: number; + close: number; + cancel: number; + transfer_in: number; + transfer_out: number; + master_transfer_sub: number; + sub_transfer_master: number; } ⋮---- -/** Cancel order response data from swap_cancel, swap_cross_cancel, swap_cancelall, swap_cross_cancelall */ -export interface FuturesCancelOrder { - errors: FuturesCancelOrderError[]; - /** Comma-separated list of successfully cancelled order_id or client_order_id */ - successes: string; +/** GET /api/v1/contract_contract_info */ +export interface FuturesCmDeliveryContractInfo { + symbol: string; + contract_code: string; + contract_type: string; + contract_size: number; + price_tick: number; + delivery_date: string; + create_date: string; + settlement_time: string; + delivery_time: string; + contract_status: number; + labels?: string[]; } ⋮---- -/** Comma-separated list of successfully cancelled order_id or client_order_id */ +/** GET /api/market/contract_constituents */ +export interface FuturesCmDeliveryConstituents { + symbol: string; + ts: number; + index_price: string; + components: FuturesIndexConstituentComponent[]; +} ⋮---- -/** Switch leverage response data from swap_switch_lever_rate */ -export interface FuturesSwitchLeverRate { +/** Contract info sub-item in query elements */ +export interface FuturesCmDeliveryQueryElementsContractInfo { contract_code: string; - margin_mode: string; - lever_rate: number; + instrument_type: number | number[]; + create_date: string; + contract_status: number; + delivery_time: string; + delivery_date: string; } ⋮---- -/** Switch leverage response data from swap_cross_switch_lever_rate */ -export interface FuturesCrossSwitchLeverRate { +/** Order limit in query elements */ +export interface FuturesCmDeliveryQueryElementsOrderLimit { + instrument_type: number; + open: string; + close: string; + trigger_protect?: number; +} +⋮---- +/** GET /api/v1/contract_query_elements */ +export interface FuturesCmDeliveryQueryElements { contract_code: string; - margin_mode: string; - lever_rate: number; - contract_type: string; - pair: string; - business_type: string; + instrument_index_code: string; + real_time_settlement?: number; + price_tick?: string; + instrument_value?: string; + transfer_profit_ratio?: number; + min_level?: string; + max_level?: string; + open_order_limit?: string; + offset_order_limit?: string; + long_position_limit?: string; + short_position_limit?: string; + week_hig_normal_limit?: number; + week_min_normal_limit?: number; + week_hig_open_limit?: number; + week_min_open_limit?: number; + week_hig_trade_limit?: number; + week_min_trade_limit?: number; + biweek_hig_normal_limit?: number; + biweek_min_normal_limit?: number; + biweek_hig_open_limit?: number; + biweek_min_open_limit?: number; + biweek_hig_trade_limit?: number; + biweek_min_trade_limit?: number; + quarter_hig_normal_limit?: number; + quarter_min_normal_limit?: number; + quarter_hig_open_limit?: number; + quarter_min_open_limit?: number; + quarter_hig_trade_limit?: number; + quarter_min_trade_limit?: number; + biquarter_hig_normal_limit?: number; + biquarter_min_normal_limit?: number; + biquarter_hig_open_limit?: number; + biquarter_min_open_limit?: number; + biquarter_hig_trade_limit?: number; + biquarter_min_trade_limit?: number; + instrument_type?: number[]; + contract_infos?: FuturesCmDeliveryQueryElementsContractInfo[]; + order_limits?: FuturesCmDeliveryQueryElementsOrderLimit[]; } ⋮---- /** - * Batch order response data from swap_batchorder and swap_cross_batchorder. - * A successful request can contain both accepted and rejected orders. + * Copy Trading */ -export interface FuturesBatchOrder { - errors: FuturesBatchOrderError[]; - success: FuturesBatchOrderSuccess[]; +⋮---- +/** Lead trading instrument from GET /api/v6/copyTrading/trader/instruments */ +export interface FuturesCopyTraderInstrument { + instId: string; + instType: string; } ⋮---- -/** Position mode item from swap_switch_position_mode and swap_cross_switch_position_mode */ -export interface FuturesSwitchPositionMode { - margin_account: string; - position_mode: string; +/** Profit detail item in trader statistics */ +export interface FuturesCopyTraderProfitDetail { + pnlRate: string; + pnl: string; + ts: string; } ⋮---- -/** Order info item from getOrderInfo, getCoinMDeliveryOrderInfo, getCoinMPerpOrderInfo. Product-specific fields optional. */ -export interface FuturesOrderInfo { - symbol: string; - contract_code: string; - volume: number; - price: number; - order_price_type: string; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - created_at: number; - canceled_at: number | null; - trade_volume: number; - trade_turnover: number; - fee: number; - trade_avg_price: number | null; - margin_frozen: number; - profit: number; - status: number; - order_source: string; - fee_asset: string; - liquidation_type: string | null; - is_tpsl: number; - real_profit: number; - update_time?: number; - /** USDM only */ - margin_asset?: string; - margin_mode?: string; - margin_account?: string; - reduce_only?: number; - fee_amount?: number; - fee_quote_amount?: number; - self_match_prevent_new?: string; - /** CM Delivery: required; USDM/CM Perp: optional */ - contract_type?: string; - pair?: string; - business_type?: string; - canceled_source?: string; - self_match_prevent?: number; +/** Trader lead trading metrics from GET /api/v6/copyTrading/trader/statistics */ +export interface FuturesCopyTraderStatistics { + instType: string; + totalFollowerNum: string; + curFollowerNum: string; + totalPnl: string; + followerTotalPnl: string; + winRate: string; + winNum: string; + lossNum: string; + profitDetails24h?: FuturesCopyTraderProfitDetail[]; + profitDetails90d: FuturesCopyTraderProfitDetail[]; } ⋮---- -/** USDM only */ +/** Profit sharing history item from GET /api/v6/copyTrading/trader/profit-sharing-history */ +export interface FuturesCopyTraderProfitSharingHistory { + id: string; + instType: string; + followerName: string; + ccy: string; + profitSharingAmt: string; + ts: string; +} ⋮---- -/** CM Delivery: required; USDM/CM Perp: optional */ +/** Profit sharing summary from GET /api/v6/copyTrading/trader/profit-sharing-history-summary or unrealized-profit-sharing-summary */ +export interface FuturesCopyTraderProfitSharingSummary { + instType: string; + ccy: string; + totalAmt: string; +} ⋮---- -/** Order detail trade item (trades array) from getOrderDetail, getCoinMDeliveryOrderDetail, getCoinMPerpOrderDetail */ -export interface FuturesOrderDetailTrade { +/** Follower info from GET /api/v6/copyTrading/trader/followers */ +export interface FuturesCopyTraderFollower { id: string; - trade_id: number | string; - trade_price: number; - trade_volume: number; - trade_turnover: number; - trade_fee: number; - role: string; - created_at: number; - profit: number; - real_profit: number; - fee_asse?: string; - price?: string; - fee_asset?: string; - canceled_source?: string; - self_match_prevent?: string | number; + instType: string; + followerAvatarLink: string; + followerName: string; + followerUid: string; + followTime: string; + followerAssetAmt: string; + followerProfitSharingAmt: string; + followerTradeAmt: string; + totalProfitSharingAmt: string; } ⋮---- -/** Order detail from getOrderDetail, getCoinMDeliveryOrderDetail, getCoinMPerpOrderDetail. Product-specific fields optional. */ -export interface FuturesOrderDetail { - symbol: string; - contract_code: string; - lever_rate: number; - direction: string; - offset: string; - volume: number; - price: number; - created_at: number; - canceled_at: number; - order_source: string; - order_price_type: string; - margin_frozen: number; - profit: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - order_type: number | string; - status: number; - trade_volume: number; - trade_turnover: number; - trade_avg_price: number; - total_page: number; - current_page: number; - total_size: number; - instrument_price: number; - final_interest: number; - adjust_value: number; - fee_asset: string; - fee: number; - liquidation_type: string; - is_tpsl: number; - real_profit: number; - trades: FuturesOrderDetailTrade[]; - /** USDM only */ - margin_asset?: string; - margin_mode?: string; - margin_account?: string; - reduce_only?: number; - self_match_prevent_new?: string; - /** CM Delivery: required; USDM/CM Perp: optional */ - contract_type?: string; - pair?: string; - business_type?: string; - canceled_source?: string; - self_match_prevent?: number; +/** Remove follower result item from POST /api/v6/copyTrading/trader/follower */ +export interface FuturesCopyTraderFollowerRemoveResult { + followerUid: string; + scode: string; + smsg: string; } ⋮---- -/** USDM only */ +/** Lead trading config from GET /api/v6/copyTrading/trader/config or POST follower-settings */ +export interface FuturesCopyTraderConfig { + instType: string; + enable: boolean; + profitSharingRatio: string; + maxFollowers: string; +} ⋮---- -/** CM Delivery: required; USDM/CM Perp: optional */ +/** Lead trading API key from POST /api/v6/copyTrading/trader/apikey */ +export interface FuturesCopyTraderApikey { + label: string; + accessKey: string; + secretKey: string; + perm: string[]; + ts: string; +} + +================ +File: src/types/response/spot.types.ts +================ +/** + * Reference Data + */ ⋮---- -/** Open order item from swap_openorders and swap_cross_openorders */ -export interface FuturesOpenOrder { - symbol: string; - contract_code: string; - volume: number; - price: number; - order_price_type: string; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - created_at: number; - trade_volume: number; - trade_turnover: number; - fee: number; - trade_avg_price: number | null; - margin_frozen: number; - margin_asset: string; - profit: number; - status: number; - order_source: string; - fee_asset: string; - liquidation_type: string | null; - canceled_at: number | null; - margin_mode: string; - margin_account: string; - is_tpsl: number; - real_profit: number; - update_time: number; - reduce_only: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; +/** Status page response from status.huobigroup.com */ +export interface SpotSystemStatusPage { + page: { + id: string; + name: string; + url: string; + time_zone: string; + updated_at: string; + }; + components: { + id: string; + name: string; + status: string; + created_at: string; + updated_at: string; + [key: string]: unknown; + }[]; + incidents: + | { + id: string; + name: string; + status: string; + created_at: string; + updated_at: string; + [key: string]: unknown; + }[] + | null; + scheduled_maintenances: + | { + id: string; + name: string; + status: string; + created_at: string; + updated_at: string; + scheduled_for: string; + scheduled_until: string; + [key: string]: unknown; + }[] + | null; + status: { + indicator: 'none' | 'minor' | 'major' | 'critical' | 'maintenance'; + description: string; + }; } ⋮---- -/** Cross margin only */ +/** Market status: 1=normal, 2=halted, 3=cancel-only */ +export type SpotMarketStatus = 1 | 2 | 3; ⋮---- -/** Open orders response from swap_openorders and swap_cross_openorders */ -export type FuturesOpenOrders = FuturesPaginatedOrders & { - self_match_prevent_new: string; - self_match_prevent?: number; - canceled_source?: string; -}; +/** Halt reason: 2=emergency-maintenance, 3=scheduled-maintenance */ +export type SpotHaltReason = 2 | 3; ⋮---- -/** History order from getHistoryOrders, getCoinMDeliveryHistoryOrders, getCoinMPerpHistoryOrders. Product-specific optional. */ -export interface FuturesHistoryOrder { - query_id: number; - order_id: number | string; - order_id_str: string; - symbol: string; - contract_code: string; - lever_rate: number; - direction: string; - offset: string; - volume: number; - price: number; - create_date: number; - update_time: number; - order_source: string; - order_price_type: string | number; - order_type: number; - margin_frozen: number; - profit: number; - trade_volume: number; - trade_turnover: number; - fee: number; - trade_avg_price: number; - status: number; - fee_asset: string; - liquidation_type: string; - is_tpsl: number; - real_profit: number; - /** USDM only */ - margin_mode?: string; - margin_account?: string; - margin_asset?: string; - reduce_only?: number; - self_match_prevent_new?: string; - /** CM Delivery: required; USDM/CM Perp: optional */ - contract_type?: string; - pair?: string; - business_type?: string; - canceled_source?: string; - self_match_prevent?: number; +export interface SpotMarketStatusData { + marketStatus: SpotMarketStatus; + haltStartTime?: number; + haltEndTime?: number; + haltReason?: SpotHaltReason; + affectedSymbols?: string; } ⋮---- -/** USDM only */ -⋮---- -/** CM Delivery: required; USDM/CM Perp: optional */ -⋮---- -/** Fill / match result from getFills, getCoinMDeliveryFills, getCoinMPerpFills. Product-specific optional. */ -export interface FuturesMatchResult { - id: string; - query_id: number; - match_id: number | string; - order_id: number | string; - order_id_str: string; - symbol: string; - contract_code: string; - direction: string; - offset: string; - trade_volume: number; - trade_price: number; - trade_turnover: number; - create_date: number; - offset_profitloss: number; - trade_fee: number; - role: string; - real_profit: number; - fee_asset: string; - order_source: string; - /** USDM only */ - margin_mode?: string; - margin_account?: string; - reduce_only?: number; - /** CM Delivery: required; USDM/CM Perp: optional */ - contract_type?: string; - pair?: string; - business_type?: string; - /** getFillsExact only */ - ht_price?: string; +export interface SpotMarketStatusResponse { + code: number; + message: string; + data: SpotMarketStatusData; } ⋮---- -/** USDM only */ -⋮---- -/** CM Delivery: required; USDM/CM Perp: optional */ +/** Trading symbol from /v2/settings/common/symbols */ +export interface SpotTradingSymbol { + sc: string; + si?: string; + scr?: string; + dn: string; + bc: string; + bcdn: string; + qc: string; + qcdn: string; + state: string; + whe?: boolean; + cd?: boolean; + te?: boolean; + toa?: number; + sp?: string; + w?: number; + ttp?: number; + tap?: number; + tpp?: number; + fp?: number; + suspend_desc?: string; + transfer_board_desc?: string; + tags?: string; + lr?: number | null; + smlr?: number | null; + flr?: string | null; + wr?: string | null; + d?: number | null; + elr?: string | null; + /** Whether the symbol supports RPI trading */ + enable_rpi?: boolean | number | string; + p?: { id?: number; name?: string; weight?: number }[]; +} ⋮---- -/** getFillsExact only */ +/** Whether the symbol supports RPI trading */ ⋮---- -/** Position mode item from swap_position_side and swap_cross_position_side */ -export interface FuturesPositionSideInfo { - margin_account: string; - position_mode: 'single_side' | 'dual_side'; +export interface SpotCurrency { + cc: string; + dn: string; + fn: string; + at?: number; + wp?: number; + ft?: string; + dma?: string; + wma?: string; + sp?: string; + w?: number; + qc?: boolean; + state?: string; + v?: boolean; + whe?: boolean; + cd?: boolean; + de?: boolean; + wed?: boolean; + cawt?: boolean; + fc?: number; + sc?: number; + swd?: string | null; + wd?: string | null; + sdd?: string | null; + dd?: string | null; + svd?: string | null; + tags?: string; } ⋮---- -/** Transfer state item from swap_cross_transfer_state */ -export interface FuturesCrossTransferState { - margin_mode: string; - margin_account: string; - /** 1: available, 0: unavailable */ - transfer_in: number; - /** 1: available, 0: unavailable */ - transfer_out: number; - /** 1: available, 0: unavailable */ - master_transfer_sub: number; - /** 1: available, 0: unavailable */ - sub_transfer_master: number; - master_transfer_sub_inner_in: number; - master_transfer_sub_inner_out: number; - sub_transfer_master_inner_in: number; - sub_transfer_master_inner_out: number; - transfer_inner_in: number; - transfer_inner_out: number; +/** Currency settings item from /v1/settings/common/currencys */ +export interface SpotV1CurrencySettings { + name: string; + dn?: string; + vat?: number; + det?: number; + wet?: number; + wp?: number; + ct?: string; + cp?: string; + ss?: string[]; + oe?: number; + dma?: string; + wma?: string; + sp?: string; + w?: number | string; + qc?: boolean; + state?: string; + v?: boolean; + whe?: boolean; + cd?: boolean; + de?: boolean; + we?: boolean; + cawt?: boolean; + cao?: boolean; + fc?: number; + sc?: number; + swd?: string | null; + wd?: string | null; + sdd?: string | null; + dd?: string | null; + svd?: string | null; + tags?: string; + fn?: string; + bc?: string; + iqc?: boolean; } ⋮---- -/** 1: available, 0: unavailable */ -⋮---- -/** 1: available, 0: unavailable */ -⋮---- -/** 1: available, 0: unavailable */ -⋮---- -/** 1: available, 0: unavailable */ -⋮---- -/** Trade state item from swap_cross_trade_state */ -export interface FuturesCrossTradeState { +/** Symbol settings item from /v1/settings/common/symbols */ +export interface SpotV1SymbolSettings { symbol: string; - contract_code: string; - margin_mode: string; - margin_account: string; - contract_type: string; - pair: string; - business_type: string; - /** 1=available, 0=unavailable */ - open: number; - /** 1=available, 0=unavailable */ - close: number; - /** 1=available, 0=unavailable */ - cancel: number; + sn?: string; + bc?: string; + qc?: string; + state?: string; + ve?: boolean; + we?: boolean; + dl?: boolean; + cd?: boolean; + te?: boolean; + ce?: boolean; + tet?: number; + toa?: number; + tca?: number; + voa?: number; + vca?: number; + sp?: string; + tm?: string; + w?: number | string; + ttp?: number; + tap?: number; + tpp?: number; + fp?: number; + tags?: string; + d?: unknown; + bcdn?: string; + qcdn?: string; + elr?: string | null; + castate?: string; + ca1oa?: number; + ca1ca?: number; + ca2oa?: number; + ca2ca?: number; } ⋮---- -/** 1=available, 0=unavailable */ -⋮---- -/** 1=available, 0=unavailable */ -⋮---- -/** 1=available, 0=unavailable */ -⋮---- -/** Trigger order open order item from swap_trigger_openorders and swap_cross_trigger_openorders */ -export interface FuturesTriggerOrderOpenOrder { +/** Market symbol settings item from /v1/settings/common/market-symbols */ +export interface SpotV1MarketSymbolSettings { symbol: string; - contract_code: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_price: number | string; - order_price: number | string; - created_at: number; - order_price_type: string; - status: number; - margin_mode: string; - margin_account: string; - reduce_only: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; + bc?: string; + qc?: string; + state?: string; + sp?: string; + tags?: string; + lr?: number; + smlr?: number; + pp?: number; + ap?: number; + vp?: number; + /** @deprecated No longer valid. */ + minoa?: number | string; + maxoa?: number | string; + minov?: number | string; + /** @deprecated No longer valid. */ + lominoa?: number | string; + lomaxoa?: number | string; + lomaxba?: number | string; + lomaxsa?: number | string; + /** @deprecated No longer valid. */ + smminoa?: number | string; + smmaxoa?: number | string; + bmmaxov?: number | string; + blmlt?: number | string; + slmgt?: number | string; + msormlt?: number | string; + mbormlt?: number | string; + at?: string; + u?: string; + mfr?: number | string; + ct?: string; + rt?: string; + rthr?: number | string; + in?: number | string; + maxov?: number | string; + flr?: number | string; + castate?: string; } ⋮---- -/** Cross margin only */ -⋮---- -/** Trigger open orders response from swap_trigger_openorders and swap_cross_trigger_openorders */ -export type FuturesTriggerOpenOrders = - FuturesPaginatedOrders; -⋮---- -/** Trigger order history item from swap_trigger_hisorders and swap_cross_trigger_hisorders */ -export interface FuturesTriggerOrderHisOrder { - symbol: string; - contract_code: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - relation_order_id: string; - order_price_type: string; - status: number; - order_source: string; - trigger_price: number | string; - triggered_price: number | string | null; - order_price: number | string; - created_at: number; - triggered_at: number | null; - order_insert_at: number; - canceled_at: number | null; - update_time: number; - fail_code: number | null; - fail_reason: string | null; - margin_mode: string; - margin_account: string; - reduce_only?: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; -} +/** @deprecated No longer valid. */ ⋮---- -/** Cross margin only */ +/** @deprecated No longer valid. */ ⋮---- -/** Trigger history orders response from getTriggerHistoryOrders, getCrossTriggerHistoryOrders */ -export type FuturesTriggerHistoryOrders = - FuturesPaginatedOrders; +/** @deprecated No longer valid. */ ⋮---- -/** TP/SL order result; when only TP or only SL is set, the other is empty */ -export interface FuturesTpslOrderResult { - order_id: number | string; - order_id_str: string; +/** Chain info item from /v1/settings/common/chains */ +export interface SpotV1ChainInfo { + chain?: string; + currency?: string; + code?: string; + ct?: string; + ac?: string; + default?: number; + dma?: string; + wma?: string; + de?: boolean; + we?: boolean; + wp?: number; + ft?: string; + dn?: string; + fn?: string; + awt?: boolean; + adt?: boolean; + ao?: boolean; + fc?: number; + sc?: number; + v?: boolean; + sda?: string | null; + swa?: string | null; + 'deposit-desc'?: string; + 'deposit-tips-desc'?: string; + 'withdraw-desc'?: string; + 'suspend-deposit-desc'?: string; + 'suspend-withdraw-desc'?: string; + 'replace-chain-info-desc'?: string; + 'replace-chain-notification-desc'?: string; + 'replace-chain-popup-desc'?: string; + ca?: string; + cct?: number; + 'withdraw-tips-desc'?: string; + 'suspend-visible-desc'?: string; } ⋮---- -/** TPSL order response data from swap_tpsl_order and swap_cross_tpsl_order. tp_order or sl_order empty when only the other is set */ -export interface FuturesTpslOrder { - tp_order?: FuturesTpslOrderResult; - sl_order?: FuturesTpslOrderResult; +/** Chain reference from /v2/reference/currencies */ +export interface SpotV2ChainReference { + chain?: string; + displayName?: string; + baseChain?: string; + baseChainProtocol?: string; + isDynamic?: boolean; + numOfConfirmations?: number; + numOfFastConfirmations?: number; + minDepositAmt?: string; + depositStatus?: string; + minWithdrawAmt?: string; + maxWithdrawAmt?: string; + withdrawQuotaPerDay?: string; + withdrawQuotaPerYear?: string; + withdrawQuotaTotal?: string; + withdrawPrecision?: number; + withdrawFeeType?: string; + transactFeeWithdraw?: string; + minTransactFeeWithdraw?: string; + maxTransactFeeWithdraw?: string; + transactFeeRateWithdraw?: string; + withdrawStatus?: string; } ⋮---- -/** TPSL open order item from swap_tpsl_openorders and swap_cross_tpsl_openorders */ -export interface FuturesTpslOpenOrder { +/** Fee rate from GET /v2/reference/transact-fee-rate */ +export interface SpotV2TransactFeeRate { symbol: string; - contract_code: string; - margin_mode: string; - margin_account: string; - volume: number; - order_type: number; - tpsl_order_type: string; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number | string; - price_protect?: boolean; - created_at: number; - order_price_type: string; - order_price: number | string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; + makerFeeRate: string; + takerFeeRate: string; + actualMakerRate: string; + actualTakerRate: string; + /** RPI order fee rate */ + rpiFeeRate?: string; } ⋮---- -/** Cross margin only */ -⋮---- -/** TPSL open orders response from swap_tpsl_openorders and swap_cross_tpsl_openorders */ -export type FuturesTpslOpenOrders = - FuturesPaginatedOrders; +/** RPI order fee rate */ ⋮---- -/** TPSL history order item from swap_tpsl_hisorders and swap_cross_tpsl_hisorders */ -export interface FuturesTpslHisOrder { - symbol: string; - contract_code: string; - margin_mode: string; - margin_account: string; - volume: number; - order_type: number; - tpsl_order_type: string; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number | string; - price_protect?: boolean; - created_at: number; - order_price_type: string; - order_price: number | string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; - canceled_at: number | null; - fail_code: number | null; - fail_reason: string | null; - triggered_price: number | string | null; - relation_order_id: string; - update_time: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; +/** Currency reference item from /v2/reference/currencies */ +export interface SpotV2CurrencyReference { + currency?: string; + instStatus?: string; + chains?: SpotV2ChainReference[]; + /** Whether the currency supports direct transfers to Poloniex */ + externalTransferEnabled?: boolean | string | number; } ⋮---- -/** Cross margin only */ +/** Whether the currency supports direct transfers to Poloniex */ ⋮---- -/** TPSL history orders response from swap_tpsl_hisorders and swap_cross_tpsl_hisorders */ -export type FuturesTpslHisOrders = FuturesPaginatedOrders; +/** + * Market Data + */ ⋮---- -/** TPSL order info item within relation_tpsl_order response. getRelationTpslOrder, getCoinMDeliveryRelationTpslOrder, getCoinMPerpRelationTpslOrder. */ -export interface FuturesRelationTpslOrderTpslInfo { - volume: number; - tpsl_order_type: string; - direction: string; - order_id: number | string; - order_id_str: string; - trigger_type: string; - trigger_price: number | string; - created_at: number; - order_price: number | string; - status: number; - relation_tpsl_order_id: string; - relation_order_id: string; - order_price_type?: string; - price_protect?: boolean; - canceled_at: number | null; - fail_code: number | null; - fail_reason: string | null; - triggered_price: number | string | null; +/** Kline/candlestick item from /market/history/kline */ +export interface SpotKline { + id: number; + open: number; + close: number; + low: number; + high: number; + amount: number; + vol: number; + count: number; } ⋮---- -/** Relation TPSL order from getRelationTpslOrder, getCoinMDeliveryRelationTpslOrder, getCoinMPerpRelationTpslOrder. Product-specific optional. */ -export interface FuturesRelationTpslOrder { - symbol: string; - contract_code: string; - volume: number; - price: number | string; - order_price_type: string; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - created_at: number; - trade_volume: number; - trade_turnover: number | string; - fee: number | string; - trade_avg_price: number | string; - margin_frozen: number | string; - profit: number | string; - status: number; - order_type: number | null; - order_source: string; - fee_asset: string; - canceled_at: number; - tpsl_order_info: FuturesRelationTpslOrderTpslInfo[]; - /** USDM only */ - margin_mode?: string; - margin_account?: string; - /** CM Delivery: required; USDM/CM Perp: optional */ - contract_type?: string; - pair?: string; - business_type?: string; +/** Merged ticker from /market/detail/merged (payload is in "tick" not "data"). */ +export interface SpotMergedTicker { + id: number; + version?: number; + open: number; + close: number; + low: number; + high: number; + amount: number; + vol: number; + count: number; + /** [price, size] */ + bid: [number, number]; + /** [price, size] */ + ask: [number, number]; } ⋮---- -/** USDM only */ +/** [price, size] */ ⋮---- -/** CM Delivery: required; USDM/CM Perp: optional */ +/** [price, size] */ ⋮---- -/** Trailing order open order item from swap_track_openorders and swap_cross_track_openorders */ -export interface FuturesTrackOpenOrder { +/** Ticker from /market/tickers */ +export interface SpotTicker { symbol: string; - contract_code: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - order_price_type: string; - status: number; - callback_rate: number | string; - active_price: number | string; - is_active: number; - margin_mode: string; - margin_account: string; - reduce_only: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; + open: number; + high: number; + low: number; + close: number; + amount: number; + vol: number; + count: number; + bid: number; + bidSize: number; + ask: number; + askSize: number; } ⋮---- -/** Cross margin only */ +/** Depth tick from /market/depth and /market/fullMbp (payload is in "tick" not "data"). */ +export interface SpotDepth { + ts: number; + version: number; + bids: [number, number][]; + asks: [number, number][]; +} ⋮---- -/** Trailing open orders response data from swap_track_openorders and swap_cross_track_openorders */ -export type FuturesTrackOpenOrders = - FuturesPaginatedOrders; +/** 24h market summary tick from /market/detail (payload is in "tick" not "data"). */ +export interface SpotDetailTick { + id: number; + low: number; + high: number; + open: number; + close: number; + vol: number; + amount: number; + version: number; + count: number; +} ⋮---- -/** Trailing order history item from swap_track_hisorders and swap_cross_track_hisorders */ -export interface FuturesTrackHisOrder { - symbol: string; - contract_code: string; - volume: number; - order_type: number; +/** Trade (shared by /market/trade and /market/history/trade) */ +export interface SpotTrade { + id: number; + ts: number; + 'trade-id': number; + amount: number; + price: number; direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - update_time: number; - order_price_type: string; - status: number; - canceled_at: number | null; - fail_code: number | null; - fail_reason: string | null; - callback_rate: number | string; - active_price: number | string; - is_active: number; - market_limit_price: number | string | null; - formula_price: number | string | null; - real_volume: number | string; - triggered_price: number | string | null; - relation_order_id: string; - margin_mode: string; - margin_account: string; - reduce_only: number; - /** Cross margin only */ - contract_type?: string; - pair?: string; - business_type?: string; } ⋮---- -/** Cross margin only */ -⋮---- -/** Trailing history orders response from swap_track_hisorders and swap_cross_track_hisorders */ -export type FuturesTrackHisOrders = - FuturesPaginatedOrders; -⋮---- -/** Cross swap item within unified_account_info */ -export interface FuturesUnifiedAccountCrossSwap { - symbol: string; - contract_code: string; - margin_mode: string; - margin_available: number | string; - cross_max_available?: number | string; - lever_rate: number | string; - contract_type: string; - business_type: string; +/** Trade tick from /market/trade (payload is in "tick" not "data"). */ +export interface SpotLastTrade { + id: number; + ts: number; + data: SpotTrade[]; } ⋮---- -/** Cross futures item within unified_account_info */ -export interface FuturesUnifiedAccountCrossFuture { - symbol: string; - contract_code: string; - margin_mode: string; - margin_available: number | string; - cross_max_available?: number | string; - lever_rate: number | string; - contract_type: string; - business_type: string; +/** Timestamp group from /market/history/trade. Each element in data array. */ +export interface SpotTradeTimestampGroup { + id: number; + ts: number; + data: SpotTrade[]; } ⋮---- -/** Isolated swap item within unified_account_info */ -export interface FuturesUnifiedAccountIsolatedSwap { - symbol: string; - contract_code: string; - margin_mode: string; - margin_available: number | string; - withdraw_available?: number | string; - lever_rate: number | string; - position_mode?: string; -} +/** + * Account + */ ⋮---- -/** Unified account info item from unified_account_info */ -export interface FuturesUnifiedAccountInfo { - margin_balance: number | string; - margin_static: number | string; - cross_profit_unreal: number | string; - cross_margin_static: number | string; - margin_asset: string; - margin_frozen: number | string; - withdraw_available: number | string; - cross_risk_rate: number | string | null; - cross_swap: FuturesUnifiedAccountCrossSwap[]; - cross_future: FuturesUnifiedAccountCrossFuture[]; - isolated_swap: FuturesUnifiedAccountIsolatedSwap[]; - userId?: string | null; +/** Account from /v1/account/accounts */ +export interface SpotAccount { + id: number; + type: string; + subtype?: string; + state: string; } ⋮---- -/** Linear swap overview account info item from linear_swap_overview_account_info */ -export interface FuturesLinearSwapOverviewAccountInfo { - margin_asset: string; - margin_balance: number | string; - margin_available: number | string; +/** Balance row from /v1/account/accounts/{account-id}/balance list */ +export interface SpotBalance { + currency: string; + type: string; + balance: string; + debt?: string; + available?: string; + 'seq-num'?: string; } ⋮---- -/** Fix position margin change record item from fix_position_margin_change_record */ -export interface FuturesFixPositionMarginChangeRecord { - query_id: number; - order_id: string; - amount: number | string; - asset: string; - symbol: string; - type: number; - direction: number; +/** Account balance from /v1/account/accounts/{account-id}/balance */ +export interface SpotAccountBalance { + id: number; + type: string; + state: string; + list: SpotBalance[]; } ⋮---- -/** Fix position margin change response data from fix_position_margin_change */ -export interface FuturesFixPositionMarginChange { - amount: number | string; - asset: string; - contract_code: string; - type: number; - direction: number; - order_id: string; - client_order_id: number | string | null; +/** Profit account balance item from /v2/account/valuation */ +export interface SpotV2ProfitAccountBalance { + distributionType: string; + balance: number; + success: boolean; + accountBalance: string; } ⋮---- -/** - * USDT Margined Futures Multi Asset - Account (v5 API) - */ -⋮---- -/** Currency detail from /v5/account/balance */ -export interface FuturesV5AccountBalanceDetail { - currency: string; - equity: string; - isolated_equity: string; - available: string; - isolated_available?: string; - withdraw_available: string; - profit_unreal: string; - isolated_profit_unreal: string; - initial_margin: string; - maintenance_margin: string; - maintenance_margin_rate: string; - initial_margin_rate: string; - voucher: string; - voucher_value: string; - created_time: number; - updated_time: number; +/** Updated info from /v2/account/valuation */ +export interface SpotV2ValuationUpdated { + success: boolean; + time: number; } ⋮---- -/** Account balance data from /v5/account/balance */ -export interface FuturesV5AccountBalance { - /** "normal" | "liquidating" | "adl" | "open_limit" */ - state: string; - equity: string; - initial_margin: string; - maintenance_margin: string; - maintenance_margin_rate: string; - profit_unreal: string; - available_margin: string; - voucher_value: string; - created_time: number; - updated_time: number; - details: FuturesV5AccountBalanceDetail[]; +/** Response from /v2/account/valuation */ +export interface SpotV2AccountValuation { + totalBalance?: string; + todayProfit?: string; + todayProfitRate?: string; + profitAccountBalanceList?: SpotV2ProfitAccountBalance[]; + updated?: SpotV2ValuationUpdated; } ⋮---- -/** "normal" | "liquidating" | "adl" | "open_limit" */ +/** Response from /v2/account/asset-valuation */ +export interface SpotV2AssetValuation { + balance: string; + timestamp: number; +} ⋮---- -/** Set asset mode response data from POST /v5/account/asset_mode */ -export interface FuturesV5AssetMode { - /** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ - assets_mode: 0 | 1 | 2; +/** Transfer result from POST /v1/account/transfer */ +export interface SpotAccountTransferResult { + 'transact-id': number; + 'transact-time': number; } ⋮---- -/** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ +export interface SpotV2PointAccountGroupId { + groupId: number; + expiryDate: number | null; + remainAmt: string; +} ⋮---- -/** Get asset mode response data from GET /v5/account/asset_mode */ -export interface FuturesV5AssetModeGet { - /** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ - asset_mode: 0 | 1 | 2; +/** Point balance from GET /v2/point/account */ +export interface SpotV2PointAccount { + accountId: string; + accountStatus: string; + acctBalance: string; + groupIds: SpotV2PointAccountGroupId[]; } ⋮---- -/** 0: Single-asset collateral (old); 1: Multi-assets collateral; 2: Single-asset collateral (new) */ +/** Point transfer result from POST /v2/point/transfer */ +export interface SpotV2PointTransfer { + transactId: string; + transactTime: number; +} ⋮---- -/** Fee deduction crypto from /v5/account/fee_deduction_currency */ -export interface FuturesV5FeeDeductionCurrency { - /** 1: Yes; 0: No */ - fee_option: 0 | 1; - /** Deduction currency (e.g. htx, trx). Not returned when fee_option = 0 */ - deduction_currency?: string; +/** Deduction info from GET /v1/account/switch/user/info */ +export interface SpotV1AccountSwitchUserInfo { + /** 1=point card deduction, 0=no */ + pointSwitch: number; + /** 1=HTX deduction, 0=no. Choose one of point card and HTX deduction. */ + currencySwitch: number; + deductionCurrency: string; + /** 1: limited, 0: unlimited */ + deductionType: number; + /** Total deductible (USDT). Only when deductionType=1 */ + totalDeductionLimit?: string; + /** Remaining deductible (USDT). Only when deductionType=1 */ + remainingDeductionLimit?: string; } ⋮---- -/** 1: Yes; 0: No */ +/** 1=point card deduction, 0=no */ ⋮---- -/** Deduction currency (e.g. htx, trx). Not returned when fee_option = 0 */ +/** 1=HTX deduction, 0=no. Choose one of point card and HTX deduction. */ ⋮---- -/** Financial record item from /v5/account/bills */ -export interface FuturesV5Bill { - id: string; - contract_code: string; - margin_mode: string; - type: string; +/** 1: limited, 0: unlimited */ +⋮---- +/** Total deductible (USDT). Only when deductionType=1 */ +⋮---- +/** Remaining deductible (USDT). Only when deductionType=1 */ +⋮---- +/** Deductible currency info from GET /v1/account/overview/info */ +export interface SpotV1AccountOverviewInfo { currency: string; - amount: string; - created_time: string; } ⋮---- -/** - * USDT Margined Futures Multi Asset - Orders (v5 API) - */ +/** Account history row from GET /v1/account/history */ +export interface SpotAccountHistory { + 'account-id': number; + currency: string; + 'record-id': number; + 'transact-amt': string; + /** Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ + 'transact-type': string; + 'avail-balance': string; + 'acct-balance': string; + 'transact-time': number; +} ⋮---- -/** Place order response from POST /v5/trade/order */ -export interface FuturesV5PlaceOrderResp { - order_id: string; - client_order_id?: string; +/** Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ +⋮---- +/** Ledger row from GET /v2/account/ledger */ +export interface SpotV2AccountLedger { + accountId: number; + currency: string; + transactAmt: number; + transactType: string; + transferType?: string; + transactId: number; + transactTime: number; + transferer: number; + transferee: number; } ⋮---- -/** Batch place order item from POST /v5/trade/batch_orders */ -export interface FuturesV5PlaceBatchOrderRespItem { - order_id: string; - client_order_id?: string; - code: number; - message: string; +/** Batch order placement result. Success: order-id, client-order-id. Error: err-code, err-msg. */ +export interface SpotV1OrderBatchPlaceResult { + 'order-id'?: number; + 'client-order-id'?: string; + 'err-code'?: string; + 'err-msg'?: string; } ⋮---- -/** Close position response from POST /v5/trade/position */ -export interface FuturesV5ClosePositionResp { - order_id: string | number; - client_order_id?: string; +/** Margin order result from POST /v1/order/auto/place */ +export interface SpotV1OrderAutoPlaceResult { + 'order-id': number; } ⋮---- -/** Open order / order info / order history item from v5 trade endpoints */ -export interface FuturesV5Order { - id: string; - contract_code: string; - contract_type?: string; - side: string; - position_side: string; - type: string; - price_match?: string | null; - order_id: string; - client_order_id: string; - margin_mode: string; - price?: string; - volume: string; - lever_rate?: number; - state: string | number; - order_source: string; - reduce_only?: boolean | string; - time_in_force: string; - tp_trigger_price?: string; - tp_order_price?: string; - tp_type?: string | null; - tp_trigger_price_type?: string | null; - sl_trigger_price?: string; - sl_order_price?: string; - sl_type?: string | null; - sl_trigger_price_type?: string | null; - trade_avg_price?: string; - trade_volume?: string; - trade_turnover?: string; - fee_currency?: string; - fee?: string; - profit?: string | null; - price_protect?: boolean | string; - cancel_reason?: string | null; - created_time?: string; - updated_time?: string; - self_match_prevent?: string; - cancel_volume?: string; +/** Canceled order id from POST /v1/order/orders/{order-id}/submitcancel */ +export type SpotV1OrderCancelResult = string; +⋮---- +/** Order status from POST /v1/order/orders/submitCancelClientOrder. 1:ready, 2:created, 3:submitted, 4:partial-filled, 5:partial-canceled, 6:filled, 7:canceled, 10:canceling */ +export type SpotV1OrderCancelByClientOrderIdResult = number; +⋮---- +/** Result from POST /v1/order/orders/batchCancelOpenOrders */ +export interface SpotV1OrderBatchCancelOpenOrdersResult { + 'success-count': number; + 'failed-count': number; + /** Next order id to cancel, -1 = none */ + 'next-id': number; } ⋮---- -/** Execution/trade detail from GET /v5/trade/order/details */ -export interface FuturesV5OrderExecutionDetail { - id?: string; - contract_code?: string; - order_id?: string; - trade_id?: string; - side?: string; - position_side?: string; - order_type?: string; - margin_mode?: string; - type?: string; - client_order_id?: string; - role?: string; - trade_price?: string; - trade_volume?: string; - trade_turnover?: string; - created_time?: string; - updated_time?: string; - order_source?: string; - fee_currency?: string; - trade_fee?: string; - deduction_price?: string; - profit?: string; - contract_type?: string; -} -⋮---- -/** Cancel-after response from POST /v5/trade/cancel-after */ -export interface FuturesV5CancelAfterResp { - current_time: string; - trigger_time?: string; -} -⋮---- -/** Place algo order item from POST /v5/algo/order */ -export interface FuturesV5PlaceAlgoOrderResp { - algo_id: string; - algo_client_order_id?: string; -} +/** Next order id to cancel, -1 = none */ ⋮---- -/** Cancel algo order item from POST /v5/algo/cancel_orders */ -export interface FuturesV5CancelAlgoOrderResp { - algo_id: string; - algo_client_order_id?: string; - code?: number; - message?: string; +/** Failed cancel from POST /v1/order/orders/batchcancel */ +export interface SpotV1OrderBatchCancelFailed { + 'order-id'?: string; + 'client-order-id'?: string; + 'err-code'?: string; + 'err-msg'?: string; + 'order-state'?: string; } ⋮---- -/** Algo order from GET /v5/algo/order, /opens, /history */ -export interface FuturesV5AlgoOrder { - id?: string | number; - algo_id: string; - algo_client_order_id?: string; - contract_code: string; - volume?: string; - type: string; - state: string; - position_side: string; - margin_mode: string; - side: string; - tp_trigger_price?: string; - tp_order_price?: string; - tp_type?: string; - tp_trigger_price_type?: string; - sl_trigger_price?: string; - sl_order_price?: string; - sl_type?: string; - sl_trigger_price_type?: string; - price?: string; - price_match?: string; - trigger_price?: string; - trigger_price_type?: string; - active_price?: string; - order_price_type?: string; - callback_rate?: string; - reduce_only?: boolean | string; - actual_volume?: string; - actual_price?: string; - actual_time?: string; - relation_order_id?: string; - created_time?: string; - updated_time?: string; - order_source?: string; +/** Result from POST /v2/algo-orders/cancel-all-after (Dead man's switch) */ +export interface SpotV2AlgoOrdersCancelAllAfterResult { + currentTime: number; + triggerTime: number; } ⋮---- /** - * USDT Margined Futures Multi Asset - Positions (v5 API) + * Conditional Order */ ⋮---- -/** Position from GET /v5/trade/position/opens */ -export interface FuturesV5Position { - contract_code: string; - position_side: string; - direction: string; - margin_mode: string; - open_avg_price: string; - volume: string; - available: string; - lever_rate: string | number; - adl_risk_percent?: number | null; - liquidation_price: string; - initial_margin: string; - maintenance_margin: string; - profit_unreal: string; - profit_rate: string; - margin_rate: string; - margin_currency: string; - last_price?: string; - mark_price?: string; - contract_type: string; - created_time: string; - updated_time: string; +/** Result from POST /v2/algo-orders (Place a conditional order) */ +export interface SpotV2AlgoOrdersPlaceResult { + clientOrderId: string; } ⋮---- -/** Leverage list entry from GET /v5/position/lever */ -export interface FuturesV5LeverListEntry { - contract_code: string; - contract_type: string; - margin_mode: string; - position_side: string; - lever_rate: number; - available_lever: string | string[]; +/** Result from POST /v2/algo-orders/cancellation (Cancel conditional orders before triggering) */ +export interface SpotV2AlgoOrdersCancellationResult { + accepted: string[]; + rejected: string[]; } ⋮---- -/** Set leverage response from POST /v5/position/lever */ -export interface FuturesV5SetLeverageResp { - contract_code: string; - margin_mode: string; - position_side?: string; - lever_rate: number; +/** Conditional order item from GET /v2/algo-orders/opening (orderStatus=created) and /history and /specific */ +export interface SpotV2AlgoOrder { + accountId: number; + source: string; + clientOrderId: string; + symbol?: string; + orderPrice?: string; + orderSize?: string; + orderValue?: string; + orderSide: string; + orderType: string; + timeInForce?: string; + stopPrice?: string; + trailingRate?: string; + orderOrigTime: number; + lastActTime: number; + orderStatus: string; + /** Only for orderStatus=triggered */ + orderId?: string; + /** Order trigger time. Only for orderStatus=triggered */ + orderCreateTime?: number; + /** Only for orderStatus=rejected */ + errCode?: number; + /** Only for orderStatus=rejected */ + errMessage?: string; } ⋮---- -/** Position mode from GET/POST /v5/position/mode */ -export interface FuturesV5PositionModeResp { - position_mode: 'single_side' | 'dual_side'; -} +/** Only for orderStatus=triggered */ ⋮---- -/** Risk limit entry from GET /v5/position/risk/limit */ -export interface FuturesV5RiskLimitEntry { - contract_code: string; - contract_type?: string; - margin_mode: string; - position_side: string; - max_lever: string; - maintenance_margin_rate: string; - max_volume: string; - min_volume: string; - volume_unit: string; -} +/** Order trigger time. Only for orderStatus=triggered */ ⋮---- -/** Risk limit tier entry from GET /v5/position/risk/limit_tier */ -export interface FuturesV5RiskLimitTierEntry { - contract_code: string; - margin_mode: string; - tier: number; - max_lever: string; - maintenance_margin_rate: string; - max_volume: string; - min_volume: string; - volume_unit: string; -} +/** Only for orderStatus=rejected */ +⋮---- +/** Only for orderStatus=rejected */ ⋮---- /** - * USDT Margined Futures Multi Asset - Basic Information (v5 API) + * Margin Loan (Cross/Isolated) */ ⋮---- -/** Risk limit entry from GET /v5/market/risk/limit */ -export interface FuturesV5MarketRiskLimitEntry { - contract_code: string; - margin_mode: string; - tier: number; - max_lever: string; - maintenance_margin_rate: string; - max_volume: string; - min_volume: string; - volume_unit?: string; +/** Repayment result from POST /v2/account/repayment. Check transaction record to confirm status. */ +export interface SpotMarginRepaymentResult { + repayId: string | number; + repayTime: number; } ⋮---- -/** Assets deduction currency from GET /v5/market/assets_deduction_currency */ -export interface FuturesV5AssetsDeductionCurrencyResp { - currency: string[]; +/** Transact ID detail from GET /v2/account/repayment (Repayment Record Reference) */ +export interface SpotRepaymentRecordTransactId { + transactId: number; + repaidPrincipal?: string; + repaidInterest?: string; + paidHt?: string; + paidPoint?: string; } ⋮---- -/** Multi-assets margin from GET /v5/market/multi_assets_margin */ -export interface FuturesV5MultiAssetsMarginResp { - multi_assets: string[]; +/** Repayment record from GET /v2/account/repayment (Repayment Record Reference) */ +export interface SpotRepaymentRecord { + repayId: string | number; + repayTime: number; + accountId: string; + currency: string; + repaidAmount: string; + transactIds?: SpotRepaymentRecordTransactId | SpotRepaymentRecordTransactId[]; } ⋮---- -/** - * Coin-M Delivery - Reference Data (FuturesCmDelivery) - */ -⋮---- -/** Ladder item from contract_adjustfactor */ -export interface FuturesCmDeliveryAdjustFactorLadder { - ladder: number; - min_size: number; - max_size: number | null; - adjust_factor: number; +/** Currency from GET /v1/margin/loan-info */ +export interface SpotMarginLoanInfoCurrency { + currency: string; + 'interest-rate': string; + 'min-loan-amt': string; + 'max-loan-amt': string; + 'loanable-amt': string; + 'actual-rate': string; } ⋮---- -/** Lever item in adjust factor list */ -export interface FuturesCmDeliveryAdjustFactorLeverItem { - lever_rate: number; - ladders: FuturesCmDeliveryAdjustFactorLadder[]; +/** Symbol from GET /v1/margin/loan-info */ +export interface SpotMarginLoanInfo { + symbol: string; + currencies: SpotMarginLoanInfoCurrency[]; } ⋮---- -/** GET /api/v1/contract_adjustfactor */ -export interface FuturesCmDeliveryAdjustFactor { +/** Loan order item from GET /v1/margin/loan-orders */ +export interface SpotMarginLoanOrder { + id: number; + 'account-id': number; + 'user-id': number; symbol: string; - list: FuturesCmDeliveryAdjustFactorLeverItem[]; + currency: string; + 'created-at': string; + 'accrued-at'?: string; + 'loan-amount': string; + 'loan-balance': string; + 'interest-rate': string; + 'interest-amount'?: string; + 'interest-balance'?: string; + state: string; + 'paid-point'?: string; + 'paid-coin'?: string; + 'deduct-rate'?: string; + 'deduct-currency'?: string; + 'deduct-amount'?: string; + 'updated-at'?: number; + 'hour-interest-rate'?: string; + 'day-interest-rate'?: string; } ⋮---- -/** Tick from contract_his_open_interest */ -export interface FuturesCmDeliveryOpenInterestTick { - volume: string; - amount_type: number; - ts: number; +/** Balance row from GET /v1/margin/accounts/balance */ +export interface SpotMarginBalance { + currency: string; + type: string; + balance: string; } ⋮---- -/** GET /api/v1/contract_his_open_interest */ -export interface FuturesCmDeliveryOpenInterest { +/** Account item from GET /v1/margin/accounts/balance */ +export interface SpotMarginAccountBalance { + id: number; + type: string; symbol: string; - contract_type: string; - tick: FuturesCmDeliveryOpenInterestTick[]; + state: string; + 'risk-rate'?: string; + 'fl-type'?: string; + 'fl-price'?: string; + list: SpotMarginBalance[]; } ⋮---- -/** Ladder item from contract_ladder_margin */ -export interface FuturesCmDeliveryLadderMarginLadder { - min_margin_balance: number; - max_margin_balance: number | null; - min_margin_available: number; - max_margin_available: number | null; +/** Account balance from GET /v1/cross-margin/accounts/balance. Single object (unlike isolated which returns array). */ +export interface SpotCrossMarginAccountBalance { + id: number; + type: string; + state: string; + 'risk-rate'?: string; + 'acct-balance-sum'?: string; + 'debt-balance-sum'?: string; + list: SpotMarginBalance[]; } ⋮---- -/** Lever item in ladder margin list */ -export interface FuturesCmDeliveryLadderMarginLeverItem { - lever_rate: number; - ladders: FuturesCmDeliveryLadderMarginLadder[]; +/** Loan order item from GET /v1/cross-margin/loan-orders */ +export interface SpotCrossMarginLoanOrder { + id: number; + 'account-id': number; + 'user-id': number; + currency: string; + 'filled-points'?: string; + 'filled-ht'?: string; + 'created-at': string | number; + 'accrued-at'?: string | number; + 'loan-amount': string; + 'loan-balance': string; + 'interest-amount'?: string; + 'interest-balance'?: string; + state: string; } ⋮---- -/** GET /api/v1/contract_ladder_margin */ -export interface FuturesCmDeliveryLadderMargin { - symbol: string; - list: FuturesCmDeliveryLadderMarginLeverItem[]; +/** Position limit from GET /v2/margin/limit */ +export interface SpotMarginLimit { + currency: string; + 'max-holdings': string; } ⋮---- -/** Ladder from GET /swap-api/v1/swap_adjustfactor */ -export interface FuturesCmPerpAdjustFactorLadder { - ladder: number; - min_size: number; - max_size: number | null; - adjust_factor: number; +/** Result from POST /v1/order/orders/batchcancel */ +export interface SpotV1OrderBatchCancelResult { + /** Successfully canceled order ids or client-order-ids */ + success: string[]; + /** Failed cancel requests */ + failed: SpotV1OrderBatchCancelFailed[]; } ⋮---- -/** Lever item from swap_adjustfactor list */ -export interface FuturesCmPerpAdjustFactorLeverItem { - lever_rate: number; - ladders: FuturesCmPerpAdjustFactorLadder[]; -} +/** Successfully canceled order ids or client-order-ids */ ⋮---- -/** GET /swap-api/v1/swap_adjustfactor */ -export interface FuturesCmPerpAdjustFactor { - symbol: string; - contract_code: string; - list: FuturesCmPerpAdjustFactorLeverItem[]; -} +/** Failed cancel requests */ ⋮---- -/** Tick from GET /swap-api/v1/swap_his_open_interest */ -export interface FuturesCmPerpOpenInterestTick { - volume: number; - amount_type: number; - ts: number; +/** Match result item from GET /v1/order/orders/{order-id}/matchresults */ +export interface SpotV1OrderMatchResult { + id: number; + symbol: string; + 'order-id': number; + 'match-id': number; + 'trade-id': number; + price: string; + 'created-at': number; + type: string; + 'filled-amount': string; + 'filled-fees': string; + 'fee-currency'?: string; + source?: string; + role?: string; + 'filled-points'?: string; + 'fee-deduct-currency'?: string; + 'fee-deduct-state'?: string; } ⋮---- -/** GET /swap-api/v1/swap_his_open_interest */ -export interface FuturesCmPerpOpenInterest { +/** Historical order from GET /v1/order/orders (search past orders) */ +export interface SpotV1OrderHistory { + id: number; + 'client-order-id'?: string; + 'account-id'?: number; + amount?: string; symbol: string; - contract_code: string; - tick: FuturesCmPerpOpenInterestTick[]; + price?: string; + 'created-at': number; + 'canceled-at'?: number; + 'finished-at'?: number; + type?: string; + 'field-amount'?: string; + 'field-cash-amount'?: string; + 'field-fees'?: string; + source?: string; + state: string; + 'stop-price'?: string; + operator?: string; + role?: string; + 'canceled-source'?: number | string; + 'canceled-source-desc'?: string; + 'market-amount'?: string; + 'ice-amount'?: string; + 'is-ice'?: boolean; + 'updated-at'?: number; } ⋮---- -/** Ladder from GET /swap-api/v1/swap_ladder_margin */ -export interface FuturesCmPerpTieredMarginLadder { - min_margin_balance: number; - max_margin_balance: number | null; - min_margin_available: number; - max_margin_available: number | null; +/** Historical order from GET /v1/order/history (48h). Includes next-time when more results exist. */ +export interface SpotV1OrderHistory48h extends SpotV1OrderHistory { + /** Next start-time or end-time for pagination. Only when results exceed size. */ + 'next-time'?: number; } ⋮---- -/** Lever item from swap_ladder_margin list */ -export interface FuturesCmPerpTieredMarginLeverItem { - lever_rate: number; - ladders: FuturesCmPerpTieredMarginLadder[]; -} +/** Next start-time or end-time for pagination. Only when results exceed size. */ ⋮---- -/** GET /swap-api/v1/swap_ladder_margin */ -export interface FuturesCmPerpTieredMargin { +/** Order detail from GET /v1/order/orders/{order-id} and getClientOrder */ +export interface SpotV1OrderDetail { + id: number; + 'client-order-id': string; symbol: string; - contract_code: string; - list: FuturesCmPerpTieredMarginLeverItem[]; + 'account-id': number; + amount: string; + price: string; + 'created-at': number; + 'finished-at': number; + 'canceled-at': number; + type: string; + 'field-amount': string; + 'field-cash-amount': string; + 'field-fees': string; + source: string; + 'canceled-source'?: string; + state: string; + 'stop-price'?: string; + operator?: string; } ⋮---- -/** List item from GET /swap-api/v1/swap_elite_account_ratio */ -export interface FuturesCmPerpAccountRatioItem { - buy_ratio: number; - sell_ratio: number; - locked_ratio: number; - ts: number; +/** Deposit address item from GET /v2/account/deposit/address */ +export interface SpotDepositAddress { + userId: number; + currency: string; + address: string; + addressTag: string; + chain: string; } ⋮---- -/** GET /swap-api/v1/swap_elite_account_ratio */ -export interface FuturesCmPerpAccountRatio { - symbol: string; - contract_code: string; - list: FuturesCmPerpAccountRatioItem[]; +/** Withdraw quota chain from GET /v2/account/withdraw/quota */ +export interface SpotWithdrawQuotaChain { + chain: string; + maxWithdrawAmt: string; + withdrawQuotaPerDay: string; + remainWithdrawQuotaPerDay: string; + withdrawQuotaPerYear: string; + remainWithdrawQuotaPerYear: string; + withdrawQuotaTotal: string; + remainWithdrawQuotaTotal: string; } ⋮---- -/** List item from GET /swap-api/v1/swap_elite_position_ratio */ -export interface FuturesCmPerpPositionRatioItem { - buy_ratio: number; - sell_ratio: number; - ts: number; +/** Withdraw quota from GET /v2/account/withdraw/quota */ +export interface SpotWithdrawQuota { + currency: string; + chains: SpotWithdrawQuotaChain[]; } ⋮---- -/** GET /swap-api/v1/swap_elite_position_ratio */ -export interface FuturesCmPerpPositionRatio { - symbol: string; - contract_code: string; - list: FuturesCmPerpPositionRatioItem[]; +/** + * Withdraw address status from GET /v2/account/withdraw/address. + * `normal`: common address. + * `white`: whitelist in effect. + * `white-delaying`: whitelist waiting out its delay. + * `processing`: pending 2FA or risk-control checks. + */ +export type SpotWithdrawAddressStatus = + | 'normal' + | 'white' + | 'white-delaying' + | 'processing'; +⋮---- +/** Withdraw address item from GET /v2/account/withdraw/address */ +export interface SpotWithdrawAddress { + currency: string; + chain: string; + note: string; + addressTag?: string; + address: string; + /** See {@link SpotWithdrawAddressStatus}. */ + status: SpotWithdrawAddressStatus; } ⋮---- -/** Item from GET /swap-api/v1/swap_estimated_settlement_price data[] */ -export interface FuturesCmPerpEstimatedSettlementPrice { - contract_code: string; - estimated_settlement_price: number | null; - settlement_type: 'delivery' | 'settlement'; -} +/** See {@link SpotWithdrawAddressStatus}. */ ⋮---- -/** GET /swap-api/v1/swap_api_state */ -export interface FuturesCmPerpSystemStatus { - symbol: string; - contract_code: string; - open: number; - close: number; - cancel: number; - transfer_in: number; - transfer_out: number; - master_transfer_sub: number; - sub_transfer_master: number; +/** Deposit/withdraw record from GET /v1/query/deposit-withdraw or GET /v1/query/withdraw/client-order-id */ +export interface SpotDepositWithdrawRecord { + id: number; + type: string; + 'sub-type'?: string; + currency: string; + /** Chain name. Poloniex rapid transfer defaults to t397342. */ + chain: string; + 'tx-hash': string; + amount: number; + 'from-addr-tag'?: string; + /** On-chain address, or UID:XXXX for Poloniex→HTX rapid transfers. */ + address: string; + 'address-tag'?: string; + fee: number; + state: string; + 'created-at': number; + 'updated-at': number; + 'error-code'?: string; + 'error-msg'?: string; } ⋮---- -/** GET /swap-api/v1/swap_funding_rate */ -export interface FuturesCmPerpFundingRate { - symbol: string; - contract_code: string; - fee_asset: string; - funding_time: string; - funding_rate: string; - estimated_rate: string | null; - next_funding_time: string | null; +/** Chain name. Poloniex rapid transfer defaults to t397342. */ +⋮---- +/** On-chain address, or UID:XXXX for Poloniex→HTX rapid transfers. */ +⋮---- +/** VASP exchange from GET /v1/query/vasp-list */ +export interface SpotVaspExchange { + 'vasp-id': string; + 'vasp-name': string; + 'legal-name': string; } ⋮---- -/** Item from GET /swap-api/v1/swap_historical_funding_rate data[] */ -export interface FuturesCmPerpHistoricalFundingRate { - symbol: string; - contract_code: string; - fee_asset: string; - funding_time: string; - funding_rate: string; - /** Deprecated, default null */ - realized_rate?: string | null; - avg_premium_index: string; +/** User rebate status from GET /broker/v1/user_rebate_status */ +export interface SpotBrokerUserRebateStatus { + spotRebateStatus: boolean; + contractRebateStatus: boolean; + spotIsNewUser: boolean; + contractIsNewUser?: boolean; } ⋮---- -/** Deprecated, default null */ +/** Sub-user fee rate from GET /broker/v1/sub-user/fee_rate */ +export interface SpotBrokerSubUserFeeRate { + userId: number; + subUserId: number; + bizType: number; + taker: string; + maker: string; + type: number; + addTaker: string; + addMaker: string; + updatedAt: number; + effectAt: number; +} ⋮---- -/** Paginated wrapper for GET /swap-api/v1/swap_historical_funding_rate */ -export type FuturesCmPerpHistoricalFundingRatePage = - FuturesPaginatedData; +/** Fee rate add result from POST /broker/v1/sub-user/fee_rate/add */ +export interface SpotBrokerFeeRateAddResult { + subUserIds: number[]; + effectAt: string; +} ⋮---- -/** Item from GET /swap-api/v3/swap_liquidation_orders data[] */ -export interface FuturesCmPerpLiquidationOrder { - query_id?: number; - contract_code: string; - symbol: string; - direction: string; - offset: string; - volume: number; - price: number; - created_at: number; - amount: number; +/** Account capital snapshot item from POST /broker/v1/account_capital_snapshot_everyday */ +export interface SpotBrokerAccountCapitalSnapshot { + accountId: number; + accountType: string; + snapshotTime: string; + convertBalance: string; + dataList: unknown[]; } ⋮---- -/** Item from GET /swap-api/v1/swap_settlement_records settlement_record[] */ -export interface FuturesCmPerpSettlementRecord { - symbol: string; - contract_code: string; - settlement_time: number; - clawback_ratio: number; - settlement_price: number; - settlement_type: string; +/** Deduct mode result item from POST /v2/sub-user/deduct-mode */ +export interface SpotSubUserDeductModeResult { + subUid: string; + deductMode: string | null; + errCode?: string; + errMessage?: string; } ⋮---- -/** Paginated wrapper for GET /swap-api/v1/swap_settlement_records */ -export type FuturesCmPerpSettlementRecordsPage = - FuturesPaginatedSettlement; +/** API key from getSubUserApiKey */ +export interface SpotSubUserApiKey { + accessKey: string; + status: string; + note: string; + permission: string; + ipAddresses: string; + validDays: number; + createTime: number; + updateTime: number; +} ⋮---- -/** Index constituents from GET /swap-api/market/swap_constituents. data is object. */ -export interface FuturesCmPerpIndexConstituents { - contract_code: string; - ts: number; - index_price: string; - components: FuturesIndexConstituentComponent[]; +/** Sub user creation result item from POST /v2/sub-user/creation */ +export interface SpotSubUserCreationResult { + userName: string; + note?: string; + uid?: number; + /** Spot account id for spot order transactions */ + spotAccountId?: number; + errCode?: string; + errMessage?: string; } ⋮---- -/** Item from GET /swap-api/v1/swap_contract_info data[] */ -export interface FuturesCmPerpContractInfo { - symbol: string; - contract_code: string; - contract_size: number; - price_tick: number; - settlement_date: string; - settlement_period: string; - create_date: string; - delivery_time: string; - contract_status: number; - labels?: string[]; +/** Spot account id for spot order transactions */ +⋮---- +/** Sub user from GET /v2/sub-user/user-list */ +export interface SpotSubUserList { + uid: number; + userState: string; + subUserName: string; + note: string; } ⋮---- -/** Item from GET /swap-api/v1/swap_open_interest data[] */ -export interface FuturesCmPerpOpenInterestCurrent { - symbol: string; - contract_code: string; - volume: number; - amount: number; - trade_amount: number; - trade_volume: number; - trade_turnover: number; +/** Result from updateSubUserLockStatus */ +export interface SpotSubUserLockStatusResult { + subUid: number; + userState: string; } ⋮---- -/** contract_infos[] item from GET /swap-api/v1/swap_query_elements */ -export interface FuturesCmPerpContractElementsContractInfo { - contract_code: string; - settlement_date: string; - /** Empty string when no delivery */ - delivery_time: string; - create_date: string; - contract_status: number; - instrument_type?: number; +/** Result from getSubUserStatus */ +export interface SpotSubUserStatusResult { + uid: number; + userState: string; } ⋮---- -/** Empty string when no delivery */ +/** Tradable market result item from POST /v2/sub-user/tradable-market */ +export interface SpotSubUserTradableMarketResult { + subUid: string; + accountType: string; + activation: string; + errCode?: number; + errMessage?: string; +} ⋮---- -/** Market depth tick from GET /swap-ex/market/depth. Payload in "tick". */ -export interface FuturesCmPerpMarketDepth { - mrid: number; - id: number; - asks: [number, number][]; - bids: [number, number][]; - ts: number; - version: number; - ch: string; +/** Result item from setSubUserTransferPermissions */ +export interface SpotSubUserTransferPermissionsResult { + subUid: number; + accountType: string; + transferrable: boolean; + errCode?: number; + errMessage?: string; } ⋮---- -/** BBO tick from GET /swap-ex/market/bbo. ask/bid: [price, qty]. Payload in "ticks". */ -export interface FuturesCmPerpMarketBbo { - contract_code: string; - mrid: number; - ask: [number, number]; - bid: [number, number]; - ts: number; +/** Account ID from sub user account list */ +export interface SpotSubUserAccountId { + accountId: number; + subType?: string; + accountStatus?: string; } ⋮---- -/** Kline item from GET /swap-ex/market/history/kline */ -export interface FuturesCmPerpKline { - id: number; - vol: number; - count: number; - open: number; - close: number; - low: number; - high: number; - amount: number; +/** Account from sub user account list */ +export interface SpotSubUserAccount { + accountType: string; + activation: string; + transferrable?: boolean; + accountIds?: SpotSubUserAccountId[]; } ⋮---- -/** Mark price kline item from GET /index/market/history/swap_mark_price_kline */ -export interface FuturesCmPerpMarkPriceKline { - id: number; - vol: string; - count: string; - open: string; - close: string; - low: string; - high: string; - amount: string; - trade_turnover: string; +/** Result from getSubUserAccounts */ +export interface SpotSubUserAccountsResult { + uid: number; + deductMode: string; + list: SpotSubUserAccount[]; } ⋮---- -/** 24h ticker from GET /swap-ex/market/detail/merged. Payload in "tick". */ -export interface FuturesCmPerp24hTicker { - id: number; - ts: number; - vol: string; - count: number; - open: string; - close: string; - low: string; - high: string; - amount: string; - ask: [number, number]; - bid: [number, number]; +/** Result from createSubUserApiKey */ +export interface SpotSubUserApiKeyCreationResult { + accessKey: string; + secretKey: string; + note: string; + permission: string; + ipAddresses: string; } ⋮---- -/** 24h ticker item from GET /v2/swap-ex/market/detail/batch_merged */ -export interface FuturesCmPerp24hTickers { - contract_code: string; - id: number; - ts: number; - amount: string; - count: number; - vol: string; - number_of: string; - open: string; - close: string; - low: string; - high: string; - ask: [number, number]; - bid: [number, number]; +/** Result from updateSubUserApiKey */ +export interface SpotSubUserApiKeyUpdateResult { + note: string; + permission: string; + ipAddresses: string; } ⋮---- -/** Trade item from GET /swap-ex/market/trade and history/trade */ -export interface FuturesCmPerpTrade { +/** Record from getSubUserDepositHistory */ +export interface SpotSubUserDepositHistoryRecord { id: number; - price: string; - amount: string; - direction: string; - ts: number; - quantity: string; - contract_code?: string; + currency: string; + txHash: string; + chain: string; + amount: number; + address: string; + addressTag: string; + state: string; + createTime: number; + updateTime: number; } ⋮---- -/** Last trade tick from GET /swap-ex/market/trade. Payload in "tick". */ -export interface FuturesCmPerpLastTrade { - id: number; - ts: number; - data: FuturesCmPerpTrade[]; +/** Balance from getSubUsersAggregatedBalance */ +export interface SpotSubUsersAggregatedBalance { + currency: string; + type: string; + balance: string; } ⋮---- -/** Trade history group from GET /swap-ex/market/history/trade. Each group has trades by timestamp. */ -export interface FuturesCmPerpTradeHistory { +/** Result from getSubUserBalance */ +export interface SpotSubUserBalanceResult { id: number; - ts: number; - data: FuturesCmPerpTrade[]; + type: string; + state: string; + list: SpotBalance[]; + symbol?: string; } ⋮---- -/** Estimated funding rate kline item from GET /index/market/history/swap_estimated_rate_kline */ -export interface FuturesCmPerpFundingRateKline { - id: number; - vol: string; - count: string; - open: string; - close: string; - low: string; - high: string; - amount: string; +/** Custody sub-account from GET /v2/sub-user/entrust-user-list */ +export interface SpotSubUserEntrustUser { + uid: number; + subUserName: string; } ⋮---- -/** Premium index kline item from GET /index/market/history/swap_premium_index_kline */ -export interface FuturesCmPerpPremiumIndexKline { - id: number; - vol: string; - count: string; - open: string; - close: string; - low: string; - high: string; - amount: string; +/** Managed transfer record from GET /v2/sub-user/managed-transfer-history */ +export interface SpotSubUserManagedTransferRecord { + currency: string; + type: string; + amount: number; + uid: number; + subUserName: string; + query_id?: string; } ⋮---- -/** Basis data item from GET /index/market/history/swap_basis */ -export interface FuturesCmPerpBasisData { - id: number; - contract_price: string; - index_price: string; - basis: string; - basis_rate: string; +/** Referral rebate detail from GET /v2/invitee/rebate/detail */ +export interface SpotReferralRebateDetail { + invitee_type: string; + invitee_rebate_rate_spot_m2: string; + invitee_rebate_rate_contract_m2: string; + invitee_rebate_rate_partner_spot?: string; + invitee_rebate_rate_partner_contract?: string; + join_time_m2: string; + join_time_partner?: string; + invitee_total_commission_usdt: string; + invitee_total_commission_trx: string; + invitee_total_commission_htx: string; + partner_total_commission_usdt: string; + partner_total_commission_trx: string; + partner_total_commission_htx: string; } ⋮---- -/** Account info from POST /swap-api/v1/swap_account_info */ -export interface FuturesCmPerpAccountInfo { - symbol: string; - contract_code: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real?: number; - profit_unreal: number; - risk_rate: number | null; - new_risk_rate?: string | null; - trade_partition?: string; - withdraw_available: number; - liquidation_price: number | null; - lever_rate: number; - adjust_factor: number; - margin_static: number; +/** Referral rebate history record from GET /v2/invitee/rebate/history */ +export interface SpotReferralRebateHistoryRecord { + date: number; + invitee_total_commission_usdt: string; + invitee_total_commission_trx: string; + invitee_total_commission_htx: string; + partner_total_commission_usdt: string; + partner_total_commission_trx: string; + partner_total_commission_htx: string; } ⋮---- -/** Position info from POST /swap-api/v1/swap_position_info */ -export interface FuturesCmPerpPositionInfo { - symbol: string; - contract_code: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; - liq_px: string; - new_risk_rate?: string | null; - trade_partition?: string; +/** Referral rebate detail from all_rebate/detail or batcher_rebate/detail */ +export interface SpotReferralAllRebateDetail { + invitee_uid: number; + invitee_type: string; + invitee_rebate_rate_spot_m2: string | null; + invitee_rebate_rate_contract_m2: string | null; + invitee_rebate_rate_partner_spot?: string | null; + invitee_rebate_rate_partner_contract?: string | null; + join_time_m2: string; + join_time_partner?: string | null; + invitee_total_commission_usdt: string; + invitee_total_commission_trx: string; + invitee_total_commission_htx: string; + partner_total_commission_usdt: string; + partner_total_commission_trx: string; + partner_total_commission_htx: string; } ⋮---- -/** Position item in getCoinMPerpAccountFull positions[] */ -export interface FuturesCmPerpAccountFullPosition { - symbol: string; - contract_code: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; +/** P2P order from GET /v1/api/c2c/order/history */ +export interface SpotP2POrderHistory { + orderNo: string; + role: string; + side: string; + counterpartNickName: string; + fiatCurrency: string; + asset: string; + amount: string; + unitPrice: string; + totalPrice: string; + fee: string; + orderStatus: string; + createTime: string; + queryId?: number; } ⋮---- -/** Account + positions from getCoinMPerpAccountFull */ -/** Account + positions from getCoinMPerpAccountFull */ -export interface FuturesCmPerpAccountFull { - symbol: string; - contract_code: string; - margin_balance: number; - margin_static: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real?: number; - profit_unreal: number; - risk_rate: number | null; - withdraw_available: number; - liquidation_price: number | null; - lever_rate: number; - adjust_factor: number; - new_risk_rate?: string | null; - trade_partition?: string; - positions: FuturesCmPerpAccountFullPosition[]; +/** Tiered rate from Earn project */ +export interface SpotEarnTieredRate { + amountStart: string; + amountEnd: string; + rate: string; } ⋮---- -/** Sub-auth error from swap_sub_auth and swap_sub_auth_list */ -export interface FuturesCmPerpSubPermissionsError { - sub_uid: string; - err_code: number | string; - err_msg: string; +/** Earn project from GET /v1/earn/project/queryEarnProjectList */ +export interface SpotEarnProject { + projectId: number; + productId: number; + calculationType: number; + type: number; + viewYearRate: string; + finishAmount: string; + projectStatus: number; + totalAmount: string; + currency: string; + startAmount: string; + apyType: number; + tieredRates?: SpotEarnTieredRate[]; + marketPerkUpLimit?: string; + marketTimeApy?: string; + marketPerkApy?: string; } ⋮---- -/** Sub-auth response from updateCoinMPerpSubPermissions */ -export interface FuturesCmPerpUpdateSubPermissions { - errors: FuturesCmPerpSubPermissionsError[]; - successes: string; +/** Result from POST /v1/earn/order/demand/add */ +export interface SpotEarnSubscribeResult { + currency: string; + amount: string; + orderId: number; + status: number; } ⋮---- -/** Sub-auth success item from swap_sub_auth_list */ -export interface FuturesCmPerpSubPermissionsSuccess { - query_id?: number; - sub_uid: string; - sub_auth: number | string; +/** Result from POST /v1/earn/order/demand/redeem-order */ +export interface SpotEarnRedeemResult { + currency: string; + amount: string; + orderId: number; + status: number; } ⋮---- -/** Sub-auth list from getCoinMPerpSubPermissions */ -export interface FuturesCmPerpSubPermissions { - errors: FuturesCmPerpSubPermissionsError[]; - successes: FuturesCmPerpSubPermissionsSuccess[]; +/** Earn user asset from GET /v1/earn/order/user/assets/list */ +export interface SpotEarnUserAsset { + projectId: number; + orderId: number; + projectType: number; + currency: string; + yesterdayIncome: string; + totalIncomeAmount: string; + totalAmount: string; + miningYearRate: string; + apyType: number; } ⋮---- -/** Sub-account list item from getCoinMPerpSubAccounts list[] */ -export interface FuturesCmPerpSubAccountsItem { - symbol: string; - contract_code: string; - margin_balance: number; - liquidation_price: number | null; - risk_rate: number | null; - query_id?: number; +/** Referral invited user from GET /v2/invitee/rebate/referrals */ +export interface SpotReferralReferral { + id: number; + invitee_uid: number; + remark: string; + referral_code: string; + invitee_type: string; + invitee_rebate_rate_spot_m2: string; + invitee_rebate_rate_contract_m2: string; + invitee_rebate_rate_partner_spot?: string | null; + invitee_rebate_rate_partner_contract?: string | null; + join_time_m2: number; + join_time_partner?: number | null; + /** Whether advanced KYC was completed */ + completed_kyc?: boolean | number | string; + /** Invitee email */ + mail?: string | null; } ⋮---- -/** Sub-account entry from getCoinMPerpSubAccounts (data array element) */ -export interface FuturesCmPerpSubAccounts { - sub_uid: number; - list: FuturesCmPerpSubAccountsItem[]; -} +/** Whether advanced KYC was completed */ ⋮---- -/** Account info item from getCoinMPerpSubAccountsAssets account_info_list[] */ -export interface FuturesCmPerpSubAccountsAssetsAccount { +/** Invitee email */ +⋮---- +/** Open order from GET /v1/order/openOrders */ +export interface SpotV1OpenOrder { + id: number; + 'client-order-id'?: string; symbol: string; - contract_code: string; - margin_balance: number; - liquidation_price: number | null; - risk_rate: number | null; + 'account-id'?: number; + price?: string; + amount?: string; + 'created-at': number; + type: string; + 'filled-amount': string; + 'filled-cash-amount': string; + 'filled-fees': string; + source?: string; + state: string; + 'stop-price'?: string; + operator?: string; } ⋮---- -/** Sub-list item from getCoinMPerpSubAccountsAssets sub_list[] */ -export interface FuturesCmPerpSubAccountsAssetsSub { - sub_uid: number; - account_info_list: FuturesCmPerpSubAccountsAssetsAccount[]; +/** Result from POST /v5/account/universal_transfer */ +export interface SpotUniversalTransferResult { + transfer_id: number; } ⋮---- -/** Response from getCoinMPerpSubAccounts */ -export type FuturesCmPerpSubAccountsAssets = - FuturesPaginatedSubList; -⋮---- -/** Sub-account account info from getCoinMPerpSubAccountAssets (data array element) */ -export interface FuturesCmPerpSubAccountAssets { - symbol: string; - contract_code: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real?: number; - profit_unreal: number; - risk_rate: number | null; - liquidation_price: number | null; - withdraw_available: number; - lever_rate: number; - adjust_factor: number; - margin_static: number; - new_risk_rate?: string | null; - trade_partition?: string; +/** Record from GET /v5/account/universal_transfer_records */ +export interface SpotUniversalTransferRecord { + id: number; + transfer_id: number | string; + amount: string; + currency?: string; + status?: string; + from_account_type: string; + to_account_type: string; + from_account_asset?: string; + to_account_asset?: string; + from_asset_type?: string; + to_asset_type?: string; + transfer_time?: number; } + +================ +File: src/types/request/spot.types.ts +================ +/** + * Reference Data + */ ⋮---- -/** Sub-account position from getCoinMPerpSubPositions (data array element) */ -export interface FuturesCmPerpSubPositions { - symbol: string; - contract_code: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; - liq_px: string; - new_risk_rate?: string | null; - trade_partition?: string; +export interface SpotGetChainsReq { + /** Show desc: 0=no, 1=all, 2=suspend deposit/withdrawal and chain exchange */ + 'show-desc'?: string; + /** Currency filter */ + currency?: string; + /** Timestamp for incremental data. Returns updates from ts to now. If no update, data is []. */ + ts?: number; } ⋮---- -/** Financial record from POST /swap-api/v3/swap_financial_record and swap_financial_record_exact */ -export interface FuturesCmPerpFinancialRecord { - query_id: number; - id: number | string; - ts: number; +/** Show desc: 0=no, 1=all, 2=suspend deposit/withdrawal and chain exchange */ +⋮---- +/** Currency filter */ +⋮---- +/** Timestamp for incremental data. Returns updates from ts to now. If no update, data is []. */ +⋮---- +/** + * Market Data + */ +⋮---- +/** Req for /market/history/kline */ +export interface SpotGetKlineReq { + /** Trading symbol (e.g. btcusdt, btc3lusdtnav for ETP NAV) */ symbol: string; - contract_code: string; - type: number; - amount: number | string; + /** Candle period. Default 1day. */ + period?: string; + /** Number of data points [1-2000]. Default 150. */ + size?: number; } ⋮---- -/** Available leverage from getCoinMPerpAvailableLeverage */ -export interface FuturesCmPerpAvailableLeverage { - contract_code: string; - available_level_rate: string; -} +/** Trading symbol (e.g. btcusdt, btc3lusdtnav for ETP NAV) */ ⋮---- -/** Order limit list item from swap_order_limit list[] */ -export interface FuturesCmPerpOrderLimitList { +/** Candle period. Default 1day. */ +⋮---- +/** Number of data points [1-2000]. Default 150. */ +⋮---- +export interface SpotGetDepthReq { + /** Trading symbol (e.g. btcusdt) */ symbol: string; - contract_code: string; - open_limit: number; - close_limit: number; + /** Depth levels per side. 5, 10, 20, 30. Default 20. step0 uses 150 if omitted. */ + depth?: number; + /** step0=no agg, step1-5=aggregation levels. Default step0. */ + type?: string; } ⋮---- -/** Order limit from POST /swap-api/v1/swap_order_limit */ -export interface FuturesCmPerpOrderLimit { - order_price_type: string; - list: FuturesCmPerpOrderLimitList[]; -} +/** Trading symbol (e.g. btcusdt) */ ⋮---- -/** Fee from POST /swap-api/v1/swap_fee */ -export interface FuturesCmPerpFee { - symbol: string; - contract_code: string; - open_maker_fee: string; - open_taker_fee: string; - close_maker_fee: string; - close_taker_fee: string; - fee_asset: string; - delivery_fee?: string; -} +/** Depth levels per side. 5, 10, 20, 30. Default 20. step0 uses 150 if omitted. */ ⋮---- -/** Transfer limit from POST /swap-api/v1/swap_transfer_limit */ -export interface FuturesCmPerpTransferLimit { - symbol: string; - contract_code: string; - transfer_in_max_each: number; - transfer_in_min_each: number; - transfer_out_max_each: number; - transfer_out_min_each: number; - transfer_in_max_daily: number; - transfer_out_max_daily: number; - net_transfer_in_max_daily: number; - net_transfer_out_max_daily: number; -} +/** step0=no agg, step1-5=aggregation levels. Default step0. */ ⋮---- -/** Position limit from POST /swap-api/v1/swap_position_limit */ -export interface FuturesCmPerpPositionLimit { - symbol: string; - contract_code: string; - buy_limit: number; - sell_limit: number; -} +/** + * Account + */ export interface SpotGetAssetValuationReq { ⋮---- -/** API trading status COR from getCoinMPerpApiStatus */ -export interface FuturesCmPerpApiStatusCor { - orders_threshold: number; - orders: number; - invalid_cancel_orders: number; - cancel_ratio_threshold: number; - cancel_ratio: number; - is_trigger: number; - is_active: number; +*/ export interface SpotGetAssetValuationReq { + /** Account type: spot, margin, otc, super-margin. Default spot. */ + accountType?: string; + /** Valuation currency: BTC, CNY, USD, JPY, etc. Case sensitive. Default BTC. */ + valuationCurrency?: string; + /** Sub user UID. Omit for API key owner. */ + subUid?: number; } ⋮---- -/** API trading status TDN from getCoinMPerpApiStatus */ -export interface FuturesCmPerpApiStatusTdn { - disables_threshold: number; - disables: number; - is_trigger: number; - is_active: number; -} +/** Account type: spot, margin, otc, super-margin. Default spot. */ ⋮---- -/** API trading status from getCoinMPerpApiStatus */ -export interface FuturesCmPerpApiStatus { - is_disable: number; - order_price_types: string; - disable_reason: string; - disable_interval: number; - recovery_time: number; - COR: FuturesCmPerpApiStatusCor; - TDN: FuturesCmPerpApiStatusTdn; -} +/** Valuation currency: BTC, CNY, USD, JPY, etc. Case sensitive. Default BTC. */ ⋮---- -/** Cancel-after response from setCoinMPerpCancelAfter */ -export interface FuturesCmPerpCancelAfter { - current_time: number; - trigger_time: number; -} +/** Sub user UID. Omit for API key owner. */ ⋮---- -/** Trigger open order item from getCoinMPerpTriggerOpenOrders */ -export interface FuturesCmPerpTriggerOpenOrder { - symbol: string; - contract_code: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_price: number | string; - order_price: number | string; - created_at: number; - order_price_type: string; - status: number; +/** Req for POST /v2/account/transfer - transfer between spot, linear-swap, otc, futures, swap */ +export interface SpotV2AccountTransferReq { + /** Source: spot, linear-swap, otc, futures, swap */ + from: string; + /** Destination: spot, linear-swap, otc, futures, swap */ + to: string; + /** Currency (e.g. usdt). Upper/lowercase supported. */ + currency: string; + /** Transfer amount */ + amount: string; + /** Margin account (e.g. btc-usdt, eth-usdt, USDT) */ + 'margin-account': string; } ⋮---- -/** Trigger open orders response from getCoinMPerpTriggerOpenOrders */ -export type FuturesCmPerpTriggerOpenOrders = - FuturesPaginatedOrders; +/** Source: spot, linear-swap, otc, futures, swap */ ⋮---- -/** Trigger history order item from getCoinMPerpTriggerHisOrders */ -export interface FuturesCmPerpTriggerHisOrder { - symbol: string; - contract_code: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - relation_order_id: string; - order_price_type: string; - status: number; - order_source: string; - trigger_price: number | string; - triggered_price: number | string | null; - order_price: number | string; - created_at: number; - triggered_at: number | null; - order_insert_at: number; - canceled_at: number | null; - update_time: number; - fail_code: number | null; - fail_reason: string | null; -} +/** Destination: spot, linear-swap, otc, futures, swap */ ⋮---- -/** Trigger history orders response from getCoinMPerpTriggerHistoryOrders */ -export type FuturesCmPerpTriggerHistoryOrders = - FuturesPaginatedOrders; +/** Currency (e.g. usdt). Upper/lowercase supported. */ ⋮---- -/** TPSL open order item from getCoinMPerpTpslOpenOrders */ -export interface FuturesCmPerpTpslOpenOrder { - symbol: string; - contract_code: string; - volume: number; - order_type: number; - tpsl_order_type: string; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number | string; - price_protect?: boolean; - created_at: number; - order_price_type: string; - order_price: number | string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; -} +/** Transfer amount */ ⋮---- -/** TPSL open orders response from getCoinMPerpTpslOpenOrders */ -export type FuturesCmPerpTpslOpenOrders = - FuturesPaginatedOrders; +/** Margin account (e.g. btc-usdt, eth-usdt, USDT) */ ⋮---- -/** TPSL history order item from getCoinMPerpTpslHistoryOrders */ -export interface FuturesCmPerpTpslHisOrder { - symbol: string; - contract_code: string; - volume: number; - order_type: number; - tpsl_order_type: string; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number | string; - price_protect?: boolean; - created_at: number; - order_price_type: string; - order_price: number | string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; - canceled_at: number | null; - fail_code: number | null; - fail_reason: string | null; - triggered_price: number | string | null; - relation_order_id: string; - update_time: number; +/** Req for POST /v1/futures/transfer - transfer between spot and future contract account */ +export interface SpotV1FuturesTransferReq { + /** Currency name */ + currency: string; + /** Amount to transfer */ + amount: string; + /** futures-to-pro (contract -> spot) or pro-to-futures (spot -> contract) */ + type: 'futures-to-pro' | 'pro-to-futures'; } ⋮---- -/** TPSL history orders response from getCoinMPerpTpslHistoryOrders */ -export type FuturesCmPerpTpslHisOrders = - FuturesPaginatedOrders; +/** Currency name */ ⋮---- -/** Trailing open order item from getCoinMPerpTrailingOpenOrders */ -export interface FuturesCmPerpTrailingOpenOrder { - symbol: string; - contract_code: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - order_price_type: string; - status: number; - callback_rate: number | string; - active_price: number | string; - is_active: number; +/** Amount to transfer */ +⋮---- +/** futures-to-pro (contract -> spot) or pro-to-futures (spot -> contract) */ +⋮---- +/** Req for POST /v1/account/transfer */ +export interface SpotAccountTransferReq { + /** Transfer out user uid */ + 'from-user': number; + /** Transfer out account type: spot, margin */ + 'from-account-type': string; + /** Transfer out account id */ + 'from-account': number; + /** Transfer in user uid */ + 'to-user': number; + /** Transfer in account type: spot, margin */ + 'to-account-type': string; + /** Transfer in account id */ + 'to-account': number; + /** Currency name */ + currency: string; + /** Amount to transfer */ + amount: string; } ⋮---- -/** Trailing open orders response from getCoinMPerpTrailingOpenOrders */ -export type FuturesCmPerpTrailingOpenOrders = - FuturesPaginatedOrders; +/** Transfer out user uid */ ⋮---- -/** Trailing history order item from getCoinMPerpTrailingHistoryOrders */ -export interface FuturesCmPerpTrailingHisOrder { - symbol: string; - contract_code: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - update_time: number; - order_price_type: string; - status: number; - canceled_at: number | null; - fail_code: number | null; - fail_reason: string | null; - callback_rate: number | string; - active_price: number | string; - is_active: number; - market_limit_price: number | string | null; - formula_price: number | string | null; - real_volume: number | string; - triggered_price: number | string | null; - relation_order_id: string; -} +/** Transfer out account type: spot, margin */ ⋮---- -/** Trailing history orders response from getCoinMPerpTrailingHistoryOrders */ -export type FuturesCmPerpTrailingHisOrders = - FuturesPaginatedOrders; +/** Transfer out account id */ ⋮---- -/** Update leverage response from updateCoinMPerpLeverage */ -export interface FuturesCmPerpUpdateLeverage { - contract_code: string; - lever_rate: number; -} +/** Transfer in user uid */ ⋮---- -/** Open order item from getCoinMPerpOpenOrders */ -export interface FuturesCmPerpOpenOrder { - symbol: string; - contract_code: string; - volume: number; - price: number; - order_price_type: string; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - created_at: number; - trade_volume: number; - trade_turnover: number; - fee: number; - trade_avg_price: number | null; - margin_frozen: number; - profit: number; - status: number; - order_source: string; - fee_asset: string; - liquidation_type: string | null; - canceled_at: number | null; - is_tpsl: number; - update_time: number; - real_profit: number; - canceled_source?: string; - self_match_prevent?: number; -} +/** Transfer in account type: spot, margin */ ⋮---- -/** Open orders response from getCoinMPerpOpenOrders */ -export type FuturesCmPerpOpenOrders = - FuturesPaginatedOrders & { - canceled_source?: string; - self_match_prevent?: number; - }; +/** Transfer in account id */ ⋮---- -/** Item from GET /swap-api/v1/swap_query_elements data[] */ -export interface FuturesCmPerpContractElements { - contract_code: string; - instrument_index_code: string; - real_time_settlement: number; - transfer_profit_ratio: number; - min_level: string; - max_level: string; - open_order_limit: string; - offset_order_limit: string; - long_position_limit: string; - short_position_limit: string; - price_tick: string; - instrument_value: string; - settle_period: number; - funding_rate_cap: string; - funding_rate_floor: string; - trigger_protect?: number; - hig_normal_limit: string; - min_normal_limit: string; - hig_open_limit: string; - min_open_limit: string; - hig_trade_limit: string; - min_trade_limit: string; - contract_infos: FuturesCmPerpContractElementsContractInfo[]; -} +/** Currency name */ ⋮---- -/** List item from contract_elite_account_ratio */ -export interface FuturesCmDeliveryEliteAccountRatioItem { - buy_ratio: number; - sell_ratio: number; - locked_ratio: number; - ts: number; -} +/** Amount to transfer */ ⋮---- -/** GET /api/v1/contract_elite_account_ratio */ -export interface FuturesCmDeliveryEliteAccountRatio { - symbol: string; - list: FuturesCmDeliveryEliteAccountRatioItem[]; +/** Req for GET /v1/account/history */ +export interface SpotGetAccountHistoryReq { + /** Account ID from GET /v1/account/accounts */ + 'account-id': string | number; + /** Currency filter */ + currency?: string; + /** Amount change types, comma-separated. Default all. Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ + 'transact-types'?: string; + /** Start time (unix ms). Query window max 1 hour. */ + 'start-time'?: number; + /** End time (unix ms). Query window within 30 days. */ + 'end-time'?: number; + /** Sort order: asc, desc. Default asc. */ + sort?: string; + /** Max items [1-500]. Default 100. */ + size?: number; + /** First record ID for pagination (next page) */ + 'from-id'?: number; } ⋮---- -/** List item from contract_elite_position_ratio */ -export interface FuturesCmDeliveryElitePositionRatioItem { - buy_ratio: number; - sell_ratio: number; - ts: number; -} +/** Account ID from GET /v1/account/accounts */ ⋮---- -/** GET /api/v1/contract_elite_position_ratio */ -export interface FuturesCmDeliveryElitePositionRatio { - symbol: string; - list: FuturesCmDeliveryElitePositionRatioItem[]; -} +/** Currency filter */ ⋮---- -/** BBO tick from GET /market/bbo. ask/bid: [price, qty]. Uses symbol (e.g. BTC_CW). */ -export interface FuturesCmDeliveryMarketBbo { - symbol: string; - mrid: number; - ask: [number, number]; - bid: [number, number]; - ts: number; -} +/** Amount change types, comma-separated. Default all. Includes loan-disburse, loan-repay, loan-interest-refund, loan-interest-pay. */ ⋮---- -/** Kline item from GET /market/history/kline */ -export interface FuturesCmDeliveryKline { - id: number; - vol: number; - count: number; - open: number; - close: number; - low: number; - high: number; - amount: number; -} +/** Start time (unix ms). Query window max 1 hour. */ ⋮---- -/** Mark price kline item from GET /index/market/history/mark_price_kline */ -export interface FuturesCmDeliveryMarkPriceKline { - id: number; - vol: string; - count: string; - open: string; - close: string; - low: string; - high: string; - amount: string; -} +/** End time (unix ms). Query window within 30 days. */ ⋮---- -/** Ticker from GET /market/detail/merged. 24h summary + best bid/ask. Payload in "tick". Alias: getCoinMDeliveryTicker/getCoinMDeliveryTickers. */ -export interface FuturesCmDeliveryTicker { - id: number; - ts: number; - vol: string; - count: number; - open: string; - close: string; - low: string; - high: string; - amount: string; - ask: [number, number]; - bid: [number, number]; -} +/** Sort order: asc, desc. Default asc. */ ⋮---- -export interface FuturesCmDeliveryTrade { - id: number; - price: string; - amount: string; - direction: string; - ts: number; - quantity: string; - symbol: string; - /** Whether the trade is an RPI trade */ - 'is-rpi-trade'?: boolean | number | string; -} +/** Max items [1-500]. Default 100. */ ⋮---- -/** Whether the trade is an RPI trade */ +/** First record ID for pagination (next page) */ ⋮---- -/** Last trade tick from GET /market/trade. Payload in "tick". */ -export interface FuturesCmDeliveryLastTrade { - id: number; - ts: number; - data: FuturesCmDeliveryTrade[]; +export interface SpotV2PointTransferReq { + /** Transferer UID */ + fromUid: string; + /** Transferee UID */ + toUid: string; + /** Group ID. 0 = termless points. For terminable points, query sub user balance first. */ + groupId: number; + /** Transfer amount (max 8 decimal places) */ + amount: string; } ⋮---- -/** Trade item from GET /market/history/trade data array. No symbol in response. */ -export interface FuturesCmDeliveryTradeHistoryItem { - id: number; - price: string | number; - amount: string | number; - direction: string; - ts: number; - quantity?: string | number; - /** Whether the trade is an RPI trade */ - 'is-rpi-trade'?: boolean | number | string; -} +/** Transferer UID */ ⋮---- -/** Whether the trade is an RPI trade */ +/** Transferee UID */ ⋮---- -/** Trade history from GET /market/history/trade. Each group has trades by timestamp. Payload in "data". Alias: getCoinMDeliveryTradeHistory. */ -export interface FuturesCmDeliveryTradeHistory { - id: number; - ts: number; - data: FuturesCmDeliveryTradeHistoryItem[]; -} +/** Group ID. 0 = termless points. For terminable points, query sub user balance first. */ ⋮---- -/** Index kline item from GET /index/market/history/index. vol/count/amount typically 0. Alias: getCoinMDeliveryIndexKlines. */ -export interface FuturesCmDeliveryIndexKline { - id: number; - vol: number; - count: number; - open: number; - close: number; - low: number; - high: number; - amount: number; -} +/** Transfer amount (max 8 decimal places) */ ⋮---- -/** Account info from POST /api/v1/contract_account_info. Per-symbol margin account. */ -export interface FuturesCmDeliveryAccountInfo { - symbol: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real: number; - profit_unreal: number; - risk_rate: number | null; - new_risk_rate: string; - trade_partition: string; - liquidation_price: number | null; - withdraw_available: number; - lever_rate: number; - adjust_factor: number; - margin_static: number; -} +/** + * Trading + */ ⋮---- -/** Sub-account list item from POST /api/v1/contract_sub_account_list. Per-symbol margin info. */ -export interface FuturesCmDeliverySubAccountListItem { - symbol: string; - margin_balance: number; - liquidation_price: number | null; - risk_rate: number | string | null; - query_id: number; -} +/** Order type: direction-type. market=no price; limit=price+amount; limit-maker=maker only; ioc=immediately or cancel; limit-fok=fill or kill; stop-*=trigger price */ +export type SpotOrderType = + | 'buy-market' + | 'sell-market' + | 'buy-limit' + | 'sell-limit' + | 'buy-ioc' + | 'sell-ioc' + | 'buy-limit-maker' + | 'sell-limit-maker' + | 'buy-stop-limit' + | 'sell-stop-limit' + | 'buy-limit-fok' + | 'sell-limit-fok' + | 'buy-stop-limit-fok' + | 'sell-stop-limit-fok'; ⋮---- -/** All sub-account from POST /api/v1/contract_sub_account_list. Alias: getCoinMDeliveryAllSubAccounts. */ -export interface FuturesCmDeliveryAllSubAccount { - sub_uid: number; - list: FuturesCmDeliverySubAccountListItem[]; -} +/** Order source: spot-api, margin-api, super-margin-api, c2c-margin-api */ +export type SpotOrderSource = + | 'spot-api' + | 'margin-api' + | 'super-margin-api' + | 'c2c-margin-api'; ⋮---- -/** Account info item from POST /api/v1/contract_sub_account_info_list sub_list[].account_info_list */ -export interface FuturesCmDeliverySubAccountInfoListItem { +/** Req for POST /v1/order/orders/place */ +export interface SpotV1OrderPlaceReq { + /** Account ID from GET /v1/account/accounts. Required for trading. */ + 'account-id': string | number; + /** Trading symbol (e.g. ethusdt) */ symbol: string; - margin_balance: number; - liquidation_price: number | null; - risk_rate: number | string | null; + /** Order type (e.g. buy-limit, sell-market) */ + type: SpotOrderType; + /** Order size. For buy-market = order value in quote currency. */ + amount: string; + /** Order price. Not used for market orders. Required for limit types. */ + price?: string; + /** Order source. Default spot-api */ + source?: SpotOrderSource; + /** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ + 'client-order-id'?: string; + /** 0=allow self-trade, 1=prevent. Default 0 */ + 'self-match-prevent'?: 0 | 1; + /** Trigger price for stop-limit orders */ + 'stop-price'?: string; + /** Operator for stop price (lte, gte, etc) */ + operator?: string; + /** RPI order - type must be buy-limit or sell-limit */ + 'time-in-force'?: 'rpi'; } ⋮---- -/** Sub-list item from POST /api/v1/contract_sub_account_info_list */ -export interface FuturesCmDeliverySubAccountInfoListSub { - sub_uid: number; - account_info_list: FuturesCmDeliverySubAccountInfoListItem[]; -} +/** Account ID from GET /v1/account/accounts. Required for trading. */ ⋮---- -/** Sub-accounts assets from POST /api/v1/contract_sub_account_info_list. Alias: getCoinMDeliverySubAccounts. */ -export type FuturesCmDeliverySubAccountsAssets = - FuturesPaginatedSubList; +/** Trading symbol (e.g. ethusdt) */ ⋮---- -/** Sub-account assets from POST /api/v1/contract_sub_account_info. Alias: getCoinMDeliverySubAccountAssets. */ -export interface FuturesCmDeliverySubAccountAssets { - symbol: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real: number; - profit_unreal: number; - risk_rate: number | string | null; - liquidation_price: number | null; - withdraw_available: number; - lever_rate: number; - adjust_factor: number; - margin_static: number; - new_risk_rate: string; - trade_partition: string; -} +/** Order type (e.g. buy-limit, sell-market) */ ⋮---- -/** Position info from POST /api/v1/contract_sub_position_info. Single sub-account positions, data array element. */ -export interface FuturesCmDeliverySubPositionInfo { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; - liq_px: string; - new_risk_rate: string; - trade_partition: string; -} +/** Order size. For buy-market = order value in quote currency. */ ⋮---- -/** Position info from POST /api/v1/contract_position_info. */ -export interface FuturesCmDeliveryPositionInfo { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; - liq_px: string; - new_risk_rate: string; - trade_partition: string; -} +/** Order price. Not used for market orders. Required for limit types. */ ⋮---- -/** Liquidation order from GET /api/v3/contract_liquidation_orders */ -export interface FuturesCmDeliveryLiquidationOrder { - query_id: number; - symbol: string; - contract_code: string; - direction: string; - offset: string; - volume: number; - amount: number; - price: number; - created_at: number; -} +/** Order source. Default spot-api */ ⋮---- -/** Settlement record list item from contract_settlement_records */ -export interface FuturesCmDeliverySettlementRecordItem { - contract_code: string; - settlement_price: number; - settlement_type: string; -} +/** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ ⋮---- -/** Settlement record from GET /api/v1/contract_settlement_records */ -export interface FuturesCmDeliverySettlementRecord { - symbol: string; - settlement_time: number; - clawback_ratio: number; - list: FuturesCmDeliverySettlementRecordItem[]; -} +/** 0=allow self-trade, 1=prevent. Default 0 */ ⋮---- -/** GET /api/v1/contract_settlement_records */ -export interface FuturesCmDeliverySettlementRecords { - total_page: number; - current_page: number; - total_size: number; - settlement_record: FuturesCmDeliverySettlementRecord[]; -} +/** Trigger price for stop-limit orders */ ⋮---- -/** Financial record from POST /api/v3/contract_financial_record and contract_financial_record_exact */ -export interface FuturesCmDeliveryFinancialRecord { - query_id?: number; - id: number; - ts: number; - symbol: string; - contract_code: string; - type: number; - amount: number | string; -} +/** Operator for stop price (lte, gte, etc) */ ⋮---- -/** Position in user settlement record from POST /api/v1/contract_user_settlement_records */ -export interface FuturesCmDeliveryUserSettlementRecordPosition { - symbol: string; - contract_code: string; - direction: string; - volume: number; - cost_open: number; - cost_hold_pre: number; - cost_hold: number; - settlement_profit_unreal: number; - settlement_price: number; - settlement_type: string; -} +/** RPI order - type must be buy-limit or sell-limit */ ⋮---- -/** User settlement record from POST /api/v1/contract_user_settlement_records */ -export interface FuturesCmDeliveryUserSettlementRecord { +/** Margin order with auto borrow/repay for POST /v1/order/auto/place. Sub-accounts not supported. */ +export interface SpotV1OrderAutoPlaceReq { symbol: string; - margin_balance_init: number; - margin_balance: number; - settlement_profit_real: number; - settlement_time: number; - clawback: number; - delivery_fee: number; - offset_profitloss: number; - fee: number; - fee_asset: string; - positions: FuturesCmDeliveryUserSettlementRecordPosition[]; + 'account-id': string | number; + type: SpotOrderType; + /** 1: automatic loan, 2: automatic repayment */ + 'trade-purpose': '1' | '2'; + source: SpotOrderSource; + /** Order volume. For market buy = order value. Use amount or market-amount, not both. */ + amount?: string; + /** Market buy = order volume, market sell = order amount. Use amount or market-amount, not both. */ + 'market-amount'?: string; + /** Amount/quantity to borrow when trade-purpose=1. Max 3 decimal precision. */ + 'borrow-amount'?: string; + price?: string; + /** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ + 'client-order-id'?: string; + 'stop-price'?: string; + operator?: string; } ⋮---- -/** Response from POST /api/v1/contract_user_settlement_records */ -export interface FuturesCmDeliveryUserSettlementRecords { - total_page: number; - current_page: number; - total_size: number; - settlement_records: FuturesCmDeliveryUserSettlementRecord[]; -} +/** 1: automatic loan, 2: automatic repayment */ ⋮---- -/** Order limit type from POST /api/v1/contract_order_limit list[].types */ -export interface FuturesCmDeliveryOrderLimitType { - contract_type: string; - open_limit: number; - close_limit: number; -} +/** Order volume. For market buy = order value. Use amount or market-amount, not both. */ ⋮---- -/** Order limit list item from POST /api/v1/contract_order_limit */ -export interface FuturesCmDeliveryOrderLimitListItem { - symbol: string; - types: FuturesCmDeliveryOrderLimitType[]; -} +/** Market buy = order volume, market sell = order amount. Use amount or market-amount, not both. */ ⋮---- -/** Response from POST /api/v1/contract_order_limit */ -export interface FuturesCmDeliveryOrderLimit { - order_price_type: string; - list: FuturesCmDeliveryOrderLimitListItem[]; -} +/** Amount/quantity to borrow when trade-purpose=1. Max 3 decimal precision. */ ⋮---- -/** Response from POST /api/v1/contract_switch_lever_rate */ -export interface FuturesCmDeliverySwitchLeverRate { - symbol: string; - lever_rate: number; -} +/** Client order ID. Max 64 chars. Valid 8h for open, 2h for completed. */ ⋮---- -/** Open order item from POST /api/v1/contract_openorders data.orders[] */ -export interface FuturesCmDeliveryOpenOrder { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - price: number; - order_price_type: string; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - client_order_id: number | string | null; - created_at: number; - trade_volume: number; - trade_turnover: number; - fee: number; - trade_avg_price: number | null; - margin_frozen: number; - profit: number; - status: number; - order_source: string; - fee_asset: string; - is_tpsl: number; - update_time: number; - real_profit: number; - liquidation_type?: string | null; - canceled_at?: number | null; +/** Req for POST /v1/order/orders/batchCancelOpenOrders */ +export interface SpotV1OrderBatchCancelOpenOrdersReq { + /** Account ID from GET /v1/account/accounts */ + 'account-id'?: string; + /** Comma-separated symbols (max 10). Default all */ + symbol?: string; + /** Order types comma-separated */ + types?: string; + /** Filter: buy, sell */ + side?: 'buy' | 'sell'; + /** Orders to cancel [1-100]. Default 100 */ + size?: number; } ⋮---- -/** Response from POST /api/v1/contract_openorders */ -export type FuturesCmDeliveryOpenOrders = - FuturesPaginatedOrders & { - self_match_prevent?: number; - canceled_source?: string; - }; +/** Account ID from GET /v1/account/accounts */ ⋮---- -/** Trigger open order item from POST /api/v1/contract_trigger_openorders data.orders[] */ -export interface FuturesCmDeliveryTriggerOpenOrder { - symbol: string; - contract_code: string; - contract_type: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_price: number; - order_price: number; - created_at: number; - order_price_type: string; - status: number; -} +/** Comma-separated symbols (max 10). Default all */ ⋮---- -/** Response from POST /api/v1/contract_trigger_openorders */ -export type FuturesCmDeliveryTriggerOpenOrders = - FuturesPaginatedOrders; +/** Order types comma-separated */ ⋮---- -/** Trigger history order item from POST /api/v1/contract_trigger_hisorders data.orders[] */ -export interface FuturesCmDeliveryTriggerHistoryOrder { - symbol: string; - contract_code: string; - contract_type: string; - trigger_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - relation_order_id: string; - order_price_type: string; - status: number; - order_source: string; - trigger_price: number; - triggered_price: number; - order_price: number; - created_at: number; - triggered_at: number; - order_insert_at: number; - canceled_at: number; - fail_code: number | null; - fail_reason: string | null; - update_time?: number; -} +/** Filter: buy, sell */ ⋮---- -/** Response from POST /api/v1/contract_trigger_hisorders */ -export type FuturesCmDeliveryTriggerHistoryOrders = - FuturesPaginatedOrders; +/** Orders to cancel [1-100]. Default 100 */ ⋮---- -/** TPSL open order item from POST /api/v1/contract_tpsl_openorders data.orders[] */ -export interface FuturesCmDeliveryTpslOpenOrder { +/** Req for GET /v1/order/orders (search past orders) */ +export interface SpotGetOrderHistoryReq { + /** Trading symbol (required) */ symbol: string; - contract_code: string; - contract_type: string; - volume: number; - order_type: number; - tpsl_order_type: 'tp' | 'sl'; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number; - order_price: number; - created_at: number; - order_price_type: string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; - price_protect?: boolean; + /** Order types comma-separated */ + types?: string; + /** Start time (unix ms). Max 48h window. */ + 'start-time'?: number; + /** End time (unix ms). Max 48h window, within 180 days. */ + 'end-time'?: number; + /** States: filled, partial-canceled, canceled (comma-separated, required) */ + states: string; + /** Start order ID for pagination */ + from?: string; + /** next=desc, prev=asc. Default both */ + direct?: 'next' | 'prev'; + /** Orders to return [1-100]. Default 100 */ + size?: number; } ⋮---- -/** Response from POST /api/v1/contract_tpsl_openorders */ -export type FuturesCmDeliveryTpslOpenOrders = - FuturesPaginatedOrders; +/** Trading symbol (required) */ ⋮---- -/** TPSL history order item from POST /api/v1/contract_tpsl_hisorders data.orders[] */ -export interface FuturesCmDeliveryTpslHistoryOrder { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - order_type: number; - tpsl_order_type: 'tp' | 'sl'; - direction: string; - order_id: number | string; - order_id_str: string; - order_source: string; - trigger_type: string; - trigger_price: number; - order_price: number; - created_at: number; - order_price_type: string; - status: number; - source_order_id: string | null; - relation_tpsl_order_id: string; - canceled_at: number; - fail_code: number | null; - fail_reason: string | null; - triggered_price: number | null; - relation_order_id: string; - update_time: number; - price_protect?: boolean; -} +/** Order types comma-separated */ ⋮---- -/** Response from POST /api/v1/contract_tpsl_hisorders */ -export type FuturesCmDeliveryTpslHistoryOrders = - FuturesPaginatedOrders; +/** Start time (unix ms). Max 48h window. */ ⋮---- -/** Trailing open order item from POST /api/v1/contract_track_openorders data.orders[] */ -export interface FuturesCmDeliveryTrailingOpenOrder { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - order_price_type: string; - status: number; - callback_rate: number; - active_price: number; - is_active: number; -} +/** End time (unix ms). Max 48h window, within 180 days. */ ⋮---- -/** Response from POST /api/v1/contract_track_openorders */ -export type FuturesCmDeliveryTrailingOpenOrders = - FuturesPaginatedOrders; +/** States: filled, partial-canceled, canceled (comma-separated, required) */ ⋮---- -/** Trailing history order item from POST /api/v1/contract_track_hisorders data.orders[] */ -export interface FuturesCmDeliveryTrailingHistoryOrder { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - order_type: number; - direction: string; - offset: string; - lever_rate: number; - order_id: number | string; - order_id_str: string; - order_source: string; - created_at: number; - update_time: number; - order_price_type: string; - status: number; - canceled_at: number; - fail_code: number | null; - fail_reason: string | null; - callback_rate: number; - active_price: number; - is_active: number; - market_limit_price: number | null; - formula_price: number | null; - real_volume: number; - triggered_price: number | null; - relation_order_id: string; -} +/** Start order ID for pagination */ ⋮---- -/** Response from POST /api/v1/contract_track_hisorders */ -export type FuturesCmDeliveryTrailingHistoryOrders = - FuturesPaginatedOrders; +/** next=desc, prev=asc. Default both */ ⋮---- -/** Fee from POST /api/v1/contract_fee */ -export interface FuturesCmDeliveryFee { - symbol: string; - open_maker_fee: string; - open_taker_fee: string; - close_maker_fee: string; - close_taker_fee: string; - delivery_fee: string; - fee_asset: string; -} +/** Orders to return [1-100]. Default 100 */ ⋮---- -/** Transfer limit from POST /api/v1/contract_transfer_limit */ -export interface FuturesCmDeliveryTransferLimit { - symbol: string; - transfer_in_max_each: number; - transfer_in_min_each: number; - transfer_out_max_each: number; - transfer_out_min_each: number; - transfer_in_max_daily: number; - transfer_out_max_daily: number; - net_transfer_in_max_daily: number; - net_transfer_out_max_daily: number; +/** Req for GET /v1/order/history (48h historical orders) */ +export interface SpotGetOrderHistory48hReq { + /** Trading symbol */ + symbol?: string; + /** Start time (unix ms). Default 48h ago */ + 'start-time'?: number; + /** End time (unix ms). Default now */ + 'end-time'?: number; + /** prev=asc, next=desc. Default next */ + direct?: 'prev' | 'next'; + /** Items per response [10-1000]. Default 100 */ + size?: number; + /** created-at: order creation time. updated-at: last update time. */ + 'sort-by'?: 'created-at' | 'updated-at'; } ⋮---- -/** Position limit list item from POST /api/v1/contract_position_limit data[].list */ -export interface FuturesCmDeliveryPositionLimitListItem { - contract_type: string; - buy_limit: number; - sell_limit: number; -} +/** Trading symbol */ ⋮---- -/** Position limit from POST /api/v1/contract_position_limit */ -export interface FuturesCmDeliveryPositionLimit { - symbol: string; - list: FuturesCmDeliveryPositionLimitListItem[]; -} +/** Start time (unix ms). Default 48h ago */ ⋮---- -/** Position in asset_position_info from POST /api/v1/contract_account_position_info */ -export interface FuturesCmDeliveryAssetPositionInfoPosition { - symbol: string; - contract_code: string; - contract_type: string; - volume: number; - available: number; - frozen: number; - cost_open: number; - cost_hold: number; - profit_unreal: number; - profit_rate: number; - profit: number; - position_margin: number; - lever_rate: number; - direction: string; - last_price: number; - adl_risk_percent?: string | number; -} +/** End time (unix ms). Default now */ ⋮---- -/** Asset + positions from POST /api/v1/contract_account_position_info. Alias: getCoinMDeliveryAssetPositionInfo. */ -export interface FuturesCmDeliveryAssetPositionInfo { - symbol: string; - margin_balance: number; - margin_position: number; - margin_frozen: number; - margin_available: number; - profit_real: number; - profit_unreal: number; - risk_rate: number | string | null; - withdraw_available: number; - liquidation_price: number | null; - lever_rate: number; - adjust_factor: number; - margin_static: number; - new_risk_rate: string; - trade_partition: string; - positions: FuturesCmDeliveryAssetPositionInfoPosition[]; -} +/** prev=asc, next=desc. Default next */ ⋮---- -/** API trading status item from GET /api/v1/contract_api_trading_status */ -export interface FuturesCmDeliveryApiTradingStatusCor { - orders_threshold: number; - orders: number; - invalid_cancel_orders: number; - cancel_ratio_threshold: number; - cancel_ratio: number; - is_trigger: number; - is_active: number; -} +/** Items per response [10-1000]. Default 100 */ ⋮---- -/** API trading status TDN from GET /api/v1/contract_api_trading_status */ -export interface FuturesCmDeliveryApiTradingStatusTdn { - disables_threshold: number; - disables: number; - is_trigger: number; - is_active: number; -} +/** created-at: order creation time. updated-at: last update time. */ ⋮---- -/** API trading status from GET /api/v1/contract_api_trading_status */ -export interface FuturesCmDeliveryApiTradingStatus { - is_disable: number; - order_price_types: string; - disable_reason: string; - disable_interval: number; - recovery_time: number; - COR: FuturesCmDeliveryApiTradingStatusCor; - TDN: FuturesCmDeliveryApiTradingStatusTdn; +/** Req for GET /v1/order/matchresults (search match results) */ +export interface SpotGetMatchResultsReq { + /** Trading symbol */ + symbol?: string; + /** Order types comma-separated */ + types?: string; + /** Start time (unix ms). 48h window, 120 days range */ + 'start-time'?: number; + /** End time (unix ms). 48h window */ + 'end-time'?: number; + /** Internal id to begin pagination (use last id of prev page) */ + from?: string; + /** next or prev. Default next */ + direct?: 'next' | 'prev'; + /** Items to return [1-500]. Default 100 */ + size?: number; } ⋮---- -/** Leverage rate from POST /api/v1/contract_available_level_rate. Alias: getCoinMDeliveryLeverageRate. */ -export interface FuturesCmDeliveryLeverageRate { - symbol: string; - available_level_rate: string; -} +/** Trading symbol */ ⋮---- -/** GET /api/v1/contract_open_interest */ -export interface FuturesCmDeliveryContractOpenInterest { - symbol: string; - contract_type: string; - contract_code: string; - volume: number; - amount: number; - trade_amount: number; - trade_volume: number; - trade_turnover: number; -} +/** Order types comma-separated */ ⋮---- -/** Delivery price from GET /api/v1/contract_delivery_price */ -export interface FuturesCmDeliveryDeliveryPrice { - delivery_price: number; -} +/** Start time (unix ms). 48h window, 120 days range */ ⋮---- -/** Estimated settlement price list item */ -export interface FuturesCmDeliveryEstimatedSettlementPriceItem { - contract_type: string; - contract_code: string; - estimated_settlement_price: number | null; - settlement_type: string; -} +/** End time (unix ms). 48h window */ ⋮---- -/** GET /api/v1/contract_estimated_settlement_price */ -export interface FuturesCmDeliveryEstimatedSettlementPrice { - symbol: string; - list: FuturesCmDeliveryEstimatedSettlementPriceItem[]; -} +/** Internal id to begin pagination (use last id of prev page) */ ⋮---- -/** GET /api/v1/contract_api_state */ -export interface FuturesCmDeliveryApiState { - symbol: string; - open: number; - close: number; - cancel: number; - transfer_in: number; - transfer_out: number; - master_transfer_sub: number; - sub_transfer_master: number; -} +/** next or prev. Default next */ ⋮---- -/** GET /api/v1/contract_contract_info */ -export interface FuturesCmDeliveryContractInfo { - symbol: string; - contract_code: string; - contract_type: string; - contract_size: number; - price_tick: number; - delivery_date: string; - create_date: string; - settlement_time: string; - delivery_time: string; - contract_status: number; - labels?: string[]; -} +/** Items to return [1-500]. Default 100 */ ⋮---- -/** GET /api/market/contract_constituents */ -export interface FuturesCmDeliveryConstituents { - symbol: string; - ts: number; - index_price: string; - components: FuturesIndexConstituentComponent[]; +/** Req for GET /v1/order/openOrders */ +export interface SpotGetOpenOrdersReq { + /** Account ID from GET /v1/account/accounts */ + 'account-id'?: string; + /** Trading symbol (e.g. ethusdt) */ + symbol?: string; + /** Filter: buy, sell */ + side?: 'buy' | 'sell'; + /** Order types comma-separated */ + types?: string; + /** Start order ID for pagination */ + from?: string; + /** prev=asc from start, next=desc from start */ + direct?: 'prev' | 'next'; + /** Orders to return [1-500]. Default 100 */ + size?: number; } ⋮---- -/** Contract info sub-item in query elements */ -export interface FuturesCmDeliveryQueryElementsContractInfo { - contract_code: string; - instrument_type: number | number[]; - create_date: string; - contract_status: number; - delivery_time: string; - delivery_date: string; -} +/** Account ID from GET /v1/account/accounts */ ⋮---- -/** Order limit in query elements */ -export interface FuturesCmDeliveryQueryElementsOrderLimit { - instrument_type: number; - open: string; - close: string; - trigger_protect?: number; -} +/** Trading symbol (e.g. ethusdt) */ ⋮---- -/** GET /api/v1/contract_query_elements */ -export interface FuturesCmDeliveryQueryElements { - contract_code: string; - instrument_index_code: string; - real_time_settlement?: number; - price_tick?: string; - instrument_value?: string; - transfer_profit_ratio?: number; - min_level?: string; - max_level?: string; - open_order_limit?: string; - offset_order_limit?: string; - long_position_limit?: string; - short_position_limit?: string; - week_hig_normal_limit?: number; - week_min_normal_limit?: number; - week_hig_open_limit?: number; - week_min_open_limit?: number; - week_hig_trade_limit?: number; - week_min_trade_limit?: number; - biweek_hig_normal_limit?: number; - biweek_min_normal_limit?: number; - biweek_hig_open_limit?: number; - biweek_min_open_limit?: number; - biweek_hig_trade_limit?: number; - biweek_min_trade_limit?: number; - quarter_hig_normal_limit?: number; - quarter_min_normal_limit?: number; - quarter_hig_open_limit?: number; - quarter_min_open_limit?: number; - quarter_hig_trade_limit?: number; - quarter_min_trade_limit?: number; - biquarter_hig_normal_limit?: number; - biquarter_min_normal_limit?: number; - biquarter_hig_open_limit?: number; - biquarter_min_open_limit?: number; - biquarter_hig_trade_limit?: number; - biquarter_min_trade_limit?: number; - instrument_type?: number[]; - contract_infos?: FuturesCmDeliveryQueryElementsContractInfo[]; - order_limits?: FuturesCmDeliveryQueryElementsOrderLimit[]; -} +/** Filter: buy, sell */ +⋮---- +/** Order types comma-separated */ +⋮---- +/** Start order ID for pagination */ +⋮---- +/** prev=asc from start, next=desc from start */ +⋮---- +/** Orders to return [1-500]. Default 100 */ ⋮---- /** - * Copy Trading + * Conditional Order */ ⋮---- -/** Lead trading instrument from GET /api/v6/copyTrading/trader/instruments */ -export interface FuturesCopyTraderInstrument { - instId: string; - instType: string; +/** Req for POST /v2/algo-orders (Place a conditional order). Conditional orders only via this endpoint, not Trading section. */ +export interface SpotV2AlgoOrdersPlaceReq { + /** Account ID. Spot, margin, super-margin. C2C margin not supported. */ + accountId?: number; + /** Trading symbol */ + symbol?: string; + /** Order price (invalid for market order) */ + orderPrice?: string; + /** Order side: buy, sell */ + orderSide?: 'buy' | 'sell'; + /** Order size (invalid for market buy order) */ + orderSize?: string; + /** Order value (only valid for market buy order) */ + orderValue?: string; + /** Time in force: gtc, boc, ioc, fok. gtc=good till cancel, boc=book or cancel, ioc=immediate or cancel, fok=fill or kill. gtc for limit; ioc for market. */ + timeInForce?: 'gtc' | 'boc' | 'ioc' | 'fok'; + /** Order type: limit, market */ + orderType?: 'limit' | 'market'; + /** Client order ID (max 64 chars). Must be unique within 24h for same user. */ + clientOrderId?: string; + /** Stop price */ + stopPrice?: string; + /** Trailing rate [0.001-0.050]. Only valid for trailing stop order */ + trailingRate?: string; } ⋮---- -/** Profit detail item in trader statistics */ -export interface FuturesCopyTraderProfitDetail { - pnlRate: string; - pnl: string; - ts: string; -} +/** Account ID. Spot, margin, super-margin. C2C margin not supported. */ ⋮---- -/** Trader lead trading metrics from GET /api/v6/copyTrading/trader/statistics */ -export interface FuturesCopyTraderStatistics { - instType: string; - totalFollowerNum: string; - curFollowerNum: string; - totalPnl: string; - followerTotalPnl: string; - winRate: string; - winNum: string; - lossNum: string; - profitDetails24h?: FuturesCopyTraderProfitDetail[]; - profitDetails90d: FuturesCopyTraderProfitDetail[]; -} +/** Trading symbol */ ⋮---- -/** Profit sharing history item from GET /api/v6/copyTrading/trader/profit-sharing-history */ -export interface FuturesCopyTraderProfitSharingHistory { - id: string; - instType: string; - followerName: string; - ccy: string; - profitSharingAmt: string; - ts: string; -} +/** Order price (invalid for market order) */ ⋮---- -/** Profit sharing summary from GET /api/v6/copyTrading/trader/profit-sharing-history-summary or unrealized-profit-sharing-summary */ -export interface FuturesCopyTraderProfitSharingSummary { - instType: string; - ccy: string; - totalAmt: string; -} +/** Order side: buy, sell */ ⋮---- -/** Follower info from GET /api/v6/copyTrading/trader/followers */ -export interface FuturesCopyTraderFollower { - id: string; - instType: string; - followerAvatarLink: string; - followerName: string; - followerUid: string; - followTime: string; - followerAssetAmt: string; - followerProfitSharingAmt: string; - followerTradeAmt: string; - totalProfitSharingAmt: string; -} +/** Order size (invalid for market buy order) */ ⋮---- -/** Remove follower result item from POST /api/v6/copyTrading/trader/follower */ -export interface FuturesCopyTraderFollowerRemoveResult { - followerUid: string; - scode: string; - smsg: string; +/** Order value (only valid for market buy order) */ +⋮---- +/** Time in force: gtc, boc, ioc, fok. gtc=good till cancel, boc=book or cancel, ioc=immediate or cancel, fok=fill or kill. gtc for limit; ioc for market. */ +⋮---- +/** Order type: limit, market */ +⋮---- +/** Client order ID (max 64 chars). Must be unique within 24h for same user. */ +⋮---- +/** Stop price */ +⋮---- +/** Trailing rate [0.001-0.050]. Only valid for trailing stop order */ +⋮---- +export interface SpotV2AlgoOrdersOpeningReq { + /** Account ID */ + accountId?: number; + /** Trading symbol */ + symbol?: string; + /** Order side: buy, sell */ + orderSide?: 'buy' | 'sell'; + /** Order type: limit, market */ + orderType?: 'limit' | 'market'; + /** Sort: asc, desc. Default desc */ + sort?: 'asc' | 'desc'; + /** Max items [1-500]. Default 100 */ + limit?: number; + /** First record ID for next-page pagination */ + fromId?: number; } ⋮---- -/** Lead trading config from GET /api/v6/copyTrading/trader/config or POST follower-settings */ -export interface FuturesCopyTraderConfig { - instType: string; - enable: boolean; - profitSharingRatio: string; - maxFollowers: string; +/** Account ID */ +⋮---- +/** Trading symbol */ +⋮---- +/** Order side: buy, sell */ +⋮---- +/** Order type: limit, market */ +⋮---- +/** Sort: asc, desc. Default desc */ +⋮---- +/** Max items [1-500]. Default 100 */ +⋮---- +/** First record ID for next-page pagination */ +⋮---- +/** Req for GET /v2/algo-orders/history (Query conditional order history). orderStatus: canceled, rejected, triggered. */ +export interface SpotV2AlgoOrdersHistoryReq { + /** Account ID */ + accountId?: number; + /** Trading symbol */ + symbol?: string; + /** Order side: buy, sell */ + orderSide?: 'buy' | 'sell'; + /** Order type: limit, market */ + orderType?: 'limit' | 'market'; + /** Order status: canceled, rejected, triggered */ + orderStatus?: 'canceled' | 'rejected' | 'triggered'; + /** Start time (unix ms) */ + startTime?: number; + /** End time (unix ms) */ + endTime?: number; + /** Sort: asc, desc */ + sort?: 'asc' | 'desc'; + /** Max items [1-500] */ + limit?: number; + /** First record ID for next-page pagination */ + fromId?: number; } ⋮---- -/** Lead trading API key from POST /api/v6/copyTrading/trader/apikey */ -export interface FuturesCopyTraderApikey { - label: string; - accessKey: string; - secretKey: string; - perm: string[]; - ts: string; +/** Account ID */ +⋮---- +/** Trading symbol */ +⋮---- +/** Order side: buy, sell */ +⋮---- +/** Order type: limit, market */ +⋮---- +/** Order status: canceled, rejected, triggered */ +⋮---- +/** Start time (unix ms) */ +⋮---- +/** End time (unix ms) */ +⋮---- +/** Sort: asc, desc */ +⋮---- +/** Max items [1-500] */ +⋮---- +/** First record ID for next-page pagination */ +⋮---- +/** + * Margin Loan (Cross/Isolated) + */ +⋮---- +/** Req for GET /v2/account/repayment (Repayment Record Reference). Sorted by repayTime. */ +export interface SpotRepaymentRecordReq { + /** Repayment transaction ID */ + repayId?: string; + /** Account ID. Default all accounts */ + accountId?: string; + /** Borrowing/lending currency. Default all currencies */ + currency?: string; + /** Start time (unix ms). Range: [(endTime – x D), endTime] */ + startTime?: number; + /** End time (unix ms). Range: [(now – y D), now]. Default now */ + endTime?: number; + /** Sort: asc, desc. Default desc */ + sort?: 'asc' | 'desc'; + /** Max items [1-100]. Default 50 */ + limit?: number; + /** Search ID for next-page pagination */ + fromId?: number; } - -================ -File: README.md -================ -# Node.js & JavaScript SDK for HTX REST APIs & WebSockets - -[![Build & Test](https://github.com/sieblyio/htx-api/actions/workflows/e2etest.yml/badge.svg?branch=main)](https://github.com/sieblyio/htx-api/actions/workflows/e2etest.yml) -[![npm version](https://img.shields.io/npm/v/%40siebly%2Fhtx-api)][1] -[![npm size](https://img.shields.io/bundlephobia/min/%40siebly%2Fhtx-api/latest)][1] -[![npm downloads](https://img.shields.io/npm/dt/%40siebly%2Fhtx-api)][1] -[![last commit](https://img.shields.io/github/last-commit/sieblyio/htx-api)][1] -[![Telegram](https://img.shields.io/badge/chat-on%20telegram-blue.svg)](https://t.me/nodetraders) -[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/sieblyio/htx-api) - -

- - - - SDK Logo - - -

- -[1]: https://www.npmjs.com/package/@siebly/htx-api - -Complete & robust JavaScript & Node.js SDK for the HTX REST APIs and WebSockets: - -- Professional, robust & complete HTX SDK for all JavaScript runtimes. -- Complete integration with HTX REST APIs and WebSockets. - - Dedicated REST clients for Spot and Derivatives (linear swap, coin swap, delivery futures) - - Unified WebSocket client for all markets -- Complete TypeScript support (with type declarations for most API requests & responses). - - Strongly typed requests and responses. - - Automated end-to-end tests ensuring reliability. -- Actively maintained with a modern, promise-driven interface. -- Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows. - - Event driven messaging. - - Smart WebSocket persistence with automatic reconnection handling. - - Emit `reconnected` event when dropped connection is restored. - - Support for both public and private WebSocket streams. -- Portable HMAC signing support for trusted server-side runtimes. -- Automatically supports both ESM and CJS projects. -- Heavy automated end-to-end testing with real API calls. -- Proxy support via axios integration. -- Active community support & collaboration in telegram: [Node.js Algo Traders](https://t.me/nodetraders). -- Looking to get started as soon as possible? Review our [HTX JavaScript QuickStart Guide](https://siebly.io/sdk/htx/javascript) on our website. -- Looking to learn about all product groups & features? Review our [HTX JavaScript Tutorial](https://siebly.io/sdk/htx/javascript/tutorial) on our website. - -## Table of Contents - -- [Installation](#installation) -- [Examples](#examples) -- [Issues & Discussion](#issues--discussion) -- [Related Projects](#related-projects) -- [Documentation](#documentation) -- [Structure](#structure) -- [Usage](#usage) - - [REST API Clients](#rest-api) - - [Spot Trading](#spot-trading) - - [Derivatives (Futures) Trading](#derivatives-futures-trading) - - [WebSockets](#websockets) - - [Public WebSocket Streams](#public-websocket-streams) - - [Private WebSocket Streams](#private-websocket-streams) - - [WebSocket API (WebsocketAPIClient)](#websocket-api-websocketapiclient) -- [Customise Logging](#customise-logging) -- [Browser/Frontend Usage](#browserfrontend-usage) - - [React and Vite](#react-and-vite) - - [Webpack](#webpack) - - [Browser Requirements](#browser-requirements) - - [Security and CORS](#security-and-cors) -- [LLMs & AI](#use-with-llms--ai) -- [Used By](#used-by) -- [Contributions & Thanks](#contributions--thanks) - -## Installation - -`npm install --save @siebly/htx-api` - -Node.js usage requires Node 22.13.0 or newer. Browser applications should follow the public-data and credential-safety guidance below. - -## Examples - -Refer to the [examples](./examples) folder for implementation demos, including: - -- **Spot WebSocket Examples**: public and private market/account streams -- **Derivatives WebSocket Examples**: linear swap, coin swap, delivery futures, and index streams - -## Issues & Discussion - -- Issues? Check the [issues tab](https://github.com/sieblyio/htx-api/issues). -- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram. -- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/sieblyio) - - - -## Related Projects - -Check out our JavaScript/TypeScript/Node.js SDKs & Projects: - -- Visit our website: [https://Siebly.io](https://siebly.io/) -- Try our REST API & WebSocket SDKs published on npmjs: - - [Bybit JavaScript SDK: bybit-api](https://www.npmjs.com/package/bybit-api) - - [Kraken JavaScript SDK: @siebly/kraken-api](https://www.npmjs.com/package/@siebly/kraken-api) - - [OKX JavaScript SDK: okx-api](https://www.npmjs.com/package/okx-api) - - [Binance JavaScript SDK: binance](https://www.npmjs.com/package/binance) - - [Gate (gate.com) JavaScript SDK: gateio-api](https://www.npmjs.com/package/gateio-api) - - [Bitget JavaScript SDK: bitget-api](https://www.npmjs.com/package/bitget-api) - - [Kucoin JavaScript SDK: kucoin-api](https://www.npmjs.com/package/kucoin-api) - - [Coinbase JavaScript SDK: coinbase-api](https://www.npmjs.com/package/coinbase-api) - - [HTX JavaScript SDK: @siebly/htx-api](https://www.npmjs.com/package/@siebly/htx-api) -- Try my misc utilities: - - [OrderBooks Node.js: orderbooks](https://www.npmjs.com/package/orderbooks) - - [Crypto Exchange Account State Cache: accountstate](https://www.npmjs.com/package/accountstate) -- Check out my examples: - - [awesome-crypto-examples Node.js](https://github.com/sieblyio/awesome-crypto-examples) - - -## Documentation - -Most methods accept JS objects. These can be populated using parameters specified by HTX's API documentation, or check the type definition in each class within this repository. - -### API Documentation Links - -- [HTX API Documentation](https://www.htx.com/en-us/opend/newApiPages/) - - [Spot Trading API](https://www.htx.com/en-us/opend/newApiPages/) - - [Derivatives Trading API](https://www.htx.com/en-us/opend/newApiPages/) -- [REST Endpoint Function List](./docs/endpointFunctionList.md) - -## Structure - -This project uses typescript. Resources are stored in 2 key structures: - -- [src](./src) - the whole connector written in typescript -- [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome! - ---- - -# Usage - -Create API credentials on HTX's website: - -- [HTX API Key Management](https://www.htx.com/apikey/) - -## REST API - -The SDK provides dedicated REST clients for different trading products: - -- **SpotClient** - for spot trading, margin, earn, sub-accounts, and account operations -- **FuturesClient** - for linear swap, coin swap, delivery futures, and copy trading operations - -Both clients default to HTX's AWS CDN domains for better connectivity. You can override this via `baseUrlKey` in the client options if needed. - -### Spot Trading - -To use HTX's Spot APIs, import (or require) the `SpotClient`: - -```javascript -import { SpotClient } from '@siebly/htx-api'; -// or if you prefer require: -// const { SpotClient } = require('@siebly/htx-api'); - -// For public endpoints, API credentials are optional -const publicClient = new SpotClient(); - -// For private endpoints, provide API credentials -const client = new SpotClient({ - apiKey: 'your-api-key', - apiSecret: 'your-api-secret', -}); - -// Public API Examples - -// Get ticker information -const ticker = await publicClient.getTicker({ - symbol: 'btcusdt', -}); -console.log('Ticker: ', ticker); - -// Get order book -const orderBook = await publicClient.getMarketDepth({ - symbol: 'btcusdt', - depth: 10, -}); -console.log('Order Book: ', orderBook); - -// Private API Examples (requires authentication) - -// Get accounts and balances -client - .getAccounts() - .then(async (accounts) => { - console.log('Accounts: ', accounts); - - const accountId = accounts.data?.[0]?.id; - if (accountId) { - const balance = await client.getAccountBalance({ accountId }); - console.log('Account Balance: ', balance); - } - }) - .catch((err) => { - console.error('Error: ', err); - }); - -// Submit a limit order -client - .submitOrder({ - 'account-id': 'your-account-id', // Retrievable via getAccounts() as shown above - symbol: 'btcusdt', - type: 'buy-limit', - amount: '0.0001', - price: '10000', - 'client-order-id': client.generateNewOrderID(), - }) - .then((result) => { - console.log('Limit Order Result: ', result); - }) - .catch((err) => { - console.error('Error: ', err); - }); - -// Submit batch of orders (max 10 per batch) -client - .submitBatchOrders([ - { - 'account-id': 'your-account-id', // Retrievable via getAccounts() as shown above - symbol: 'btcusdt', - type: 'buy-limit', - amount: '0.0001', - price: '10000.00', - 'client-order-id': client.generateNewOrderID(), - }, - { - 'account-id': 'your-account-id', - symbol: 'btcusdt', - type: 'sell-limit', - amount: '0.0001', - price: '13000.00', - 'client-order-id': client.generateNewOrderID(), - }, - ]) - .then((result) => { - console.log('Batch Order Result: ', JSON.stringify(result, null, 2)); - }) - .catch((err) => { - console.error('Error: ', err); - }); -``` - -See [SpotClient](./src/SpotClient.ts) for further information. - -### Derivatives (Futures) Trading - -Use the `FuturesClient` for futures and swap trading operations: - -```javascript -import { FuturesClient } from '@siebly/htx-api'; -// or if you prefer require: -// const { FuturesClient } = require('@siebly/htx-api'); - -// For public endpoints, API credentials are optional -const publicClient = new FuturesClient(); - -// For private endpoints, provide API credentials -const client = new FuturesClient({ - apiKey: 'your-api-key', - apiSecret: 'your-api-secret', -}); - -// Public API Examples - -// Get order book for a specific contract -const orderBook = await publicClient.getLinearSwapMarketDepth({ - contract_code: 'BTC-USDT', - type: 'step0', -}); -console.log('Futures Order Book: ', orderBook); - -// Get ticker information -const ticker = await publicClient.getLinearSwapTicker({ - contract_code: 'BTC-USDT', -}); -console.log('Futures Ticker: ', ticker); - -// Private API Examples (requires authentication) - -// Get cross margin account info -client - .getLinearSwapCrossAccountInfo() - .then((accounts) => { - console.log('Cross Account Info: ', accounts); - }) - .catch((err) => { - console.error('Error: ', err); - }); - -// Submit a cross margin limit order -client - .submitLinearSwapCrossOrder({ - contract_code: 'BTC-USDT', - direction: 'buy', - volume: 1, - lever_rate: 5, - order_price_type: 'limit', - price: 10000, - }) - .then((result) => { - console.log('Limit Order Result: ', JSON.stringify(result, null, 2)); - }) - .catch((err) => { - console.error('Error: ', err); - }); -``` - -See [FuturesClient](./src/FuturesClient.ts) for further information. - -## WebSockets - -HTX supports two types of WebSocket connections: - -1. **WebSocket Subscriptions** - Real-time market data and account updates via the `WebsocketClient` -2. **WebSocket API** - REST-like request/response trading via `WebsocketAPIClient` or `sendWSAPIRequest()` - -### WebSocket Subscriptions (WebsocketClient) - -The unified `WebsocketClient` handles all HTX WebSocket streams with automatic connection management and reconnection. - -Key WebSocket features: - -- Event driven messaging -- Smart WebSocket persistence with automatic reconnection -- Heartbeat mechanisms to detect disconnections -- Automatic resubscription after reconnection -- Support for Spot and Derivatives markets (linear swap, coin swap, delivery) -- Support for both public and private WebSocket streams - -Each connection is tracked using a `WsKey` (see [WS_KEY_MAP](./src/lib/websocket/websocket-util.ts)). Pass the appropriate `WsKey` when subscribing so the client routes your request to the correct endpoint. - -### Public WebSocket Streams - -For public market data, API credentials are not required: - -```javascript -import { WebsocketClient, WS_KEY_MAP } from '@siebly/htx-api'; -// or if you prefer require: -// const { WebsocketClient, WS_KEY_MAP } = require('@siebly/htx-api'); - -// Create WebSocket client for public streams -const wsClient = new WebsocketClient(); - -// Set up event handlers -wsClient.on('open', (data) => { - console.log('WebSocket connected: ', data?.wsKey); -}); - -wsClient.on('message', (data) => { - console.log('Data received: ', JSON.stringify(data, null, 2)); -}); - -wsClient.on('reconnected', (data) => { - console.log('WebSocket reconnected: ', data); -}); - -wsClient.on('exception', (data) => { - console.error('WebSocket error: ', data); -}); - -// Spot - Subscribe to public data streams -wsClient.subscribe( - [ - 'market.btcusdt.kline.1min', - 'market.btcusdt.ticker', - 'market.btcusdt.depth.step0', - 'market.btcusdt.trade.detail', - ], - WS_KEY_MAP.spotPublic, -); - -// Spot feed - high-frequency topics such as BBO and MBP -wsClient.subscribe( - ['market.btcusdt.mbp.5', 'market.btcusdt.trade.detail'], - WS_KEY_MAP.spotFeed, -); - -// Linear swap (USDT-margined) public streams -wsClient.subscribe( - [ - 'market.BTC-USDT.kline.1min', - 'market.BTC-USDT.detail', - 'market.BTC-USDT.trade.detail', - 'market.BTC-USDT.bbo', - ], - WS_KEY_MAP.linearSwapPublic, -); - -// Derivatives index/mark price streams -wsClient.subscribe( - ['market.BTC-USDT.index.1min', 'market.BTC-USDT.mark_price.1min'], - WS_KEY_MAP.derivativesIndex, -); -``` - -### Private WebSocket Streams - -For private account data streams, API credentials are required: - -```javascript -import { WebsocketClient, WS_KEY_MAP } from '@siebly/htx-api'; - -// Create WebSocket client with API credentials for private streams -const wsClient = new WebsocketClient({ - apiKey: 'your-api-key', - apiSecret: 'your-api-secret', -}); - -// Set up event handlers -wsClient.on('open', (data) => { - console.log('Private WebSocket connected: ', data?.wsKey); -}); - -wsClient.on('message', (data) => { - console.log('Private data received: ', JSON.stringify(data, null, 2)); -}); - -wsClient.on('authenticated', (data) => { - console.log('WebSocket authenticated: ', data); -}); - -wsClient.on('response', (data) => { - console.log('WebSocket response: ', data); -}); - -wsClient.on('exception', (data) => { - console.error('WebSocket error: ', data); -}); - -// Spot - Subscribe to private data streams -// Note: SDK automatically handles authentication before subscribing -wsClient.subscribe( - ['accounts.update#1', 'orders#btcusdt', 'trade.clearing#btcusdt#0'], - WS_KEY_MAP.spotPrivateV2, -); - -// Linear swap private streams -wsClient.subscribe( - ['orders.BTC-USDT', 'accounts.BTC-USDT', 'positions.BTC-USDT'], - WS_KEY_MAP.linearSwapPrivate, -); -``` - -For more comprehensive examples, including custom logging and error handling, check the [examples](./examples/Spot/WebSockets) and [examples](./examples/Derivatives/WebSockets) folders. - -### WebSocket API (WebsocketAPIClient) - -Use `WebsocketAPIClient` for typed REST-like trading methods over a persisted WebSocket connection, or call `WebsocketClient.sendWSAPIRequest()` directly for lower-level control. - -Trade connections connect and authenticate lazily on the first request. Optional pre-connect: `client.getWSClient().connectWSAPI(WS_KEY_MAP.spotTrade)`. - -Trade keys: `spotTrade`, `linearSwapTrade`, `coinDeliveryTrade`, `coinSwapTrade`. - -```javascript -import { WebsocketAPIClient, WS_KEY_MAP } from '@siebly/htx-api'; - -const client = new WebsocketAPIClient({ - apiKey: 'your-api-key', - apiSecret: 'your-api-secret', -}); - -// Spot -const order = await client.submitSpotOrder({ - 'account-id': 123456, - symbol: 'btcusdt', - type: 'buy-limit', - amount: '0.001', - price: '20000', - source: 'spot-api', -}); - -// Derivatives -const linearOrder = await client.placeLinearSwapOrder({ - contract_code: 'BTC-USDT', - margin_mode: 'cross', - position_side: 'long', - side: 'buy', - type: 'limit', - time_in_force: 'gtc', - price: '20000', - volume: '1', - reduce_only: 0, -}); -``` - -See [WebsocketAPIClient](./src/WebsocketAPIClient.ts) for all typed methods. Examples: [Spot](./examples/Spot/WebSockets/wsAPI.ts), [Derivatives](./examples/Derivatives/WebSockets/wsAPI.ts), [raw spot](./examples/Spot/WebSockets/wsAPI.RAW.ts), [raw derivatives](./examples/Derivatives/WebSockets/wsAPI.RAW.ts). - ---- - -## Customise Logging - -Pass a custom logger which supports the log methods `trace`, `info` and `error`, or override methods from the default logger as desired. - -```javascript -import { WebsocketClient, DefaultLogger } from '@siebly/htx-api'; - -// E.g. customise logging for only the trace level: -const customLogger = { - ...DefaultLogger, - trace: (...params) => { - // console.log('trace', ...params); - }, - info: (...params) => { - console.log('info', ...params); - }, - error: (...params) => { - console.error('error', ...params); - }, -}; - -const ws = new WebsocketClient( - { - apiKey: 'apiKeyHere', - apiSecret: 'apiSecretHere', - }, - customLogger, -); -``` - -In rare situations, you may want to see the raw HTTP requests being built as well as the API response. These can be enabled by setting the `HTXTRACE` env var to `true`. - -## Browser/Frontend Usage - -The package's ESM entry can be imported directly by modern frontend bundlers. Do not build or copy a separate SDK bundle into your application. - -Browser applications should use the SDK only for public market data. Keep API keys, API secrets, authenticated REST calls, private WebSocket subscriptions, and WebSocket API trading on a trusted backend. - -### React and Vite - -Install and import the package normally; no SDK-specific Vite plugin or Node.js polyfill is required: - -```bash -npm install @siebly/htx-api -``` - -```tsx -import { useEffect, useState } from 'react'; -import { SpotClient, WebsocketClient, WS_KEY_MAP } from '@siebly/htx-api'; - -export function BtcTicker() { - const [ticker, setTicker] = useState(); - - useEffect(() => { - const restClient = new SpotClient(); - const wsClient = new WebsocketClient(); - - restClient.getTicker({ symbol: 'btcusdt' }).then(setTicker); - - const onMessage = (message: unknown) => setTicker(message); - wsClient.on('message', onMessage); - wsClient.subscribe('market.btcusdt.ticker', WS_KEY_MAP.spotPublic); - - return () => { - wsClient.off('message', onMessage); - wsClient.closeAll(); - }; - }, []); - - return
{JSON.stringify(ticker, null, 2)}
; -} -``` - -The cleanup is important during navigation, hot reloads, and React Strict Mode development checks so that an old socket is not left reconnecting in the background. - -### Webpack - -Webpack 5 can consume the same package entry directly: - -```javascript -import { SpotClient, WebsocketClient } from '@siebly/htx-api'; -``` - -Use a normal `target: 'web'` application build. The SDK does not require a checked-in UMD bundle or `resolve.fallback` shims for Node.js core modules. - -Direct `