MCPcopy Create free account
hub / github.com/ccxt/ccxt / withdraw

Method withdraw

python/ccxt/async_support/htx.py:6396–6450  ·  view source on GitHub ↗

https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003 make a withdrawal :param str code: unified currency code :param float amount: the amount to withdraw :param str address: the address to withdraw to :param str tag:

(self, code: str, amount: float, address: str, tag: Str = None, params={})

Source from the content-addressed store, hash-verified

6394 return self.safe_string(statuses, status, status)
6395
6396 async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
6397 """
6398
6399 https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003
6400
6401 make a withdrawal
6402 :param str code: unified currency code
6403 :param float amount: the amount to withdraw
6404 :param str address: the address to withdraw to
6405 :param str tag:
6406 :param dict [params]: extra parameters specific to the exchange API endpoint
6407 :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
6408 """
6409 tag, params = self.handle_withdraw_tag_and_params(tag, params)
6410 await self.load_markets()
6411 self.check_address(address)
6412 currency = self.currency(code)
6413 request = {
6414 'address': address, # only supports existing addresses in your withdraw address list
6415 'currency': currency['id'].lower(),
6416 }
6417 if tag is not None:
6418 request['addr-tag'] = tag # only for XRP?
6419 networkCode = None
6420 networkCode, params = self.handle_network_code_and_params(params)
6421 if networkCode is not None:
6422 request['chain'] = self.network_code_to_id(networkCode, code)
6423 amount = float(self.currency_to_precision(code, amount, networkCode))
6424 withdrawOptions = self.safe_value(self.options, 'withdraw', {})
6425 if self.safe_bool(withdrawOptions, 'includeFee', False):
6426 fee = self.safe_number(params, 'fee')
6427 if fee is None:
6428 currencies = await self.fetch_currencies()
6429 self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
6430 targetNetwork = self.safe_value(currency['networks'], networkCode, {})
6431 fee = self.safe_number(targetNetwork, 'fee')
6432 if fee is None:
6433 raise ArgumentsRequired(self.id + ' withdraw() function can not find withdraw fee for chosen network. You need to re-load markets with "exchange.loadMarkets(True)", or provide the "fee" parameter')
6434 # fee needs to be deducted from whole amount
6435 feeString = self.currency_to_precision(code, fee, networkCode)
6436 params = self.omit(params, 'fee')
6437 amountString = self.number_to_string(amount)
6438 amountSubtractedString = Precise.string_sub(amountString, feeString)
6439 amountSubtracted = float(amountSubtractedString)
6440 request['fee'] = float(feeString)
6441 amount = float(self.currency_to_precision(code, amountSubtracted, networkCode))
6442 request['amount'] = amount
6443 response = await self.spotPrivatePostV1DwWithdrawApiCreate(self.extend(request, params))
6444 #
6445 # {
6446 # "status": "ok",
6447 # "data": "99562054"
6448 # }
6449 #
6450 return self.parse_transaction(response, currency)
6451
6452 def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
6453 #

Callers

nothing calls this directly

Calls 15

network_code_to_idMethod · 0.95
fetch_currenciesMethod · 0.95
parse_transactionMethod · 0.95
ArgumentsRequiredClass · 0.90
check_addressMethod · 0.80
currency_to_precisionMethod · 0.80
safe_valueMethod · 0.80
safe_boolMethod · 0.80
safe_numberMethod · 0.80
map_to_safe_mapMethod · 0.80

Tested by

no test coverage detected