From a521338091d4abfed4d5a58705419d146a8fc745 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 17 Feb 2025 12:14:14 +0100 Subject: [PATCH] feat(): updated types for Market and Trade categories --- src/rest-client-v5.ts | 30 ++++++++++++++++-------------- src/types/request/v5-market.ts | 1 + src/types/request/v5-trade.ts | 5 +++++ src/types/response/v5-market.ts | 9 +++++++++ src/types/response/v5-position.ts | 1 + src/types/response/v5-trade.ts | 2 ++ src/types/shared-v5.ts | 5 ++++- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 0262485..9ffd24a 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -551,7 +551,9 @@ export class RestClientV5 extends BaseRestClient { cancelAllOrders( params: CancelAllOrdersParamsV5, - ): Promise> { + ): Promise< + APIResponseV3WithTime<{ list: OrderResultV5[]; success: string }> + > { return this.postPrivate('/v5/order/cancel-all', params); } @@ -566,6 +568,18 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/order/history', params); } + /** + * Query users' execution records, sorted by execTime in descending order + * + * Unified account covers: Spot / Linear contract / Options + * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures + */ + getExecutionList( + params: GetExecutionListParamsV5, + ): Promise>> { + return this.getPrivate('/v5/execution/list', params); + } + /** * This endpoint allows you to place more than one order in a single request. * Covers: Option (UTA, UTA Pro) / USDT Perpetual, UDSC Perpetual, USDC Futures (UTA Pro) @@ -675,7 +689,7 @@ export class RestClientV5 extends BaseRestClient { * Only for institutional clients! */ setDisconnectCancelAllWindowV2(params: { - product: 'OPTION' | 'SPOT' | 'DERIVATIVES'; + product?: 'OPTION' | 'SPOT' | 'DERIVATIVES'; timeWindow: number; }): Promise> { return this.postPrivate('/v5/order/disconnected-cancel-all', params); @@ -811,18 +825,6 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/position/add-margin', params); } - /** - * Query users' execution records, sorted by execTime in descending order - * - * Unified account covers: Spot / Linear contract / Options - * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures - */ - getExecutionList( - params: GetExecutionListParamsV5, - ): Promise>> { - return this.getPrivate('/v5/execution/list', params); - } - /** * Query user's closed profit and loss records. The results are sorted by createdTime in descending order. * diff --git a/src/types/request/v5-market.ts b/src/types/request/v5-market.ts index f5a3c4b..3d37b16 100644 --- a/src/types/request/v5-market.ts +++ b/src/types/request/v5-market.ts @@ -108,6 +108,7 @@ export interface GetInsuranceParamsV5 { export interface GetRiskLimitParamsV5 { category?: 'linear' | 'inverse'; symbol?: string; + cursor?: string; } export interface GetOptionDeliveryPriceParamsV5 { diff --git a/src/types/request/v5-trade.ts b/src/types/request/v5-trade.ts index 437c70c..76aad5a 100644 --- a/src/types/request/v5-trade.ts +++ b/src/types/request/v5-trade.ts @@ -8,6 +8,7 @@ import { OrderTriggerByV5, OrderTypeV5, PositionIdx, + StopOrderTypeV5, } from '../shared-v5'; export interface OrderParamsV5 { @@ -51,6 +52,7 @@ export interface AmendOrderParamsV5 { triggerPrice?: string; qty?: string; price?: string; + tpslMode?: 'Full' | 'Partial'; takeProfit?: string; stopLoss?: string; tpTriggerBy?: OrderTriggerByV5; @@ -86,6 +88,7 @@ export interface GetAccountHistoricOrdersParamsV5 { category: CategoryV5; symbol?: string; baseCoin?: string; + settleCoin?: string; orderId?: string; orderLinkId?: string; orderFilter?: OrderFilterV5; @@ -102,11 +105,13 @@ export interface CancelAllOrdersParamsV5 { baseCoin?: string; settleCoin?: string; orderFilter?: OrderFilterV5; + stopOrderType?: StopOrderTypeV5; } export interface BatchOrderParamsV5 { symbol: string; side: OrderSideV5; + isLeverage?: 0 | 1; orderType: OrderTypeV5; qty: string; price?: string; diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index 8041b6b..1a9cdee 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -163,6 +163,8 @@ export interface OrderbookResponseV5 { a: OrderbookLevelV5[]; ts: number; u: number; + seq: number; + cts: number; } export interface TickerLinearInverseV5 { @@ -192,6 +194,7 @@ export interface TickerLinearInverseV5 { preOpenPrice: string; preQty: string; curPreListingPhase: string; + basis: string; } export interface TickerOptionV5 { @@ -252,6 +255,10 @@ export interface PublicTradeV5 { side: OrderSideV5; time: string; isBlockTrade: boolean; + mP?: string; + iP?: string; + mIv?: string; + iv?: string; } /** @@ -279,6 +286,7 @@ export interface HistoricalVolatilityV5 { export interface InsuranceDataV5 { coin: string; + symbols: string; balance: string; value: string; } @@ -299,6 +307,7 @@ export interface RiskLimitV5 { isLowestRisk: 0 | 1; maxLeverage: string; mmDeduction: string; + nextPageCursor?: string; } /** @deprecated use DeliveryPriceV5 instead */ diff --git a/src/types/response/v5-position.ts b/src/types/response/v5-position.ts index 3500c50..eb09d36 100644 --- a/src/types/response/v5-position.ts +++ b/src/types/response/v5-position.ts @@ -108,6 +108,7 @@ export interface ExecutionV5 { underlyingPrice?: string; blockTradeId?: string; closedSize?: string; + seq: number; } export interface ClosedPnLV5 { diff --git a/src/types/response/v5-trade.ts b/src/types/response/v5-trade.ts index 8e61cfd..454823d 100644 --- a/src/types/response/v5-trade.ts +++ b/src/types/response/v5-trade.ts @@ -107,5 +107,7 @@ export interface SpotBorrowCheckResultV5 { side: OrderSideV5; maxTradeQty: string; maxTradeAmount: string; + spotMaxTradeQty: string; + spotMaxTradeAmount: string; borrowCoin: string; } diff --git a/src/types/shared-v5.ts b/src/types/shared-v5.ts index 514111f..b594b6d 100644 --- a/src/types/shared-v5.ts +++ b/src/types/shared-v5.ts @@ -142,7 +142,10 @@ export type StopOrderTypeV5 = | 'Stop' | 'PartialTakeProfit' | 'PartialStopLoss' - | 'tpslOrder'; + | 'tpslOrder' + | 'OcoOrder' + | 'MmRateClose' + | 'BidirectionalTpslOrder'; /** * Position index. Used to identify positions in different position modes.