diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 5b3232f..1c047e3 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -382,10 +382,6 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/mix/market/vip-fee-rate`); } - getFuturesMergeDepth(params: object): Promise> { - return this.get(`/api/v2/mix/market/merge-depth`, params); - } - getFuturesTicker(params: object): Promise> { return this.get(`/api/v2/mix/market/ticker`, params); } @@ -394,12 +390,8 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/mix/market/tickers`, params); } - getFuturesRecentTrades(params: object): Promise> { - return this.get(`/api/v2/mix/market/fills`, params); - } - - getFuturesHistoricTrades(params: object): Promise> { - return this.get(`/api/v2/mix/market/fills-history`, params); + getFuturesMergeDepth(params: object): Promise> { + return this.get(`/api/v2/mix/market/merge-depth`, params); } getFuturesCandlestickData(params: object): Promise> { @@ -422,6 +414,14 @@ export class RestClientV2 extends BaseRestClient { return this.get(`/api/v2/mix/market/history-mark-candles`, params); } + getFuturesRecentTrades(params: object): Promise> { + return this.get(`/api/v2/mix/market/fills`, params); + } + + getFuturesHistoricTrades(params: object): Promise> { + return this.get(`/api/v2/mix/market/fills-history`, params); + } + getFuturesOpenInterest(params: object): Promise> { return this.get(`/api/v2/mix/market/open-interest`, params); } @@ -472,7 +472,7 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/mix/account/set-leverage`, params); } - adjustFuturesPositionMargin(params: object): Promise> { + setFuturesPositionMargin(params: object): Promise> { return this.postPrivate(`/api/v2/mix/account/set-margin`, params); } @@ -520,7 +520,11 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/mix/order/place-order`, params); } - futuresSubmitReverseal(params: object): Promise> { + futuresCancelOrder(params: object): Promise> { + return this.postPrivate(`/api/v2/mix/order/cancel-order`, params); + } + + futuresSubmitReversal(params: object): Promise> { return this.postPrivate(`/api/v2/mix/order/click-backhand`, params); } @@ -532,10 +536,6 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/mix/order/modify-order`, params); } - futuresCancelOrder(params: object): Promise> { - return this.postPrivate(`/api/v2/mix/order/cancel-order`, params); - } - futuresBatchCancelOrders(params: object): Promise> { return this.postPrivate(`/api/v2/mix/order/batch-cancel-orders`, params); } @@ -544,11 +544,11 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate(`/api/v2/mix/order/close-positions`, params); } - getFuturesOrderDetail(params: object): Promise> { + getFuturesOrder(params: object): Promise> { return this.getPrivate(`/api/v2/mix/order/detail`, params); } - getFuturesOrderFillDetails(params: object): Promise> { + getFuturesFills(params: object): Promise> { return this.getPrivate(`/api/v2/mix/order/fills`, params); } diff --git a/src/util/websocket-util.ts b/src/util/websocket-util.ts index 2637169..231bf3e 100644 --- a/src/util/websocket-util.ts +++ b/src/util/websocket-util.ts @@ -19,38 +19,25 @@ type NetworkMap< export const WS_BASE_URL_MAP: Record< WsKey, - Record<'all' | 'public' | 'private', NetworkMap<'livenet'>> + Record<'all', NetworkMap<'livenet'>> > = { mixv1: { all: { livenet: 'wss://ws.bitget.com/mix/v1/stream', }, - public: { - livenet: 'N/A', - }, - private: { - livenet: 'N/A', - }, }, spotv1: { all: { livenet: 'wss://ws.bitget.com/spot/v1/stream', }, - public: { - livenet: 'N/A', - }, - private: { - livenet: 'N/A', - }, }, - v2: { + v2Public: { all: { - livenet: 'N/A', - }, - public: { livenet: 'wss://ws.bitget.com/v2/ws/public', }, - private: { + }, + v2Private: { + all: { livenet: 'wss://ws.bitget.com/v2/ws/private', }, }, @@ -60,13 +47,15 @@ export const WS_BASE_URL_MAP: Record< export const WS_KEY_MAP = { spotv1: 'spotv1', mixv1: 'mixv1', - v2: 'v2', + v2Public: 'v2Public', + v2Private: 'v2Private', } as const; /** Any WS keys in this list will trigger auth on connect, if credentials are available */ export const WS_AUTH_ON_CONNECT_KEYS: WsKey[] = [ WS_KEY_MAP.spotv1, WS_KEY_MAP.mixv1, + WS_KEY_MAP.v2Private, ]; /** Any WS keys in this list will ALWAYS skip the authentication process, even if credentials are available */ @@ -113,7 +102,8 @@ export function getMaxTopicsPerSubscribeEvent(wsKey: WsKey): number | null { switch (wsKey) { case 'mixv1': case 'spotv1': - case 'v2': { + case 'v2Public': + case 'v2Private': { // Technically there doesn't seem to be a documented cap, but there is a size limit per request. Doesn't hurt to batch requests. return 15; } diff --git a/src/websocket-client.ts b/src/websocket-client.ts index 2ac02e6..1b634ee 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -646,6 +646,12 @@ export class WebsocketClient extends EventEmitter { case WS_KEY_MAP.mixv1: { return WS_BASE_URL_MAP.mixv1.all[networkKey]; } + case WS_KEY_MAP.v2Private: { + return WS_BASE_URL_MAP.v2Private.all[networkKey]; + } + case WS_KEY_MAP.v2Public: { + return WS_BASE_URL_MAP.v2Public.all[networkKey]; + } default: { this.logger.error('getWsUrl(): Unhandled wsKey: ', { ...LOGGER_CATEGORY,