convert from one currency to another https://developers.binance.com/docs/convert/trade/Accept-Quote :param str id: the id of the trade that you want to make :param str fromCode: the currency that you want to sell and convert from :param str toCode: the curr
(self, id: str, fromCode: str, toCode: str, amount: Num = None, params={})
| 13319 | return self.parse_conversion(response, fromCurrency, toCurrency) |
| 13320 | |
| 13321 | def create_convert_trade(self, id: str, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion: |
| 13322 | """ |
| 13323 | convert from one currency to another |
| 13324 | |
| 13325 | https://developers.binance.com/docs/convert/trade/Accept-Quote |
| 13326 | |
| 13327 | :param str id: the id of the trade that you want to make |
| 13328 | :param str fromCode: the currency that you want to sell and convert from |
| 13329 | :param str toCode: the currency that you want to buy and convert into |
| 13330 | :param float [amount]: how much you want to trade in units of the from currency |
| 13331 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 13332 | :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>` |
| 13333 | """ |
| 13334 | self.load_markets() |
| 13335 | request = {} |
| 13336 | response = None |
| 13337 | if (fromCode == 'BUSD') or (toCode == 'BUSD'): |
| 13338 | if amount is None: |
| 13339 | raise ArgumentsRequired(self.id + ' createConvertTrade() requires an amount argument') |
| 13340 | request['clientTranId'] = id |
| 13341 | request['asset'] = fromCode |
| 13342 | request['targetAsset'] = toCode |
| 13343 | request['amount'] = amount |
| 13344 | response = self.sapiPostAssetConvertTransfer(self.extend(request, params)) |
| 13345 | # |
| 13346 | # { |
| 13347 | # "tranId": 118263407119, |
| 13348 | # "status": "S" |
| 13349 | # } |
| 13350 | # |
| 13351 | else: |
| 13352 | request['quoteId'] = id |
| 13353 | response = self.sapiPostConvertAcceptQuote(self.extend(request, params)) |
| 13354 | # |
| 13355 | # { |
| 13356 | # "orderId":"933256278426274426", |
| 13357 | # "createTime":1623381330472, |
| 13358 | # "orderStatus":"PROCESS" |
| 13359 | # } |
| 13360 | # |
| 13361 | fromCurrency = self.currency(fromCode) |
| 13362 | toCurrency = self.currency(toCode) |
| 13363 | return self.parse_conversion(response, fromCurrency, toCurrency) |
| 13364 | |
| 13365 | def fetch_convert_trade(self, id: str, code: Str = None, params={}) -> Conversion: |
| 13366 | """ |
nothing calls this directly
no test coverage detected