From eb1520126af8a774a45a21505cd34643daec63a5 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Sat, 14 Aug 2021 19:54:49 +0100 Subject: [PATCH] expose connectPrivate() util method for spot --- src/websocket-client.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/websocket-client.ts b/src/websocket-client.ts index 9ed36ae..fb195aa 100644 --- a/src/websocket-client.ts +++ b/src/websocket-client.ts @@ -101,7 +101,8 @@ const getLinearWsKeyForTopic = (topic: string): WsKey => { return wsKeyLinearPublic; } const getSpotWsKeyForTopic = (topic: string): WsKey => { - const privateLinearTopics = ['position', 'execution', 'order', 'stop_order']; + const privateLinearTopics = ['position', 'execution', 'order', 'stop_order', 'outboundAccountInfo', 'executionReport', 'ticketInfo']; + if (privateLinearTopics.includes(topic)) { return wsKeySpotPrivate; } @@ -233,6 +234,20 @@ export class WebsocketClient extends EventEmitter { } } + public connectPrivate(): Promise | undefined { + if (this.isInverse()) { + return this.connect(wsKeyInverse); + } + + if (this.isLinear()) { + return this.connect(wsKeyLinearPrivate); + } + + if (this.isSpot()) { + return this.connect(wsKeySpotPrivate); + } + } + private async connect(wsKey: WsKey): Promise { try { if (this.wsStore.isWsOpen(wsKey)) {