diff --git a/package-lock.json b/package-lock.json index 5f09f6b..76fb1b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "4.0.0-beta.8", + "version": "4.0.0-beta.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "4.0.0-beta.8", + "version": "4.0.0-beta.9", "license": "MIT", "dependencies": { "axios": "^1.7.9", diff --git a/package.json b/package.json index d9842b4..ad975ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "4.0.0-beta.8", + "version": "4.0.0-beta.9", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/types/response/v5-trade.ts b/src/types/response/v5-trade.ts index f7eba1a..0e591d9 100644 --- a/src/types/response/v5-trade.ts +++ b/src/types/response/v5-trade.ts @@ -78,16 +78,18 @@ export interface BatchCreateOrderResultV5 { createAt: string; } +export interface BatchOrdersRetExtInfoV5 { + list: { + code: number; + msg: string; + }[]; +} + export interface BatchOrdersResponseV5 { result: { list: T; }; - retExtInfo: { - list: { - code: number; - msg: string; - }[]; - }; + retExtInfo: BatchOrdersRetExtInfoV5; } export interface BatchAmendOrderResultV5 { diff --git a/src/types/websockets/ws-api.ts b/src/types/websockets/ws-api.ts index 962a232..7431dac 100644 --- a/src/types/websockets/ws-api.ts +++ b/src/types/websockets/ws-api.ts @@ -12,10 +12,12 @@ import { BatchCancelOrderResultV5, BatchCreateOrderResultV5, BatchOrdersResponseV5, + BatchOrdersRetExtInfoV5, OrderResultV5, } from '../response'; import { WsKey } from './ws-general'; +// When new WS API operations are added, make sure to also update WS_API_Operations[] below export type WSAPIOperation = | 'order.create' | 'order.amend' @@ -24,6 +26,15 @@ export type WSAPIOperation = | 'order.amend-batch' | 'order.cancel-batch'; +export const WS_API_Operations: WSAPIOperation[] = [ + 'order.create', + 'order.amend', + 'order.cancel', + 'order.create-batch', + 'order.amend-batch', + 'order.cancel-batch', +]; + export type WsOperation = | 'subscribe' | 'unsubscribe' @@ -31,12 +42,6 @@ export type WsOperation = | 'ping' | 'pong'; -export const WS_API_Operations: WSAPIOperation[] = [ - 'order.create', - 'order.amend', - 'order.cancel', -]; - export interface WsRequestOperationBybit { req_id: string; op: WsOperation; @@ -100,17 +105,18 @@ export interface WsAPITopicRequestParamMap { 'order.create': OrderParamsV5; 'order.amend': AmendOrderParamsV5; 'order.cancel': CancelOrderParamsV5; + 'order.create-batch': { category: 'option' | 'linear'; - orders: BatchOrderParamsV5[]; + request: BatchOrderParamsV5[]; }; 'order.amend-batch': { category: 'option' | 'linear'; - orders: BatchAmendOrderParamsV5[]; + request: BatchAmendOrderParamsV5[]; }; 'order.cancel-batch': { category: 'option' | 'linear'; - orders: BatchCancelOrderParamsV5[]; + request: BatchCancelOrderParamsV5[]; }; } @@ -121,18 +127,26 @@ export interface WsAPIOperationResponseMap { 'order.create': WSAPIResponse; 'order.amend': WSAPIResponse; 'order.cancel': WSAPIResponse; + 'order.create-batch': WSAPIResponse< - BatchOrdersResponseV5, + { list: BatchCreateOrderResultV5[] }, 'order.create-batch' - >; + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; 'order.amend-batch': WSAPIResponse< - BatchOrdersResponseV5, + { list: BatchAmendOrderResultV5[] }, 'order.amend-batch' - >; + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; 'order.cancel-batch': WSAPIResponse< - BatchOrdersResponseV5, + { list: BatchCancelOrderResultV5[] }, 'order.cancel-batch' - >; + > & { + retExtInfo: BatchOrdersRetExtInfoV5; + }; + ping: { retCode: 0 | number; retMsg: 'OK' | string;