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

Method subscribe_private

python/ccxt/pro/gate.py:2075–2111  ·  view source on GitHub ↗
(self, url, messageHash, payload, channel, params, requiresUid=False)

Source from the content-addressed store, hash-verified

2073 return await self.watch(url, messageHash, request, messageHash, requestId)
2074
2075 async def subscribe_private(self, url, messageHash, payload, channel, params, requiresUid=False):
2076 self.check_required_credentials()
2077 # uid is required for some subscriptions only so it's not a part of required credentials
2078 if requiresUid:
2079 if self.uid is None or len(self.uid) == 0:
2080 raise ArgumentsRequired(self.id + ' requires uid to subscribe')
2081 idArray = [self.uid]
2082 if payload is None:
2083 payload = idArray
2084 else:
2085 payload = self.array_concat(idArray, payload)
2086 time = self.seconds()
2087 event = 'subscribe'
2088 signaturePayload = 'channel=' + channel + '&' + 'event=' + event + '&' + 'time=' + str(time)
2089 signature = self.hmac(self.encode(signaturePayload), self.encode(self.secret), hashlib.sha512, 'hex')
2090 auth = {
2091 'method': 'api_key',
2092 'KEY': self.apiKey,
2093 'SIGN': signature,
2094 }
2095 requestId = self.request_id()
2096 request = {
2097 'id': requestId,
2098 'time': time,
2099 'channel': channel,
2100 'event': event,
2101 'auth': auth,
2102 }
2103 if payload is not None:
2104 request['payload'] = payload
2105 client = self.client(url)
2106 if not (messageHash in client.subscriptions):
2107 tempSubscriptionHash = str(requestId)
2108 # in case of authenticationError we will throw
2109 client.subscriptions[tempSubscriptionHash] = messageHash
2110 message = self.extend(request, params)
2111 return await self.watch(url, messageHash, message, messageHash, messageHash)

Callers 5

watch_my_tradesMethod · 0.95
watch_balanceMethod · 0.95
watch_positionsMethod · 0.95
watch_ordersMethod · 0.95

Calls 10

request_idMethod · 0.95
ArgumentsRequiredClass · 0.90
array_concatMethod · 0.80
secondsMethod · 0.45
hmacMethod · 0.45
encodeMethod · 0.45
clientMethod · 0.45
extendMethod · 0.45
watchMethod · 0.45

Tested by

no test coverage detected