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