@ignore subscribes to a websocket channel https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe :param str name: the name of the channel :param boolean isPrivate: whether the channel is private or not :param str [symbol]: unified ma
(self, name: str, isPrivate: bool, symbol=None, params={})
| 60 | }) |
| 61 | |
| 62 | async def subscribe(self, name: str, isPrivate: bool, symbol=None, params={}): |
| 63 | """ |
| 64 | @ignore |
| 65 | subscribes to a websocket channel |
| 66 | |
| 67 | https://docs.cloud.coinbase.com/advanced-trade-api/docs/ws-overview#subscribe |
| 68 | |
| 69 | :param str name: the name of the channel |
| 70 | :param boolean isPrivate: whether the channel is private or not |
| 71 | :param str [symbol]: unified market symbol |
| 72 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 73 | :returns dict: subscription to a websocket channel |
| 74 | """ |
| 75 | await self.load_markets() |
| 76 | market = None |
| 77 | messageHash = name |
| 78 | productIds = [] |
| 79 | if isinstance(symbol, list): |
| 80 | symbols = self.market_symbols(symbol) |
| 81 | marketIds = self.market_ids(symbols) |
| 82 | productIds = marketIds |
| 83 | messageHash = messageHash + '::' + ','.join(symbol) |
| 84 | elif symbol is not None: |
| 85 | market = self.market(symbol) |
| 86 | messageHash = name + '::' + symbol |
| 87 | productIds = [market['id']] |
| 88 | url = self.urls['api']['ws'] |
| 89 | subscribe = { |
| 90 | 'type': 'subscribe', |
| 91 | 'product_ids': productIds, |
| 92 | 'channel': name, |
| 93 | # 'api_key': self.apiKey, |
| 94 | # 'timestamp': timestamp, |
| 95 | # 'signature': self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256), |
| 96 | } |
| 97 | if isPrivate: |
| 98 | subscribe = self.extend(subscribe, self.create_ws_auth(name, productIds)) |
| 99 | return await self.watch(url, messageHash, subscribe, messageHash) |
| 100 | |
| 101 | async def un_subscribe(self, topic: str, name: str, isPrivate: bool, symbol=None): |
| 102 | """ |
no test coverage detected