feat(account-order): adds WSAccountOrderEventV5 & WSAccountOrderV5 interfaces

This commit is contained in:
Caius Citiriga
2023-11-15 18:30:34 +01:00
parent 285e333d3f
commit a93b45a6b2
2 changed files with 77 additions and 1 deletions

View File

@@ -1,4 +1,17 @@
import { RestClientOptions, WS_KEY_MAP } from '../util';
import {
CategoryV5,
OCOTriggerTypeV5,
OrderRejectReasonV5,
OrderSMPTypeV5,
OrderSideV5,
OrderStatusV5,
OrderTimeInForceV5,
OrderTriggerByV5,
OrderTypeV5,
StopOrderTypeV5,
TPSLModeV5,
} from './v5-shared';
/** For spot markets, spotV3 is recommended */
export type APIMarket =
@@ -81,7 +94,7 @@ export type WsPrivateTopic =
export type WsTopic = WsPublicTopics | WsPrivateTopic;
/** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */
export type WsKey = typeof WS_KEY_MAP[keyof typeof WS_KEY_MAP];
export type WsKey = (typeof WS_KEY_MAP)[keyof typeof WS_KEY_MAP];
export interface WSClientConfigurableOptions {
key?: string;
@@ -113,3 +126,62 @@ export interface WebsocketClientOptions extends WSClientConfigurableOptions {
pingInterval: number;
reconnectTimeout: number;
}
///////////////////////////////////////////////////////////
// WS events interfaces
///////////////////////////////////////////////////////////
export interface WSAccountOrderV5 {
qty: string;
price: string;
symbol: string;
orderId: string;
orderIv: string;
stopLoss: string;
smpGroup: number;
side: OrderSideV5;
placeType: string;
avgPrice?: string;
leavesQty?: string;
isLeverage: string;
cancelType: string;
cumExecQty: string;
cumExecFee: string;
smpOrderId: string;
takeProfit: string;
reduceOnly: boolean;
orderLinkId: string;
positionIdx: number;
tpTriggerBy: string;
slTriggerBy: string;
createdTime: string;
updatedTime: string;
feeCurrency: string;
triggerPrice: string;
category: CategoryV5;
cumExecValue: string;
blockTradeId: string;
leavesValue?: string;
slLimitPrice?: string;
tpLimitPrice?: string;
tpslMode?: TPSLModeV5;
orderType: OrderTypeV5;
smpType: OrderSMPTypeV5;
closeOnTrigger: boolean;
triggerDirection: number;
orderStatus: OrderStatusV5;
lastPriceOnCreated: string;
triggerBy: OrderTriggerByV5;
stopOrderType: StopOrderTypeV5;
timeInForce: OrderTimeInForceV5;
ocoTriggerType?: OCOTriggerTypeV5;
rejectReason?: OrderRejectReasonV5;
}
export interface WSAccountOrderEventV5 {
id: string;
wsKey: WsKey;
topic: 'order';
creationTime: number;
data: WSAccountOrderV5[];
}