diff --git a/package-lock.json b/package-lock.json index b69b319..3bc75f6 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 f106477..349b300 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..5b50482 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -5,7 +5,136 @@ import { FuturesCandlesRequestV2, SpotCandlesRequestV2, SpotAccountBill, + SpotHistoricCandlesRequestV2, + SpotHistoricTradesRequest, + SpotOrderRequest, + SpotCancelandSubmitOrderRequest, + SpotCancelOrderRequest, + SpotBatchOrderRequest, + SpotBatchCancelOrderRequest, + GetSpotOrderInfoRequest, + GetSpotOpenOrdersRequest, + GetSpotHistoryOrdersRequest, + GetSpotFillsRequest, + SpotPlanOrderRequest, + SpotModifyPlanOrderRequest, + GetSpotCurrentPlanOrdersRequest, + GetSpotHistoryPlanOrdersRequest, + GetSpotAccountBillsRequest, + SpotTransferRequest, + SpotAccountType, + SpotSubAccountTransferRequest, + SpotWithdrawalRequest, + SpotMainSubTransferRecordRequest, + GetSpotTransferRecordRequest, + GetSpotSubAccountDepositRecordRequest, + GetSpotWithdrawalRecordRequest, + GetSpotDepositRecordRequest, + 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, + GetBorrowHistoryRequest, + GetRepayHistoryRequest, + GetInterestHistoryRequest, + GetLiquidationHistoryRequest, + GetFinancialHistoryRequest, + MarginPlaceOrderRequest, + MarginBatchOrdersRequest, + GetMarginCurrentOrdersRequest, + GetHistoryOrdersRequest, + GetMarginOrderFillsRequest, + GetMarginLiquidationOrdersRequest, + GetFuturesTraderCurrentOrdersRequest, + GetFuturesTraderHistoryOrdersRequest, + ModifyFuturesTraderOrderTPSLRequest, + GetFuturesTraderProfitShareDetailRequest, + CopyTradingProductType, + FuturesTraderSymbolSettingReq, + GetFuturesTraderFollowers, + GetFollowerFuturesCurrentTrackingOrdersRequest, + GetFollowerFuturesHistoryTrackingOrdersRequest, + UpdateFuturesFollowerTPSLRequest, + UpdateFuturesFollowerSettingsRequest, + GetFuturesFollowerTradersRequest, + CloseFuturesFollowerPositionsRequest, + getSpotTraderHistoryProfitReq, + GetSpotTraderHistoryOrdersReq, + GetSpotTraderCurrentOrdersReq, + GetSpotTraderFollowersRequest, + SpotFollowerCopyTradeSetting, + GetSpotFollowerHistoryOrdersRequest, + GetSpotFollowerOpenOrdersRequest, + GetEarnSavingsAssetsRequest, + GetEarnSavingsRecordsRequest, + RedeemSavingsRequest, + GetSharkfinAssetsRequest, + GetSharkfinRecordsRequest, + GetLoanEstInterestAndBorrowableRequest, + BorrowLoanRequest, + RepayLoanRequest, + GetLoanRepayHistoryRequest, + ModifyLoanPledgeRateRequest, + GetLoanPledgeRateHistoryRequest, + GetLoanHistoryRequest, + GetLiquidationRecordsRequest, } from './types'; +import { + CreateSubaccountApiKeyRequest, + GetSubaccountsRequest, + ModifySubaccountApiKeyRequest, + ModifySubRequest, + SubDepositRecordsRequest, + SubWithdrawalRecordsRequest, + SubWithdrawalRequest, +} from './types/request/v2/broker'; +import { + ConvertQuoteRequest, + ConvertRequest, + CreateVirtualSubApiKeyRequest, + CreateVirtualSubRequest, + GetAnnouncementsRequest, + GetConvertHistoryRequest, + GetFuturesTransactionsRequest, + GetMarginTransactionsRequest, + GetMerchantAdvertisementsRequest, + GetMerchantP2POrdersRequest, + GetP2PMerchantsRequest, + GetP2PTransactionsRequest, + GetSpotTransactionsRequest, + GetTradeRateRequest, + ModifyVirtualSubRequest, + ModifyVirtualSubApiKeyRequest, + GetConvertBGBHistoryRequest, +} 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?: GetAnnouncementsRequest, + ): 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: GetTradeRateRequest): 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: GetSpotTransactionsRequest, + ): Promise> { return this.getPrivate(`/api/v2/tax/spot-record`, params); } - getFuturesTransactionRecords(params: object): Promise> { + getFuturesTransactionRecords( + params: GetFuturesTransactionsRequest, + ): Promise> { return this.getPrivate(`/api/v2/tax/future-record`, params); } - getMarginTransactionRecords(params: object): Promise> { + getMarginTransactionRecords( + params: GetMarginTransactionsRequest, + ): Promise> { return this.getPrivate(`/api/v2/tax/margin-record`, params); } - getP2PTransactionRecords(params: object): Promise> { + getP2PTransactionRecords( + params: GetP2PTransactionsRequest, + ): 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?: GetP2PMerchantsRequest, + ): 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: GetMerchantP2POrdersRequest, + ): Promise> { return this.getPrivate(`/api/v2/p2p/orderList`, params); } - getP2PMerchantAdvertisementList(params: object): Promise> { + getP2PMerchantAdvertisementList( + params: GetMerchantAdvertisementsRequest, + ): 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: ModifyVirtualSubRequest, + ): Promise> { return this.postPrivate(`/api/v2/user/modify-virtual-subaccount`, params); } batchCreateVirtualSubaccountAndAPIKey( - params: object, + params: CreateVirtualSubRequest, ): 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: CreateVirtualSubApiKeyRequest, + ): Promise> { return this.postPrivate( '/api/v2/user/create-virtual-subaccount-apikey', params, ); } - modifyVirtualSubaccountAPIKey(params: object): Promise> { + modifyVirtualSubaccountAPIKey( + params: ModifyVirtualSubApiKeyRequest, + ): 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: ConvertQuoteRequest, + ): Promise> { return this.getPrivate(`/api/v2/convert/quoted-price`, params); } - convert(params: object): Promise> { + convert(params: ConvertRequest): Promise> { return this.postPrivate(`/api/v2/convert/trade`, params); } - getConvertHistory(params: object): Promise> { + getConvertHistory( + params: GetConvertHistoryRequest, + ): 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: GetConvertBGBHistoryRequest, + ): 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: SpotHistoricTradesRequest, + ): 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: SpotOrderRequest): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-order`, params); } - spotCancelOrder(params: object): Promise> { + spotCancelandSubmitOrder( + params: SpotCancelandSubmitOrderRequest, + ): Promise> { + return this.postPrivate(`/api/v2/spot/trade/cancel-replace-order`, params); + } + + spotBatchCancelandSubmitOrder(params: { + orderList: SpotCancelandSubmitOrderRequest[]; + }): Promise> { + return this.postPrivate( + `/api/v2/spot/trade/batch-cancel-replace-order`, + params, + ); + } + + spotCancelOrder(params: SpotCancelOrderRequest): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-order`, params); } - spotBatchSubmitOrders(params: object): Promise> { + spotBatchSubmitOrders( + params: SpotBatchOrderRequest, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/batch-orders`, params); } - spotBatchCancelOrders(params: object): Promise> { + spotBatchCancelOrders( + params: SpotBatchCancelOrderRequest, + ): 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?: GetSpotOrderInfoRequest): Promise> { return this.getPrivate(`/api/v2/spot/trade/orderInfo`, params); } - getSpotOpenOrders(params?: object): Promise> { + getSpotOpenOrders( + params?: GetSpotOpenOrdersRequest, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/unfilled-orders`, params); } - getSpotHistoricOrders(params?: object): Promise> { + getSpotHistoricOrders( + params?: GetSpotHistoryOrdersRequest, + ): Promise> { return this.getPrivate(`/api/v2/spot/trade/history-orders`, params); } - getSpotFills(params: object): Promise> { + getSpotFills(params: GetSpotFillsRequest): Promise> { return this.getPrivate(`/api/v2/spot/trade/fills`, params); } @@ -431,31 +658,44 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitPlanOrder(params: object): Promise> { + spotSubmitPlanOrder(params: SpotPlanOrderRequest): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-plan-order`, params); } - spotModifyPlanOrder(params: object): Promise> { + spotModifyPlanOrder( + params: SpotModifyPlanOrderRequest, + ): 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: GetSpotCurrentPlanOrdersRequest, + ): 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: GetSpotHistoryPlanOrdersRequest, + ): 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 +712,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 +723,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?: GetSpotAccountBillsRequest, + ): Promise> { return this.getPrivate(`/api/v2/spot/account/bills`, params); } - spotTransfer(params: object): Promise> { + spotTransfer(params: SpotTransferRequest): Promise> { return this.postPrivate(`/api/v2/spot/wallet/transfer`, params); } - getSpotTransferableCoins(params: object): Promise> { + getSpotTransferableCoins(params: { + fromType: SpotAccountType; + toType: SpotAccountType; + }): Promise> { return this.getPrivate(`/api/v2/spot/wallet/transfer-coin-info`, params); } - spotSubTransfer(params: object): Promise> { + spotSubTransfer( + params: SpotSubAccountTransferRequest, + ): 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: SpotWithdrawalRequest): 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: SpotMainSubTransferRecordRequest, + ): Promise> { return this.getPrivate( `/api/v2/spot/account/sub-main-trans-record`, params, ); } - getSubAccountDepositRecords(params: object): Promise> { + getSpotTransferHistory( + params: GetSpotTransferRecordRequest, + ): 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: GetSpotSubAccountDepositRecordRequest, + ): Promise> { return this.getPrivate( `/api/v2/spot/wallet/subaccount-deposit-records`, params, ); } + getSpotDepositHistory( + params: GetSpotDepositRecordRequest, + ): Promise> { + return this.getPrivate(`/api/v2/spot/wallet/deposit-records`, params); + } + + getSpotWithdrawalHistory( + params: GetSpotWithdrawalRecordRequest, + ): Promise> { + return this.getPrivate(`/api/v2/spot/wallet/withdrawal-records`, params); + } + /** * * @@ -582,15 +845,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 +884,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 +964,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 +1044,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 +1078,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 +1160,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 +1224,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 +1238,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?: GetSubaccountsRequest): Promise> { return this.getPrivate(`/api/v2/broker/account/subaccount-list`, params); } - modifySubaccount(params: object): Promise> { + modifySubaccount(params: ModifySubRequest): 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: SubWithdrawalRequest, + ): 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: SubDepositRecordsRequest, + ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-deposit`, params); } - subaccountWithdrawalRecords(params: object): Promise> { + subaccountWithdrawalRecords( + params: SubWithdrawalRecordsRequest, + ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-withdrawal`, params); } @@ -904,21 +1327,25 @@ export class RestClientV2 extends BaseRestClient { * */ - createSubaccountApiKey(params: object): Promise> { + createSubaccountApiKey( + params: CreateSubaccountApiKeyRequest, + ): 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: ModifySubaccountApiKeyRequest, + ): Promise> { return this.postPrivate( `/api/v2/broker/manage/modify-subaccount-apikey`, params, @@ -951,7 +1378,7 @@ export class RestClientV2 extends BaseRestClient { getMarginBorrowHistory( marginType: MarginType, - params: object, + params: GetBorrowHistoryRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -962,7 +1389,7 @@ export class RestClientV2 extends BaseRestClient { getMarginRepayHistory( marginType: MarginType, - params: object, + params: GetRepayHistoryRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -973,7 +1400,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestHistory( marginType: MarginType, - params: object, + params: GetInterestHistoryRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -984,7 +1411,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationHistory( marginType: MarginType, - params: object, + params: GetLiquidationHistoryRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -995,7 +1422,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFinancialHistory( marginType: MarginType, - params: object, + params: GetFinancialHistoryRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1012,7 +1439,7 @@ export class RestClientV2 extends BaseRestClient { getMarginAccountAssets( marginType: MarginType, - params?: object, + params?: { coin?: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1023,7 +1450,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 +1465,10 @@ export class RestClientV2 extends BaseRestClient { marginRepay( marginType: MarginType, - params: object, + params: { + coin: string; + repayAmount: string; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1050,7 +1484,7 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxBorrowable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1061,7 +1495,7 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxTransferable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1072,7 +1506,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestRateAndMaxBorrowable( marginType: MarginType, - params: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1083,7 +1517,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 +1525,7 @@ export class RestClientV2 extends BaseRestClient { marginFlashRepay( marginType: MarginType, - params?: object, + params: { coin: string }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1102,7 +1536,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFlashRepayResult( marginType: MarginType, - params: object, + params: { idList: string }, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1119,7 +1553,7 @@ export class RestClientV2 extends BaseRestClient { marginSubmitOrder( marginType: MarginType, - params: object, + params: MarginPlaceOrderRequest, ): Promise> { assertMarginType(marginType); return this.postPrivate(`/api/v2/margin/${marginType}/place-order`, params); @@ -1127,7 +1561,7 @@ export class RestClientV2 extends BaseRestClient { marginBatchSubmitOrders( marginType: MarginType, - params: object, + params: MarginBatchOrdersRequest, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1138,7 +1572,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 +1587,10 @@ export class RestClientV2 extends BaseRestClient { marginBatchCancelOrders( marginType: MarginType, - params: object, + params: { + symbol: string; + orderIdList: string[]; + }, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1160,7 +1601,7 @@ export class RestClientV2 extends BaseRestClient { getMarginOpenOrders( marginType: MarginType, - params: object, + params: GetMarginCurrentOrdersRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/open-orders`, params); @@ -1168,7 +1609,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrders( marginType: MarginType, - params: object, + params: GetHistoryOrdersRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1179,7 +1620,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrderFills( marginType: MarginType, - params: object, + params: GetMarginOrderFillsRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/fills`, params); @@ -1187,7 +1628,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationOrders( marginType: MarginType, - params: object, + params: GetMarginLiquidationOrdersRequest, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1212,21 +1653,27 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesTraderCurrentOrder(params: object): Promise> { + getFuturesTraderCurrentOrder( + params: GetFuturesTraderCurrentOrdersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-current-track`, params, ); } - getFuturesTraderHistoryOrders(params: object): Promise> { + getFuturesTraderHistoryOrders( + params: GetFuturesTraderHistoryOrdersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-history-track`, params, ); } - modifyFuturesTraderOrderTPSL(params: object): Promise> { + modifyFuturesTraderOrderTPSL( + params: ModifyFuturesTraderOrderTPSLRequest, + ): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/order-modify-tpsl`, params, @@ -1242,7 +1689,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderProfitShareHistory( - params: object, + params: GetFuturesTraderProfitShareDetailRequest, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/profit-history-details`, @@ -1250,53 +1697,76 @@ export class RestClientV2 extends BaseRestClient { ); } - closeFuturesTraderOrder(params: object): Promise> { + closeFuturesTraderOrder(params: { + trackingNo: string; + symbol: string; + productType: CopyTradingProductType; + }): 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: CopyTradingProductType; + }): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/config-query-symbols`, params, ); } - updateFuturesTraderSymbolSettings(params: object): Promise> { + updateFuturesTraderSymbolSettings(params: { + settingList: FuturesTraderSymbolSettingReq[]; + }): 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?: GetFuturesTraderFollowers, + ): 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 +1781,70 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesFollowerCurrentOrders(params: object): Promise> { + getFuturesFollowerCurrentOrders( + params: GetFollowerFuturesCurrentTrackingOrdersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-current-orders`, params, ); } - getFuturesFollowerHistoryOrders(params: object): Promise> { + getFuturesFollowerHistoryOrders( + params: GetFollowerFuturesHistoryTrackingOrdersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-history-orders`, params, ); } - updateFuturesFollowerTPSL(params: object): Promise> { + updateFuturesFollowerTPSL( + params: UpdateFuturesFollowerTPSLRequest, + ): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/setting-tpsl`, params); } - updateFuturesFollowerSettings(params: object): Promise> { + updateFuturesFollowerSettings( + params: UpdateFuturesFollowerSettingsRequest, + ): 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: CloseFuturesFollowerPositionsRequest, + ): Promise> { return this.postPrivate( `/api/v2/copy/mix-follower/close-positions`, params, ); } - getFuturesFollowerTraders(params: object): Promise> { + getFuturesFollowerTraders( + params: GetFuturesFollowerTradersRequest, + ): Promise> { return this.getPrivate(`/api/v2/copy/mix-follower/query-traders`, params); } - getFuturesFollowerFollowLimit(params: object): Promise> { + getFuturesFollowerFollowLimit(params: { + symbol: string; + productType: CopyTradingProductType; + }): 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 +1886,20 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/copy/spot-trader/profit-summarys`); } - getSpotTraderHistoryProfit(params: object): Promise> { + getSpotTraderHistoryProfit( + params: getSpotTraderHistoryProfitReq, + ): 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 +1907,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: GetSpotTraderHistoryOrdersReq, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/order-history-track`, params, ); } - getSpotTraderCurrentOrders(params: object): Promise> { + getSpotTraderCurrentOrders( + params: GetSpotTraderCurrentOrdersReq, + ): 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 +1969,9 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/copy/spot-trader/config-query-settings`); } - getSpotTraderFollowers(params: object): Promise> { + getSpotTraderFollowers( + params: GetSpotTraderFollowersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/config-query-followers`, params, @@ -1468,62 +1981,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: SpotFollowerCopyTradeSetting[]; + }): 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: GetSpotFollowerHistoryOrdersRequest, + ): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-history-orders`, params, ); } - getSpotFollowerOpenOrders(params: object): Promise> { + getSpotFollowerOpenOrders( + params: GetSpotFollowerOpenOrdersRequest, + ): 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 +2073,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 +2084,48 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/savings/account`); } - getEarnSavingsAssets(params: object): Promise> { + getEarnSavingsAssets( + params: GetEarnSavingsAssetsRequest, + ): Promise> { return this.getPrivate(`/api/v2/earn/savings/assets`, params); } - getEarnSavingsRecords(params: object): Promise> { + getEarnSavingsRecords( + params: GetEarnSavingsRecordsRequest, + ): 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: RedeemSavingsRequest): 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 +2137,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 +2149,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 +2161,34 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/sharkfin/account`); } - getSharkfinAssets(params: object): Promise> { + getSharkfinAssets( + params: GetSharkfinAssetsRequest, + ): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/assets`, params); } - getSharkfinRecords(params: object): Promise> { + getSharkfinRecords( + params: GetSharkfinRecordsRequest, + ): 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 +2200,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: GetLoanEstInterestAndBorrowableRequest, + ): Promise> { return this.get(`/api/v2/earn/loan/public/hour-interest`, params); } - borrowLoan(params: object): Promise> { + borrowLoan(params: BorrowLoanRequest): 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: RepayLoanRequest): Promise> { return this.postPrivate(`/api/v2/earn/loan/repay`, params); } - getRepayHistory(params: object): Promise> { + getRepayHistory( + params: GetLoanRepayHistoryRequest, + ): Promise> { return this.getPrivate(`/api/v2/earn/loan/repay-history`, params); } - updateLoanPledgeRate(params: object): Promise> { + updateLoanPledgeRate( + params: ModifyLoanPledgeRateRequest, + ): Promise> { return this.postPrivate(`/api/v2/earn/loan/revise-pledge`, params); } - getLoanPledgeRateHistory(params: object): Promise> { + getLoanPledgeRateHistory( + params: GetLoanPledgeRateHistoryRequest, + ): Promise> { return this.getPrivate(`/api/v2/earn/loan/revise-history`, params); } - getLoanHistory(params: object): Promise> { + getLoanHistory(params: GetLoanHistoryRequest): 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: GetLiquidationRecordsRequest, + ): 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..a350c50 --- /dev/null +++ b/src/types/request/v2/broker.ts @@ -0,0 +1,99 @@ +/** + * + * * Broker | Subaccount + * + */ + +export interface GetSubaccountsRequest { + limit?: string; + idLessThan?: string; + status?: 'normal' | 'freeze' | 'del'; + startTime?: string; + endTime?: string; +} + +export type SubaccountPermission = + | 'withdraw' + | 'transfer' + | 'spot_trade' + | 'contract_trade' + | 'read' + | 'deposit' + | 'margin_trade'; + +export type SubaccountLanguage = + | '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 SubaccountStatus = 'normal' | 'freeze'; + +export interface ModifySubRequest { + subUid: string; + permList: SubaccountPermission[]; + status: SubaccountStatus; + language?: SubaccountLanguage; +} + +export interface SubWithdrawalRequest { + subUid: string; + coin: string; + dest: 'on_chain' | 'internal_transfer'; + chain?: string; + address: string; + amount: string; + tag?: string; + clientOid?: string; +} + +export interface SubDepositRecordsRequest { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface SubWithdrawalRecordsRequest { + orderId?: string; + userId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Broker | Subaccount + * + */ + +export interface CreateSubaccountApiKeyRequest { + subUid: string; + passphrase: string; + label?: string; + ipList: string[]; + permType: string; + permList: string[]; +} + +export interface ModifySubaccountApiKeyRequest { + 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..6ad352f --- /dev/null +++ b/src/types/request/v2/common.ts @@ -0,0 +1,187 @@ +import { FuturesProductTypeV2, MarginType } from '../shared'; + +/** + * + * * Common | Notice + * + */ + +export interface GetAnnouncementsRequest { + annType?: string; + startTime?: string; + endTime?: string; + language: string; +} + +/** + * + * * Common | Public + * + */ + +export interface GetTradeRateRequest { + symbol: string; + businessType: string; +} + +/** + * + * * Common | Tax + * + */ + +export interface GetSpotTransactionsRequest { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetFuturesTransactionsRequest { + productType?: FuturesProductTypeV2; + marginCoin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetMarginTransactionsRequest { + marginType?: MarginType; + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +export interface GetP2PTransactionsRequest { + coin?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | P2P + * + */ + +export interface GetP2PMerchantsRequest { + online?: 'yes' | 'no'; + idLessThan?: string; + limit?: string; +} + +export interface GetMerchantP2POrdersRequest { + startTime: string; + endTime?: string; + idLessThan?: string; + limit?: string; + status?: string; + advNo: string; + side?: string; + coin?: string; + language: string; + fiat?: string; + orderNo?: string; +} + +export interface GetMerchantAdvertisementsRequest { + 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 ModifyVirtualSubRequest { + subAccountUid: string; + permList: string[]; + status: string; +} + +export interface CreateVirtualSubRequest { + subAccountName: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface CreateVirtualSubApiKeyRequest { + subAccountUid: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +export interface ModifyVirtualSubApiKeyRequest { + subAccountUid: string; + subAccountApiKey: string; + passphrase: string; + label: string; + ipList?: string[]; + permList?: string[]; +} + +/** + * + * * Common | Convert + * + */ + +export interface ConvertQuoteRequest { + fromCoin: string; + fromCoinSize?: string; + toCoin: string; + toCoinSize?: string; +} + +export interface ConvertRequest { + fromCoin: string; + fromCoinSize: string; + cnvtPrice: string; + toCoin: string; + toCoinSize: string; + traceId: string; +} + +export interface GetConvertHistoryRequest { + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Common | BGB Convert + * + */ + +export interface GetConvertBGBHistoryRequest { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; + } \ No newline at end of file diff --git a/src/types/request/v2/copytrading.ts b/src/types/request/v2/copytrading.ts new file mode 100644 index 0000000..f9928ce --- /dev/null +++ b/src/types/request/v2/copytrading.ts @@ -0,0 +1,223 @@ +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ + +export type CopyTradingProductType = + | 'USDT-FUTURES' + | 'COIN-FUTURES' + | 'USDC-FUTURES'; + +export interface GetFuturesTraderCurrentOrdersRequest { + symbol?: string; + productType: CopyTradingProductType; + startTime?: string; + endTime?: string; + limit?: string; + idGreaterThan?: string; + idLessThan?: string; +} + +export interface GetFuturesTraderHistoryOrdersRequest { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + order?: 'asc' | 'desc'; + symbol?: string; + productType: CopyTradingProductType; +} + +export interface ModifyFuturesTraderOrderTPSLRequest { + trackingNo: string; + productType: CopyTradingProductType; + stopSurplusPrice?: string; + stopLossPrice?: string; +} + +export interface GetFuturesTraderProfitShareDetailRequest { + coin?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesTraderSymbolSettingReq { + symbol: string; + productType: CopyTradingProductType; + settingType: 'ADD' | 'DELETE' | 'UPDATE'; + stopSurplusRatio?: string; + stopLossRatio?: string; +} + +export interface GetFuturesTraderFollowers { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ + +export interface GetFollowerFuturesCurrentTrackingOrdersRequest { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; + productType: CopyTradingProductType; + traderId?: string; +} + +export interface GetFollowerFuturesHistoryTrackingOrdersRequest { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; + productType: CopyTradingProductType; + traderId?: string; +} + +export interface UpdateFuturesFollowerTPSLRequest { + trackingNo: string; + symbol?: string; + productType: CopyTradingProductType; + 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 FollowerCopyTradeSetting { + symbol: string; + productType: CopyTradingProductType; + marginType: 'trader' | 'specify'; + marginCoin?: string; + leverType: LeverageType; + longLeverage?: string; + shortLeverage?: string; + traceType: TraceType; + traceValue: string; + maxHoldSize?: string; + stopSurplusRatio?: string; + stopLossRatio?: string; +} + +export interface UpdateFuturesFollowerSettingsRequest { + traderId: string; + autoCopy?: AutoCopyOption; + mode?: FollowMode; + settings: FollowerCopyTradeSetting[]; +} +export interface CloseFuturesFollowerPositionsRequest { + productType: CopyTradingProductType; + trackingNo?: string; + symbol?: string; + marginCoin?: string; + marginMode?: 'isolated' | 'cross'; + holdSide?: 'long' | 'short'; +} + +export interface GetFuturesFollowerTradersRequest { + startTime?: string; + endTime?: string; + pageNo?: string; + pageSize?: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Trader api + * + * + */ + +export interface getSpotTraderHistoryProfitReq { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + coin?: string; +} + +export interface GetSpotTraderHistoryOrdersReq { + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; + symbol?: string; +} + +export interface GetSpotTraderCurrentOrdersReq { + symbol?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetSpotTraderFollowersRequest { + pageNo?: string; + pageSize?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ + +export interface SpotFollowerCopyTradeSetting { + symbol: string; + traceType: 'percent' | 'amount' | 'count'; + maxHoldSize: string; + traceValue: string; + stopLossRatio?: string; + stopSurplusRatio?: string; +} + +export interface GetSpotFollowerHistoryOrdersRequest { + symbol?: string; + traderId?: string; + idLessThan?: string; + idGreaterThan?: string; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface GetSpotFollowerOpenOrdersRequest { + 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..dfbe14b --- /dev/null +++ b/src/types/request/v2/earn.ts @@ -0,0 +1,136 @@ +/** + * + * + * Earn | Savings + * + * + */ + +export interface GetEarnSavingsAssetsRequest { + periodType: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetEarnSavingsRecordsRequest { + coin?: string; + periodType: string; + orderType?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface RedeemSavingsRequest { + productId: string; + orderId?: string; + periodType: string; + amount: string; +} + +/** + * + * + * Earn | Shark Fin + * + * + */ + +export interface GetSharkfinAssetsRequest { + status: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSharkfinRecordsRequest { + coin?: string; + type: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * + * Earn | Loan + * + * + */ + +export interface GetLoanEstInterestAndBorrowableRequest { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY'; + pledgeAmount?: string; +} + +export interface BorrowLoanRequest { + loanCoin: string; + pledgeCoin: string; + daily: 'SEVEN' | 'THIRTY'; + pledgeAmount?: string; + loanAmount?: string; +} + +export interface RepayLoanRequest { + orderId: string; + amount?: string; + repayUnlock?: string; + repayAll: string; +} + +export interface GetLoanRepayHistoryRequest { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface ModifyLoanPledgeRateRequest { + orderId: string; + amount: string; + pledgeCoin: string; + reviseType: string; +} + +export interface GetLoanPledgeRateHistoryRequest { + orderId?: string; + reviseSide?: string; + pledgeCoin?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface GetLoanHistoryRequest { + orderId?: string; + loanCoin?: string; + pledgeCoin?: string; + status?: string; + startTime: string; + endTime: string; + pageNo?: string; + pageSize?: string; +} + +export interface GetLiquidationRecordsRequest { + 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..5ca0f5e 100644 --- a/src/types/request/v2/futures.ts +++ b/src/types/request/v2/futures.ts @@ -1,32 +1,441 @@ -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 { - productType: FuturesProductTypeV2; - symbol?: string; - coin?: string; - businessType?: string; - idLessThan?: string; - startTime?: string; - endTime?: string; - limit?: string; -} - -export interface FuturesCandlesRequestV2 { - symbol: string; - productType: FuturesProductTypeV2; - granularity: FuturesKlineInterval; - startTime?: string; - endTime?: string; - kLineType?: FuturesKlineTypeV2; - limit?: string; -} +import { FuturesPlanTypeV2, FuturesProductTypeV2 } from '../shared'; +import { FuturesKlineInterval } from '../v1/futuresV1'; + +export type FuturesKlineTypeV2 = 'MARKET' | 'MARK' | 'INDEX'; + +export interface FuturesAccountBillRequestV2 { + productType: FuturesProductTypeV2; + symbol?: string; + coin?: string; + businessType?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; + 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; + granularity: FuturesKlineInterval; + startTime?: string; + endTime?: string; + 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 FuturesOrderSource = + | '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?: FuturesOrderSource; + startTime?: string; + endTime?: string; + limit?: string; +} + +export interface FuturesCancelAllOrdersRequestV2 { + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + requestTime?: string; + receiveWindow?: string; +} + +/** + * + * * Futures | Trigger Orders + * + */ + +export type FuturesTriggerType = 'fill_price' | 'mark_price'; + +export type FuturesStpMode = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export interface FuturesTPSLOrderRequestV2 { + marginCoin: string; + productType: FuturesProductTypeV2; + symbol: string; + planType: FuturesPlanTypeV2; + triggerPrice: string; + triggerType?: FuturesTriggerType; + executePrice?: string; + holdSide: 'long' | 'short' | 'buy' | 'sell'; + size: string; + rangeRate?: string; + clientOid?: string; + stpMode?: FuturesStpMode; +} + +export type FuturesTriggerPriceType = + | '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?: FuturesTriggerPriceType; + stopLossTriggerPrice?: string; + stopLossExecutePrice?: string; + stopLossTriggerType?: FuturesTriggerPriceType; + stpMode?: FuturesStpMode; +} + +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?: FuturesTriggerPriceType; + newStopLossTriggerPrice?: string; + newStopLossExecutePrice?: string; + newStopLossTriggerType?: FuturesTriggerPriceType; +} + +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 FuturesCancelPlanOrderItem { + orderId?: string; + clientOid?: string; +} + +export type FuturesPlanOrderType = + | 'normal_plan' + | 'profit_plan' + | 'loss_plan' + | 'pos_profit' + | 'pos_loss' + | 'moving_plan'; + +export interface FuturesCancelPlanOrderRequestV2 { + orderIdList?: FuturesCancelPlanOrderItem[]; + symbol?: string; + productType: FuturesProductTypeV2; + marginCoin?: string; + planType?: FuturesPlanOrderType; +} + +export type FuturesPlanStatus = 'executed' | 'fail_trigger' | 'cancelled'; + +export interface FuturesGetHistoryPlanOrdersRequestV2 { + orderId?: string; + clientOid?: string; + planType: 'normal_plan' | 'track_plan' | 'profit_loss'; + planStatus?: FuturesPlanStatus; + 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..63e99d3 --- /dev/null +++ b/src/types/request/v2/margin.ts @@ -0,0 +1,148 @@ +/** + * + * * Margin | Cross/Isolated | Order Record + * + */ + +export interface GetBorrowHistoryRequest { + loanId?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetRepayHistoryRequest { + repayId?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetInterestHistoryRequest { + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetLiquidationHistoryRequest { + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetFinancialHistoryRequest { + marginType?: string; + coin?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Margin | Cross/Isolated | Account + * + */ + +/** + * + * * Margin | Cross/Isolated | Trade + * + */ + +export type MarginOrderType = 'limit' | 'market'; + +export type MarginLoanType = + | 'normal' + | 'autoLoan' + | 'autoRepay' + | 'autoLoanAndRepay'; + +export type MarginTimeInForce = 'gtc' | 'post_only' | 'fok' | 'ioc'; + +export type MarginOrderSide = 'buy' | 'sell'; + +export type MarginSTPMode = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export interface MarginPlaceOrderRequest { + symbol: string; + orderType: MarginOrderType; + price?: string; + loanType: MarginLoanType; + force: MarginTimeInForce; + baseSize?: string; + quoteSize?: string; + clientOid?: string; + side: MarginOrderSide; + stpMode?: MarginSTPMode; +} + +export interface MarginBatchOrderEntry { + orderType: MarginOrderType; + price?: string; + loanType: MarginLoanType; + force: MarginTimeInForce; + baseSize?: string; + quoteSize?: string; + clientOid?: string; + side: MarginOrderSide; + stpMode?: MarginSTPMode; +} + +export interface MarginBatchOrdersRequest { + symbol: string; + orderList: MarginBatchOrderEntry[]; +} + +export interface GetMarginCurrentOrdersRequest { + symbol: string; + orderId?: string; + clientOid?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetHistoryOrdersRequest { + symbol: string; + orderId?: string; + enterPointSource?: string; + clientOid?: string; + startTime: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetMarginOrderFillsRequest { + symbol: string; + orderId?: string; + idLessThan?: string; + startTime: string; + endTime?: string; + limit?: string; +} + +export interface GetMarginLiquidationOrdersRequest { + 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..1d5d049 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 SpotHistoricTradesRequest { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +/** + * + * * Spot | Trade + * + */ + +export type SpotOrderSide = 'buy' | 'sell'; + +export type SpotOrderType = 'limit' | 'market'; + +export type SpotOrderForce = 'gtc' | 'post_only' | 'fok' | 'ioc'; + +export type SpotTPSLType = 'normal' | 'tpsl'; + +export type SpotSTPMode = + | 'none' + | 'cancel_taker' + | 'cancel_maker' + | 'cancel_both'; + +export type SpotBatchMode = 'single' | 'multiple'; + +export interface SpotOrderRequest { + symbol: string; + side: SpotOrderSide; + orderType: SpotOrderType; + force: SpotOrderForce; + price?: string; + size: string; + clientOid?: string; + triggerPrice?: string; + tpslType?: SpotTPSLType; + requestTime?: string; + receiveWindow?: string; + stpMode?: SpotSTPMode; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelandSubmitOrderRequest { + symbol: string; + price: string; + size: string; + orderId?: string; + clientOid?: string; + newClientOid?: string; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotCancelOrderRequest { + symbol: string; + tpslType?: SpotTPSLType; + orderId?: string; + clientOid?: string; +} + +export interface SpotBatchOrderRequestItem { + symbol?: string; + side: SpotOrderSide; + orderType: SpotOrderType; + force: SpotOrderForce; + price?: string; + size: string; + clientOid?: string; + stpMode?: SpotSTPMode; + presetTakeProfitPrice?: string; + executeTakeProfitPrice?: string; + presetStopLossPrice?: string; + executeStopLossPrice?: string; +} + +export interface SpotBatchOrderRequest { + symbol?: string; + batchMode?: SpotBatchMode; + orderList: SpotBatchOrderRequestItem[]; +} + +export interface SpotBatchCancelOrderRequest { + symbol?: string; + batchMode?: SpotBatchMode; + orderList: { + symbol?: string; + orderId?: string; + clientOid?: string; + }[]; +} + +export interface GetSpotOrderInfoRequest { + orderId?: string; + clientOid?: string; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotOpenOrdersRequest { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLType; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotHistoryOrdersRequest { + symbol?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; + orderId?: string; + tpslType?: SpotTPSLType; + requestTime?: string; + receiveWindow?: string; +} + +export interface GetSpotFillsRequest { + symbol: string; + orderId?: string; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +/** + * + * * Spot | Trigger Orders + * + */ + +export type SpotPlanType = 'amount' | 'total'; + +export type SpotTriggerType = 'fill_price' | 'mark_price'; + +export interface SpotPlanOrderRequest { + symbol: string; + side: SpotOrderSide; + triggerPrice: string; + orderType: SpotOrderType; + executePrice?: string; + planType?: SpotPlanType; + size: string; + triggerType: SpotTriggerType; + clientOid?: string; + force?: SpotOrderForce; + stpMode?: SpotSTPMode; +} + +export interface SpotModifyPlanOrderRequest { + orderId?: string; + clientOid?: string; + triggerPrice: string; + orderType: SpotOrderType; + executePrice?: string; + size: string; +} + +export interface GetSpotCurrentPlanOrdersRequest { + symbol: string; + limit?: string; + idLessThan?: string; + startTime?: string; + endTime?: string; +} + +export interface GetSpotHistoryPlanOrdersRequest { + symbol: string; + startTime: string; + endTime: string; + limit?: string; +} + +/** + * + * * Spot | Account + * + */ + +export type SpotBillGroupType = + | 'deposit' + | 'withdraw' + | 'transaction' + | 'transfer' + | 'other'; + +export type SpotBusinessType = + | '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 SpotAccountType = + | 'spot' + | 'p2p' + | 'coin_futures' + | 'usdt_futures' + | 'usdc_futures' + | 'crossed_margin' + | 'isolated_margin'; + +export interface GetSpotAccountBillsRequest { + coin?: string; + groupType?: SpotBillGroupType; + businessType?: SpotBusinessType; + startTime?: string; + endTime?: string; + limit?: string; + idLessThan?: string; +} + +export interface SpotTransferRequest { + fromType: SpotAccountType; + toType: SpotAccountType; + amount: string; + coin: string; + symbol: string; + clientOid?: string; +} + +export interface SpotSubAccountTransferRequest { + fromType: SpotAccountType; + toType: SpotAccountType; + amount: string; + coin: string; + symbol?: string; + clientOid?: string; + fromUserId: string; + toUserId: string; +} + +export interface SpotWithdrawalRequest { + 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 SpotMainSubTransferRecordRequest { + coin?: string; + role?: 'initiator' | 'receiver'; + subUid?: string; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotTransferRecordRequest { + coin: string; + fromType: SpotAccountType; + startTime?: string; + endTime?: string; + clientOid?: string; + limit?: string; + idLessThan?: string; +} + +export interface GetSpotSubAccountDepositRecordRequest { + subUid: string; + coin?: string; + startTime?: string; + endTime?: string; + idLessThan?: string; + limit?: string; +} + +export interface GetSpotWithdrawalRecordRequest { + coin?: string; + clientOid?: string; + startTime: string; + endTime: string; + idLessThan?: string; + orderId?: string; + limit?: string; +} + +export interface GetSpotDepositRecordRequest { + coin?: string; + orderId?: string; + startTime: string; + endTime: string; + idLessThan?: string; + limit?: string; +} \ No newline at end of file