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

Method transfer

python/ccxt/grvt.py:1677–1732  ·  view source on GitHub ↗

transfer currency internally between wallets on the same account https://api-docs.grvt.io/trading_api/#transfer_1 :param str code: unified currency codeåå :param float amount: amount to transfer :param str fromAccount: account to transfer from :para

(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})

Source from the content-addressed store, hash-verified

1675 return [matchedResults, nonMatchedResults]
1676
1677 def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1678 """
1679 transfer currency internally between wallets on the same account
1680
1681 https://api-docs.grvt.io/trading_api/#transfer_1
1682
1683 :param str code: unified currency codeåå
1684 :param float amount: amount to transfer
1685 :param str fromAccount: account to transfer from
1686 :param str toAccount: account to transfer to
1687 :param dict [params]: extra parameters specific to the exchange API endpoint
1688 :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
1689 """
1690 self.load_markets_and_sign_in()
1691 currency = self.currency(code)
1692 defaultFromAccountId = self.safe_string(self.options, 'userMainAccountId')
1693 if self.in_array(fromAccount, ['trading', 'funding']) and self.in_array(toAccount, ['trading', 'funding']):
1694 tradingAccountId = None
1695 tradingAccountId, params = self.handle_option_and_params(params, 'transfer', 'tradingAccountId')
1696 fundingAccountId = None
1697 fundingAccountId, params = self.handle_option_and_params(params, 'transfer', 'fundingAccountId')
1698 if tradingAccountId is None or fundingAccountId is None:
1699 raise ArgumentsRequired(self.id + ' transfer(): you should set(in the options or params) "tradingAccountId" and "fundingAccountId"(you can use "0" main funding account id)')
1700 fromAccount = tradingAccountId if (fromAccount == 'trading') else fundingAccountId
1701 toAccount = tradingAccountId if (toAccount == 'trading') else fundingAccountId
1702 request = {
1703 'from_account_id': self.safe_string(params, 'from_account_id', defaultFromAccountId),
1704 'from_sub_account_id': self.safe_string(params, 'from_sub_account_id', fromAccount),
1705 'to_account_id': self.safe_string(params, 'to_account_id', defaultFromAccountId),
1706 'to_sub_account_id': self.safe_string(params, 'to_sub_account_id', toAccount),
1707 'currency': currency['id'],
1708 'num_tokens': self.currency_to_precision(code, amount),
1709 'signature': self.default_signature(),
1710 'transfer_type': 'STANDARD',
1711 'transfer_metadata': None,
1712 }
1713 request = self.create_signed_request(request, 'EIP712_TRANSFER_TYPE', currency)
1714 response = None
1715 try:
1716 response = self.privateTradingPostFullV1Transfer(self.extend(request, params))
1717 except Exception as error:
1718 msg = self.exception_message(error)
1719 isFromFundingAccount = fromAccount == 'funding'
1720 if isFromFundingAccount and msg.find('You are not authorized'):
1721 raise PermissionDenied(self.id + ' transfer() failed. Ensure you use funding api-keys when trying to transfer from Funding accounts: ' + msg)
1722 raise error
1723 #
1724 # {
1725 # "result": {
1726 # "ack": "true",
1727 # "tx_id": "1028403"
1728 # }
1729 # }
1730 #
1731 result = self.safe_dict(response, 'result', {})
1732 return self.parse_transfer(result, currency)
1733
1734 def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:

Callers

nothing calls this directly

Calls 15

default_signatureMethod · 0.95
create_signed_requestMethod · 0.95
parse_transferMethod · 0.95
ArgumentsRequiredClass · 0.90
PermissionDeniedClass · 0.90
safe_stringMethod · 0.80
in_arrayMethod · 0.80
currency_to_precisionMethod · 0.80
exception_messageMethod · 0.80
findMethod · 0.80
safe_dictMethod · 0.80

Tested by

no test coverage detected