transfer currency internally between wallets on the same account :param str code: unified currency codeåå :param float amount: amount to transfer :param str fromAccount: account to transfer from :param str toAccount: account to transfer to :param dict
(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})
| 3181 | return self.parse_deposit_withdraw_fees(data, codes, 'assetCode') |
| 3182 | |
| 3183 | def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry: |
| 3184 | """ |
| 3185 | transfer currency internally between wallets on the same account |
| 3186 | :param str code: unified currency codeåå |
| 3187 | :param float amount: amount to transfer |
| 3188 | :param str fromAccount: account to transfer from |
| 3189 | :param str toAccount: account to transfer to |
| 3190 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 3191 | :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>` |
| 3192 | """ |
| 3193 | self.load_markets() |
| 3194 | self.load_accounts() |
| 3195 | account = self.safe_dict(self.accounts, 0, {}) |
| 3196 | accountGroup = self.safe_string(account, 'id') |
| 3197 | currency = self.currency(code) |
| 3198 | accountsByType = self.safe_dict(self.options, 'accountsByType', {}) |
| 3199 | fromId = self.safe_string(accountsByType, fromAccount, fromAccount) |
| 3200 | toId = self.safe_string(accountsByType, toAccount, toAccount) |
| 3201 | if fromId != 'cash' and toId != 'cash': |
| 3202 | raise ExchangeError(self.id + ' transfer() only supports direct balance transfer between spot and swap, spot and margin') |
| 3203 | request = { |
| 3204 | 'account-group': accountGroup, |
| 3205 | 'amount': self.currency_to_precision(code, amount), |
| 3206 | 'asset': currency['id'], |
| 3207 | 'fromAccount': fromId, |
| 3208 | 'toAccount': toId, |
| 3209 | } |
| 3210 | response = self.v1PrivateAccountGroupPostTransfer(self.extend(request, params)) |
| 3211 | # |
| 3212 | # {"code": "0"} |
| 3213 | # |
| 3214 | transferOptions = self.safe_dict(self.options, 'transfer', {}) |
| 3215 | fillResponseFromRequest = self.safe_bool(transferOptions, 'fillResponseFromRequest', True) |
| 3216 | transfer = self.parse_transfer(response, currency) |
| 3217 | if fillResponseFromRequest: |
| 3218 | transfer['fromAccount'] = fromAccount |
| 3219 | transfer['toAccount'] = toAccount |
| 3220 | transfer['amount'] = amount |
| 3221 | transfer['currency'] = code |
| 3222 | return transfer |
| 3223 | |
| 3224 | def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry: |
| 3225 | # |
nothing calls this directly
no test coverage detected