Merge pull request #300 from caiusCitiriga/feat/ws-typeguards
feat(types): adds WSAccountOrderEventV5 & WSAccountOrderV5 interfaces
This commit is contained in:
@@ -3,3 +3,4 @@ export * from './request';
|
|||||||
export * from './shared';
|
export * from './shared';
|
||||||
export * from './v5-shared';
|
export * from './v5-shared';
|
||||||
export * from './websockets';
|
export * from './websockets';
|
||||||
|
export * from './websocket.events';
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export type OrderSideV5 = 'Buy' | 'Sell';
|
|||||||
export type OrderTypeV5 = 'Market' | 'Limit';
|
export type OrderTypeV5 = 'Market' | 'Limit';
|
||||||
export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
|
export type OrderTimeInForceV5 = 'GTC' | 'IOC' | 'FOK' | 'PostOnly';
|
||||||
export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice';
|
export type OrderTriggerByV5 = 'LastPrice' | 'IndexPrice' | 'MarkPrice';
|
||||||
|
export type OCOTriggerTypeV5 =
|
||||||
|
| 'OcoTriggerByUnknown'
|
||||||
|
| 'OcoTriggerTp'
|
||||||
|
| 'OcoTriggerBySl';
|
||||||
|
|
||||||
export type OrderSMPTypeV5 =
|
export type OrderSMPTypeV5 =
|
||||||
| 'None'
|
| 'None'
|
||||||
|
|||||||
69
src/types/websocket.events.ts
Normal file
69
src/types/websocket.events.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import {
|
||||||
|
CategoryV5,
|
||||||
|
OCOTriggerTypeV5,
|
||||||
|
OrderRejectReasonV5,
|
||||||
|
OrderSMPTypeV5,
|
||||||
|
OrderSideV5,
|
||||||
|
OrderStatusV5,
|
||||||
|
OrderTimeInForceV5,
|
||||||
|
OrderTriggerByV5,
|
||||||
|
OrderTypeV5,
|
||||||
|
StopOrderTypeV5,
|
||||||
|
TPSLModeV5,
|
||||||
|
} from './v5-shared';
|
||||||
|
import { WsKey } from './websockets';
|
||||||
|
|
||||||
|
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[];
|
||||||
|
}
|
||||||
@@ -81,7 +81,7 @@ export type WsPrivateTopic =
|
|||||||
export type WsTopic = WsPublicTopics | WsPrivateTopic;
|
export type WsTopic = WsPublicTopics | WsPrivateTopic;
|
||||||
|
|
||||||
/** This is used to differentiate between each of the available websocket streams (as bybit has multiple websockets) */
|
/** 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 {
|
export interface WSClientConfigurableOptions {
|
||||||
key?: string;
|
key?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user