(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None)
| 3063 | return self.parse_margin_modification(response, market) |
| 3064 | |
| 3065 | def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Str = None): |
| 3066 | type = self.safe_string(api, 0) |
| 3067 | version = self.safe_string(api, 1) |
| 3068 | access = self.safe_string(api, 2) |
| 3069 | url = None |
| 3070 | if (type == 'api' and version == 'kline') or (type == 'open' and path.find('listenKey') >= 0): |
| 3071 | url = self.urls['api'][type] |
| 3072 | else: |
| 3073 | url = self.urls['api'][type] + '/' + version |
| 3074 | url = url + '/' + self.implode_params(path, params) |
| 3075 | params = self.omit(params, self.extract_params(path)) |
| 3076 | if access == 'private': |
| 3077 | self.check_required_credentials() |
| 3078 | recvWindow = self.safe_integer(self.options, 'recvWindow', 5000) |
| 3079 | if type == 'spot' or type == 'open': |
| 3080 | query = self.urlencode(self.extend({ |
| 3081 | 'timestamp': self.nonce(), |
| 3082 | 'recvWindow': recvWindow, |
| 3083 | }, params)) |
| 3084 | signature = self.hmac(self.encode(query), self.encode(self.secret), hashlib.sha256) |
| 3085 | query += '&' + 'signature=' + signature |
| 3086 | headers = { |
| 3087 | 'X-MBX-APIKEY': self.apiKey, |
| 3088 | } |
| 3089 | if (method == 'GET') or (method == 'DELETE'): |
| 3090 | url += '?' + query |
| 3091 | else: |
| 3092 | body = query |
| 3093 | headers['Content-Type'] = 'application/x-www-form-urlencoded' |
| 3094 | else: |
| 3095 | timestamp = str(self.nonce()) |
| 3096 | signPath = None |
| 3097 | if type == 'fapi': |
| 3098 | signPath = '/fapi' |
| 3099 | elif type == 'dapi': |
| 3100 | signPath = '/dapi' |
| 3101 | signPath = signPath + '/' + version + '/' + path |
| 3102 | signMessage = timestamp + method + signPath |
| 3103 | if method == 'GET': |
| 3104 | keys = list(params.keys()) |
| 3105 | keysLength = len(keys) |
| 3106 | if keysLength > 0: |
| 3107 | signMessage += '?' + self.urlencode(params) |
| 3108 | signature = self.hmac(self.encode(signMessage), self.encode(self.secret), hashlib.sha256) |
| 3109 | headers = { |
| 3110 | 'X-CH-APIKEY': self.apiKey, |
| 3111 | 'X-CH-SIGN': signature, |
| 3112 | 'X-CH-TS': timestamp, |
| 3113 | } |
| 3114 | url += '?' + self.urlencode(params) |
| 3115 | else: |
| 3116 | query = self.extend({ |
| 3117 | 'recvWindow': recvWindow, |
| 3118 | }, params) |
| 3119 | body = self.json(query) |
| 3120 | signMessage += body |
| 3121 | signature = self.hmac(self.encode(signMessage), self.encode(self.secret), hashlib.sha256) |
| 3122 | headers = { |
nothing calls this directly
no test coverage detected