From cf2464a2104ea5adaccaeef90e65760755786d3c Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 10 Dec 2024 12:16:28 +0100 Subject: [PATCH 1/5] v2.1.0 feat(): added all request types --- package-lock.json | 4 +- package.json | 2 +- src/rest-client-v2.ts | 1133 ++++++++++++++++++++------- src/types/request/index.ts | 17 +- src/types/request/shared.ts | 63 +- src/types/request/v2/broker.ts | 99 +++ src/types/request/v2/common.ts | 187 +++++ src/types/request/v2/copytrading.ts | 223 ++++++ src/types/request/v2/earn.ts | 136 ++++ src/types/request/v2/futures.ts | 473 ++++++++++- src/types/request/v2/margin.ts | 148 ++++ src/types/request/v2/spot.ts | 378 ++++++++- 12 files changed, 2500 insertions(+), 363 deletions(-) create mode 100644 src/types/request/v2/broker.ts create mode 100644 src/types/request/v2/common.ts create mode 100644 src/types/request/v2/copytrading.ts create mode 100644 src/types/request/v2/earn.ts create mode 100644 src/types/request/v2/margin.ts 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 From d7dfaf205cec6fc75f0b6ed23a0800e8c363dff9 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 10 Dec 2024 13:21:49 +0100 Subject: [PATCH 2/5] chore(): nothing changed, LF/CRLF only --- src/types/request/v2/futures.ts | 882 ++++++++++++++++---------------- 1 file changed, 441 insertions(+), 441 deletions(-) diff --git a/src/types/request/v2/futures.ts b/src/types/request/v2/futures.ts index 5ca0f5e..5f8ddcb 100644 --- a/src/types/request/v2/futures.ts +++ b/src/types/request/v2/futures.ts @@ -1,441 +1,441 @@ -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; -} +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; +} From 0c8813ec32e1be85bddbea2e834ebad438483f92 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 10 Dec 2024 14:31:23 +0100 Subject: [PATCH 3/5] chore(): updated type suffixes, added V2 --- src/rest-client-v2.ts | 364 ++++++++++++++-------------- src/types/request/v2/broker.ts | 26 +- src/types/request/v2/common.ts | 46 ++-- src/types/request/v2/copytrading.ts | 42 ++-- src/types/request/v2/earn.ts | 26 +- src/types/request/v2/margin.ts | 22 +- src/types/request/v2/spot.ts | 52 ++-- 7 files changed, 290 insertions(+), 288 deletions(-) diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 5b50482..287b1f0 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -6,30 +6,30 @@ import { SpotCandlesRequestV2, SpotAccountBill, SpotHistoricCandlesRequestV2, - SpotHistoricTradesRequest, - SpotOrderRequest, - SpotCancelandSubmitOrderRequest, - SpotCancelOrderRequest, - SpotBatchOrderRequest, - SpotBatchCancelOrderRequest, - GetSpotOrderInfoRequest, - GetSpotOpenOrdersRequest, - GetSpotHistoryOrdersRequest, - GetSpotFillsRequest, - SpotPlanOrderRequest, - SpotModifyPlanOrderRequest, - GetSpotCurrentPlanOrdersRequest, - GetSpotHistoryPlanOrdersRequest, - GetSpotAccountBillsRequest, - SpotTransferRequest, + SpotHistoricTradesRequestV2, + SpotOrderRequestV2, + SpotCancelandSubmitOrderRequestV2, + SpotCancelOrderRequestV2, + SpotBatchOrderRequestV2, + SpotBatchCancelOrderRequestV2, + GetSpotOrderInfoRequestV2, + GetSpotOpenOrdersRequestV2, + GetSpotHistoryOrdersRequestV2, + GetSpotFillsRequestV2, + SpotPlanOrderRequestV2, + SpotModifyPlanOrderRequestV2, + GetSpotCurrentPlanOrdersRequestV2, + GetSpotHistoryPlanOrdersRequestV2, + GetSpotAccountBillsRequestV2, + SpotTransferRequestV2, SpotAccountType, - SpotSubAccountTransferRequest, - SpotWithdrawalRequest, - SpotMainSubTransferRecordRequest, - GetSpotTransferRecordRequest, - GetSpotSubAccountDepositRecordRequest, - GetSpotWithdrawalRecordRequest, - GetSpotDepositRecordRequest, + SpotSubAccountTransferRequestV2, + SpotWithdrawalRequestV2, + SpotMainSubTransferRecordRequestV2, + GetSpotTransferRecordRequestV2, + GetSpotSubAccountDepositRecordRequestV2, + GetSpotWithdrawalRecordRequestV2, + GetSpotDepositRecordRequestV2, FuturesMergeDepthRequestV2, FuturesProductTypeV2, FuturesRecentTradesRequestV2, @@ -62,78 +62,78 @@ import { FuturesGetPlanOrdersRequestV2, FuturesCancelPlanOrderRequestV2, FuturesGetHistoryPlanOrdersRequestV2, - GetBorrowHistoryRequest, - GetRepayHistoryRequest, - GetInterestHistoryRequest, - GetLiquidationHistoryRequest, - GetFinancialHistoryRequest, - MarginPlaceOrderRequest, - MarginBatchOrdersRequest, - GetMarginCurrentOrdersRequest, - GetHistoryOrdersRequest, - GetMarginOrderFillsRequest, - GetMarginLiquidationOrdersRequest, - GetFuturesTraderCurrentOrdersRequest, - GetFuturesTraderHistoryOrdersRequest, - ModifyFuturesTraderOrderTPSLRequest, - GetFuturesTraderProfitShareDetailRequest, + GetBorrowHistoryRequestV2, + GetRepayHistoryRequestV2, + GetInterestHistoryRequestV2, + GetLiquidationHistoryRequestV2, + GetFinancialHistoryRequestV2, + MarginPlaceOrderRequestV2, + MarginBatchOrdersRequestV2, + GetMarginCurrentOrdersRequestV2, + GetHistoryOrdersRequestV2, + GetMarginOrderFillsRequestV2, + GetMarginLiquidationOrdersRequestV2, + GetFuturesTraderCurrentOrdersRequestV2, + GetFuturesTraderHistoryOrdersRequestV2, + ModifyFuturesTraderOrderTPSLRequestV2, + GetFuturesTraderProfitShareDetailRequestV2, 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, + FuturesTraderSymbolSettingRequestV2, + GetFuturesTraderFollowersRequestV2, + GetFollowerFuturesCurrentTrackingOrdersRequestV2, + GetFollowerFuturesHistoryTrackingOrdersRequestV2, + UpdateFuturesFollowerTPSLRequestV2, + UpdateFuturesFollowerSettingsRequestV2, + GetFuturesFollowerTradersRequestV2, + CloseFuturesFollowerPositionsRequestV2, + GetSpotTraderHistoryProfitRequestV2, + GetSpotTraderHistoryOrdersRequestV2, + GetSpotTraderCurrentOrdersRequestV2, + GetSpotTraderFollowersRequestV2, + SpotFollowerCopyTradeSettingV2, + GetSpotFollowerHistoryOrdersRequestV2, + GetSpotFollowerOpenOrdersRequestV2, + GetEarnSavingsAssetsRequestV2, + GetEarnSavingsRecordsRequestV2, + RedeemSavingsRequestV2, + GetSharkfinAssetsRequestV2, + GetSharkfinRecordsRequestV2, + GetLoanEstInterestAndBorrowableRequestV2, + BorrowLoanRequestV2, + RepayLoanRequestV2, + GetLoanRepayHistoryRequestV2, + ModifyLoanPledgeRateRequestV2, + GetLoanPledgeRateHistoryRequestV2, + GetLoanHistoryRequestV2, + GetLiquidationRecordsRequestV2, } from './types'; import { - CreateSubaccountApiKeyRequest, - GetSubaccountsRequest, - ModifySubaccountApiKeyRequest, - ModifySubRequest, - SubDepositRecordsRequest, - SubWithdrawalRecordsRequest, - SubWithdrawalRequest, + CreateSubAccountApiKeyRequestV2, + GetSubAccountsRequestV2, + ModifySubAccountApiKeyRequestV2, + ModifySubRequestV2, + SubDepositRecordsRequestV2, + SubWithdrawalRecordsRequestV2, + SubWithdrawalRequestV2, } from './types/request/v2/broker'; import { - ConvertQuoteRequest, - ConvertRequest, - CreateVirtualSubApiKeyRequest, - CreateVirtualSubRequest, - GetAnnouncementsRequest, - GetConvertHistoryRequest, - GetFuturesTransactionsRequest, - GetMarginTransactionsRequest, - GetMerchantAdvertisementsRequest, - GetMerchantP2POrdersRequest, - GetP2PMerchantsRequest, - GetP2PTransactionsRequest, - GetSpotTransactionsRequest, - GetTradeRateRequest, - ModifyVirtualSubRequest, - ModifyVirtualSubApiKeyRequest, - GetConvertBGBHistoryRequest, + ConvertQuoteRequestV2, + ConvertRequestV2, + CreateVirtualSubApiKeyRequestV2, + CreateVirtualSubRequestV2, + GetAnnouncementsRequestV2, + GetConvertHistoryRequestV2, + GetFuturesTransactionsRequestV2, + GetMarginTransactionsRequestV2, + GetMerchantAdvertisementsRequestV2, + GetMerchantP2POrdersRequestV2, + GetP2PMerchantsRequestV2, + GetP2PTransactionsRequestV2, + GetSpotTransactionsRequestV2, + GetTradeRateRequestV2, + ModifyVirtualSubRequestV2, + ModifyVirtualSubApiKeyRequestV2, + GetConvertBGBHistoryRequestV2, } from './types/request/v2/common'; import { REST_CLIENT_TYPE_ENUM, assertMarginType } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -235,7 +235,7 @@ export class RestClientV2 extends BaseRestClient { */ getAnnouncements( - params?: GetAnnouncementsRequest, + params?: GetAnnouncementsRequestV2, ): Promise> { return this.get(`/api/v2/public/annoucements`, params); } @@ -250,7 +250,7 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/public/time`); } - getTradeRate(params: GetTradeRateRequest): Promise> { + getTradeRate(params: GetTradeRateRequestV2): Promise> { return this.getPrivate(`/api/v2/common/trade-rate`, params); } @@ -261,25 +261,25 @@ export class RestClientV2 extends BaseRestClient { */ getSpotTransactionRecords( - params: GetSpotTransactionsRequest, + params: GetSpotTransactionsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/tax/spot-record`, params); } getFuturesTransactionRecords( - params: GetFuturesTransactionsRequest, + params: GetFuturesTransactionsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/tax/future-record`, params); } getMarginTransactionRecords( - params: GetMarginTransactionsRequest, + params: GetMarginTransactionsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/tax/margin-record`, params); } getP2PTransactionRecords( - params: GetP2PTransactionsRequest, + params: GetP2PTransactionsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/tax/p2p-record`, params); } @@ -291,7 +291,7 @@ export class RestClientV2 extends BaseRestClient { */ getP2PMerchantList( - params?: GetP2PMerchantsRequest, + params?: GetP2PMerchantsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/p2p/merchantList`, params); } @@ -301,13 +301,13 @@ export class RestClientV2 extends BaseRestClient { } getP2PMerchantOrders( - params: GetMerchantP2POrdersRequest, + params: GetMerchantP2POrdersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/p2p/orderList`, params); } getP2PMerchantAdvertisementList( - params: GetMerchantAdvertisementsRequest, + params: GetMerchantAdvertisementsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/p2p/advList`, params); } @@ -405,13 +405,13 @@ export class RestClientV2 extends BaseRestClient { } modifyVirtualSubaccount( - params: ModifyVirtualSubRequest, + params: ModifyVirtualSubRequestV2, ): Promise> { return this.postPrivate(`/api/v2/user/modify-virtual-subaccount`, params); } batchCreateVirtualSubaccountAndAPIKey( - params: CreateVirtualSubRequest, + params: CreateVirtualSubRequestV2, ): Promise> { return this.postPrivate( '/api/v2/user/batch-create-subaccount-and-apikey', @@ -428,7 +428,7 @@ export class RestClientV2 extends BaseRestClient { } createVirtualSubaccountAPIKey( - params: CreateVirtualSubApiKeyRequest, + params: CreateVirtualSubApiKeyRequestV2, ): Promise> { return this.postPrivate( '/api/v2/user/create-virtual-subaccount-apikey', @@ -437,7 +437,7 @@ export class RestClientV2 extends BaseRestClient { } modifyVirtualSubaccountAPIKey( - params: ModifyVirtualSubApiKeyRequest, + params: ModifyVirtualSubApiKeyRequestV2, ): Promise> { return this.postPrivate( '/api/v2/user/modify-virtual-subaccount-apikey', @@ -483,17 +483,17 @@ export class RestClientV2 extends BaseRestClient { } getConvertQuotedPrice( - params: ConvertQuoteRequest, + params: ConvertQuoteRequestV2, ): Promise> { return this.getPrivate(`/api/v2/convert/quoted-price`, params); } - convert(params: ConvertRequest): Promise> { + convert(params: ConvertRequestV2): Promise> { return this.postPrivate(`/api/v2/convert/trade`, params); } getConvertHistory( - params: GetConvertHistoryRequest, + params: GetConvertHistoryRequestV2, ): Promise> { return this.getPrivate(`/api/v2/convert/convert-record`, params); } @@ -513,7 +513,7 @@ export class RestClientV2 extends BaseRestClient { } getConvertBGBHistory( - params: GetConvertBGBHistoryRequest, + params: GetConvertBGBHistoryRequestV2, ): Promise> { return this.getPrivate(`/api/v2/convert/bgb-convert-records`, params); } @@ -582,7 +582,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotHistoricTrades( - params: SpotHistoricTradesRequest, + params: SpotHistoricTradesRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/market/fills-history`, params); } @@ -593,18 +593,18 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitOrder(params: SpotOrderRequest): Promise> { + spotSubmitOrder(params: SpotOrderRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-order`, params); } spotCancelandSubmitOrder( - params: SpotCancelandSubmitOrderRequest, + params: SpotCancelandSubmitOrderRequestV2, ): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-replace-order`, params); } spotBatchCancelandSubmitOrder(params: { - orderList: SpotCancelandSubmitOrderRequest[]; + orderList: SpotCancelandSubmitOrderRequestV2[]; }): Promise> { return this.postPrivate( `/api/v2/spot/trade/batch-cancel-replace-order`, @@ -612,18 +612,18 @@ export class RestClientV2 extends BaseRestClient { ); } - spotCancelOrder(params: SpotCancelOrderRequest): Promise> { + spotCancelOrder(params: SpotCancelOrderRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/trade/cancel-order`, params); } spotBatchSubmitOrders( - params: SpotBatchOrderRequest, + params: SpotBatchOrderRequestV2, ): Promise> { return this.postPrivate(`/api/v2/spot/trade/batch-orders`, params); } spotBatchCancelOrders( - params: SpotBatchCancelOrderRequest, + params: SpotBatchCancelOrderRequestV2, ): Promise> { return this.postPrivate(`/api/v2/spot/trade/batch-cancel-order`, params); } @@ -632,23 +632,23 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/spot/trade/cancel-symbol-order`, params); } - getSpotOrder(params?: GetSpotOrderInfoRequest): Promise> { + getSpotOrder(params?: GetSpotOrderInfoRequestV2): Promise> { return this.getPrivate(`/api/v2/spot/trade/orderInfo`, params); } getSpotOpenOrders( - params?: GetSpotOpenOrdersRequest, + params?: GetSpotOpenOrdersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/trade/unfilled-orders`, params); } getSpotHistoricOrders( - params?: GetSpotHistoryOrdersRequest, + params?: GetSpotHistoryOrdersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/trade/history-orders`, params); } - getSpotFills(params: GetSpotFillsRequest): Promise> { + getSpotFills(params: GetSpotFillsRequestV2): Promise> { return this.getPrivate(`/api/v2/spot/trade/fills`, params); } @@ -658,12 +658,14 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitPlanOrder(params: SpotPlanOrderRequest): Promise> { + spotSubmitPlanOrder( + params: SpotPlanOrderRequestV2, + ): Promise> { return this.postPrivate(`/api/v2/spot/trade/place-plan-order`, params); } spotModifyPlanOrder( - params: SpotModifyPlanOrderRequest, + params: SpotModifyPlanOrderRequestV2, ): Promise> { return this.postPrivate(`/api/v2/spot/trade/modify-plan-order`, params); } @@ -676,7 +678,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotCurrentPlanOrders( - params: GetSpotCurrentPlanOrdersRequest, + params: GetSpotCurrentPlanOrdersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/trade/current-plan-order`, params); } @@ -688,7 +690,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotHistoricPlanOrders( - params: GetSpotHistoryPlanOrdersRequest, + params: GetSpotHistoryPlanOrdersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/trade/history-plan-order`, params); } @@ -734,12 +736,12 @@ export class RestClientV2 extends BaseRestClient { } getSpotAccountBills( - params?: GetSpotAccountBillsRequest, + params?: GetSpotAccountBillsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/account/bills`, params); } - spotTransfer(params: SpotTransferRequest): Promise> { + spotTransfer(params: SpotTransferRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/wallet/transfer`, params); } @@ -751,17 +753,17 @@ export class RestClientV2 extends BaseRestClient { } spotSubTransfer( - params: SpotSubAccountTransferRequest, + params: SpotSubAccountTransferRequestV2, ): Promise> { return this.postPrivate(`/api/v2/spot/wallet/subaccount-transfer`, params); } - spotWithdraw(params: SpotWithdrawalRequest): Promise> { + spotWithdraw(params: SpotWithdrawalRequestV2): Promise> { return this.postPrivate(`/api/v2/spot/wallet/withdrawal`, params); } getSpotMainSubTransferRecord( - params: SpotMainSubTransferRecordRequest, + params: SpotMainSubTransferRecordRequestV2, ): Promise> { return this.getPrivate( `/api/v2/spot/account/sub-main-trans-record`, @@ -770,7 +772,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotTransferHistory( - params: GetSpotTransferRecordRequest, + params: GetSpotTransferRecordRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/account/transferRecords`, params); } @@ -807,7 +809,7 @@ export class RestClientV2 extends BaseRestClient { } getSubAccountDepositRecords( - params: GetSpotSubAccountDepositRecordRequest, + params: GetSpotSubAccountDepositRecordRequestV2, ): Promise> { return this.getPrivate( `/api/v2/spot/wallet/subaccount-deposit-records`, @@ -816,13 +818,13 @@ export class RestClientV2 extends BaseRestClient { } getSpotDepositHistory( - params: GetSpotDepositRecordRequest, + params: GetSpotDepositRecordRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/wallet/deposit-records`, params); } getSpotWithdrawalHistory( - params: GetSpotWithdrawalRecordRequest, + params: GetSpotWithdrawalRecordRequestV2, ): Promise> { return this.getPrivate(`/api/v2/spot/wallet/withdrawal-records`, params); } @@ -1245,11 +1247,11 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/broker/account/create-subaccount`, params); } - getSubaccounts(params?: GetSubaccountsRequest): Promise> { + getSubaccounts(params?: GetSubAccountsRequestV2): Promise> { return this.getPrivate(`/api/v2/broker/account/subaccount-list`, params); } - modifySubaccount(params: ModifySubRequest): Promise> { + modifySubaccount(params: ModifySubRequestV2): Promise> { return this.postPrivate(`/api/v2/broker/account/modify-subaccount`, params); } @@ -1290,7 +1292,7 @@ export class RestClientV2 extends BaseRestClient { } subaccountWithdrawal( - params: SubWithdrawalRequest, + params: SubWithdrawalRequestV2, ): Promise> { return this.postPrivate( `/api/v2/broker/account/subaccount-withdrawal`, @@ -1310,13 +1312,13 @@ export class RestClientV2 extends BaseRestClient { } subaccountDepositRecords( - params: SubDepositRecordsRequest, + params: SubDepositRecordsRequestV2, ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-deposit`, params); } subaccountWithdrawalRecords( - params: SubWithdrawalRecordsRequest, + params: SubWithdrawalRecordsRequestV2, ): Promise> { return this.postPrivate(`/api/v2/broker/subaccount-withdrawal`, params); } @@ -1328,7 +1330,7 @@ export class RestClientV2 extends BaseRestClient { */ createSubaccountApiKey( - params: CreateSubaccountApiKeyRequest, + params: CreateSubAccountApiKeyRequestV2, ): Promise> { return this.postPrivate( `/api/v2/broker/manage/create-subaccount-apikey`, @@ -1344,7 +1346,7 @@ export class RestClientV2 extends BaseRestClient { } modifySubaccountApiKey( - params: ModifySubaccountApiKeyRequest, + params: ModifySubAccountApiKeyRequestV2, ): Promise> { return this.postPrivate( `/api/v2/broker/manage/modify-subaccount-apikey`, @@ -1378,7 +1380,7 @@ export class RestClientV2 extends BaseRestClient { getMarginBorrowHistory( marginType: MarginType, - params: GetBorrowHistoryRequest, + params: GetBorrowHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1389,7 +1391,7 @@ export class RestClientV2 extends BaseRestClient { getMarginRepayHistory( marginType: MarginType, - params: GetRepayHistoryRequest, + params: GetRepayHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1400,7 +1402,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestHistory( marginType: MarginType, - params: GetInterestHistoryRequest, + params: GetInterestHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1411,7 +1413,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationHistory( marginType: MarginType, - params: GetLiquidationHistoryRequest, + params: GetLiquidationHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1422,7 +1424,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFinancialHistory( marginType: MarginType, - params: GetFinancialHistoryRequest, + params: GetFinancialHistoryRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1553,7 +1555,7 @@ export class RestClientV2 extends BaseRestClient { marginSubmitOrder( marginType: MarginType, - params: MarginPlaceOrderRequest, + params: MarginPlaceOrderRequestV2, ): Promise> { assertMarginType(marginType); return this.postPrivate(`/api/v2/margin/${marginType}/place-order`, params); @@ -1561,7 +1563,7 @@ export class RestClientV2 extends BaseRestClient { marginBatchSubmitOrders( marginType: MarginType, - params: MarginBatchOrdersRequest, + params: MarginBatchOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.postPrivate( @@ -1601,7 +1603,7 @@ export class RestClientV2 extends BaseRestClient { getMarginOpenOrders( marginType: MarginType, - params: GetMarginCurrentOrdersRequest, + params: GetMarginCurrentOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/open-orders`, params); @@ -1609,7 +1611,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrders( marginType: MarginType, - params: GetHistoryOrdersRequest, + params: GetHistoryOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1620,7 +1622,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrderFills( marginType: MarginType, - params: GetMarginOrderFillsRequest, + params: GetMarginOrderFillsRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/fills`, params); @@ -1628,7 +1630,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationOrders( marginType: MarginType, - params: GetMarginLiquidationOrdersRequest, + params: GetMarginLiquidationOrdersRequestV2, ): Promise> { assertMarginType(marginType); return this.getPrivate( @@ -1654,7 +1656,7 @@ export class RestClientV2 extends BaseRestClient { */ getFuturesTraderCurrentOrder( - params: GetFuturesTraderCurrentOrdersRequest, + params: GetFuturesTraderCurrentOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-current-track`, @@ -1663,7 +1665,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderHistoryOrders( - params: GetFuturesTraderHistoryOrdersRequest, + params: GetFuturesTraderHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/order-history-track`, @@ -1672,7 +1674,7 @@ export class RestClientV2 extends BaseRestClient { } modifyFuturesTraderOrderTPSL( - params: ModifyFuturesTraderOrderTPSLRequest, + params: ModifyFuturesTraderOrderTPSLRequestV2, ): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/order-modify-tpsl`, @@ -1689,7 +1691,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderProfitShareHistory( - params: GetFuturesTraderProfitShareDetailRequest, + params: GetFuturesTraderProfitShareDetailRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/profit-history-details`, @@ -1736,7 +1738,7 @@ export class RestClientV2 extends BaseRestClient { } updateFuturesTraderSymbolSettings(params: { - settingList: FuturesTraderSymbolSettingReq[]; + settingList: FuturesTraderSymbolSettingRequestV2[]; }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/config-setting-symbols`, @@ -1756,7 +1758,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderFollowers( - params?: GetFuturesTraderFollowers, + params?: GetFuturesTraderFollowersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/config-query-followers`, @@ -1782,7 +1784,7 @@ export class RestClientV2 extends BaseRestClient { */ getFuturesFollowerCurrentOrders( - params: GetFollowerFuturesCurrentTrackingOrdersRequest, + params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-current-orders`, @@ -1791,7 +1793,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesFollowerHistoryOrders( - params: GetFollowerFuturesHistoryTrackingOrdersRequest, + params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-history-orders`, @@ -1800,13 +1802,13 @@ export class RestClientV2 extends BaseRestClient { } updateFuturesFollowerTPSL( - params: UpdateFuturesFollowerTPSLRequest, + params: UpdateFuturesFollowerTPSLRequestV2, ): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/setting-tpsl`, params); } updateFuturesFollowerSettings( - params: UpdateFuturesFollowerSettingsRequest, + params: UpdateFuturesFollowerSettingsRequestV2, ): Promise> { return this.postPrivate(`/api/v2/copy/mix-follower/settings`, params); } @@ -1818,7 +1820,7 @@ export class RestClientV2 extends BaseRestClient { } closeFuturesFollowerPositions( - params: CloseFuturesFollowerPositionsRequest, + params: CloseFuturesFollowerPositionsRequestV2, ): Promise> { return this.postPrivate( `/api/v2/copy/mix-follower/close-positions`, @@ -1827,7 +1829,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesFollowerTraders( - params: GetFuturesFollowerTradersRequest, + params: GetFuturesFollowerTradersRequestV2, ): Promise> { return this.getPrivate(`/api/v2/copy/mix-follower/query-traders`, params); } @@ -1887,7 +1889,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotTraderHistoryProfit( - params: getSpotTraderHistoryProfitReq, + params: GetSpotTraderHistoryProfitRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/profit-history-details`, @@ -1919,7 +1921,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotTraderHistoryOrders( - params: GetSpotTraderHistoryOrdersReq, + params: GetSpotTraderHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/order-history-track`, @@ -1928,7 +1930,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotTraderCurrentOrders( - params: GetSpotTraderCurrentOrdersReq, + params: GetSpotTraderCurrentOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/order-current-track`, @@ -1970,7 +1972,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotTraderFollowers( - params: GetSpotTraderFollowersRequest, + params: GetSpotTraderFollowersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-trader/config-query-followers`, @@ -1996,7 +1998,7 @@ export class RestClientV2 extends BaseRestClient { traderId: string; autoCopy?: 'on' | 'off'; mode?: 'basic' | 'advanced'; - settings: SpotFollowerCopyTradeSetting[]; + settings: SpotFollowerCopyTradeSettingV2[]; }): Promise> { return this.postPrivate(`/api/v2/copy/spot-follower/settings`, params); } @@ -2034,7 +2036,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotFollowerHistoryOrders( - params: GetSpotFollowerHistoryOrdersRequest, + params: GetSpotFollowerHistoryOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-history-orders`, @@ -2043,7 +2045,7 @@ export class RestClientV2 extends BaseRestClient { } getSpotFollowerOpenOrders( - params: GetSpotFollowerOpenOrdersRequest, + params: GetSpotFollowerOpenOrdersRequestV2, ): Promise> { return this.getPrivate( `/api/v2/copy/spot-follower/query-current-orders`, @@ -2085,13 +2087,13 @@ export class RestClientV2 extends BaseRestClient { } getEarnSavingsAssets( - params: GetEarnSavingsAssetsRequest, + params: GetEarnSavingsAssetsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/savings/assets`, params); } getEarnSavingsRecords( - params: GetEarnSavingsRecordsRequest, + params: GetEarnSavingsRecordsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/savings/records`, params); } @@ -2118,7 +2120,7 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/savings/subscribe-result`, params); } - earnRedeemSavings(params: RedeemSavingsRequest): Promise> { + earnRedeemSavings(params: RedeemSavingsRequestV2): Promise> { return this.postPrivate(`/api/v2/earn/savings/redeem`, params); } @@ -2162,13 +2164,13 @@ export class RestClientV2 extends BaseRestClient { } getSharkfinAssets( - params: GetSharkfinAssetsRequest, + params: GetSharkfinAssetsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/assets`, params); } getSharkfinRecords( - params: GetSharkfinRecordsRequest, + params: GetSharkfinRecordsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/sharkfin/records`, params); } @@ -2205,12 +2207,12 @@ export class RestClientV2 extends BaseRestClient { } getLoanEstInterestAndBorrowable( - params: GetLoanEstInterestAndBorrowableRequest, + params: GetLoanEstInterestAndBorrowableRequestV2, ): Promise> { return this.get(`/api/v2/earn/loan/public/hour-interest`, params); } - borrowLoan(params: BorrowLoanRequest): Promise> { + borrowLoan(params: BorrowLoanRequestV2): Promise> { return this.postPrivate(`/api/v2/earn/loan/borrow`, params); } @@ -2222,29 +2224,29 @@ export class RestClientV2 extends BaseRestClient { return this.getPrivate(`/api/v2/earn/loan/ongoing-orders`, params); } - repayLoan(params: RepayLoanRequest): Promise> { + repayLoan(params: RepayLoanRequestV2): Promise> { return this.postPrivate(`/api/v2/earn/loan/repay`, params); } getRepayHistory( - params: GetLoanRepayHistoryRequest, + params: GetLoanRepayHistoryRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/loan/repay-history`, params); } updateLoanPledgeRate( - params: ModifyLoanPledgeRateRequest, + params: ModifyLoanPledgeRateRequestV2, ): Promise> { return this.postPrivate(`/api/v2/earn/loan/revise-pledge`, params); } getLoanPledgeRateHistory( - params: GetLoanPledgeRateHistoryRequest, + params: GetLoanPledgeRateHistoryRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/loan/revise-history`, params); } - getLoanHistory(params: GetLoanHistoryRequest): Promise> { + getLoanHistory(params: GetLoanHistoryRequestV2): Promise> { return this.getPrivate(`/api/v2/earn/loan/borrow-history`, params); } @@ -2253,7 +2255,7 @@ export class RestClientV2 extends BaseRestClient { } getLoanLiquidationRecords( - params: GetLiquidationRecordsRequest, + params: GetLiquidationRecordsRequestV2, ): Promise> { return this.getPrivate(`/api/v2/earn/loan/reduces`, params); } diff --git a/src/types/request/v2/broker.ts b/src/types/request/v2/broker.ts index a350c50..b144e14 100644 --- a/src/types/request/v2/broker.ts +++ b/src/types/request/v2/broker.ts @@ -4,7 +4,7 @@ * */ -export interface GetSubaccountsRequest { +export interface GetSubAccountsRequestV2 { limit?: string; idLessThan?: string; status?: 'normal' | 'freeze' | 'del'; @@ -12,7 +12,7 @@ export interface GetSubaccountsRequest { endTime?: string; } -export type SubaccountPermission = +export type SubAccountPermission = | 'withdraw' | 'transfer' | 'spot_trade' @@ -21,7 +21,7 @@ export type SubaccountPermission = | 'deposit' | 'margin_trade'; -export type SubaccountLanguage = +export type SubAccountLanguage = | 'en_US' | 'zh_CN' | 'ja_JP' @@ -35,16 +35,16 @@ export type SubaccountLanguage = | 'pt_PT' | 'th_TH'; -export type SubaccountStatus = 'normal' | 'freeze'; +export type SubAccountStatus = 'normal' | 'freeze'; -export interface ModifySubRequest { +export interface ModifySubRequestV2 { subUid: string; - permList: SubaccountPermission[]; - status: SubaccountStatus; - language?: SubaccountLanguage; + permList: SubAccountPermission[]; + status: SubAccountStatus; + language?: SubAccountLanguage; } -export interface SubWithdrawalRequest { +export interface SubWithdrawalRequestV2 { subUid: string; coin: string; dest: 'on_chain' | 'internal_transfer'; @@ -55,7 +55,7 @@ export interface SubWithdrawalRequest { clientOid?: string; } -export interface SubDepositRecordsRequest { +export interface SubDepositRecordsRequestV2 { orderId?: string; userId?: string; startTime?: string; @@ -64,7 +64,7 @@ export interface SubDepositRecordsRequest { idLessThan?: string; } -export interface SubWithdrawalRecordsRequest { +export interface SubWithdrawalRecordsRequestV2 { orderId?: string; userId?: string; startTime?: string; @@ -79,7 +79,7 @@ export interface SubWithdrawalRecordsRequest { * */ -export interface CreateSubaccountApiKeyRequest { +export interface CreateSubAccountApiKeyRequestV2 { subUid: string; passphrase: string; label?: string; @@ -88,7 +88,7 @@ export interface CreateSubaccountApiKeyRequest { permList: string[]; } -export interface ModifySubaccountApiKeyRequest { +export interface ModifySubAccountApiKeyRequestV2 { subUid: string; apiKey: string; label?: string; diff --git a/src/types/request/v2/common.ts b/src/types/request/v2/common.ts index 6ad352f..051273b 100644 --- a/src/types/request/v2/common.ts +++ b/src/types/request/v2/common.ts @@ -6,7 +6,7 @@ import { FuturesProductTypeV2, MarginType } from '../shared'; * */ -export interface GetAnnouncementsRequest { +export interface GetAnnouncementsRequestV2 { annType?: string; startTime?: string; endTime?: string; @@ -19,7 +19,7 @@ export interface GetAnnouncementsRequest { * */ -export interface GetTradeRateRequest { +export interface GetTradeRateRequestV2 { symbol: string; businessType: string; } @@ -30,7 +30,7 @@ export interface GetTradeRateRequest { * */ -export interface GetSpotTransactionsRequest { +export interface GetSpotTransactionsRequestV2 { coin?: string; startTime: string; endTime: string; @@ -38,7 +38,7 @@ export interface GetSpotTransactionsRequest { idLessThan?: string; } -export interface GetFuturesTransactionsRequest { +export interface GetFuturesTransactionsRequestV2 { productType?: FuturesProductTypeV2; marginCoin?: string; startTime: string; @@ -47,7 +47,7 @@ export interface GetFuturesTransactionsRequest { idLessThan?: string; } -export interface GetMarginTransactionsRequest { +export interface GetMarginTransactionsRequestV2 { marginType?: MarginType; coin?: string; startTime: string; @@ -56,7 +56,7 @@ export interface GetMarginTransactionsRequest { idLessThan?: string; } -export interface GetP2PTransactionsRequest { +export interface GetP2PTransactionsRequestV2 { coin?: string; startTime: string; endTime: string; @@ -70,13 +70,13 @@ export interface GetP2PTransactionsRequest { * */ -export interface GetP2PMerchantsRequest { +export interface GetP2PMerchantsRequestV2 { online?: 'yes' | 'no'; idLessThan?: string; limit?: string; } -export interface GetMerchantP2POrdersRequest { +export interface GetMerchantP2POrdersRequestV2 { startTime: string; endTime?: string; idLessThan?: string; @@ -90,7 +90,7 @@ export interface GetMerchantP2POrdersRequest { orderNo?: string; } -export interface GetMerchantAdvertisementsRequest { +export interface GetMerchantAdvertisementsRequestV2 { startTime: string; endTime?: string; idLessThan?: string; @@ -112,13 +112,13 @@ export interface GetMerchantAdvertisementsRequest { * */ -export interface ModifyVirtualSubRequest { +export interface ModifyVirtualSubRequestV2 { subAccountUid: string; permList: string[]; status: string; } -export interface CreateVirtualSubRequest { +export interface CreateVirtualSubRequestV2 { subAccountName: string; passphrase: string; label: string; @@ -126,7 +126,7 @@ export interface CreateVirtualSubRequest { permList?: string[]; } -export interface CreateVirtualSubApiKeyRequest { +export interface CreateVirtualSubApiKeyRequestV2 { subAccountUid: string; passphrase: string; label: string; @@ -134,7 +134,7 @@ export interface CreateVirtualSubApiKeyRequest { permList?: string[]; } -export interface ModifyVirtualSubApiKeyRequest { +export interface ModifyVirtualSubApiKeyRequestV2 { subAccountUid: string; subAccountApiKey: string; passphrase: string; @@ -149,14 +149,14 @@ export interface ModifyVirtualSubApiKeyRequest { * */ -export interface ConvertQuoteRequest { +export interface ConvertQuoteRequestV2 { fromCoin: string; fromCoinSize?: string; toCoin: string; toCoinSize?: string; } -export interface ConvertRequest { +export interface ConvertRequestV2 { fromCoin: string; fromCoinSize: string; cnvtPrice: string; @@ -165,7 +165,7 @@ export interface ConvertRequest { traceId: string; } -export interface GetConvertHistoryRequest { +export interface GetConvertHistoryRequestV2 { startTime: string; endTime: string; limit?: string; @@ -178,10 +178,10 @@ export interface GetConvertHistoryRequest { * */ -export interface GetConvertBGBHistoryRequest { - orderId?: string; - startTime: string; - endTime: string; - limit?: string; - idLessThan?: string; - } \ No newline at end of file +export interface GetConvertBGBHistoryRequestV2 { + orderId?: string; + startTime: string; + endTime: string; + limit?: string; + idLessThan?: string; +} diff --git a/src/types/request/v2/copytrading.ts b/src/types/request/v2/copytrading.ts index f9928ce..85cbd65 100644 --- a/src/types/request/v2/copytrading.ts +++ b/src/types/request/v2/copytrading.ts @@ -11,7 +11,7 @@ export type CopyTradingProductType = | 'COIN-FUTURES' | 'USDC-FUTURES'; -export interface GetFuturesTraderCurrentOrdersRequest { +export interface GetFuturesTraderCurrentOrdersRequestV2 { symbol?: string; productType: CopyTradingProductType; startTime?: string; @@ -21,7 +21,7 @@ export interface GetFuturesTraderCurrentOrdersRequest { idLessThan?: string; } -export interface GetFuturesTraderHistoryOrdersRequest { +export interface GetFuturesTraderHistoryOrdersRequestV2 { idLessThan?: string; idGreaterThan?: string; startTime?: string; @@ -32,14 +32,14 @@ export interface GetFuturesTraderHistoryOrdersRequest { productType: CopyTradingProductType; } -export interface ModifyFuturesTraderOrderTPSLRequest { +export interface ModifyFuturesTraderOrderTPSLRequestV2 { trackingNo: string; productType: CopyTradingProductType; stopSurplusPrice?: string; stopLossPrice?: string; } -export interface GetFuturesTraderProfitShareDetailRequest { +export interface GetFuturesTraderProfitShareDetailRequestV2 { coin?: string; idLessThan?: string; idGreaterThan?: string; @@ -48,7 +48,7 @@ export interface GetFuturesTraderProfitShareDetailRequest { limit?: string; } -export interface FuturesTraderSymbolSettingReq { +export interface FuturesTraderSymbolSettingRequestV2 { symbol: string; productType: CopyTradingProductType; settingType: 'ADD' | 'DELETE' | 'UPDATE'; @@ -56,7 +56,7 @@ export interface FuturesTraderSymbolSettingReq { stopLossRatio?: string; } -export interface GetFuturesTraderFollowers { +export interface GetFuturesTraderFollowersRequestV2 { pageNo?: string; pageSize?: string; startTime?: string; @@ -71,7 +71,7 @@ export interface GetFuturesTraderFollowers { * */ -export interface GetFollowerFuturesCurrentTrackingOrdersRequest { +export interface GetFollowerFuturesCurrentTrackingOrdersRequestV2 { idLessThan?: string; idGreaterThan?: string; startTime?: string; @@ -82,7 +82,7 @@ export interface GetFollowerFuturesCurrentTrackingOrdersRequest { traderId?: string; } -export interface GetFollowerFuturesHistoryTrackingOrdersRequest { +export interface GetFollowerFuturesHistoryTrackingOrdersRequestV2 { idLessThan?: string; idGreaterThan?: string; startTime?: string; @@ -93,7 +93,7 @@ export interface GetFollowerFuturesHistoryTrackingOrdersRequest { traderId?: string; } -export interface UpdateFuturesFollowerTPSLRequest { +export interface UpdateFuturesFollowerTPSLRequestV2 { trackingNo: string; symbol?: string; productType: CopyTradingProductType; @@ -106,7 +106,7 @@ export type FollowMode = 'basic' | 'advanced'; export type LeverageType = 'position' | 'specify' | 'trader'; export type TraceType = 'percent' | 'amount' | 'count'; -export interface FollowerCopyTradeSetting { +export interface FollowerCopyTradeSettingRequestV2 { symbol: string; productType: CopyTradingProductType; marginType: 'trader' | 'specify'; @@ -121,13 +121,13 @@ export interface FollowerCopyTradeSetting { stopLossRatio?: string; } -export interface UpdateFuturesFollowerSettingsRequest { +export interface UpdateFuturesFollowerSettingsRequestV2 { traderId: string; autoCopy?: AutoCopyOption; mode?: FollowMode; - settings: FollowerCopyTradeSetting[]; + settings: FollowerCopyTradeSettingRequestV2[]; } -export interface CloseFuturesFollowerPositionsRequest { +export interface CloseFuturesFollowerPositionsRequestV2 { productType: CopyTradingProductType; trackingNo?: string; symbol?: string; @@ -136,7 +136,7 @@ export interface CloseFuturesFollowerPositionsRequest { holdSide?: 'long' | 'short'; } -export interface GetFuturesFollowerTradersRequest { +export interface GetFuturesFollowerTradersRequestV2 { startTime?: string; endTime?: string; pageNo?: string; @@ -151,7 +151,7 @@ export interface GetFuturesFollowerTradersRequest { * */ -export interface getSpotTraderHistoryProfitReq { +export interface GetSpotTraderHistoryProfitRequestV2 { idLessThan?: string; idGreaterThan?: string; startTime?: string; @@ -160,7 +160,7 @@ export interface getSpotTraderHistoryProfitReq { coin?: string; } -export interface GetSpotTraderHistoryOrdersReq { +export interface GetSpotTraderHistoryOrdersRequestV2 { idLessThan?: string; idGreaterThan?: string; startTime?: string; @@ -169,7 +169,7 @@ export interface GetSpotTraderHistoryOrdersReq { symbol?: string; } -export interface GetSpotTraderCurrentOrdersReq { +export interface GetSpotTraderCurrentOrdersRequestV2 { symbol?: string; idLessThan?: string; idGreaterThan?: string; @@ -178,7 +178,7 @@ export interface GetSpotTraderCurrentOrdersReq { limit?: string; } -export interface GetSpotTraderFollowersRequest { +export interface GetSpotTraderFollowersRequestV2 { pageNo?: string; pageSize?: string; startTime?: string; @@ -193,7 +193,7 @@ export interface GetSpotTraderFollowersRequest { * */ -export interface SpotFollowerCopyTradeSetting { +export interface SpotFollowerCopyTradeSettingV2 { symbol: string; traceType: 'percent' | 'amount' | 'count'; maxHoldSize: string; @@ -202,7 +202,7 @@ export interface SpotFollowerCopyTradeSetting { stopSurplusRatio?: string; } -export interface GetSpotFollowerHistoryOrdersRequest { +export interface GetSpotFollowerHistoryOrdersRequestV2 { symbol?: string; traderId?: string; idLessThan?: string; @@ -212,7 +212,7 @@ export interface GetSpotFollowerHistoryOrdersRequest { limit?: string; } -export interface GetSpotFollowerOpenOrdersRequest { +export interface GetSpotFollowerOpenOrdersRequestV2 { symbol?: string; traderId?: string; idLessThan?: string; diff --git a/src/types/request/v2/earn.ts b/src/types/request/v2/earn.ts index dfbe14b..30687b9 100644 --- a/src/types/request/v2/earn.ts +++ b/src/types/request/v2/earn.ts @@ -6,7 +6,7 @@ * */ -export interface GetEarnSavingsAssetsRequest { +export interface GetEarnSavingsAssetsRequestV2 { periodType: string; startTime?: string; endTime?: string; @@ -14,7 +14,7 @@ export interface GetEarnSavingsAssetsRequest { idLessThan?: string; } -export interface GetEarnSavingsRecordsRequest { +export interface GetEarnSavingsRecordsRequestV2 { coin?: string; periodType: string; orderType?: string; @@ -24,7 +24,7 @@ export interface GetEarnSavingsRecordsRequest { idLessThan?: string; } -export interface RedeemSavingsRequest { +export interface RedeemSavingsRequestV2 { productId: string; orderId?: string; periodType: string; @@ -39,7 +39,7 @@ export interface RedeemSavingsRequest { * */ -export interface GetSharkfinAssetsRequest { +export interface GetSharkfinAssetsRequestV2 { status: string; startTime?: string; endTime?: string; @@ -47,7 +47,7 @@ export interface GetSharkfinAssetsRequest { idLessThan?: string; } -export interface GetSharkfinRecordsRequest { +export interface GetSharkfinRecordsRequestV2 { coin?: string; type: string; startTime?: string; @@ -64,14 +64,14 @@ export interface GetSharkfinRecordsRequest { * */ -export interface GetLoanEstInterestAndBorrowableRequest { +export interface GetLoanEstInterestAndBorrowableRequestV2 { loanCoin: string; pledgeCoin: string; daily: 'SEVEN' | 'THIRTY'; pledgeAmount?: string; } -export interface BorrowLoanRequest { +export interface BorrowLoanRequestV2 { loanCoin: string; pledgeCoin: string; daily: 'SEVEN' | 'THIRTY'; @@ -79,14 +79,14 @@ export interface BorrowLoanRequest { loanAmount?: string; } -export interface RepayLoanRequest { +export interface RepayLoanRequestV2 { orderId: string; amount?: string; repayUnlock?: string; repayAll: string; } -export interface GetLoanRepayHistoryRequest { +export interface GetLoanRepayHistoryRequestV2 { orderId?: string; loanCoin?: string; pledgeCoin?: string; @@ -96,14 +96,14 @@ export interface GetLoanRepayHistoryRequest { pageSize?: string; } -export interface ModifyLoanPledgeRateRequest { +export interface ModifyLoanPledgeRateRequestV2 { orderId: string; amount: string; pledgeCoin: string; reviseType: string; } -export interface GetLoanPledgeRateHistoryRequest { +export interface GetLoanPledgeRateHistoryRequestV2 { orderId?: string; reviseSide?: string; pledgeCoin?: string; @@ -113,7 +113,7 @@ export interface GetLoanPledgeRateHistoryRequest { pageSize?: string; } -export interface GetLoanHistoryRequest { +export interface GetLoanHistoryRequestV2 { orderId?: string; loanCoin?: string; pledgeCoin?: string; @@ -124,7 +124,7 @@ export interface GetLoanHistoryRequest { pageSize?: string; } -export interface GetLiquidationRecordsRequest { +export interface GetLiquidationRecordsRequestV2 { orderId?: string; loanCoin?: string; pledgeCoin?: string; diff --git a/src/types/request/v2/margin.ts b/src/types/request/v2/margin.ts index 63e99d3..02e0ba1 100644 --- a/src/types/request/v2/margin.ts +++ b/src/types/request/v2/margin.ts @@ -4,7 +4,7 @@ * */ -export interface GetBorrowHistoryRequest { +export interface GetBorrowHistoryRequestV2 { loanId?: string; coin?: string; startTime: string; @@ -13,7 +13,7 @@ export interface GetBorrowHistoryRequest { idLessThan?: string; } -export interface GetRepayHistoryRequest { +export interface GetRepayHistoryRequestV2 { repayId?: string; coin?: string; startTime: string; @@ -22,7 +22,7 @@ export interface GetRepayHistoryRequest { idLessThan?: string; } -export interface GetInterestHistoryRequest { +export interface GetInterestHistoryRequestV2 { coin?: string; startTime: string; endTime?: string; @@ -30,14 +30,14 @@ export interface GetInterestHistoryRequest { idLessThan?: string; } -export interface GetLiquidationHistoryRequest { +export interface GetLiquidationHistoryRequestV2 { startTime: string; endTime?: string; limit?: string; idLessThan?: string; } -export interface GetFinancialHistoryRequest { +export interface GetFinancialHistoryRequestV2 { marginType?: string; coin?: string; startTime: string; @@ -76,7 +76,7 @@ export type MarginSTPMode = | 'cancel_maker' | 'cancel_both'; -export interface MarginPlaceOrderRequest { +export interface MarginPlaceOrderRequestV2 { symbol: string; orderType: MarginOrderType; price?: string; @@ -101,12 +101,12 @@ export interface MarginBatchOrderEntry { stpMode?: MarginSTPMode; } -export interface MarginBatchOrdersRequest { +export interface MarginBatchOrdersRequestV2 { symbol: string; orderList: MarginBatchOrderEntry[]; } -export interface GetMarginCurrentOrdersRequest { +export interface GetMarginCurrentOrdersRequestV2 { symbol: string; orderId?: string; clientOid?: string; @@ -116,7 +116,7 @@ export interface GetMarginCurrentOrdersRequest { idLessThan?: string; } -export interface GetHistoryOrdersRequest { +export interface GetHistoryOrdersRequestV2 { symbol: string; orderId?: string; enterPointSource?: string; @@ -127,7 +127,7 @@ export interface GetHistoryOrdersRequest { idLessThan?: string; } -export interface GetMarginOrderFillsRequest { +export interface GetMarginOrderFillsRequestV2 { symbol: string; orderId?: string; idLessThan?: string; @@ -136,7 +136,7 @@ export interface GetMarginOrderFillsRequest { limit?: string; } -export interface GetMarginLiquidationOrdersRequest { +export interface GetMarginLiquidationOrdersRequestV2 { type?: 'swap' | 'place_order'; symbol?: string; fromCoin?: string; diff --git a/src/types/request/v2/spot.ts b/src/types/request/v2/spot.ts index 1d5d049..e6d1f2a 100644 --- a/src/types/request/v2/spot.ts +++ b/src/types/request/v2/spot.ts @@ -33,7 +33,7 @@ export interface SpotHistoricCandlesRequestV2 { limit?: string; } -export interface SpotHistoricTradesRequest { +export interface SpotHistoricTradesRequestV2 { symbol: string; limit?: string; idLessThan?: string; @@ -63,7 +63,7 @@ export type SpotSTPMode = export type SpotBatchMode = 'single' | 'multiple'; -export interface SpotOrderRequest { +export interface SpotOrderRequestV2 { symbol: string; side: SpotOrderSide; orderType: SpotOrderType; @@ -82,7 +82,7 @@ export interface SpotOrderRequest { executeStopLossPrice?: string; } -export interface SpotCancelandSubmitOrderRequest { +export interface SpotCancelandSubmitOrderRequestV2 { symbol: string; price: string; size: string; @@ -95,14 +95,14 @@ export interface SpotCancelandSubmitOrderRequest { executeStopLossPrice?: string; } -export interface SpotCancelOrderRequest { +export interface SpotCancelOrderRequestV2 { symbol: string; tpslType?: SpotTPSLType; orderId?: string; clientOid?: string; } -export interface SpotBatchOrderRequestItem { +export interface SpotBatchOrderRequestItemV2 { symbol?: string; side: SpotOrderSide; orderType: SpotOrderType; @@ -117,13 +117,13 @@ export interface SpotBatchOrderRequestItem { executeStopLossPrice?: string; } -export interface SpotBatchOrderRequest { +export interface SpotBatchOrderRequestV2 { symbol?: string; batchMode?: SpotBatchMode; - orderList: SpotBatchOrderRequestItem[]; + orderList: SpotBatchOrderRequestItemV2[]; } -export interface SpotBatchCancelOrderRequest { +export interface SpotBatchCancelOrderRequestV2 { symbol?: string; batchMode?: SpotBatchMode; orderList: { @@ -133,14 +133,14 @@ export interface SpotBatchCancelOrderRequest { }[]; } -export interface GetSpotOrderInfoRequest { +export interface GetSpotOrderInfoRequestV2 { orderId?: string; clientOid?: string; requestTime?: string; receiveWindow?: string; } -export interface GetSpotOpenOrdersRequest { +export interface GetSpotOpenOrdersRequestV2 { symbol?: string; startTime?: string; endTime?: string; @@ -152,7 +152,7 @@ export interface GetSpotOpenOrdersRequest { receiveWindow?: string; } -export interface GetSpotHistoryOrdersRequest { +export interface GetSpotHistoryOrdersRequestV2 { symbol?: string; startTime?: string; endTime?: string; @@ -164,7 +164,7 @@ export interface GetSpotHistoryOrdersRequest { receiveWindow?: string; } -export interface GetSpotFillsRequest { +export interface GetSpotFillsRequestV2 { symbol: string; orderId?: string; startTime?: string; @@ -183,7 +183,7 @@ export type SpotPlanType = 'amount' | 'total'; export type SpotTriggerType = 'fill_price' | 'mark_price'; -export interface SpotPlanOrderRequest { +export interface SpotPlanOrderRequestV2 { symbol: string; side: SpotOrderSide; triggerPrice: string; @@ -197,7 +197,7 @@ export interface SpotPlanOrderRequest { stpMode?: SpotSTPMode; } -export interface SpotModifyPlanOrderRequest { +export interface SpotModifyPlanOrderRequestV2 { orderId?: string; clientOid?: string; triggerPrice: string; @@ -206,7 +206,7 @@ export interface SpotModifyPlanOrderRequest { size: string; } -export interface GetSpotCurrentPlanOrdersRequest { +export interface GetSpotCurrentPlanOrdersRequestV2 { symbol: string; limit?: string; idLessThan?: string; @@ -214,7 +214,7 @@ export interface GetSpotCurrentPlanOrdersRequest { endTime?: string; } -export interface GetSpotHistoryPlanOrdersRequest { +export interface GetSpotHistoryPlanOrdersRequestV2 { symbol: string; startTime: string; endTime: string; @@ -258,7 +258,7 @@ export type SpotAccountType = | 'crossed_margin' | 'isolated_margin'; -export interface GetSpotAccountBillsRequest { +export interface GetSpotAccountBillsRequestV2 { coin?: string; groupType?: SpotBillGroupType; businessType?: SpotBusinessType; @@ -268,7 +268,7 @@ export interface GetSpotAccountBillsRequest { idLessThan?: string; } -export interface SpotTransferRequest { +export interface SpotTransferRequestV2 { fromType: SpotAccountType; toType: SpotAccountType; amount: string; @@ -277,7 +277,7 @@ export interface SpotTransferRequest { clientOid?: string; } -export interface SpotSubAccountTransferRequest { +export interface SpotSubAccountTransferRequestV2 { fromType: SpotAccountType; toType: SpotAccountType; amount: string; @@ -288,7 +288,7 @@ export interface SpotSubAccountTransferRequest { toUserId: string; } -export interface SpotWithdrawalRequest { +export interface SpotWithdrawalRequestV2 { coin: string; transferType: 'on_chain' | 'internal_transfer'; address: string; @@ -301,7 +301,7 @@ export interface SpotWithdrawalRequest { clientOid?: string; } -export interface SpotMainSubTransferRecordRequest { +export interface SpotMainSubTransferRecordRequestV2 { coin?: string; role?: 'initiator' | 'receiver'; subUid?: string; @@ -312,7 +312,7 @@ export interface SpotMainSubTransferRecordRequest { idLessThan?: string; } -export interface GetSpotTransferRecordRequest { +export interface GetSpotTransferRecordRequestV2 { coin: string; fromType: SpotAccountType; startTime?: string; @@ -322,7 +322,7 @@ export interface GetSpotTransferRecordRequest { idLessThan?: string; } -export interface GetSpotSubAccountDepositRecordRequest { +export interface GetSpotSubAccountDepositRecordRequestV2 { subUid: string; coin?: string; startTime?: string; @@ -331,7 +331,7 @@ export interface GetSpotSubAccountDepositRecordRequest { limit?: string; } -export interface GetSpotWithdrawalRecordRequest { +export interface GetSpotWithdrawalRecordRequestV2 { coin?: string; clientOid?: string; startTime: string; @@ -341,11 +341,11 @@ export interface GetSpotWithdrawalRecordRequest { limit?: string; } -export interface GetSpotDepositRecordRequest { +export interface GetSpotDepositRecordRequestV2 { coin?: string; orderId?: string; startTime: string; endTime: string; idLessThan?: string; limit?: string; -} \ No newline at end of file +} From d7aa53e2c10994878c03771aeeb43a3ec18d6033 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 10 Dec 2024 14:50:27 +0100 Subject: [PATCH 4/5] chore(): added v2 suffixes --- src/rest-client-v2.ts | 14 +++--- src/types/request/v2/copytrading.ts | 20 ++++---- src/types/request/v2/spot.ts | 78 ++++++++++++++--------------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 287b1f0..5774191 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -22,7 +22,7 @@ import { GetSpotHistoryPlanOrdersRequestV2, GetSpotAccountBillsRequestV2, SpotTransferRequestV2, - SpotAccountType, + SpotAccountTypeV2, SpotSubAccountTransferRequestV2, SpotWithdrawalRequestV2, SpotMainSubTransferRecordRequestV2, @@ -77,7 +77,7 @@ import { GetFuturesTraderHistoryOrdersRequestV2, ModifyFuturesTraderOrderTPSLRequestV2, GetFuturesTraderProfitShareDetailRequestV2, - CopyTradingProductType, + CopyTradingProductTypeV2, FuturesTraderSymbolSettingRequestV2, GetFuturesTraderFollowersRequestV2, GetFollowerFuturesCurrentTrackingOrdersRequestV2, @@ -746,8 +746,8 @@ export class RestClientV2 extends BaseRestClient { } getSpotTransferableCoins(params: { - fromType: SpotAccountType; - toType: SpotAccountType; + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; }): Promise> { return this.getPrivate(`/api/v2/spot/wallet/transfer-coin-info`, params); } @@ -1702,7 +1702,7 @@ export class RestClientV2 extends BaseRestClient { closeFuturesTraderOrder(params: { trackingNo: string; symbol: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; }): Promise> { return this.postPrivate( `/api/v2/copy/mix-trader/order-close-positions`, @@ -1729,7 +1729,7 @@ export class RestClientV2 extends BaseRestClient { } getFuturesTraderSymbolSettings(params: { - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; }): Promise> { return this.getPrivate( `/api/v2/copy/mix-trader/config-query-symbols`, @@ -1836,7 +1836,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerFollowLimit(params: { symbol: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; }): Promise> { return this.getPrivate( `/api/v2/copy/mix-follower/query-quantity-limit`, diff --git a/src/types/request/v2/copytrading.ts b/src/types/request/v2/copytrading.ts index 85cbd65..48b65ee 100644 --- a/src/types/request/v2/copytrading.ts +++ b/src/types/request/v2/copytrading.ts @@ -6,14 +6,14 @@ * */ -export type CopyTradingProductType = +export type CopyTradingProductTypeV2 = | 'USDT-FUTURES' | 'COIN-FUTURES' | 'USDC-FUTURES'; export interface GetFuturesTraderCurrentOrdersRequestV2 { symbol?: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; startTime?: string; endTime?: string; limit?: string; @@ -29,12 +29,12 @@ export interface GetFuturesTraderHistoryOrdersRequestV2 { limit?: string; order?: 'asc' | 'desc'; symbol?: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; } export interface ModifyFuturesTraderOrderTPSLRequestV2 { trackingNo: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; stopSurplusPrice?: string; stopLossPrice?: string; } @@ -50,7 +50,7 @@ export interface GetFuturesTraderProfitShareDetailRequestV2 { export interface FuturesTraderSymbolSettingRequestV2 { symbol: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; settingType: 'ADD' | 'DELETE' | 'UPDATE'; stopSurplusRatio?: string; stopLossRatio?: string; @@ -78,7 +78,7 @@ export interface GetFollowerFuturesCurrentTrackingOrdersRequestV2 { endTime?: string; limit?: string; symbol?: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; traderId?: string; } @@ -89,14 +89,14 @@ export interface GetFollowerFuturesHistoryTrackingOrdersRequestV2 { endTime?: string; limit?: string; symbol?: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; traderId?: string; } export interface UpdateFuturesFollowerTPSLRequestV2 { trackingNo: string; symbol?: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; stopSurplusPrice?: string; stopLossPrice?: string; } @@ -108,7 +108,7 @@ export type TraceType = 'percent' | 'amount' | 'count'; export interface FollowerCopyTradeSettingRequestV2 { symbol: string; - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; marginType: 'trader' | 'specify'; marginCoin?: string; leverType: LeverageType; @@ -128,7 +128,7 @@ export interface UpdateFuturesFollowerSettingsRequestV2 { settings: FollowerCopyTradeSettingRequestV2[]; } export interface CloseFuturesFollowerPositionsRequestV2 { - productType: CopyTradingProductType; + productType: CopyTradingProductTypeV2; trackingNo?: string; symbol?: string; marginCoin?: string; diff --git a/src/types/request/v2/spot.ts b/src/types/request/v2/spot.ts index e6d1f2a..84eb86c 100644 --- a/src/types/request/v2/spot.ts +++ b/src/types/request/v2/spot.ts @@ -47,35 +47,35 @@ export interface SpotHistoricTradesRequestV2 { * */ -export type SpotOrderSide = 'buy' | 'sell'; +export type SpotOrderSideV2 = 'buy' | 'sell'; -export type SpotOrderType = 'limit' | 'market'; +export type SpotOrderTypeV2 = 'limit' | 'market'; -export type SpotOrderForce = 'gtc' | 'post_only' | 'fok' | 'ioc'; +export type SpotOrderForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; -export type SpotTPSLType = 'normal' | 'tpsl'; +export type SpotTPSLTypeV2 = 'normal' | 'tpsl'; -export type SpotSTPMode = +export type SpotSTPModeV2 = | 'none' | 'cancel_taker' | 'cancel_maker' | 'cancel_both'; -export type SpotBatchMode = 'single' | 'multiple'; +export type SpotBatchModeV2 = 'single' | 'multiple'; export interface SpotOrderRequestV2 { symbol: string; - side: SpotOrderSide; - orderType: SpotOrderType; - force: SpotOrderForce; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; price?: string; size: string; clientOid?: string; triggerPrice?: string; - tpslType?: SpotTPSLType; + tpslType?: SpotTPSLTypeV2; requestTime?: string; receiveWindow?: string; - stpMode?: SpotSTPMode; + stpMode?: SpotSTPModeV2; presetTakeProfitPrice?: string; executeTakeProfitPrice?: string; presetStopLossPrice?: string; @@ -97,20 +97,20 @@ export interface SpotCancelandSubmitOrderRequestV2 { export interface SpotCancelOrderRequestV2 { symbol: string; - tpslType?: SpotTPSLType; + tpslType?: SpotTPSLTypeV2; orderId?: string; clientOid?: string; } export interface SpotBatchOrderRequestItemV2 { symbol?: string; - side: SpotOrderSide; - orderType: SpotOrderType; - force: SpotOrderForce; + side: SpotOrderSideV2; + orderType: SpotOrderTypeV2; + force: SpotOrderForceV2; price?: string; size: string; clientOid?: string; - stpMode?: SpotSTPMode; + stpMode?: SpotSTPModeV2; presetTakeProfitPrice?: string; executeTakeProfitPrice?: string; presetStopLossPrice?: string; @@ -119,13 +119,13 @@ export interface SpotBatchOrderRequestItemV2 { export interface SpotBatchOrderRequestV2 { symbol?: string; - batchMode?: SpotBatchMode; + batchMode?: SpotBatchModeV2; orderList: SpotBatchOrderRequestItemV2[]; } export interface SpotBatchCancelOrderRequestV2 { symbol?: string; - batchMode?: SpotBatchMode; + batchMode?: SpotBatchModeV2; orderList: { symbol?: string; orderId?: string; @@ -147,7 +147,7 @@ export interface GetSpotOpenOrdersRequestV2 { idLessThan?: string; limit?: string; orderId?: string; - tpslType?: SpotTPSLType; + tpslType?: SpotTPSLTypeV2; requestTime?: string; receiveWindow?: string; } @@ -159,7 +159,7 @@ export interface GetSpotHistoryOrdersRequestV2 { idLessThan?: string; limit?: string; orderId?: string; - tpslType?: SpotTPSLType; + tpslType?: SpotTPSLTypeV2; requestTime?: string; receiveWindow?: string; } @@ -179,29 +179,29 @@ export interface GetSpotFillsRequestV2 { * */ -export type SpotPlanType = 'amount' | 'total'; +export type SpotPlanTypeV2 = 'amount' | 'total'; -export type SpotTriggerType = 'fill_price' | 'mark_price'; +export type SpotTriggerTypeV2 = 'fill_price' | 'mark_price'; export interface SpotPlanOrderRequestV2 { symbol: string; - side: SpotOrderSide; + side: SpotOrderSideV2; triggerPrice: string; - orderType: SpotOrderType; + orderType: SpotOrderTypeV2; executePrice?: string; - planType?: SpotPlanType; + planType?: SpotPlanTypeV2; size: string; - triggerType: SpotTriggerType; + triggerType: SpotTriggerTypeV2; clientOid?: string; - force?: SpotOrderForce; - stpMode?: SpotSTPMode; + force?: SpotOrderForceV2; + stpMode?: SpotSTPModeV2; } export interface SpotModifyPlanOrderRequestV2 { orderId?: string; clientOid?: string; triggerPrice: string; - orderType: SpotOrderType; + orderType: SpotOrderTypeV2; executePrice?: string; size: string; } @@ -227,14 +227,14 @@ export interface GetSpotHistoryPlanOrdersRequestV2 { * */ -export type SpotBillGroupType = +export type SpotBillGroupTypeV2 = | 'deposit' | 'withdraw' | 'transaction' | 'transfer' | 'other'; -export type SpotBusinessType = +export type SpotBusinessTypeV2 = | 'deposit' | 'withdraw' | 'buy' @@ -249,7 +249,7 @@ export type SpotBusinessType = | 'system lock' | 'user lock'; -export type SpotAccountType = +export type SpotAccountTypeV2 = | 'spot' | 'p2p' | 'coin_futures' @@ -260,8 +260,8 @@ export type SpotAccountType = export interface GetSpotAccountBillsRequestV2 { coin?: string; - groupType?: SpotBillGroupType; - businessType?: SpotBusinessType; + groupType?: SpotBillGroupTypeV2; + businessType?: SpotBusinessTypeV2; startTime?: string; endTime?: string; limit?: string; @@ -269,8 +269,8 @@ export interface GetSpotAccountBillsRequestV2 { } export interface SpotTransferRequestV2 { - fromType: SpotAccountType; - toType: SpotAccountType; + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; amount: string; coin: string; symbol: string; @@ -278,8 +278,8 @@ export interface SpotTransferRequestV2 { } export interface SpotSubAccountTransferRequestV2 { - fromType: SpotAccountType; - toType: SpotAccountType; + fromType: SpotAccountTypeV2; + toType: SpotAccountTypeV2; amount: string; coin: string; symbol?: string; @@ -314,7 +314,7 @@ export interface SpotMainSubTransferRecordRequestV2 { export interface GetSpotTransferRecordRequestV2 { coin: string; - fromType: SpotAccountType; + fromType: SpotAccountTypeV2; startTime?: string; endTime?: string; clientOid?: string; From 84f3849ee65e464d2e560b2910ec4201d128d968 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 10 Dec 2024 16:09:27 +0100 Subject: [PATCH 5/5] chore(): added V2 suffixes --- src/types/request/v2/broker.ts | 12 +++++------ src/types/request/v2/futures.ts | 36 ++++++++++++++++----------------- src/types/request/v2/margin.ts | 30 +++++++++++++-------------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/types/request/v2/broker.ts b/src/types/request/v2/broker.ts index b144e14..5655666 100644 --- a/src/types/request/v2/broker.ts +++ b/src/types/request/v2/broker.ts @@ -12,7 +12,7 @@ export interface GetSubAccountsRequestV2 { endTime?: string; } -export type SubAccountPermission = +export type SubAccountPermissionV2 = | 'withdraw' | 'transfer' | 'spot_trade' @@ -21,7 +21,7 @@ export type SubAccountPermission = | 'deposit' | 'margin_trade'; -export type SubAccountLanguage = +export type SubAccountLanguageV2 = | 'en_US' | 'zh_CN' | 'ja_JP' @@ -35,13 +35,13 @@ export type SubAccountLanguage = | 'pt_PT' | 'th_TH'; -export type SubAccountStatus = 'normal' | 'freeze'; +export type SubAccountStatusV2 = 'normal' | 'freeze'; export interface ModifySubRequestV2 { subUid: string; - permList: SubAccountPermission[]; - status: SubAccountStatus; - language?: SubAccountLanguage; + permList: SubAccountPermissionV2[]; + status: SubAccountStatusV2; + language?: SubAccountLanguageV2; } export interface SubWithdrawalRequestV2 { diff --git a/src/types/request/v2/futures.ts b/src/types/request/v2/futures.ts index 5f8ddcb..695ecdb 100644 --- a/src/types/request/v2/futures.ts +++ b/src/types/request/v2/futures.ts @@ -261,7 +261,7 @@ export interface FuturesGetOpenOrdersRequestV2 { limit?: string; } -export type FuturesOrderSource = +export type FuturesOrderSourceV2 = | 'normal' | 'market' | 'profit_market' @@ -287,7 +287,7 @@ export interface FuturesGetHistoryOrdersRequestV2 { symbol?: string; productType: FuturesProductTypeV2; idLessThan?: string; - orderSource?: FuturesOrderSource; + orderSource?: FuturesOrderSourceV2; startTime?: string; endTime?: string; limit?: string; @@ -307,9 +307,9 @@ export interface FuturesCancelAllOrdersRequestV2 { * */ -export type FuturesTriggerType = 'fill_price' | 'mark_price'; +export type FuturesTriggerTypeV2 = 'fill_price' | 'mark_price'; -export type FuturesStpMode = +export type FuturesStpModeV2 = | 'none' | 'cancel_taker' | 'cancel_maker' @@ -321,16 +321,16 @@ export interface FuturesTPSLOrderRequestV2 { symbol: string; planType: FuturesPlanTypeV2; triggerPrice: string; - triggerType?: FuturesTriggerType; + triggerType?: FuturesTriggerTypeV2; executePrice?: string; holdSide: 'long' | 'short' | 'buy' | 'sell'; size: string; rangeRate?: string; clientOid?: string; - stpMode?: FuturesStpMode; + stpMode?: FuturesStpModeV2; } -export type FuturesTriggerPriceType = +export type FuturesTriggerPriceTypeV2 = | 'fill_price' | 'mark_price' | 'index_price'; @@ -353,11 +353,11 @@ export interface FuturesPlanOrderRequestV2 { reduceOnly?: 'YES' | 'NO'; stopSurplusTriggerPrice?: string; stopSurplusExecutePrice?: string; - stopSurplusTriggerType?: FuturesTriggerPriceType; + stopSurplusTriggerType?: FuturesTriggerPriceTypeV2; stopLossTriggerPrice?: string; stopLossExecutePrice?: string; - stopLossTriggerType?: FuturesTriggerPriceType; - stpMode?: FuturesStpMode; + stopLossTriggerType?: FuturesTriggerPriceTypeV2; + stpMode?: FuturesStpModeV2; } export interface FuturesModifyTPSLOrderRequestV2 { @@ -386,10 +386,10 @@ export interface FuturesModifyPlanOrderRequestV2 { newTriggerType?: 'fill_price' | 'mark_price'; newStopSurplusTriggerPrice?: string; newStopSurplusExecutePrice?: string; - newStopSurplusTriggerType?: FuturesTriggerPriceType; + newStopSurplusTriggerType?: FuturesTriggerPriceTypeV2; newStopLossTriggerPrice?: string; newStopLossExecutePrice?: string; - newStopLossTriggerType?: FuturesTriggerPriceType; + newStopLossTriggerType?: FuturesTriggerPriceTypeV2; } export interface FuturesGetPlanOrdersRequestV2 { @@ -404,12 +404,12 @@ export interface FuturesGetPlanOrdersRequestV2 { limit?: string; } -interface FuturesCancelPlanOrderItem { +interface FuturesCancelPlanOrderItemV2 { orderId?: string; clientOid?: string; } -export type FuturesPlanOrderType = +export type FuturesPlanOrderTypeV2 = | 'normal_plan' | 'profit_plan' | 'loss_plan' @@ -418,20 +418,20 @@ export type FuturesPlanOrderType = | 'moving_plan'; export interface FuturesCancelPlanOrderRequestV2 { - orderIdList?: FuturesCancelPlanOrderItem[]; + orderIdList?: FuturesCancelPlanOrderItemV2[]; symbol?: string; productType: FuturesProductTypeV2; marginCoin?: string; - planType?: FuturesPlanOrderType; + planType?: FuturesPlanOrderTypeV2; } -export type FuturesPlanStatus = 'executed' | 'fail_trigger' | 'cancelled'; +export type FuturesPlanStatusV2 = 'executed' | 'fail_trigger' | 'cancelled'; export interface FuturesGetHistoryPlanOrdersRequestV2 { orderId?: string; clientOid?: string; planType: 'normal_plan' | 'track_plan' | 'profit_loss'; - planStatus?: FuturesPlanStatus; + planStatus?: FuturesPlanStatusV2; symbol?: string; productType: FuturesProductTypeV2; idLessThan?: string; diff --git a/src/types/request/v2/margin.ts b/src/types/request/v2/margin.ts index 02e0ba1..d8fc184 100644 --- a/src/types/request/v2/margin.ts +++ b/src/types/request/v2/margin.ts @@ -58,19 +58,19 @@ export interface GetFinancialHistoryRequestV2 { * */ -export type MarginOrderType = 'limit' | 'market'; +export type MarginOrderTypeV2 = 'limit' | 'market'; -export type MarginLoanType = +export type MarginLoanTypeV2 = | 'normal' | 'autoLoan' | 'autoRepay' | 'autoLoanAndRepay'; -export type MarginTimeInForce = 'gtc' | 'post_only' | 'fok' | 'ioc'; +export type MarginTimeInForceV2 = 'gtc' | 'post_only' | 'fok' | 'ioc'; -export type MarginOrderSide = 'buy' | 'sell'; +export type MarginOrderSideV2 = 'buy' | 'sell'; -export type MarginSTPMode = +export type MarginSTPModeV2 = | 'none' | 'cancel_taker' | 'cancel_maker' @@ -78,27 +78,27 @@ export type MarginSTPMode = export interface MarginPlaceOrderRequestV2 { symbol: string; - orderType: MarginOrderType; + orderType: MarginOrderTypeV2; price?: string; - loanType: MarginLoanType; - force: MarginTimeInForce; + loanType: MarginLoanTypeV2; + force: MarginTimeInForceV2; baseSize?: string; quoteSize?: string; clientOid?: string; - side: MarginOrderSide; - stpMode?: MarginSTPMode; + side: MarginOrderSideV2; + stpMode?: MarginSTPModeV2; } export interface MarginBatchOrderEntry { - orderType: MarginOrderType; + orderType: MarginOrderTypeV2; price?: string; - loanType: MarginLoanType; - force: MarginTimeInForce; + loanType: MarginLoanTypeV2; + force: MarginTimeInForceV2; baseSize?: string; quoteSize?: string; clientOid?: string; - side: MarginOrderSide; - stpMode?: MarginSTPMode; + side: MarginOrderSideV2; + stpMode?: MarginSTPModeV2; } export interface MarginBatchOrdersRequestV2 {