(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None)
| 2168 | return self.milliseconds() - self.options['timeDifference'] |
| 2169 | |
| 2170 | def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None): |
| 2171 | endpoint = '/' + path |
| 2172 | url = self.urls['api'][api] |
| 2173 | sortedParams = params if isinstance(params, list) else self.keysort(params) |
| 2174 | if api == 'private': |
| 2175 | self.check_required_credentials() |
| 2176 | ts = str(self.nonce()) |
| 2177 | recvWindow = self.safe_string_2(self.options, 'recvWindow', 'X-Window', '5000') |
| 2178 | optionInstructions = self.safe_dict(self.options, 'instructions', {}) |
| 2179 | optionPathInstructions = self.safe_dict(optionInstructions, path, {}) |
| 2180 | instruction = self.safe_string(optionPathInstructions, method, '') |
| 2181 | payload = '' |
| 2182 | if (path == 'api/v1/orders') and (method == 'POST'): # for createOrders |
| 2183 | payload = self.generate_batch_payload(sortedParams, ts, recvWindow, instruction) |
| 2184 | else: |
| 2185 | queryString = self.urlencode(sortedParams) |
| 2186 | if len(queryString) > 0: |
| 2187 | queryString += '&' |
| 2188 | payload = 'instruction=' + instruction + '&' + queryString + 'timestamp=' + ts + '&window=' + recvWindow |
| 2189 | secretBytes = self.base64_to_binary(self.secret) |
| 2190 | seed = self.array_slice(secretBytes, 0, 32) |
| 2191 | signature = self.eddsa(self.encode(payload), seed, 'ed25519') |
| 2192 | headers = { |
| 2193 | 'X-Timestamp': ts, |
| 2194 | 'X-Window': recvWindow, |
| 2195 | 'X-API-Key': self.apiKey, |
| 2196 | 'X-Signature': signature, |
| 2197 | 'X-Broker-Id': '1400', |
| 2198 | } |
| 2199 | if method != 'GET': |
| 2200 | body = self.json(sortedParams) |
| 2201 | headers['Content-Type'] = 'application/json' |
| 2202 | if method == 'GET': |
| 2203 | query = self.urlencode(sortedParams) |
| 2204 | if len(query) != 0: |
| 2205 | endpoint += '?' + query |
| 2206 | url += endpoint |
| 2207 | return {'url': url, 'method': method, 'body': body, 'headers': headers} |
| 2208 | |
| 2209 | def generate_batch_payload(self, params, ts, recvWindow, instruction): |
| 2210 | payload = '' |
nothing calls this directly
no test coverage detected