diff --git a/package-lock.json b/package-lock.json index 53c19a3..5c86bb6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "2.0.13", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "2.0.13", + "version": "2.1.0", "license": "MIT", "dependencies": { "axios": "^1.6.1", diff --git a/package.json b/package.json index 000cd02..d5d362e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "2.0.13", + "version": "2.1.0", "description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index f5b9082..5774191 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -5,7 +5,136 @@ import { FuturesCandlesRequestV2, SpotCandlesRequestV2, SpotAccountBill, + SpotHistoricCandlesRequestV2, + SpotHistoricTradesRequestV2, + SpotOrderRequestV2, + SpotCancelandSubmitOrderRequestV2, + SpotCancelOrderRequestV2, + SpotBatchOrderRequestV2, + SpotBatchCancelOrderRequestV2, + GetSpotOrderInfoRequestV2, + GetSpotOpenOrdersRequestV2, + GetSpotHistoryOrdersRequestV2, + GetSpotFillsRequestV2, + SpotPlanOrderRequestV2, + SpotModifyPlanOrderRequestV2, + GetSpotCurrentPlanOrdersRequestV2, + GetSpotHistoryPlanOrdersRequestV2, + GetSpotAccountBillsRequestV2, + SpotTransferRequestV2, + SpotAccountTypeV2, + SpotSubAccountTransferRequestV2, + SpotWithdrawalRequestV2, + SpotMainSubTransferRecordRequestV2, + GetSpotTransferRecordRequestV2, + GetSpotSubAccountDepositRecordRequestV2, + GetSpotWithdrawalRecordRequestV2, + GetSpotDepositRecordRequestV2, + FuturesMergeDepthRequestV2, + FuturesProductTypeV2, + FuturesRecentTradesRequestV2, + FuturesHistoricTradesRequestV2, + FuturesSingleAccountRequestV2, + FuturesInterestHistoryRequestV2, + FuturesOpenCountRequestV2, + FuturesSetAutoMarginRequestV2, + FuturesSetLeverageRequestV2, + FuturesSetPositionMarginRequestV2, + FuturesSetMarginModeRequestV2, + FuturesHistoricalPositionsRequestV2, + FuturesPlaceOrderRequestV2, + FuturesReversalOrderRequestV2, + FuturesBatchOrderRequestV2, + FuturesModifyOrderRequestV2, + FuturesCancelOrderRequestV2, + FuturesBatchCancelOrderRequestV2, + FuturesFlashClosePositionsRequestV2, + FuturesGetOrderRequestV2, + FuturesGetOrderFillsRequestV2, + FuturesGetHistoricalFillsRequestV2, + FuturesGetOpenOrdersRequestV2, + FuturesGetHistoryOrdersRequestV2, + FuturesCancelAllOrdersRequestV2, + FuturesTPSLOrderRequestV2, + FuturesPlanOrderRequestV2, + FuturesModifyTPSLOrderRequestV2, + FuturesModifyPlanOrderRequestV2, + FuturesGetPlanOrdersRequestV2, + FuturesCancelPlanOrderRequestV2, + FuturesGetHistoryPlanOrdersRequestV2, + GetBorrowHistoryRequestV2, + GetRepayHistoryRequestV2, + GetInterestHistoryRequestV2, + GetLiquidationHistoryRequestV2, + GetFinancialHistoryRequestV2, + MarginPlaceOrderRequestV2, + MarginBatchOrdersRequestV2, + GetMarginCurrentOrdersRequestV2, + GetHistoryOrdersRequestV2, + GetMarginOrderFillsRequestV2, + GetMarginLiquidationOrdersRequestV2, + GetFuturesTraderCurrentOrdersRequestV2, + GetFuturesTraderHistoryOrdersRequestV2, + ModifyFuturesTraderOrderTPSLRequestV2, + GetFuturesTraderProfitShareDetailRequestV2, + CopyTradingProductTypeV2, + FuturesTraderSymbolSettingRequestV2, + GetFuturesTraderFollowersRequestV2, + GetFollowerFuturesCurrentTrackingOrdersRequestV2, + GetFollowerFuturesHistoryTrackingOrdersRequestV2, + UpdateFuturesFollowerTPSLRequestV2, + UpdateFuturesFollowerSettingsRequestV2, + GetFuturesFollowerTradersRequestV2, + CloseFuturesFollowerPositionsRequestV2, + GetSpotTraderHistoryProfitRequestV2, + GetSpotTraderHistoryOrdersRequestV2, + GetSpotTraderCurrentOrdersRequestV2, + GetSpotTraderFollowersRequestV2, + SpotFollowerCopyTradeSettingV2, + GetSpotFollowerHistoryOrdersRequestV2, + GetSpotFollowerOpenOrdersRequestV2, + GetEarnSavingsAssetsRequestV2, + GetEarnSavingsRecordsRequestV2, + RedeemSavingsRequestV2, + GetSharkfinAssetsRequestV2, + GetSharkfinRecordsRequestV2, + GetLoanEstInterestAndBorrowableRequestV2, + BorrowLoanRequestV2, + RepayLoanRequestV2, + GetLoanRepayHistoryRequestV2, + ModifyLoanPledgeRateRequestV2, + GetLoanPledgeRateHistoryRequestV2, + GetLoanHistoryRequestV2, + GetLiquidationRecordsRequestV2, } from './types'; +import { + CreateSubAccountApiKeyRequestV2, + GetSubAccountsRequestV2, + ModifySubAccountApiKeyRequestV2, + ModifySubRequestV2, + SubDepositRecordsRequestV2, + SubWithdrawalRecordsRequestV2, + SubWithdrawalRequestV2, +} from './types/request/v2/broker'; +import { + ConvertQuoteRequestV2, + ConvertRequestV2, + CreateVirtualSubApiKeyRequestV2, + CreateVirtualSubRequestV2, + GetAnnouncementsRequestV2, + GetConvertHistoryRequestV2, + GetFuturesTransactionsRequestV2, + GetMarginTransactionsRequestV2, + GetMerchantAdvertisementsRequestV2, + GetMerchantP2POrdersRequestV2, + GetP2PMerchantsRequestV2, + GetP2PTransactionsRequestV2, + GetSpotTransactionsRequestV2, + GetTradeRateRequestV2, + ModifyVirtualSubRequestV2, + ModifyVirtualSubApiKeyRequestV2, + GetConvertBGBHistoryRequestV2, +} from './types/request/v2/common'; import { REST_CLIENT_TYPE_ENUM, assertMarginType } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -105,8 +234,10 @@ export class RestClientV2 extends BaseRestClient { * */ - getAnnouncements(): Promise> { - return this.get(`/api/v2/public/annoucements`); + getAnnouncements( + params?: GetAnnouncementsRequestV2, + ): Promise> { + return this.get(`/api/v2/public/annoucements`, params); } /** @@ -119,7 +250,7 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/public/time`); } - getTradeRate(params: object): Promise> { + getTradeRate(params: GetTradeRateRequestV2): Promise> { return this.getPrivate(`/api/v2/common/trade-rate`, params); } @@ -129,19 +260,27 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotTransactionRecords(params: object): Promise> { + getSpotTransactionRecords( + params: GetSpotTransactionsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/tax/spot-record`, params); } - getFuturesTransactionRecords(params: object): Promise> { + getFuturesTransactionRecords( + params: GetFuturesTransactionsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/tax/future-record`, params); } - getMarginTransactionRecords(params: object): Promise> { + getMarginTransactionRecords( + params: GetMarginTransactionsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/tax/margin-record`, params); } - getP2PTransactionRecords(params: object): Promise> { + getP2PTransactionRecords( + params: GetP2PTransactionsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/tax/p2p-record`, params); } @@ -151,7 +290,9 @@ export class RestClientV2 extends BaseRestClient { * */ - getP2PMerchantList(params?: object): Promise> { + getP2PMerchantList( + params?: GetP2PMerchantsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/p2p/merchantList`, params); } @@ -159,11 +300,15 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/p2p/merchantInfo`); } - getP2PMerchantOrders(params: object): Promise> { + getP2PMerchantOrders( + params: GetMerchantP2POrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/p2p/orderList`, params); } - getP2PMerchantAdvertisementList(params: object): Promise> { + getP2PMerchantAdvertisementList( + params: GetMerchantAdvertisementsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/p2p/advList`, params); } @@ -173,53 +318,77 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotWhaleNetFlowData(params: object): Promise> { + getSpotWhaleNetFlowData(params: { + symbol: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/market/whale-net-flow`, params); } - getFuturesActiveTakerBuySellVolumeData( - params: object, - ): Promise> { + getFuturesActiveTakerBuySellVolumeData(params: { + symbol: string; + period?: string; + }): Promise> { return this.get(`/api/v2/mix/market/taker-buy-sell`, params); } - getFuturesActiveLongShortPositionData( - params: object, - ): Promise> { + getFuturesActiveLongShortPositionData(params: { + symbol: string; + period?: string; + }): Promise> { return this.get(`/api/v2/mix/market/position-long-short`, params); } - getFuturesLongShortRatio(params: object): Promise> { + getFuturesLongShortRatio(params: { + symbol: string; + period?: string; + coin?: string; + }): Promise> { return this.get(`/api/v2/mix/market/long-short-ratio`, params); } - getMarginLoanGrowthRate(params: object): Promise> { + getMarginLoanGrowthRate(params: { + symbol: string; + period?: string; + coin?: string; + }): Promise> { return this.get(`/api/v2/mix/market/loan-growth`, params); } - getIsolatedMarginBorrowingRatio(params: object): Promise> { + getIsolatedMarginBorrowingRatio(params: { + symbol: string; + period?: string; + }): Promise> { return this.get(`/api/v2/mix/market/isolated-borrow-rate`, params); } - getFuturesActiveBuySellVolumeData(params: object): Promise> { + getFuturesActiveBuySellVolumeData(params: { + symbol: string; + period?: string; + }): Promise> { return this.get(`/api/v2/mix/market/long-short`, params); } - getSpotFundFlow(): Promise> { - return this.get(`/api/v2/spot/market/fund-flow`); + getSpotFundFlow(params: { + symbol: string; + period?: string; + }): Promise> { + return this.get(`/api/v2/spot/market/fund-flow`, params); } getTradeDataSupportSymbols(): Promise> { return this.get(`/api/v2/spot/market/support-symbols`); } - getSpotFundNetFlowData(params: object): Promise> { + getSpotFundNetFlowData(params: { + symbol: string; + }): Promise> { return this.get(`/api/v2/spot/market/fund-net-flow`, params); } - getFuturesActiveLongShortAccountData( - params: object, - ): Promise> { + getFuturesActiveLongShortAccountData(params: { + symbol: string; + period?: string; + }): Promise> { return this.get(`/api/v2/mix/market/account-long-short`, params); } @@ -229,16 +398,20 @@ export class RestClientV2 extends BaseRestClient { * */ - createVirtualSubaccount(params: object): Promise> { + createVirtualSubaccount(params: { + subAccountList: string[]; + }): Promise> { return this.postPrivate(`/api/v2/user/create-virtual-subaccount`, params); } - modifyVirtualSubaccount(params: object): Promise> { + modifyVirtualSubaccount( + params: ModifyVirtualSubRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/user/modify-virtual-subaccount`, params); } batchCreateVirtualSubaccountAndAPIKey( - params: object, + params: CreateVirtualSubRequestV2, ): Promise> { return this.postPrivate( '/api/v2/user/batch-create-subaccount-and-apikey', @@ -246,25 +419,35 @@ export class RestClientV2 extends BaseRestClient { ); } - getVirtualSubaccounts(params?: object): Promise> { + getVirtualSubaccounts(params?: { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze'; + }): Promise> { return this.getPrivate(`/api/v2/user/virtual-subaccount-list`, params); } - createVirtualSubaccountAPIKey(params: object): Promise> { + createVirtualSubaccountAPIKey( + params: CreateVirtualSubApiKeyRequestV2, + ): Promise> { return this.postPrivate( '/api/v2/user/create-virtual-subaccount-apikey', params, ); } - modifyVirtualSubaccountAPIKey(params: object): Promise> { + modifyVirtualSubaccountAPIKey( + params: ModifyVirtualSubApiKeyRequestV2, + ): Promise> { return this.postPrivate( '/api/v2/user/modify-virtual-subaccount-apikey', params, ); } - getVirtualSubaccountAPIKeys(params: object): Promise> { + getVirtualSubaccountAPIKeys(params: { + subAccountUid: string; + }): Promise> { return this.getPrivate( '/api/v2/user/virtual-subaccount-apikey-list', params, @@ -276,11 +459,11 @@ export class RestClientV2 extends BaseRestClient { * * Common | Assets * */ - getFundingAssets(params?: object): Promise> { + getFundingAssets(params?: { coin?: string }): Promise> { return this.getPrivate(`/api/v2/account/funding-assets`, params); } - getBotAccount(params?: object): Promise> { + getBotAccount(params?: { accountType?: string }): Promise> { return this.getPrivate(`/api/v2/account/bot-assets`, params); } @@ -299,15 +482,19 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/convert/currencies`); } - getConvertQuotedPrice(params: object): Promise> { + getConvertQuotedPrice( + params: ConvertQuoteRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/convert/quoted-price`, params); } - convert(params: object): Promise> { + convert(params: ConvertRequestV2): Promise> { return this.postPrivate(`/api/v2/convert/trade`, params); } - getConvertHistory(params: object): Promise> { + getConvertHistory( + params: GetConvertHistoryRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/convert/convert-record`, params); } @@ -321,11 +508,13 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/convert/bgb-convert-coin-list`); } - convertBGB(params: object): Promise> { + convertBGB(params: { coinList: string }): Promise> { return this.postPrivate(`/api/v2/convert/bgb-convert`, params); } - getConvertBGBHistory(params: object): Promise> { + getConvertBGBHistory( + params: GetConvertBGBHistoryRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/convert/bgb-convert-records`, params); } @@ -343,11 +532,11 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotCoinInfo(params?: object): Promise> { + getSpotCoinInfo(params?: { coin?: string }): Promise> { return this.getPrivate(`/api/v2/spot/public/coins`, params); } - getSpotSymbolInfo(params?: object): Promise> { + getSpotSymbolInfo(params?: { symbol?: string }): Promise> { return this.getPrivate(`/api/v2/spot/public/symbols`, params); } @@ -355,15 +544,23 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/spot/market/vip-fee-rate`); } - getSpotTicker(params?: object): Promise> { + getSpotTicker(params?: { symbol?: string }): Promise> { return this.getPrivate(`/api/v2/spot/market/tickers`, params); } - getSpotMergeDepth(params: object): Promise> { + getSpotMergeDepth(params: { + symbol: string; + precision?: string; + limit?: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/market/merge-depth`, params); } - getSpotOrderBookDepth(params: object): Promise> { + getSpotOrderBookDepth(params: { + symbol: string; + type?: string; + limit?: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/market/orderbook`, params); } @@ -371,15 +568,22 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/spot/market/candles`, params); } - getSpotHistoricCandles(params: object): Promise> { + getSpotHistoricCandles( + params: SpotHistoricCandlesRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/market/history-candles`, params); } - getSpotRecentTrades(params: object): Promise> { + getSpotRecentTrades(params: { + symbol: string; + limit?: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/market/fills`, params); } - getSpotHistoricTrades(params: object): Promise> { + getSpotHistoricTrades( + params: SpotHistoricTradesRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/market/fills-history`, params); } @@ -389,39 +593,62 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitOrder(params: object): Promise> { + spotSubmitOrder(params: SpotOrderRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-order`, params); } - spotCancelOrder(params: object): Promise> { + spotCancelandSubmitOrder( + params: SpotCancelandSubmitOrderRequestV2, + ): Promise> { + return this.postPrivate(`/api/v2/spot/trade/cancel-replace-order`, params); + } + + spotBatchCancelandSubmitOrder(params: { + orderList: SpotCancelandSubmitOrderRequestV2[]; + }): Promise> { + return this.postPrivate( + `/api/v2/spot/trade/batch-cancel-replace-order`, + params, + ); + } + + spotCancelOrder(params: SpotCancelOrderRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-order`, params); } - spotBatchSubmitOrders(params: object): Promise> { + spotBatchSubmitOrders( + params: SpotBatchOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/batch-orders`, params); } - spotBatchCancelOrders(params: object): Promise> { + spotBatchCancelOrders( + params: SpotBatchCancelOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/batch-cancel-order`, params); } - spotCancelSymbolOrder(params: object): Promise> { + spotCancelSymbolOrder(params: { symbol: string }): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-symbol-order`, params); } - getSpotOrder(params: object): Promise> { + getSpotOrder(params?: GetSpotOrderInfoRequestV2): Promise> { return this.getPrivate(`/api/v2/spot/trade/orderInfo`, params); } - getSpotOpenOrders(params?: object): Promise> { + getSpotOpenOrders( + params?: GetSpotOpenOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/unfilled-orders`, params); } - getSpotHistoricOrders(params?: object): Promise> { + getSpotHistoricOrders( + params?: GetSpotHistoryOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/history-orders`, params); } - getSpotFills(params: object): Promise> { + getSpotFills(params: GetSpotFillsRequestV2): Promise> { return this.getPrivate(`/api/v2/spot/trade/fills`, params); } @@ -431,31 +658,46 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitPlanOrder(params: object): Promise> { + spotSubmitPlanOrder( + params: SpotPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-plan-order`, params); } - spotModifyPlanOrder(params: object): Promise> { + spotModifyPlanOrder( + params: SpotModifyPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/modify-plan-order`, params); } - spotCancelPlanOrder(params: object): Promise> { + spotCancelPlanOrder(params: { + clientOid?: string; + orderId?: string; + }): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-plan-order`, params); } - getSpotCurrentPlanOrders(params: object): Promise> { + getSpotCurrentPlanOrders( + params: GetSpotCurrentPlanOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/current-plan-order`, params); } - getSpotPlanSubOrder(params: object): Promise> { + getSpotPlanSubOrder(params: { + planOrderId: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/trade/plan-sub-order`, params); } - getSpotHistoricPlanOrders(params: object): Promise> { + getSpotHistoricPlanOrders( + params: GetSpotHistoryPlanOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/history-plan-order`, params); } - spotCancelPlanOrders(params?: object): Promise> { + spotCancelPlanOrders(params?: { + symbolList?: string[]; + }): Promise> { return this.postPrivate( '/api/v2/spot/trade/batch-cancel-plan-order', params, @@ -472,7 +714,10 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/spot/account/info`); } - getSpotAccountAssets(params?: object): Promise> { + getSpotAccountAssets(params?: { + coin?: string; + assetType?: string; + }): Promise> { return this.getPrivate(`/api/v2/spot/account/assets`, params); } @@ -480,90 +725,110 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/spot/account/subaccount-assets`); } - spotModifyDepositAccount(params: object): Promise> { + spotModifyDepositAccount(params: { + accountType: string; + coin: string; + }): Promise> { return this.postPrivate( `/api/v2/spot/wallet/modify-deposit-account`, params, ); } - getSpotAccountBills(params?: { - coin?: string; - groupType?: string; - businessType?: string; - startTime?: string; - endTime?: string; - limit?: string; - idLessThan?: string; - }): Promise> { + getSpotAccountBills( + params?: GetSpotAccountBillsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/spot/account/bills`, params); } - spotTransfer(params: object): Promise> { + spotTransfer(params: SpotTransferRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/wallet/transfer`, params); } - getSpotTransferableCoins(params: object): Promise> { + getSpotTransferableCoins(params: { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + }): Promise> { return this.getPrivate(`/api/v2/spot/wallet/transfer-coin-info`, params); } - spotSubTransfer(params: object): Promise> { + spotSubTransfer( + params: SpotSubAccountTransferRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/wallet/subaccount-transfer`, params); } - getSpotTransferHistory(params: object): Promise> { - return this.getPrivate(`/api/v2/spot/account/transferRecords`, params); - } - - spotSwitchBGBDeduct(params: object): Promise> { - return this.postPrivate(`/api/v2/spot/account/switch-deduct`, params); - } - - spotWithdraw(params: object): Promise> { + spotWithdraw(params: SpotWithdrawalRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/wallet/withdrawal`, params); } - getSpotDepositAddress(params: object): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/deposit-address`, params); - } - - getSpotSubDepositAddress(params: object): Promise> { - return this.getPrivate( - `/api/v2/spot/wallet/subaccount-deposit-address`, - params, - ); - } - - getSpotDepositHistory(params: object): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/deposit-records`, params); - } - - getSpotBGBDeductInfo(): Promise> { - return this.getPrivate(`/api/v2/spot/account/deduct-info`); - } - - spotCancelWithdrawal(params: object): Promise> { - return this.postPrivate(`/api/v2/spot/wallet/cancel-withdrawal`, params); - } - - getSpotWithdrawalHistory(params: object): Promise> { - return this.getPrivate(`/api/v2/spot/wallet/withdrawal-records`, params); - } - - getSpotMainSubTransferRecord(params: object): Promise> { + getSpotMainSubTransferRecord( + params: SpotMainSubTransferRecordRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/spot/account/sub-main-trans-record`, params, ); } - getSubAccountDepositRecords(params: object): Promise> { + getSpotTransferHistory( + params: GetSpotTransferRecordRequestV2, + ): Promise> { + return this.getPrivate(`/api/v2/spot/account/transferRecords`, params); + } + + spotSwitchBGBDeduct(params: { deduct: boolean }): Promise> { + return this.postPrivate(`/api/v2/spot/account/switch-deduct`, params); + } + + getSpotDepositAddress(params: { + coin: string; + chain?: string; + size: string; + }): Promise> { + return this.getPrivate(`/api/v2/spot/wallet/deposit-address`, params); + } + + getSpotSubDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; + size: string; + }): Promise> { + return this.getPrivate( + `/api/v2/spot/wallet/subaccount-deposit-address`, + params, + ); + } + getSpotBGBDeductInfo(): Promise> { + return this.getPrivate(`/api/v2/spot/account/deduct-info`); + } + + spotCancelWithdrawal(params: { orderId: string }): Promise> { + return this.postPrivate(`/api/v2/spot/wallet/cancel-withdrawal`, params); + } + + getSubAccountDepositRecords( + params: GetSpotSubAccountDepositRecordRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/spot/wallet/subaccount-deposit-records`, params, ); } + getSpotDepositHistory( + params: GetSpotDepositRecordRequestV2, + ): Promise> { + return this.getPrivate(`/api/v2/spot/wallet/deposit-records`, params); + } + + getSpotWithdrawalHistory( + params: GetSpotWithdrawalRecordRequestV2, + ): Promise> { + return this.getPrivate(`/api/v2/spot/wallet/withdrawal-records`, params); + } + /** * * @@ -582,15 +847,36 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/mix/market/vip-fee-rate`); } - getFuturesTicker(params: object): Promise> { + getFuturesInterestRateHistory(params: { + coin: string; + }): Promise> { + return this.get(`/api/v2/mix/market/union-interest-rate-history`, params); + } + + getFuturesTicker(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/ticker`, params); } - getFuturesAllTickers(params: object): Promise> { + getFuturesInterestExchangeRate(): Promise> { + return this.get(`/api/v2/mix/market/exchange-rate`); + } + + getFuturesDiscountRate(): Promise> { + return this.get(`/api/v2/mix/market/discount-rate`); + } + + getFuturesAllTickers(params: { + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/tickers`, params); } - getFuturesMergeDepth(params: object): Promise> { + getFuturesMergeDepth( + params: FuturesMergeDepthRequestV2, + ): Promise> { return this.get(`/api/v2/mix/market/merge-depth`, params); } @@ -600,51 +886,77 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/mix/market/candles`, params); } - getFuturesHistoricCandles(params: object): Promise> { + getFuturesHistoricCandles( + params: FuturesCandlesRequestV2, + ): Promise> { return this.get(`/api/v2/mix/market/history-candles`, params); } getFuturesHistoricIndexPriceCandles( - params: object, + params: FuturesCandlesRequestV2, ): Promise> { return this.get(`/api/v2/mix/market/history-index-candles`, params); } getFuturesHistoricMarkPriceCandles( - params: object, + params: FuturesCandlesRequestV2, ): Promise> { return this.get(`/api/v2/mix/market/history-mark-candles`, params); } - getFuturesRecentTrades(params: object): Promise> { + getFuturesRecentTrades( + params: FuturesRecentTradesRequestV2, + ): Promise> { return this.get(`/api/v2/mix/market/fills`, params); } - getFuturesHistoricTrades(params: object): Promise> { + getFuturesHistoricTrades( + params: FuturesHistoricTradesRequestV2, + ): Promise> { return this.get(`/api/v2/mix/market/fills-history`, params); } - getFuturesOpenInterest(params: object): Promise> { + getFuturesOpenInterest(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/open-interest`, params); } - getFuturesNextFundingTime(params: object): Promise> { + getFuturesNextFundingTime(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/funding-time`, params); } - getFuturesSymbolPrice(params: object): Promise> { + getFuturesSymbolPrice(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/symbol-price`, params); } - getFuturesHistoricFundingRates(params: object): Promise> { + getFuturesHistoricFundingRates(params: { + symbol: string; + productType: FuturesProductTypeV2; + pageSize?: string; + pageNumber?: string; + }): Promise> { return this.get(`/api/v2/mix/market/history-fund-rate`, params); } - getFuturesCurrentFundingRate(params: object): Promise> { + getFuturesCurrentFundingRate(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/current-fund-rate`, params); } - getFuturesContractConfig(params: object): Promise> { + getFuturesContractConfig(params: { + symbol: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.get(`/api/v2/mix/market/contracts`, params); } @@ -654,39 +966,71 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesAccountAsset(params: object): Promise> { + getFuturesAccountAsset( + params: FuturesSingleAccountRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/account/account`, params); } - getFuturesAccountAssets(params: object): Promise> { + getFuturesAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise> { return this.getPrivate(`/api/v2/mix/account/accounts`, params); } - getFuturesSubAccountAssets(params: object): Promise> { + getFuturesSubAccountAssets(params: { + productType: FuturesProductTypeV2; + }): Promise> { return this.getPrivate(`/api/v2/mix/account/sub-account-assets`, params); } - getFuturesOpenCount(params: object): Promise> { + getFuturesInterestHistory( + params: FuturesInterestHistoryRequestV2, + ): Promise> { + return this.getPrivate(`/api/v2/mix/account/interest-history`, params); + } + + getFuturesOpenCount( + params: FuturesOpenCountRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/account/open-count`, params); } - setFuturesLeverage(params: object): Promise> { + setFuturesLeverage( + params: FuturesSetLeverageRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/account/set-leverage`, params); } - setFuturesPositionAutoMargin(params: object): Promise> { + setFuturesPositionAutoMargin( + params: FuturesSetAutoMarginRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/account/set-auto-margin`, params); } - setFuturesPositionMargin(params: object): Promise> { + setFuturesPositionMargin( + params: FuturesSetPositionMarginRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/account/set-margin`, params); } - setFuturesMarginMode(params: object): Promise> { + setFuturesAssetMode(params: { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + assetMode: 'single' | 'union'; + }): Promise> { + return this.postPrivate(`/api/v2/mix/account/set-asset-mode`, params); + } + + setFuturesMarginMode( + params: FuturesSetMarginModeRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/account/set-margin-mode`, params); } - setFuturesPositionMode(params: object): Promise> { + setFuturesPositionMode(params: { + productType: FuturesProductTypeV2; + posMode: 'one_way_mode' | 'hedge_mode'; + }): Promise> { return this.postPrivate(`/api/v2/mix/account/set-position-mode`, params); } @@ -702,19 +1046,31 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesPositionTier(params: object): Promise> { + getFuturesPositionTier(params: { + productType: FuturesProductTypeV2; + symbol: string; + }): Promise> { return this.get(`/api/v2/mix/market/query-position-lever`, params); } - getFuturesPosition(params: object): Promise> { + getFuturesPosition(params: { + productType: FuturesProductTypeV2; + symbol: string; + marginCoin: string; + }): Promise> { return this.getPrivate(`/api/v2/mix/position/single-position`, params); } - getFuturesPositions(params: object): Promise> { + getFuturesPositions(params: { + productType: FuturesProductTypeV2; + marginCoin?: string; + }): Promise> { return this.getPrivate(`/api/v2/mix/position/all-position`, params); } - getFuturesHistoricPositions(params?: object): Promise> { + getFuturesHistoricPositions( + params?: FuturesHistoricalPositionsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/position/history-position`, params); } @@ -724,55 +1080,79 @@ export class RestClientV2 extends BaseRestClient { * */ - futuresSubmitOrder(params: object): Promise> { + futuresSubmitOrder( + params: FuturesPlaceOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/place-order`, params); } - futuresCancelOrder(params: object): Promise> { + futuresCancelOrder( + params: FuturesCancelOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/cancel-order`, params); } - futuresSubmitReversal(params: object): Promise> { + futuresSubmitReversal( + params: FuturesReversalOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/click-backhand`, params); } - futuresBatchSubmitOrders(params: object): Promise> { + futuresBatchSubmitOrders( + params: FuturesBatchOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/batch-place-order`, params); } - futuresModifyOrder(params: object): Promise> { + futuresModifyOrder( + params: FuturesModifyOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/modify-order`, params); } - futuresBatchCancelOrders(params: object): Promise> { + futuresBatchCancelOrders( + params: FuturesBatchCancelOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/batch-cancel-orders`, params); } - futuresFlashClosePositions(params: object): Promise> { + futuresFlashClosePositions( + params: FuturesFlashClosePositionsRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/close-positions`, params); } - getFuturesOrder(params: object): Promise> { + getFuturesOrder(params: FuturesGetOrderRequestV2): Promise> { return this.getPrivate(`/api/v2/mix/order/detail`, params); } - getFuturesFills(params: object): Promise> { + getFuturesFills( + params: FuturesGetOrderFillsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/fills`, params); } - getFuturesHistoricOrderFills(params: object): Promise> { + getFuturesHistoricOrderFills( + params: FuturesGetHistoricalFillsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/fill-history`, params); } - getFuturesOpenOrders(params: object): Promise> { + getFuturesOpenOrders( + params: FuturesGetOpenOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/orders-pending`, params); } - getFuturesHistoricOrders(params: object): Promise> { + getFuturesHistoricOrders( + params: FuturesGetHistoryOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/orders-history`, params); } - futuresCancelAllOrders(params: object): Promise> { + futuresCancelAllOrders( + params: FuturesCancelAllOrdersRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/cancel-all-orders`, params); } @@ -782,35 +1162,53 @@ export class RestClientV2 extends BaseRestClient { * */ - futuresSubmitPlanSubOrder(params: object): Promise> { + futuresSubmitPlanSubOrder(params: { + planType: 'normal_plan' | 'track_plan'; + planOrderId: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.postPrivate(`/api/v2/mix/order/plan-sub-order`, params); } - futuresSubmitTPSLOrder(params: object): Promise> { + futuresSubmitTPSLOrder( + params: FuturesTPSLOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/place-tpsl-order`, params); } - futuresSubmitPlanOrder(params: object): Promise> { + futuresSubmitPlanOrder( + params: FuturesPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/place-plan-order`, params); } - futuresModifyTPSLPOrder(params: object): Promise> { + futuresModifyTPSLPOrder( + params: FuturesModifyTPSLOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/modify-tpsl-order`, params); } - futuresModifyPlanOrder(params: object): Promise> { + futuresModifyPlanOrder( + params: FuturesModifyPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/modify-plan-order`, params); } - futuresCancelPlanOrder(params: object): Promise> { + futuresCancelPlanOrder( + params: FuturesCancelPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/mix/order/cancel-plan-order`, params); } - getFuturesPlanOrders(params: object): Promise> { + getFuturesPlanOrders( + params: FuturesGetPlanOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/orders-plan-pending`, params); } - getFuturesHistoricPlanOrders(params: object): Promise> { + getFuturesHistoricPlanOrders( + params: FuturesGetHistoryPlanOrdersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/mix/order/orders-plan-history`, params); } @@ -828,7 +1226,10 @@ export class RestClientV2 extends BaseRestClient { * */ - modifySubaccountEmail(params: object): Promise> { + modifySubaccountEmail(params: { + subUid: string; + subaccountEmail: string; + }): Promise> { return this.postPrivate( `/api/v2/broker/account/modify-subaccount-email`, params, @@ -839,62 +1240,86 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/broker/account/info`); } - createSubaccount(params: object): Promise> { + createSubaccount(params: { + subaccountName: string; + label: string; + }): Promise> { return this.postPrivate(`/api/v2/broker/account/create-subaccount`, params); } - getSubaccounts(params?: object): Promise> { + getSubaccounts(params?: GetSubAccountsRequestV2): Promise> { return this.getPrivate(`/api/v2/broker/account/subaccount-list`, params); } - modifySubaccount(params: object): Promise> { + modifySubaccount(params: ModifySubRequestV2): Promise> { return this.postPrivate(`/api/v2/broker/account/modify-subaccount`, params); } - getSubaccountEmail(params: object): Promise> { + getSubaccountEmail(params: { subUid: string }): Promise> { return this.getPrivate(`/api/v2/broker/account/subaccount-email`, params); } - getSubaccountSpotAssets(params: object): Promise> { + getSubaccountSpotAssets(params: { + subUid: string; + coin?: string; + assetType?: 'hold_only' | 'all'; + }): Promise> { return this.getPrivate( `/api/v2/broker/account/subaccount-spot-assets`, params, ); } - getSubaccountFuturesAssets(params: object): Promise> { + getSubaccountFuturesAssets(params: { + subUid: string; + productType: FuturesProductTypeV2; + }): Promise> { return this.getPrivate( `/api/v2/broker/account/subaccount-future-assets`, params, ); } - createSubaccountDepositAddress(params: object): Promise> { + createSubaccountDepositAddress(params: { + subUid: string; + coin: string; + chain?: string; + }): Promise> { return this.postPrivate( `/api/v2/broker/account/subaccount-address`, params, ); } - subaccountWithdrawal(params: object): Promise> { + subaccountWithdrawal( + params: SubWithdrawalRequestV2, + ): Promise> { return this.postPrivate( `/api/v2/broker/account/subaccount-withdrawal`, params, ); } - subaccountSetAutoTransfer(params: object): Promise> { + subaccountSetAutoTransfer(params: { + subUid: string; + coin: string; + toAccountType: string; + }): Promise> { return this.postPrivate( `/api/v2/broker/account/set-subaccount-autotransfer`, params, ); } - subaccountDepositRecords(params: object): Promise> { + subaccountDepositRecords( + params: SubDepositRecordsRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-deposit`, params); } - subaccountWithdrawalRecords(params: object): Promise> { + subaccountWithdrawalRecords( + params: SubWithdrawalRecordsRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-withdrawal`, params); } @@ -904,21 +1329,25 @@ export class RestClientV2 extends BaseRestClient { * */ - createSubaccountApiKey(params: object): Promise> { + createSubaccountApiKey( + params: CreateSubAccountApiKeyRequestV2, + ): Promise> { return this.postPrivate( `/api/v2/broker/manage/create-subaccount-apikey`, params, ); } - getSubaccountApiKey(params: object): Promise> { + getSubaccountApiKey(params: { subUid: string }): Promise> { return this.getPrivate( `/api/v2/broker/manage/subaccount-apikey-list`, params, ); } - modifySubaccountApiKey(params: object): Promise> { + modifySubaccountApiKey( + params: ModifySubAccountApiKeyRequestV2, + ): Promise> { return this.postPrivate( `/api/v2/broker/manage/modify-subaccount-apikey`, params, @@ -951,7 +1380,7 @@ export class RestClientV2 extends BaseRestClient { getMarginBorrowHistory( marginType: MarginType, - params: object, + params: GetBorrowHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -962,7 +1391,7 @@ export class RestClientV2 extends BaseRestClient { getMarginRepayHistory( marginType: MarginType, - params: object, + params: GetRepayHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -973,7 +1402,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestHistory( marginType: MarginType, - params: object, + params: GetInterestHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -984,7 +1413,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationHistory( marginType: MarginType, - params: object, + params: GetLiquidationHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -995,7 +1424,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFinancialHistory( marginType: MarginType, - params: object, + params: GetFinancialHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1012,7 +1441,7 @@ export class RestClientV2 extends BaseRestClient { getMarginAccountAssets( marginType: MarginType, - params?: object, + params?: { coin?: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1023,7 +1452,11 @@ export class RestClientV2 extends BaseRestClient { marginBorrow( marginType: MarginType, - params: object, + params: { + coin: string; + borrowAmount: string; + clientOid?: string; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1034,7 +1467,10 @@ export class RestClientV2 extends BaseRestClient { marginRepay( marginType: MarginType, - params: object, + params: { + coin: string; + repayAmount: string; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1050,7 +1486,7 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxBorrowable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1061,7 +1497,7 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxTransferable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1072,7 +1508,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestRateAndMaxBorrowable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1083,7 +1519,7 @@ export class RestClientV2 extends BaseRestClient { getMarginTierConfiguration( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/tier-data`, params); @@ -1091,7 +1527,7 @@ export class RestClientV2 extends BaseRestClient { marginFlashRepay( marginType: MarginType, - params?: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1102,7 +1538,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFlashRepayResult( marginType: MarginType, - params: object, + params: { idList: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1119,7 +1555,7 @@ export class RestClientV2 extends BaseRestClient { marginSubmitOrder( marginType: MarginType, - params: object, + params: MarginPlaceOrderRequestV2, ): Promise> { assertMarginType(marginType); return this.postPrivate(`/api/v2/margin/${marginType}/place-order`, params); @@ -1127,7 +1563,7 @@ export class RestClientV2 extends BaseRestClient { marginBatchSubmitOrders( marginType: MarginType, - params: object, + params: MarginBatchOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1138,7 +1574,11 @@ export class RestClientV2 extends BaseRestClient { marginCancelOrder( marginType: MarginType, - params: object, + params: { + symbol: string; + orderId?: string; + clientOid?: string; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1149,7 +1589,10 @@ export class RestClientV2 extends BaseRestClient { marginBatchCancelOrders( marginType: MarginType, - params: object, + params: { + symbol: string; + orderIdList: string[]; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1160,7 +1603,7 @@ export class RestClientV2 extends BaseRestClient { getMarginOpenOrders( marginType: MarginType, - params: object, + params: GetMarginCurrentOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/open-orders`, params); @@ -1168,7 +1611,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrders( marginType: MarginType, - params: object, + params: GetHistoryOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1179,7 +1622,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrderFills( marginType: MarginType, - params: object, + params: GetMarginOrderFillsRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/fills`, params); @@ -1187,7 +1630,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationOrders( marginType: MarginType, - params: object, + params: GetMarginLiquidationOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1212,21 +1655,27 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesTraderCurrentOrder(params: object): Promise> { + getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-current-track`, params, ); } - getFuturesTraderHistoryOrders(params: object): Promise> { + getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-history-track`, params, ); } - modifyFuturesTraderOrderTPSL(params: object): Promise> { + modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequestV2, + ): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/order-modify-tpsl`, params, @@ -1242,7 +1691,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderProfitShareHistory( - params: object, + params: GetFuturesTraderProfitShareDetailRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/profit-history-details`, @@ -1250,53 +1699,76 @@ export class RestClientV2 extends BaseRestClient { ); } - closeFuturesTraderOrder(params: object): Promise> { + closeFuturesTraderOrder(params: { + trackingNo: string; + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/order-close-positions`, params, ); } - getFuturesTraderProfitShare(params: object): Promise> { + getFuturesTraderProfitShare(params?: { + coin?: string; + pageSize?: string; + pageNo?: string; + }): Promise> { return this.getPrivate(`/api/v2/copy/mix-trader/profit-details`, params); } - getFuturesTraderProfitShareGroup(params: object): Promise> { + getFuturesTraderProfitShareGroup(params?: { + pageSize?: string; + pageNo?: string; + }): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/profits-group-coin-date`, params, ); } - getFuturesTraderSymbolSettings(params: object): Promise> { + getFuturesTraderSymbolSettings(params: { + productType: CopyTradingProductTypeV2; + }): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/config-query-symbols`, params, ); } - updateFuturesTraderSymbolSettings(params: object): Promise> { + updateFuturesTraderSymbolSettings(params: { + settingList: FuturesTraderSymbolSettingRequestV2[]; + }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/config-setting-symbols`, params, ); } - updateFuturesTraderGlobalSettings(params: object): Promise> { + updateFuturesTraderGlobalSettings(params?: { + enable?: 'YES' | 'NO'; + showTotalEquity?: 'YES' | 'NO'; + showTpsl?: 'YES' | 'NO'; + }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/config-settings-base`, params, ); } - getFuturesTraderFollowers(params: object): Promise> { + getFuturesTraderFollowers( + params?: GetFuturesTraderFollowersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/config-query-followers`, params, ); } - removeFuturesTraderFollower(params: object): Promise> { + removeFuturesTraderFollower(params: { + followerUid: string; + }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/config-remove-follower`, params, @@ -1311,51 +1783,70 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesFollowerCurrentOrders(params: object): Promise> { + getFuturesFollowerCurrentOrders( + params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-current-orders`, params, ); } - getFuturesFollowerHistoryOrders(params: object): Promise> { + getFuturesFollowerHistoryOrders( + params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-history-orders`, params, ); } - updateFuturesFollowerTPSL(params: object): Promise> { + updateFuturesFollowerTPSL( + params: UpdateFuturesFollowerTPSLRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/setting-tpsl`, params); } - updateFuturesFollowerSettings(params: object): Promise> { + updateFuturesFollowerSettings( + params: UpdateFuturesFollowerSettingsRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/settings`, params); } - getFuturesFollowerSettings(params: object): Promise> { + getFuturesFollowerSettings(params: { + traderId: string; + }): Promise> { return this.getPrivate(`/api/v2/copy/mix-follower/query-settings`, params); } - closeFuturesFollowerPositions(params: object): Promise> { + closeFuturesFollowerPositions( + params: CloseFuturesFollowerPositionsRequestV2, + ): Promise> { return this.postPrivate( `/api/v2/copy/mix-follower/close-positions`, params, ); } - getFuturesFollowerTraders(params: object): Promise> { + getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/copy/mix-follower/query-traders`, params); } - getFuturesFollowerFollowLimit(params: object): Promise> { + getFuturesFollowerFollowLimit(params: { + symbol: string; + productType: CopyTradingProductTypeV2; + }): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-quantity-limit`, params, ); } - unfollowFuturesTrader(params: object): Promise> { + unfollowFuturesTrader(params: { + traderId: string; + }): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/cancel-trader`, params); } @@ -1397,14 +1888,20 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/copy/spot-trader/profit-summarys`); } - getSpotTraderHistoryProfit(params: object): Promise> { + getSpotTraderHistoryProfit( + params: GetSpotTraderHistoryProfitRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/profit-history-details`, params, ); } - getSpotTraderUnrealizedProfit(params: object): Promise> { + getSpotTraderUnrealizedProfit(params?: { + coin?: string; + pageNo?: string; + pageSize?: string; + }): Promise> { return this.getPrivate(`/api/v2/copy/spot-trader/profit-details`, params); } @@ -1412,42 +1909,58 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/copy/spot-trader/order-total-detail`); } - modifySpotTraderOrderTPSL(params: object): Promise> { + modifySpotTraderOrderTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; + }): Promise> { return this.postPrivate( `/api/v2/copy/spot-trader/order-modify-tpsl`, params, ); } - getSpotTraderHistoryOrders(params: object): Promise> { + getSpotTraderHistoryOrders( + params: GetSpotTraderHistoryOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/order-history-track`, params, ); } - getSpotTraderCurrentOrders(params: object): Promise> { + getSpotTraderCurrentOrders( + params: GetSpotTraderCurrentOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/order-current-track`, params, ); } - sellSpotTrader(params: object): Promise> { + sellSpotTrader(params: { + trackingNoList: string[]; + symbol: string; + }): Promise> { return this.postPrivate( `/api/v2/copy/spot-trader/order-close-tracking`, params, ); } - getSpotTraderSymbolSettings(params: object): Promise> { + getSpotTraderSymbolSettings(params: { + symbolList: string[]; + settingType: 'add' | 'delete'; + }): Promise> { return this.postPrivate( `/api/v2/copy/spot-trader/config-setting-symbols`, params, ); } - removeSpotTraderFollowers(params: object): Promise> { + removeSpotTraderFollowers(params: { + followerUid: string; + }): Promise> { return this.postPrivate( `/api/v2/copy/spot-trader/config-remove-follower`, params, @@ -1458,7 +1971,9 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/copy/spot-trader/config-query-settings`); } - getSpotTraderFollowers(params: object): Promise> { + getSpotTraderFollowers( + params: GetSpotTraderFollowersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/config-query-followers`, params, @@ -1468,62 +1983,87 @@ export class RestClientV2 extends BaseRestClient { /** * * - * Copy Trading | Spot copy trading | Trader api + * Copy Trading | Spot copy trading | Follower api * * */ - cancelSpotFollowerOrder(params: object): Promise> { + cancelSpotFollowerOrder(params: { + trackingNoList: string[]; + }): Promise> { return this.postPrivate(`/api/v2/copy/spot-follower/stop-order`, params); } - updateSpotFollowerSettings(params: object): Promise> { + updateSpotFollowerSettings(params: { + traderId: string; + autoCopy?: 'on' | 'off'; + mode?: 'basic' | 'advanced'; + settings: SpotFollowerCopyTradeSettingV2[]; + }): Promise> { return this.postPrivate(`/api/v2/copy/spot-follower/settings`, params); } - updateSpotFollowerTPSL(params: object): Promise> { + updateSpotFollowerTPSL(params: { + trackingNo: string; + stopSurplusPrice?: string; + stopLossPrice?: string; + }): Promise> { return this.postPrivate(`/api/v2/copy/spot-follower/setting-tpsl`, params); } - getSpotFollowerTraders(params: object): Promise> { + getSpotFollowerTraders(params?: { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; + }): Promise> { return this.getPrivate(`/api/v2/copy/spot-follower/query-traders`, params); } - getSpotFollowerCurrentTraderSymbols( - params: object, - ): Promise> { + getSpotFollowerCurrentTraderSymbols(params: { + traderId: string; + }): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-trader-symbols`, params, ); } - getSpotFollowerSettings(params: object): Promise> { + getSpotFollowerSettings(params: { + traderId: string; + }): Promise> { return this.getPrivate(`/api/v2/copy/spot-follower/query-settings`, params); } - getSpotFollowerHistoryOrders(params: object): Promise> { + getSpotFollowerHistoryOrders( + params: GetSpotFollowerHistoryOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-history-orders`, params, ); } - getSpotFollowerOpenOrders(params: object): Promise> { + getSpotFollowerOpenOrders( + params: GetSpotFollowerOpenOrdersRequestV2, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-current-orders`, params, ); } - sellSpotFollower(params: object): Promise> { + sellSpotFollower(params: { + trackingNoList: string[]; + symbol: string; + }): Promise> { return this.postPrivate( `/api/v2/copy/spot-follower/order-close-tracking`, params, ); } - unfollowSpotTrader(params: object): Promise> { + unfollowSpotTrader(params: { traderId: string }): Promise> { return this.postPrivate(`/api/v2/copy/spot-follower/cancel-trader`, params); } @@ -1535,7 +2075,10 @@ export class RestClientV2 extends BaseRestClient { * */ - getEarnSavingsProducts(params: object): Promise> { + getEarnSavingsProducts(params?: { + coin?: string; + filter?: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/savings/product`, params); } @@ -1543,27 +2086,48 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/savings/account`); } - getEarnSavingsAssets(params: object): Promise> { + getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/savings/assets`, params); } - getEarnSavingsRecords(params: object): Promise> { + getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/savings/records`, params); } - getEarnSavingsSubscription(params: object): Promise> { + getEarnSavingsSubscription(params: { + productId: string; + periodType: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/savings/subscribe-info`, params); } - earnSubscribeSavings(params: object): Promise> { + earnSubscribeSavings(params: { + productId: string; + periodType: string; + amount: string; + }): Promise> { return this.postPrivate(`/api/v2/earn/savings/subscribe`, params); } - getEarnSavingsSubscriptionResult(params: object): Promise> { + getEarnSavingsSubscriptionResult(params: { + productId: string; + periodType: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/savings/subscribe-result`, params); } - getEarnSavingsRedemptionResult(params: object): Promise> { + earnRedeemSavings(params: RedeemSavingsRequestV2): Promise> { + return this.postPrivate(`/api/v2/earn/savings/redeem`, params); + } + + getEarnSavingsRedemptionResult(params: { + orderId: string; + periodType: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/savings/redeem-result`, params); } @@ -1575,7 +2139,7 @@ export class RestClientV2 extends BaseRestClient { * */ - getEarnAccount(params?: object): Promise> { + getEarnAccount(params?: { coin?: string }): Promise> { return this.getPrivate(`/api/v2/earn/account/assets`, params); } @@ -1587,7 +2151,11 @@ export class RestClientV2 extends BaseRestClient { * */ - getSharkfinProducts(params: object): Promise> { + getSharkfinProducts(params: { + coin: string; + limit?: string; + idLessThan?: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/product`, params); } @@ -1595,23 +2163,34 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/sharkfin/account`); } - getSharkfinAssets(params: object): Promise> { + getSharkfinAssets( + params: GetSharkfinAssetsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/assets`, params); } - getSharkfinRecords(params: object): Promise> { + getSharkfinRecords( + params: GetSharkfinRecordsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/records`, params); } - getSharkfinSubscription(params: object): Promise> { + getSharkfinSubscription(params: { + productId: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/subscribe-info`, params); } - subscribeSharkfin(params: object): Promise> { + subscribeSharkfin(params: { + productId: string; + amount: string; + }): Promise> { return this.postPrivate(`/api/v2/earn/sharkfin/subscribe`, params); } - getSharkfinSubscriptionResult(params: object): Promise> { + getSharkfinSubscriptionResult(params: { + orderId: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/subscribe-result`, params); } @@ -1623,47 +2202,61 @@ export class RestClientV2 extends BaseRestClient { * */ - getLoanCurrencies(params?: object): Promise> { + getLoanCurrencies(params?: { coin?: string }): Promise> { return this.get(`/api/v2/earn/loan/public/coinInfos`, params); } - getLoanEstInterestAndBorrowable(params: object): Promise> { + getLoanEstInterestAndBorrowable( + params: GetLoanEstInterestAndBorrowableRequestV2, + ): Promise> { return this.get(`/api/v2/earn/loan/public/hour-interest`, params); } - borrowLoan(params: object): Promise> { + borrowLoan(params: BorrowLoanRequestV2): Promise> { return this.postPrivate(`/api/v2/earn/loan/borrow`, params); } - getOngoingLoanOrders(params: object): Promise> { + getOngoingLoanOrders(params?: { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + }): Promise> { return this.getPrivate(`/api/v2/earn/loan/ongoing-orders`, params); } - repayLoan(params: object): Promise> { + repayLoan(params: RepayLoanRequestV2): Promise> { return this.postPrivate(`/api/v2/earn/loan/repay`, params); } - getRepayHistory(params: object): Promise> { + getRepayHistory( + params: GetLoanRepayHistoryRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/loan/repay-history`, params); } - updateLoanPledgeRate(params: object): Promise> { + updateLoanPledgeRate( + params: ModifyLoanPledgeRateRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/earn/loan/revise-pledge`, params); } - getLoanPledgeRateHistory(params: object): Promise> { + getLoanPledgeRateHistory( + params: GetLoanPledgeRateHistoryRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/loan/revise-history`, params); } - getLoanHistory(params: object): Promise> { + getLoanHistory(params: GetLoanHistoryRequestV2): Promise> { return this.getPrivate(`/api/v2/earn/loan/borrow-history`, params); } - getLoanDebts(params?: object): Promise> { - return this.getPrivate(`/api/v2/earn/loan/debts`, params); + getLoanDebts(): Promise> { + return this.getPrivate(`/api/v2/earn/loan/debts`); } - getLoanLiquidationRecords(params: object): Promise> { + getLoanLiquidationRecords( + params: GetLiquidationRecordsRequestV2, + ): Promise> { return this.getPrivate(`/api/v2/earn/loan/reduces`, params); } } diff --git a/src/types/request/index.ts b/src/types/request/index.ts index a092236..4c25afa 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -1,6 +1,11 @@ -export * from './v1/brokerV1'; -export * from './v1/futuresV1'; -export * from './v1/spotV1'; -export * from './v2/futures'; -export * from './v2/spot'; -export * from './shared'; +export * from './v1/brokerV1'; +export * from './v1/futuresV1'; +export * from './v1/spotV1'; +export * from './v2/futures'; +export * from './v2/spot'; +export * from './v2/broker'; +export * from './v2/margin'; +export * from './v2/copytrading'; +export * from './v2/earn'; +export * from './shared'; +export * from './v2/common'; diff --git a/src/types/request/shared.ts b/src/types/request/shared.ts index 6d21f7a..23b4db4 100644 --- a/src/types/request/shared.ts +++ b/src/types/request/shared.ts @@ -1,24 +1,39 @@ -/** Pagination */ -export interface Pagination { - /** Time after */ - after?: string; - /** Time before */ - before?: string; - /** Elements per page */ - limit?: string; -} - -export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; - -export interface GetHistoricTradesParams { - symbol: string; - limit?: string; - tradeId?: string; - startTime?: string; - endTime?: string; -} - -/** - * The margin type, used directly in building the endpoint URL - */ -export type MarginType = 'crossed' | 'isolated'; +/** Pagination */ +export interface Pagination { + /** Time after */ + after?: string; + /** Time before */ + before?: string; + /** Elements per page */ + limit?: string; +} + +export type OrderTimeInForce = 'normal' | 'post_only' | 'fok' | 'ioc'; + +export interface GetHistoricTradesParams { + symbol: string; + limit?: string; + tradeId?: string; + startTime?: string; + endTime?: string; +} + +/** + * The margin type, used directly in building the endpoint URL + */ +export type MarginType = 'crossed' | 'isolated'; + +export type FuturesProductTypeV2 = + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES' + | 'SUSDT-FUTURES' + | 'SCOIN-FUTURES' + | 'SUSDC-FUTURES'; + +export type FuturesPlanTypeV2 = + | 'profit_plan' + | 'loss_plan' + | 'moving_plan' + | 'pos_profit' + | 'pos_loss'; diff --git a/src/types/request/v2/broker.ts b/src/types/request/v2/broker.ts new file mode 100644 index 0000000..5655666 --- /dev/null +++ b/src/types/request/v2/broker.ts @@ -0,0 +1,99 @@ +/** + * + * * Broker | Subaccount + * + */ + +export interface GetSubAccountsRequestV2 { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze' | 'del'; + startTime?: string; + endTime?: string; +} + +export type SubAccountPermissionV2 = + | 'withdraw' + | 'transfer' + | 'spot_trade' + | 'contract_trade' + | 'read' + | 'deposit' + | 'margin_trade'; + +export type SubAccountLanguageV2 = + | 'en_US' + | 'zh_CN' + | 'ja_JP' + | 'vi_VN' + | 'zh_TW' + | 'ru_RU' + | 'es_ES' + | 'tr_TR' + | 'fr_FR' + | 'de_DE' + | 'pt_PT' + | 'th_TH'; + +export type SubAccountStatusV2 = 'normal' | 'freeze'; + +export interface ModifySubRequestV2 { + subUid: string; + permList: SubAccountPermissionV2[]; + status: SubAccountStatusV2; + language?: SubAccountLanguageV2; +} + +export interface SubWithdrawalRequestV2 { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + chain?: string; + address: string; + amount: string; + tag?: string; + clientOid?: string; +} + +export interface SubDepositRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface SubWithdrawalRecordsRequestV2 { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Broker | Subaccount + * + */ + +export interface CreateSubAccountApiKeyRequestV2 { + subUid: string; + passphrase: string; + label?: string; + ipList: string[]; + permType: string; + permList: string[]; +} + +export interface ModifySubAccountApiKeyRequestV2 { + subUid: string; + apiKey: string; + label?: string; + passphrase: string; + ipList?: string[]; + permType?: string; + permList: string[]; +} diff --git a/src/types/request/v2/common.ts b/src/types/request/v2/common.ts new file mode 100644 index 0000000..051273b --- /dev/null +++ b/src/types/request/v2/common.ts @@ -0,0 +1,187 @@ +import { FuturesProductTypeV2, MarginType } from '../shared'; + +/** + * + * * Common | Notice + * + */ + +export interface GetAnnouncementsRequestV2 { + annType?: string; + startTime?: string; + endTime?: string; + language: string; +} + +/** + * + * * Common | Public + * + */ + +export interface GetTradeRateRequestV2 { + symbol: string; + businessType: string; +} + +/** + * + * * Common | Tax + * + */ + +export interface GetSpotTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetFuturesTransactionsRequestV2 { + productType?: FuturesProductTypeV2; + marginCoin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetMarginTransactionsRequestV2 { + marginType?: MarginType; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetP2PTransactionsRequestV2 { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | P2P + * + */ + +export interface GetP2PMerchantsRequestV2 { + online?: 'yes' | 'no'; + idLessThan?: string; + limit?: string; +} + +export interface GetMerchantP2POrdersRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status?: string; + advNo: string; + side?: string; + coin?: string; + language: string; + fiat?: string; + orderNo?: string; +} + +export interface GetMerchantAdvertisementsRequestV2 { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status: string; + advNo?: string; + side: string; + coin: string; + language?: string; + fiat: string; + orderBy?: string; + payMethodId?: string; + sourceType?: string; +} + +/** + * + * * Common | Virtual Subaccount + * + */ + +export interface ModifyVirtualSubRequestV2 { + subAccountUid: string; + permList: string[]; + status: string; +} + +export interface CreateVirtualSubRequestV2 { + subAccountName: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface CreateVirtualSubApiKeyRequestV2 { + subAccountUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface ModifyVirtualSubApiKeyRequestV2 { + subAccountUid: string; + subAccountApiKey: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +/** + * + * * Common | Convert + * + */ + +export interface ConvertQuoteRequestV2 { + fromCoin: string; + fromCoinSize?: string; + toCoin: string; + toCoinSize?: string; +} + +export interface ConvertRequestV2 { + fromCoin: string; + fromCoinSize: string; + cnvtPrice: string; + toCoin: string; + toCoinSize: string; + traceId: string; +} + +export interface GetConvertHistoryRequestV2 { + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | BGB Convert + * + */ + +export interface GetConvertBGBHistoryRequestV2 { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} diff --git a/src/types/request/v2/copytrading.ts b/src/types/request/v2/copytrading.ts new file mode 100644 index 0000000..48b65ee --- /dev/null +++ b/src/types/request/v2/copytrading.ts @@ -0,0 +1,223 @@ +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ + +export type CopyTradingProductTypeV2 = + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + +export interface GetFuturesTraderCurrentOrdersRequestV2 { + symbol?: string; + productType: CopyTradingProductTypeV2; + startTime?: string; + endTime?: string; + limit?: string; + idGreaterThan?: string; + idLessThan?: string; +} + +export interface GetFuturesTraderHistoryOrdersRequestV2 { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + order?: 'asc' | 'desc'; + symbol?: string; + productType: CopyTradingProductTypeV2; +} + +export interface ModifyFuturesTraderOrderTPSLRequestV2 { + trackingNo: string; + productType: CopyTradingProductTypeV2; + stopSurplusPrice?: string; + stopLossPrice?: string; +} + +export interface GetFuturesTraderProfitShareDetailRequestV2 { + coin?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesTraderSymbolSettingRequestV2 { + symbol: string; + productType: CopyTradingProductTypeV2; + settingType: 'ADD' | 'DELETE' | 'UPDATE'; + stopSurplusRatio?: string; + stopLossRatio?: string; +} + +export interface GetFuturesTraderFollowersRequestV2 { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ + +export interface GetFollowerFuturesCurrentTrackingOrdersRequestV2 { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; + productType: CopyTradingProductTypeV2; + traderId?: string; +} + +export interface GetFollowerFuturesHistoryTrackingOrdersRequestV2 { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; + productType: CopyTradingProductTypeV2; + traderId?: string; +} + +export interface UpdateFuturesFollowerTPSLRequestV2 { + trackingNo: string; + symbol?: string; + productType: CopyTradingProductTypeV2; + stopSurplusPrice?: string; + stopLossPrice?: string; +} + +export type AutoCopyOption = 'on' | 'off'; +export type FollowMode = 'basic' | 'advanced'; +export type LeverageType = 'position' | 'specify' | 'trader'; +export type TraceType = 'percent' | 'amount' | 'count'; + +export interface FollowerCopyTradeSettingRequestV2 { + symbol: string; + productType: CopyTradingProductTypeV2; + marginType: 'trader' | 'specify'; + marginCoin?: string; + leverType: LeverageType; + longLeverage?: string; + shortLeverage?: string; + traceType: TraceType; + traceValue: string; + maxHoldSize?: string; + stopSurplusRatio?: string; + stopLossRatio?: string; +} + +export interface UpdateFuturesFollowerSettingsRequestV2 { + traderId: string; + autoCopy?: AutoCopyOption; + mode?: FollowMode; + settings: FollowerCopyTradeSettingRequestV2[]; +} +export interface CloseFuturesFollowerPositionsRequestV2 { + productType: CopyTradingProductTypeV2; + trackingNo?: string; + symbol?: string; + marginCoin?: string; + marginMode?: 'isolated' | 'cross'; + holdSide?: 'long' | 'short'; +} + +export interface GetFuturesFollowerTradersRequestV2 { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Trader api + * + * + */ + +export interface GetSpotTraderHistoryProfitRequestV2 { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + coin?: string; +} + +export interface GetSpotTraderHistoryOrdersRequestV2 { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; +} + +export interface GetSpotTraderCurrentOrdersRequestV2 { + symbol?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetSpotTraderFollowersRequestV2 { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ + +export interface SpotFollowerCopyTradeSettingV2 { + symbol: string; + traceType: 'percent' | 'amount' | 'count'; + maxHoldSize: string; + traceValue: string; + stopLossRatio?: string; + stopSurplusRatio?: string; +} + +export interface GetSpotFollowerHistoryOrdersRequestV2 { + symbol?: string; + traderId?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetSpotFollowerOpenOrdersRequestV2 { + symbol?: string; + traderId?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} diff --git a/src/types/request/v2/earn.ts b/src/types/request/v2/earn.ts new file mode 100644 index 0000000..30687b9 --- /dev/null +++ b/src/types/request/v2/earn.ts @@ -0,0 +1,136 @@ +/** + * + * + * Earn | Savings + * + * + */ + +export interface GetEarnSavingsAssetsRequestV2 { + periodType: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetEarnSavingsRecordsRequestV2 { + coin?: string; + periodType: string; + orderType?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface RedeemSavingsRequestV2 { + productId: string; + orderId?: string; + periodType: string; + amount: string; +} + +/** + * + * + * Earn | Shark Fin + * + * + */ + +export interface GetSharkfinAssetsRequestV2 { + status: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSharkfinRecordsRequestV2 { + coin?: string; + type: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * + * Earn | Loan + * + * + */ + +export interface GetLoanEstInterestAndBorrowableRequestV2 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY'; + pledgeAmount?: string; +} + +export interface BorrowLoanRequestV2 { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY'; + pledgeAmount?: string; + loanAmount?: string; +} + +export interface RepayLoanRequestV2 { + orderId: string; + amount?: string; + repayUnlock?: string; + repayAll: string; +} + +export interface GetLoanRepayHistoryRequestV2 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface ModifyLoanPledgeRateRequestV2 { + orderId: string; + amount: string; + pledgeCoin: string; + reviseType: string; +} + +export interface GetLoanPledgeRateHistoryRequestV2 { + orderId?: string; + reviseSide?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface GetLoanHistoryRequestV2 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface GetLiquidationRecordsRequestV2 { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} diff --git a/src/types/request/v2/futures.ts b/src/types/request/v2/futures.ts index 5499289..695ecdb 100644 --- a/src/types/request/v2/futures.ts +++ b/src/types/request/v2/futures.ts @@ -1,13 +1,6 @@ +import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared'; import { FuturesKlineInterval } from '../v1/futuresV1'; -export type FuturesProductTypeV2 = - | 'USDT-FUTURES' - | 'COIN-FUTURES' - | 'USDC-FUTURES' - | 'SUSDT-FUTURES' - | 'SCOIN-FUTURES' - | 'SUSDC-FUTURES'; - export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; export interface FuturesAccountBillRequestV2 { @@ -21,6 +14,34 @@ export interface FuturesAccountBillRequestV2 { limit?: string; } +/** + * + * * Futures | Market + * + */ + +export interface FuturesMergeDepthRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + precision?: 'scale0' | 'scale1' | 'scale2' | 'scale3'; + limit?: '1' | '5' | '15' | '50' | 'max'; +} + +export interface FuturesRecentTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: string; +} + +export interface FuturesHistoricTradesRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + export interface FuturesCandlesRequestV2 { symbol: string; productType: FuturesProductTypeV2; @@ -30,3 +51,391 @@ export interface FuturesCandlesRequestV2 { kLineType?: FuturesKlineTypeV2; limit?: string; } + +/** + * + * * Futures | Account + * + */ + +export interface FuturesSingleAccountRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; +} + +export interface FuturesInterestHistoryRequestV2 { + productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; + coin?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesOpenCountRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + openAmount: string; + openPrice: string; + leverage?: string; +} + +export interface FuturesSetAutoMarginRequestV2 { + symbol: string; + autoMargin: 'on' | 'off'; + marginCoin: string; + amount: string; + holdSide?: 'long' | 'short'; +} + +export interface FuturesSetLeverageRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + leverage: string; + holdSide?: 'long' | 'short'; +} + +export interface FuturesSetPositionMarginRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + holdSide: 'long' | 'short'; + amount: string; +} + +export interface FuturesSetMarginModeRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; +} + +/** + * + * * Futures | Position + * + */ + +export interface FuturesHistoricalPositionsRequestV2 { + symbol?: string; + productType?: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +/** + * + * * Futures | Trade + * + */ + +export interface FuturesPlaceOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; +} + +export interface FuturesReversalOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + size: string; + side?: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + clientOid?: string; +} + +interface FuturesBatchOrderItem { + size: string; + price?: string; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + force?: 'ioc' | 'fok' | 'gtc' | 'post_only'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + presetStopSurplusPrice?: string; + presetStopLossPrice?: string; + stpMode?: 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; +} + +export interface FuturesBatchOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin: string; + marginMode: 'isolated' | 'crossed'; + orderList: FuturesBatchOrderItem[]; +} + +export interface FuturesModifyOrderRequestV2 { + orderId?: string; + clientOid?: string; + symbol: string; + productType: FuturesProductTypeV2; + newClientOid: string; + newSize?: string; + newPrice?: string; + newPresetStopSurplusPrice?: string; + newPresetStopLossPrice?: string; +} + +export interface FuturesCancelOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + orderId?: string; + clientOid?: string; +} + +interface FuturesBatchCancelOrderItem { + orderId?: string; + clientOid?: string; +} + +export interface FuturesBatchCancelOrderRequestV2 { + orderIdList?: FuturesBatchCancelOrderItem[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; +} + +export interface FuturesFlashClosePositionsRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + holdSide?: 'long' | 'short'; +} + +export interface FuturesGetOrderRequestV2 { + symbol: string; + productType: FuturesProductTypeV2; + orderId?: string; + clientOid?: string; +} + +export interface FuturesGetOrderFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesGetHistoricalFillsRequestV2 { + orderId?: string; + symbol?: string; + productType: FuturesProductTypeV2; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; +} + +export interface FuturesGetOpenOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + status?: 'live' | 'partially_filled'; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export type FuturesOrderSourceV2 = + | 'normal' + | 'market' + | 'profit_market' + | 'loss_market' + | 'Trader_delegate' + | 'trader_profit' + | 'trader_loss' + | 'reverse' + | 'trader_reverse' + | 'profit_limit' + | 'loss_limit' + | 'liquidation' + | 'delivery_close_long' + | 'delivery_close_short' + | 'pos_profit_limit' + | 'pos_profit_market' + | 'pos_loss_limit' + | 'pos_loss_market'; + +export interface FuturesGetHistoryOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + orderSource?: FuturesOrderSourceV2; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesCancelAllOrdersRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + requestTime?: string; + receiveWindow?: string; +} + +/** + * + * * Futures | Trigger Orders + * + */ + +export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; + +export type FuturesStpModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export interface FuturesTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + planType: FuturesPlanTypeV2; + triggerPrice: string; + triggerType?: FuturesTriggerTypeV2; + executePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + size: string; + rangeRate?: string; + clientOid?: string; + stpMode?: FuturesStpModeV2; +} + +export type FuturesTriggerPriceTypeV2 = + | 'fill_price' + | 'mark_price' + | 'index_price'; + +export interface FuturesPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; + symbol: string; + productType: FuturesProductTypeV2; + marginMode: 'isolated' | 'crossed'; + marginCoin: string; + size: string; + price?: string; + callbackRatio?: string; + triggerPrice: string; + triggerType: 'mark_price' | 'fill_price'; + side: 'buy' | 'sell'; + tradeSide?: 'open' | 'close'; + orderType: 'limit' | 'market'; + clientOid?: string; + reduceOnly?: 'YES' | 'NO'; + stopSurplusTriggerPrice?: string; + stopSurplusExecutePrice?: string; + stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + stopLossTriggerPrice?: string; + stopLossExecutePrice?: string; + stopLossTriggerType?: FuturesTriggerPriceTypeV2; + stpMode?: FuturesStpModeV2; +} + +export interface FuturesModifyTPSLOrderRequestV2 { + orderId?: string; + clientOid?: string; + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + triggerPrice: string; + triggerType?: 'fill_price' | 'mark_price'; + executePrice?: string; + size: string; + rangeRate?: string; +} + +export interface FuturesModifyPlanOrderRequestV2 { + planType: 'normal_plan' | 'track_plan'; + orderId?: string; + clientOid?: string; + symbol: string; + productType: FuturesProductTypeV2; + newSize?: string; + newPrice?: string; + newCallbackRatio?: string; + newTriggerPrice?: string; + newTriggerType?: 'fill_price' | 'mark_price'; + newStopSurplusTriggerPrice?: string; + newStopSurplusExecutePrice?: string; + newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; + newStopLossTriggerPrice?: string; + newStopLossExecutePrice?: string; + newStopLossTriggerType?: FuturesTriggerPriceTypeV2; +} + +export interface FuturesGetPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + symbol?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +interface FuturesCancelPlanOrderItemV2 { + orderId?: string; + clientOid?: string; +} + +export type FuturesPlanOrderTypeV2 = + | 'normal_plan' + | 'profit_plan' + | 'loss_plan' + | 'pos_profit' + | 'pos_loss' + | 'moving_plan'; + +export interface FuturesCancelPlanOrderRequestV2 { + orderIdList?: FuturesCancelPlanOrderItemV2[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + planType?: FuturesPlanOrderTypeV2; +} + +export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; + +export interface FuturesGetHistoryPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + planStatus?: FuturesPlanStatusV2; + symbol?: string; + productType: FuturesProductTypeV2; + idLessThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} diff --git a/src/types/request/v2/margin.ts b/src/types/request/v2/margin.ts new file mode 100644 index 0000000..d8fc184 --- /dev/null +++ b/src/types/request/v2/margin.ts @@ -0,0 +1,148 @@ +/** + * + * * Margin | Cross/Isolated | Order Record + * + */ + +export interface GetBorrowHistoryRequestV2 { + loanId?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetRepayHistoryRequestV2 { + repayId?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetInterestHistoryRequestV2 { + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetLiquidationHistoryRequestV2 { + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetFinancialHistoryRequestV2 { + marginType?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Margin | Cross/Isolated | Account + * + */ + +/** + * + * * Margin | Cross/Isolated | Trade + * + */ + +export type MarginOrderTypeV2 = 'limit' | 'market'; + +export type MarginLoanTypeV2 = + | 'normal' + | 'autoLoan' + | 'autoRepay' + | 'autoLoanAndRepay'; + +export type MarginTimeInForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; + +export type MarginOrderSideV2 = 'buy' | 'sell'; + +export type MarginSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export interface MarginPlaceOrderRequestV2 { + symbol: string; + orderType: MarginOrderTypeV2; + price?: string; + loanType: MarginLoanTypeV2; + force: MarginTimeInForceV2; + baseSize?: string; + quoteSize?: string; + clientOid?: string; + side: MarginOrderSideV2; + stpMode?: MarginSTPModeV2; +} + +export interface MarginBatchOrderEntry { + orderType: MarginOrderTypeV2; + price?: string; + loanType: MarginLoanTypeV2; + force: MarginTimeInForceV2; + baseSize?: string; + quoteSize?: string; + clientOid?: string; + side: MarginOrderSideV2; + stpMode?: MarginSTPModeV2; +} + +export interface MarginBatchOrdersRequestV2 { + symbol: string; + orderList: MarginBatchOrderEntry[]; +} + +export interface GetMarginCurrentOrdersRequestV2 { + symbol: string; + orderId?: string; + clientOid?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetHistoryOrdersRequestV2 { + symbol: string; + orderId?: string; + enterPointSource?: string; + clientOid?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetMarginOrderFillsRequestV2 { + symbol: string; + orderId?: string; + idLessThan?: string; + startTime: string; + endTime?: string; + limit?: string; +} + +export interface GetMarginLiquidationOrdersRequestV2 { + type?: 'swap' | 'place_order'; + symbol?: string; + fromCoin?: string; + toCoin?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} diff --git a/src/types/request/v2/spot.ts b/src/types/request/v2/spot.ts index 74a8cae..84eb86c 100644 --- a/src/types/request/v2/spot.ts +++ b/src/types/request/v2/spot.ts @@ -1,27 +1,351 @@ -type SpotKlineIntervalV2 = - | '1min' - | '5min' - | '15min' - | '30min' - | '1h' - | '4h' - | '6h' - | '12h' - | '1day' - | '3day' - | '1week' - | '1M' - | '6Hutc' - | '12Hutc' - | '1Dutc' - | '3Dutc' - | '1Wutc' - | '1Mutc'; - -export interface SpotCandlesRequestV2 { - symbol: string; - granularity: SpotKlineIntervalV2; - startTime?: string; - endTime?: string; - limit?: string; -} +type SpotKlineIntervalV2 = + | '1min' + | '5min' + | '15min' + | '30min' + | '1h' + | '4h' + | '6h' + | '12h' + | '1day' + | '3day' + | '1week' + | '1M' + | '6Hutc' + | '12Hutc' + | '1Dutc' + | '3Dutc' + | '1Wutc' + | '1Mutc'; + +export interface SpotCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface SpotHistoricCandlesRequestV2 { + symbol: string; + granularity: SpotKlineIntervalV2; + endTime?: string; + limit?: string; +} + +export interface SpotHistoricTradesRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * * Spot | Trade + * + */ + +export type SpotOrderSideV2 = 'buy' | 'sell'; + +export type SpotOrderTypeV2 = 'limit' | 'market'; + +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; + +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; + +export type SpotSTPModeV2 = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export type SpotBatchModeV2 = 'single' | 'multiple'; + +export interface SpotOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelandSubmitOrderRequestV2 { + symbol: string; + price: string; + size: string; + orderId?: string; + clientOid?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelOrderRequestV2 { + symbol: string; + tpslType?: SpotTPSLTypeV2; + orderId?: string; + clientOid?: string; +} + +export interface SpotBatchOrderRequestItemV2 { + symbol?: string; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; + price?: string; + size: string; + clientOid?: string; + stpMode?: SpotSTPModeV2; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotBatchOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: SpotBatchOrderRequestItemV2[]; +} + +export interface SpotBatchCancelOrderRequestV2 { + symbol?: string; + batchMode?: SpotBatchModeV2; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; +} + +export interface GetSpotOrderInfoRequestV2 { + orderId?: string; + clientOid?: string; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotOpenOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotHistoryOrdersRequestV2 { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLTypeV2; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotFillsRequestV2 { + symbol: string; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Spot | Trigger Orders + * + */ + +export type SpotPlanTypeV2 = 'amount' | 'total'; + +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; + +export interface SpotPlanOrderRequestV2 { + symbol: string; + side: SpotOrderSideV2; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + planType?: SpotPlanTypeV2; + size: string; + triggerType: SpotTriggerTypeV2; + clientOid?: string; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; +} + +export interface SpotModifyPlanOrderRequestV2 { + orderId?: string; + clientOid?: string; + triggerPrice: string; + orderType: SpotOrderTypeV2; + executePrice?: string; + size: string; +} + +export interface GetSpotCurrentPlanOrdersRequestV2 { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +export interface GetSpotHistoryPlanOrdersRequestV2 { + symbol: string; + startTime: string; + endTime: string; + limit?: string; +} + +/** + * + * * Spot | Account + * + */ + +export type SpotBillGroupTypeV2 = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; + +export type SpotBusinessTypeV2 = + | 'deposit' + | 'withdraw' + | 'buy' + | 'sell' + | 'deduction of handling fee' + | 'transfer-in' + | 'transfer-out' + | 'rebate rewards' + | 'airdrop rewards' + | 'USDT contract rewards' + | 'mix contract rewards' + | 'system lock' + | 'user lock'; + +export type SpotAccountTypeV2 = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; + +export interface GetSpotAccountBillsRequestV2 { + coin?: string; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface SpotTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol: string; + clientOid?: string; +} + +export interface SpotSubAccountTransferRequestV2 { + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; + amount: string; + coin: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; +} + +export interface SpotWithdrawalRequestV2 { + coin: string; + transferType: 'on_chain' | 'internal_transfer'; + address: string; + chain?: string; + innerToType?: 'email' | 'mobile' | 'uid'; + areaCode?: string; + tag?: string; + size: string; + remark?: string; + clientOid?: string; +} + +export interface SpotMainSubTransferRecordRequestV2 { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotTransferRecordRequestV2 { + coin: string; + fromType: SpotAccountTypeV2; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotSubAccountDepositRecordRequestV2 { + subUid: string; + coin?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; +} + +export interface GetSpotWithdrawalRecordRequestV2 { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; + limit?: string; +} + +export interface GetSpotDepositRecordRequestV2 { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + idLessThan?: string; + limit?: string; +}