(self, path, api: Any = [], method='GET', params={}, headers: dict = None, body: Any = None)
| 10603 | return self.milliseconds() - self.options['timeDifference'] |
| 10604 | |
| 10605 | def sign(self, path, api: Any = [], method='GET', params={}, headers: dict = None, body: Any = None): |
| 10606 | signed = api[0] == 'private' |
| 10607 | endpoint = api[1] |
| 10608 | pathPart = '/api' |
| 10609 | request = '/' + self.implode_params(path, params) |
| 10610 | payload = pathPart + request |
| 10611 | url = self.implode_hostname(self.urls['api'][endpoint]) + payload |
| 10612 | query = self.omit(params, self.extract_params(path)) |
| 10613 | if not signed and (method == 'GET'): |
| 10614 | keys = list(query.keys()) |
| 10615 | keysLength = len(keys) |
| 10616 | if keysLength > 0: |
| 10617 | url = url + '?' + self.urlencode(query) |
| 10618 | if signed: |
| 10619 | self.check_required_credentials() |
| 10620 | timestamp = str(self.nonce()) |
| 10621 | auth = timestamp + method + payload |
| 10622 | if method == 'POST': |
| 10623 | body = self.json(params) |
| 10624 | auth += body |
| 10625 | else: |
| 10626 | if params: |
| 10627 | sortedParams = self.keysort(params) |
| 10628 | queryInner = '?' + self.urlencode(sortedParams, True) |
| 10629 | # check #21169 pr |
| 10630 | if queryInner.find('%24') > -1: |
| 10631 | queryInner = queryInner.replace('%24', '$') |
| 10632 | url += queryInner |
| 10633 | # bitget signs the raw(non-percent-encoded) query string, so the |
| 10634 | # signature must use the decoded values(e.g. non-ascii market ids) |
| 10635 | auth += '?' + self.rawencode(sortedParams) |
| 10636 | signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256, 'base64') |
| 10637 | broker = self.safe_string(self.options, 'broker') |
| 10638 | headers = { |
| 10639 | 'ACCESS-KEY': self.apiKey, |
| 10640 | 'ACCESS-SIGN': signature, |
| 10641 | 'ACCESS-TIMESTAMP': timestamp, |
| 10642 | 'ACCESS-PASSPHRASE': self.password, |
| 10643 | 'X-CHANNEL-API-CODE': broker, |
| 10644 | } |
| 10645 | if method == 'POST': |
| 10646 | headers['Content-Type'] = 'application/json' |
| 10647 | sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False) |
| 10648 | if sandboxMode and (path != 'v2/public/time') and (path != 'v3/market/current-fund-rate'): |
| 10649 | # https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336 |
| 10650 | if headers is None: |
| 10651 | headers = {} |
| 10652 | productType = self.safe_string(params, 'productType') |
| 10653 | if (productType != 'SCOIN-FUTURES') and (productType != 'SUSDT-FUTURES') and (productType != 'SUSDC-FUTURES'): |
| 10654 | headers['PAPTRADING'] = '1' |
| 10655 | return {'url': url, 'method': method, 'body': body, 'headers': headers} |
nothing calls this directly
no test coverage detected