(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Any = None)
| 11504 | return scheme + '//' + domain + '/' |
| 11505 | |
| 11506 | def sign(self, path, api: Any = 'public', method='GET', params={}, headers: dict = None, body: Any = None): |
| 11507 | urls = self.urls |
| 11508 | if not (api in urls['api']): |
| 11509 | raise NotSupported(self.id + ' does not have a testnet/sandbox URL for ' + api + ' endpoints') |
| 11510 | url = self.urls['api'][api] |
| 11511 | url += '/' + path |
| 11512 | if path == 'historicalTrades': |
| 11513 | if self.apiKey: |
| 11514 | headers = { |
| 11515 | 'X-MBX-APIKEY': self.apiKey, |
| 11516 | } |
| 11517 | else: |
| 11518 | raise AuthenticationError(self.id + ' historicalTrades endpoint requires `apiKey` credential') |
| 11519 | userDataStream = (path == 'userDataStream') or (path == 'listenKey') or (path == 'userListenToken') |
| 11520 | if userDataStream: |
| 11521 | if self.apiKey: |
| 11522 | # v1 special case for userDataStream |
| 11523 | headers = { |
| 11524 | 'X-MBX-APIKEY': self.apiKey, |
| 11525 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 11526 | } |
| 11527 | if method != 'GET': |
| 11528 | body = self.urlencode(params) |
| 11529 | else: |
| 11530 | raise AuthenticationError(self.id + ' userDataStream endpoint requires `apiKey` credential') |
| 11531 | elif (api == 'private') or (api == 'eapiPrivate') or (api == 'sapi' and path != 'system/status') or (api == 'sapiV2') or (api == 'sapiV3') or (api == 'sapiV4') or (api == 'dapiPrivate') or (api == 'dapiPrivateV2') or (api == 'fapiPrivate') or (api == 'fapiPrivateV2') or (api == 'fapiPrivateV3') or (api == 'papiV2' or api == 'papi' and path != 'ping'): |
| 11532 | self.check_required_credentials() |
| 11533 | if (url.find('testnet.binancefuture.com') > -1) and self.isSandboxModeEnabled and (not self.safe_bool(self.options, 'disableFuturesSandboxWarning')): |
| 11534 | raise NotSupported(self.id + ' testnet/sandbox mode is not supported for futures anymore, please check the deprecation announcement https://t.me/ccxt_announcements/92 and consider using the demo trading instead.') |
| 11535 | if method == 'POST' and ((path == 'order') or (path == 'sor/order')): |
| 11536 | # inject in implicit API calls |
| 11537 | newClientOrderId = self.safe_string(params, 'newClientOrderId') |
| 11538 | if newClientOrderId is None: |
| 11539 | isSpotOrMargin = (api.find('sapi') > -1 or api == 'private') |
| 11540 | marketType = 'spot' if isSpotOrMargin else 'future' |
| 11541 | defaultId = 'x-xcKtGhcu' if (not isSpotOrMargin) else 'x-TKT5PX2F' |
| 11542 | broker = self.safe_dict(self.options, 'broker', {}) |
| 11543 | brokerId = self.safe_string(broker, marketType, defaultId) |
| 11544 | params['newClientOrderId'] = brokerId + self.uuid22() |
| 11545 | query = None |
| 11546 | # handle batchOrders |
| 11547 | if (path == 'batchOrders') and ((method == 'POST') or (method == 'PUT')): |
| 11548 | batchOrders = self.safe_list(params, 'batchOrders', []) |
| 11549 | checkedBatchOrders = batchOrders |
| 11550 | if method == 'POST' and api == 'fapiPrivate': |
| 11551 | # check broker id if batchOrders are called with fapiPrivatePostBatchOrders |
| 11552 | checkedBatchOrders = [] |
| 11553 | for i in range(0, len(batchOrders)): |
| 11554 | batchOrder = batchOrders[i] |
| 11555 | newClientOrderId = self.safe_string(batchOrder, 'newClientOrderId') |
| 11556 | if newClientOrderId is None: |
| 11557 | defaultId = 'x-xcKtGhcu' # batchOrders can not be spot or margin |
| 11558 | broker = self.safe_dict(self.options, 'broker', {}) |
| 11559 | brokerId = self.safe_string(broker, 'future', defaultId) |
| 11560 | newClientOrderId = brokerId + self.uuid22() |
| 11561 | batchOrder['newClientOrderId'] = newClientOrderId |
| 11562 | checkedBatchOrders.append(batchOrder) |
| 11563 | queryBatch = (self.json(checkedBatchOrders)) |
nothing calls this directly
no test coverage detected