Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion ts/src/pro/bybit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// ---------------------------------------------------------------------------

import bybitRest from '../bybit.js';
Expand Down Expand Up @@ -1581,6 +1580,32 @@
client.resolve (newPositions, 'positions');
}

/**
* @method
* @name bybit#unwatchPositions
* @description unWatches all open positions
* @see https://bybit-exchange.github.io/docs/v5/websocket/private/position
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} status of the unwatch request
*/
async unwatchPositions (symbols: Strings = undefined, params = {}): Promise<any> {
await this.loadMarkets ();
const method = 'watchPositions';
let messageHash = 'unsubscribe:positions';
let subHash = 'positions';
if (!this.isEmpty (symbols)) {
symbols = this.marketSymbols (symbols);
messageHash += '::' + symbols.join (',');
subHash += '::' + symbols.join (',');
}
const firstSymbol = this.safeString (symbols, 0);
const url = await this.getUrlByMarketType (firstSymbol, true, method, params);
await this.authenticate (url);
const topics = [ 'position' ];
return await this.unWatchTopics (url, 'positions', symbols, [ messageHash ], [ subHash ], topics, params);
}

/**
* @method
* @name bybit#watchLiquidations
Expand Down Expand Up @@ -2657,5 +2682,6 @@
}
}
return message;
}

Check failure on line 2685 in ts/src/pro/bybit.ts

View workflow job for this annotation

GitHub Actions / build

Block must not be padded by blank lines

}
1 change: 1 addition & 0 deletions ts/src/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ class testMainClass {
'watchOrders': [ symbol ],
'watchPosition': [ symbol ],
'watchPositions': [ symbol ],
'unwatchPositions': [ symbol ],
};
}
const market = exchange.market (symbol);
Expand Down
Loading