code
stringlengths
3
6.57k
NotSupported(self.id + ' setLeverage()
getattr(self, method)
self.extend(request, params)
set_margin_mode(self, marginType, symbol=None, params={})
marginType.upper()
if (marginType != 'ISOLATED')
and (marginType != 'CROSSED')
BadRequest(self.id + ' marginType must be either isolated or crossed')
self.load_markets()
self.market(symbol)
NotSupported(self.id + ' setMarginMode()
getattr(self, method)
self.extend(request, params)
set_position_mode(self, hedged, symbol=None, params={})
self.safe_string(self.options, 'defaultType', 'future')
self.safe_string(params, 'type', defaultType)
self.omit(params, ['type'])
getattr(self, method)
self.extend(request, params)
sign(self, path, api='public', method='GET', params={}, headers=None, body=None)
not (api in self.urls['api'])
NotSupported(self.id + ' does not have a testnet/sandbox URL for ' + api + ' endpoints')
AuthenticationError(self.id + ' historicalTrades endpoint requires `apiKey` credential')
or (path == 'listenKey')
self.urlencode(params)
AuthenticationError(self.id + ' userDataStream endpoint requires `apiKey` credential')
elif (api == 'private')
or (api == 'sapi')
or (api == 'wapi' and path != 'systemStatus')
or (api == 'dapiPrivate')
or (api == 'dapiPrivateV2')
or (api == 'fapiPrivate')
or (api == 'fapiPrivateV2')
self.check_required_credentials()
self.safe_integer(self.options, 'recvWindow', 5000)
if (api == 'sapi')
and (path == 'asset/dust')
self.nonce()
elif (path == 'batchOrders')
or (path.find('sub-account')
self.nonce()
self.nonce()
self.hmac(self.encode(query)
self.encode(self.secret)
if (method == 'GET')
or (method == 'DELETE')
or (api == 'wapi')
self.urlencode(params)
handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody)
if (code == 418)
or (code == 429)
DDoSProtection(self.id + ' ' + str(code)
body.find('Price * QTY is zero or less')
InvalidOrder(self.id + ' order cost = amount * price is zero or less ' + body)
body.find('LOT_SIZE')
InvalidOrder(self.id + ' order amount should be evenly divisible by lot size ' + body)
body.find('PRICE_FILTER')
InvalidOrder(self.id + ' order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid float value in general, use self.price_to_precision(symbol, amount)
self.safe_value(response, 'success', True)
self.safe_string(response, 'msg')
json.loads(message)
self.safe_string(response, 'msg')
self.throw_exactly_matched_exception(self.exceptions['exact'], message, self.id + ' ' + message)
self.throw_broadly_matched_exception(self.exceptions['broad'], message, self.id + ' ' + message)
self.safe_string(response, 'code')
if (error == '200')
Precise.string_equals(error, '0')
if (error == '-2015')
DDoSProtection(self.id + ' temporary banned: ' + body)
self.throw_exactly_matched_exception(self.exceptions['exact'], error, feedback)
ExchangeError(feedback)
ExchangeError(self.id + ' ' + body)
calculate_rate_limiter_cost(self, api, method, path, params, config={}, context={})
if ('noSymbol' in config)
not ('symbol' in params)
elif ('noPoolId' in config)
not ('poolId' in params)
elif ('byLimit' in config)
and ('limit' in params)
range(0, len(byLimit)
self.safe_integer(config, 'cost', 1)
request(self, path, api='public', method='GET', params={}, headers=None, body=None, config={}, context={})
self.fetch2(path, api, method, params, headers, body, config, context)
if (api == 'private')
or (api == 'wapi')
modify_margin_helper(self, symbol, amount, addOrReduce, params={})
self.safe_string(self.options, 'defaultType', 'future')
self.safe_string(params, 'type', defaultType)
if (type == 'margin')
or (type == 'spot')
NotSupported(self.id + ' add / reduce margin only supported with type future or delivery')
self.load_markets()
self.market(symbol)
getattr(self, method)
self.extend(request, params)
self.safe_integer(response, 'type')
if (rawType == 1)
self.safe_number(response, 'amount')
self.safe_string(response, 'code')
if (errorCode == '200')