@ignore unsubscribes to a websocket channel https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe :param str topic: unified topic :param str name: the name of the channel :param boolean isPrivate: whether the channel is private or n
(self, topic: str, name: str, isPrivate: bool, symbols: Strings = None, params={})
| 186 | return await self.watch_multiple(url, messageHashes, subscribe, messageHashes) |
| 187 | |
| 188 | async def un_subscribe_multiple(self, topic: str, name: str, isPrivate: bool, symbols: Strings = None, params={}): |
| 189 | """ |
| 190 | @ignore |
| 191 | unsubscribes to a websocket channel |
| 192 | |
| 193 | https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe |
| 194 | |
| 195 | :param str topic: unified topic |
| 196 | :param str name: the name of the channel |
| 197 | :param boolean isPrivate: whether the channel is private or not |
| 198 | :param str[] [symbols]: unified market symbol |
| 199 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 200 | :returns dict: subscription to a websocket channel |
| 201 | """ |
| 202 | if self.safe_bool(self.options, 'unSubscriptionPending', False): |
| 203 | raise ExchangeError(self.id + ' another unSubscription is pending, coinbase does not support concurrent unSubscriptions') |
| 204 | self.options['unSubscriptionPending'] = True |
| 205 | await self.load_markets() |
| 206 | productIds = [] |
| 207 | watchMessageHashes = [] |
| 208 | unWatchMessageHashes = [] |
| 209 | symbols = self.market_symbols(symbols, None, False) |
| 210 | for i in range(0, len(symbols)): |
| 211 | symbol = symbols[i] |
| 212 | market = self.market(symbol) |
| 213 | marketId = market['id'] |
| 214 | productIds.append(marketId) |
| 215 | watchMessageHashes.append(name + '::' + symbol) |
| 216 | unWatchMessageHashes.append('unsubscribe:' + name + '::' + symbol) |
| 217 | url = self.urls['api']['ws'] |
| 218 | message = { |
| 219 | 'type': 'unsubscribe', |
| 220 | 'product_ids': productIds, |
| 221 | 'channel': name, |
| 222 | } |
| 223 | if isPrivate: |
| 224 | message = self.extend(message, self.create_ws_auth(name, productIds)) |
| 225 | subscription = { |
| 226 | 'messageHashes': unWatchMessageHashes, |
| 227 | 'subMessageHashes': watchMessageHashes, |
| 228 | 'topic': topic, |
| 229 | 'unsubscribe': True, |
| 230 | 'symbols': symbols, |
| 231 | } |
| 232 | self.options['unSubscription'] = subscription |
| 233 | res = await self.watch_multiple(url, unWatchMessageHashes, message, unWatchMessageHashes, subscription) |
| 234 | self.options['unSubscriptionPending'] = False |
| 235 | self.options['unSubscription'] = None |
| 236 | return res |
| 237 | |
| 238 | def create_ws_auth(self, name: str, productIds: List[str]): |
| 239 | subscribe = {} |
no test coverage detected