expose connectPrivate() util method for spot

This commit is contained in:
tiagosiebler
2021-08-14 19:54:49 +01:00
parent 4d7886ff72
commit eb1520126a

View File

@@ -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<WebSocket | undefined> | 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<WebSocket | undefined> {
try {
if (this.wsStore.isWsOpen(wsKey)) {