MCPcopy Create free account
hub / github.com/ccxt/ccxt / subscribe

Method subscribe

python/ccxt/pro/coinbase.py:62–99  ·  view source on GitHub ↗

@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={})

Source from the content-addressed store, hash-verified

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 """

Callers 4

watch_tickerMethod · 0.95
watch_tradesMethod · 0.95
watch_ordersMethod · 0.95
watch_order_bookMethod · 0.95

Calls 7

create_ws_authMethod · 0.95
market_symbolsMethod · 0.80
market_idsMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45
watchMethod · 0.45

Tested by

no test coverage detected