v4.0.0-beta.9: fix() batch order ws api handling

This commit is contained in:
tiagosiebler
2025-03-03 10:45:28 +00:00
parent d638cf174a
commit f45018da88
4 changed files with 40 additions and 24 deletions

View File

@@ -78,16 +78,18 @@ export interface BatchCreateOrderResultV5 {
createAt: string;
}
export interface BatchOrdersRetExtInfoV5 {
list: {
code: number;
msg: string;
}[];
}
export interface BatchOrdersResponseV5<T extends unknown[]> {
result: {
list: T;
};
retExtInfo: {
list: {
code: number;
msg: string;
}[];
};
retExtInfo: BatchOrdersRetExtInfoV5;
}
export interface BatchAmendOrderResultV5 {

View File

@@ -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<TWSTopic extends string> {
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<OrderResultV5, 'order.create'>;
'order.amend': WSAPIResponse<OrderResultV5, 'order.amend'>;
'order.cancel': WSAPIResponse<OrderResultV5, 'order.cancel'>;
'order.create-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchCreateOrderResultV5[]>,
{ list: BatchCreateOrderResultV5[] },
'order.create-batch'
>;
> & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
'order.amend-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchAmendOrderResultV5[]>,
{ list: BatchAmendOrderResultV5[] },
'order.amend-batch'
>;
> & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
'order.cancel-batch': WSAPIResponse<
BatchOrdersResponseV5<BatchCancelOrderResultV5[]>,
{ list: BatchCancelOrderResultV5[] },
'order.cancel-batch'
>;
> & {
retExtInfo: BatchOrdersRetExtInfoV5;
};
ping: {
retCode: 0 | number;
retMsg: 'OK' | string;