transfer currency internally between wallets on the same account https://phemex-docs.github.io/#transfer-between-spot-and-futures https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub :param str c
(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})
| 4490 | return response |
| 4491 | |
| 4492 | def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry: |
| 4493 | """ |
| 4494 | transfer currency internally between wallets on the same account |
| 4495 | |
| 4496 | https://phemex-docs.github.io/#transfer-between-spot-and-futures |
| 4497 | https://phemex-docs.github.io/#universal-transfer-main-account-only-transfer-between-sub-to-main-main-to-sub-or-sub-to-sub |
| 4498 | |
| 4499 | :param str code: unified currency code |
| 4500 | :param float amount: amount to transfer |
| 4501 | :param str fromAccount: account to transfer from |
| 4502 | :param str toAccount: account to transfer to |
| 4503 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 4504 | :param str [params.bizType]: for transferring between main and sub-acounts either 'SPOT' or 'PERPETUAL' default is 'SPOT' |
| 4505 | :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>` |
| 4506 | """ |
| 4507 | self.load_markets() |
| 4508 | currency = self.currency(code) |
| 4509 | accountsByType = self.safe_value(self.options, 'accountsByType', {}) |
| 4510 | fromId = self.safe_string(accountsByType, fromAccount, fromAccount) |
| 4511 | toId = self.safe_string(accountsByType, toAccount, toAccount) |
| 4512 | scaledAmmount = self.to_ev(amount, currency) |
| 4513 | direction = None |
| 4514 | transfer = None |
| 4515 | if fromId == 'spot' and toId == 'future': |
| 4516 | direction = 2 |
| 4517 | elif fromId == 'future' and toId == 'spot': |
| 4518 | direction = 1 |
| 4519 | if direction is not None: |
| 4520 | request = { |
| 4521 | 'currency': currency['id'], |
| 4522 | 'moveOp': direction, |
| 4523 | 'amountEv': scaledAmmount, |
| 4524 | } |
| 4525 | response = self.privatePostAssetsTransfer(self.extend(request, params)) |
| 4526 | # |
| 4527 | # { |
| 4528 | # "code": "0", |
| 4529 | # "msg": "OK", |
| 4530 | # "data": { |
| 4531 | # "linkKey": "8564eba4-c9ec-49d6-9b8c-2ec5001a0fb9", |
| 4532 | # "userId": "4018340", |
| 4533 | # "currency": "USD", |
| 4534 | # "amountEv": "10", |
| 4535 | # "side": "2", |
| 4536 | # "status": "10" |
| 4537 | # } |
| 4538 | # } |
| 4539 | # |
| 4540 | data = self.safe_value(response, 'data', {}) |
| 4541 | transfer = self.parse_transfer(data, currency) |
| 4542 | else: # sub account transfer |
| 4543 | request = { |
| 4544 | 'fromUserId': fromId, |
| 4545 | 'toUserId': toId, |
| 4546 | 'amountEv': scaledAmmount, |
| 4547 | 'currency': currency['id'], |
| 4548 | 'bizType': self.safe_string(params, 'bizType', 'SPOT'), |
| 4549 | } |
nothing calls this directly
no test coverage detected